summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/visual/rasterizer.h2
-rw-r--r--servers/visual/visual_server_raster.h2
-rw-r--r--servers/visual/visual_server_scene.cpp33
-rw-r--r--servers/visual/visual_server_scene.h1
-rw-r--r--servers/visual/visual_server_wrap_mt.h2
-rw-r--r--servers/visual_server.h2
6 files changed, 36 insertions, 6 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 2499551607..4bb34af241 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -193,6 +193,8 @@ public:
virtual void textures_keep_original(bool p_enable) = 0;
+ virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0;
+
/* SKY API */
virtual RID sky_create() = 0;
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index f34951f452..91542625e0 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -168,6 +168,8 @@ public:
BIND1(textures_keep_original, bool)
+ BIND2(texture_set_proxy, RID, RID)
+
/* SKY API */
BIND0R(RID, sky_create)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 69827b330d..72fb1df94b 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -303,6 +303,23 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
VSG::storage->instance_remove_dependency(instance->base, instance);
+ if (instance->base_type == VS::INSTANCE_GI_PROBE) {
+ //if gi probe is baking, wait until done baking, else race condition may happen when removing it
+ //from octree
+ InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
+
+ //make sure probes are done baking
+ while (!probe_bake_list.empty()) {
+ OS::get_singleton()->delay_usec(1);
+ }
+ //make sure this one is done baking
+
+ while (gi_probe->dynamic.updating_stage == GI_UPDATE_STAGE_LIGHTING) {
+ //wait until bake is done if it's baking
+ OS::get_singleton()->delay_usec(1);
+ }
+ }
+
if (scenario && instance->octree_id) {
scenario->octree.erase(instance->octree_id); //make dependencies generated by the octree go away
instance->octree_id = 0;
@@ -331,10 +348,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
- while (gi_probe->dynamic.updating_stage == GI_UPDATE_STAGE_LIGHTING) {
- //wait until bake is done if it's baking
- OS::get_singleton()->delay_usec(1);
- }
if (gi_probe->update_element.in_list()) {
gi_probe_update_list.remove(&gi_probe->update_element);
}
@@ -2589,7 +2602,15 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
}
//send back to main thread to update un little chunks
+ if (probe_bake_mutex) {
+ probe_bake_mutex->lock();
+ }
+
probe_data->dynamic.updating_stage = GI_UPDATE_STAGE_UPLOADING;
+
+ if (probe_bake_mutex) {
+ probe_bake_mutex->unlock();
+ }
}
bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) {
@@ -2722,11 +2743,11 @@ void VisualServerScene::render_probes() {
case GI_UPDATE_STAGE_CHECK: {
if (_check_gi_probe(instance_probe) || force_lighting) {
- //send to lighting thread
- probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING;
+//send to lighting thread
#ifndef NO_THREADS
probe_bake_mutex->lock();
+ probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING;
probe_bake_list.push_back(instance_probe);
probe_bake_mutex->unlock();
probe_bake_sem->post();
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 9af5ffb74d..bc5d266113 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -438,6 +438,7 @@ public:
: update_element(this) {
invalid = true;
base_version = 0;
+ dynamic.updating_stage = GI_UPDATE_STAGE_CHECK;
}
};
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index d1069a410c..1c3b34d16f 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -100,6 +100,8 @@ public:
FUNC1(textures_keep_original, bool)
+ FUNC2(texture_set_proxy, RID, RID)
+
/* SKY API */
FUNCRID(sky)
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 9df389999a..350097c1b5 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -141,6 +141,8 @@ public:
virtual void textures_keep_original(bool p_enable) = 0;
+ virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0;
+
/* SKY API */
virtual RID sky_create() = 0;