summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp14
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h3
-rw-r--r--servers/visual/rasterizer.h3
-rw-r--r--servers/visual/visual_server_viewport.cpp4
-rw-r--r--servers/visual/visual_server_viewport.h3
6 files changed, 23 insertions, 8 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 5447a17dcc..913aa62452 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1227,6 +1227,8 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
t->detect_normal(t->detect_normal_ud);
}
#endif
+ if (t->render_target)
+ t->render_target->used_in_frame = true;
if (storage->config.srgb_decode_supported) {
//if SRGB decode extension is present, simply switch the texture to whathever is needed
@@ -4008,6 +4010,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
storage->frame.clear_request = false;
} else if (!probe && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
clear_color = Color(0, 0, 0, 0);
+ storage->frame.clear_request = false;
+
} else if (!env || env->bg_mode == VS::ENV_BG_CLEAR_COLOR) {
if (storage->frame.clear_request) {
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 509b14a22e..c697672bd8 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -6060,10 +6060,20 @@ void RasterizerStorageGLES3::render_target_set_flag(RID p_render_target, RenderT
default: {}
}
}
+bool RasterizerStorageGLES3::render_target_was_used(RID p_render_target) {
-bool RasterizerStorageGLES3::render_target_renedered_in_frame(RID p_render_target) {
+ RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ ERR_FAIL_COND_V(!rt, false);
- return false;
+ return rt->used_in_frame;
+}
+
+void RasterizerStorageGLES3::render_target_clear_used(RID p_render_target) {
+
+ RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ ERR_FAIL_COND(!rt);
+
+ rt->used_in_frame = false;
}
void RasterizerStorageGLES3::render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index a53c3d7dd2..ca0194bd5e 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -1273,7 +1273,8 @@ public:
virtual RID render_target_get_texture(RID p_render_target) const;
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
- virtual bool render_target_renedered_in_frame(RID p_render_target);
+ virtual bool render_target_was_used(RID p_render_target);
+ virtual void render_target_clear_used(RID p_render_target);
virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa);
/* CANVAS SHADOW */
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 75434c5fc5..a722b4744d 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -484,7 +484,8 @@ public:
virtual void render_target_set_size(RID p_render_target, int p_width, int p_height) = 0;
virtual RID render_target_get_texture(RID p_render_target) const = 0;
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) = 0;
- virtual bool render_target_renedered_in_frame(RID p_render_target) = 0;
+ virtual bool render_target_was_used(RID p_render_target) = 0;
+ virtual void render_target_clear_used(RID p_render_target) = 0;
virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) = 0;
/* CANVAS SHADOW */
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index a99b890601..2fbbcd225f 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -266,11 +266,13 @@ void VisualServerViewport::draw_viewports() {
ERR_CONTINUE(!vp->render_target.is_valid());
- bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE;
+ bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE || (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_VISIBLE && VSG::storage->render_target_was_used(vp->render_target));
if (!visible)
continue;
+ VSG::storage->render_target_clear_used(vp->render_target);
+
VSG::rasterizer->set_current_render_target(vp->render_target);
VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h
index 4d46e39b77..f963ce4aa3 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/visual/visual_server_viewport.h
@@ -69,8 +69,6 @@ public:
VS::ViewportClearMode clear_mode;
- bool rendered_in_prev_frame;
-
struct CanvasKey {
int layer;
@@ -100,7 +98,6 @@ public:
Viewport() {
update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE;
clear_mode = VS::VIEWPORT_CLEAR_ALWAYS;
- rendered_in_prev_frame = false;
disable_environment = false;
viewport_to_screen = 0;
shadow_atlas_size = 0;