From 2e71f6a806133f9c200411fb4808dd3260d0fabf Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Sun, 27 Aug 2023 18:00:35 +0800 Subject: [PATCH] fix glMapBufferRange return null when r_index + last_item_index > max_instances (cherry picked from commit d48b95a30548fc7228e38af86508c7b2311b5572) --- drivers/gles3/rasterizer_canvas_gles3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 86405fa3f04..09f3e13d46a 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1451,7 +1451,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index) { void RasterizerCanvasGLES3::_add_to_batch(uint32_t &r_index, bool &r_batch_broken) { state.canvas_instance_batches[state.current_batch_index].instance_count++; r_index++; - if (r_index >= data.max_instances_per_buffer) { + if (r_index + state.last_item_index >= data.max_instances_per_buffer) { // Copy over all data needed for rendering right away // then go back to recording item commands. glBindBuffer(GL_ARRAY_BUFFER, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[state.current_instance_buffer_index]);