From 1eb0039b6eae3f4fab75ca6bb746712a233d32cb Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Mon, 29 Jul 2024 10:49:48 +1000 Subject: [PATCH] Fix regression around OpenGL swapchain optimisation for OpenXR --- drivers/gles3/rasterizer_gles3.cpp | 4 ++-- drivers/gles3/rasterizer_gles3.h | 2 +- servers/rendering/dummy/rasterizer_dummy.h | 2 +- servers/rendering/renderer_compositor.h | 2 +- servers/rendering/renderer_rd/renderer_compositor_rd.h | 2 +- servers/rendering/renderer_viewport.cpp | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 5ff95391a2f..37e7256d764 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -107,7 +107,7 @@ void RasterizerGLES3::end_frame(bool p_swap_buffers) { utils->capture_timestamps_end(); } -void RasterizerGLES3::end_viewport(bool p_swap_buffers) { +void RasterizerGLES3::gl_end_frame(bool p_swap_buffers) { if (p_swap_buffers) { DisplayServer::get_singleton()->swap_buffers(); } else { @@ -491,7 +491,7 @@ void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_c copy_effects->copy_to_rect(screenrect); glBindTexture(GL_TEXTURE_2D, 0); - end_viewport(true); + gl_end_frame(true); texture_storage->texture_free(texture); } diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index 0d0c26016db..80a4a792bb2 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -99,7 +99,7 @@ public: void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount); - void end_viewport(bool p_swap_buffers); + void gl_end_frame(bool p_swap_buffers); void end_frame(bool p_swap_buffers); void finalize(); diff --git a/servers/rendering/dummy/rasterizer_dummy.h b/servers/rendering/dummy/rasterizer_dummy.h index a4f353359a5..c3f5f3102d3 100644 --- a/servers/rendering/dummy/rasterizer_dummy.h +++ b/servers/rendering/dummy/rasterizer_dummy.h @@ -88,7 +88,7 @@ public: void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) override {} - void end_viewport(bool p_swap_buffers) override {} + void gl_end_frame(bool p_swap_buffers) override {} void end_frame(bool p_swap_buffers) override { if (p_swap_buffers) { diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index ab789d5b4de..933b9e457f5 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -98,7 +98,7 @@ public: virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0; - virtual void end_viewport(bool p_swap_buffers) = 0; + virtual void gl_end_frame(bool p_swap_buffers) = 0; virtual void end_frame(bool p_swap_buffers) = 0; virtual void finalize() = 0; virtual uint64_t get_frame_number() const = 0; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 95c2b812d94..0222a995779 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -122,7 +122,7 @@ public: void begin_frame(double frame_step); void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount); - void end_viewport(bool p_swap_buffers) {} + void gl_end_frame(bool p_swap_buffers) {} void end_frame(bool p_swap_buffers); void finalize(); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 10e295ab04d..1049cb63cd3 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -786,6 +786,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { if (blits.size() > 0) { RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blits.ptr(), blits.size()); + RSG::rasterizer->gl_end_frame(p_swap_buffers); } } else if (blits.size() > 0) { if (!blit_to_screen_list.has(vp->viewport_to_screen)) { @@ -796,7 +797,6 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { blit_to_screen_list[vp->viewport_to_screen].push_back(blits[b]); } } - RSG::rasterizer->end_viewport(p_swap_buffers && blits.size() > 0); } } } else @@ -826,10 +826,10 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { Vector blit_to_screen_vec; blit_to_screen_vec.push_back(blit); RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1); + RSG::rasterizer->gl_end_frame(p_swap_buffers); } else { blit_to_screen_list[vp->viewport_to_screen].push_back(blit); } - RSG::rasterizer->end_viewport(p_swap_buffers); } }