From 7c4cf1c043752493bcb4ef5a5cf14591272cda45 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Tue, 24 Nov 2020 13:24:15 +0000 Subject: [PATCH] Batching - BackBuffer copy fix For fixing a previous issue state.canvas_texscreen_used was reset to false at the start of each render_joined_item. This was causing a later shader that used SCREEN_TEXTURE to force recapturing the back buffer immediately prior to use, which we don't want. This PR preserves the state across joined items, and also prevents joining of items that copy the back buffer as this may be problematic. It turns out that the original issue that needed the line is now fixed, and the later issue is also fixed by removing it. --- drivers/gles2/rasterizer_canvas_gles2.cpp | 4 ---- drivers/gles3/rasterizer_canvas_gles3.cpp | 4 ---- drivers/gles_common/rasterizer_canvas_batcher.h | 5 +++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 2e237b08797..c143e85fa07 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -1946,10 +1946,6 @@ void RasterizerCanvasGLES2::render_joined_item(const BItemJoined &p_bij, RenderI } #endif - // this must be reset for each joined item, - // it only exists to prevent capturing the screen more than once per item - state.canvas_texscreen_used = false; - // all the joined items will share the same state with the first item Item *ci = bdata.item_refs[p_bij.first_item_ref].item; diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 2df1d995027..dfeab470dff 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1203,10 +1203,6 @@ void RasterizerCanvasGLES3::render_joined_item(const BItemJoined &p_bij, RenderI } #endif - // this must be reset for each joined item, - // it only exists to prevent capturing the screen more than once per item - state.canvas_texscreen_used = false; - // all the joined items will share the same state with the first item Item *p_ci = bdata.item_refs[p_bij.first_item_ref].item; diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index c449d806b16..60a357cc76b 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -3048,6 +3048,11 @@ PREAMBLE(bool)::_detect_item_batch_break(RenderItemState &r_ris, RasterizerCanva } // else + // special case, back buffer copy, so don't join + if (p_ci->copy_back_buffer) { + return true; + } + return false; }