Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D: Fix clip children and rendering artefacts #102161

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,6 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_

// Clear out state used in 2D pass
reset_canvas();
state.current_batch_index = 0;
state.canvas_instance_batches.clear();
state.current_data_buffer_index = (state.current_data_buffer_index + 1) % state.canvas_instance_data_buffers.size();
state.current_instance_buffer_index = 0;
}
Expand Down Expand Up @@ -807,6 +805,8 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
}

glDisable(GL_SCISSOR_TEST);
state.current_batch_index = 0;
state.canvas_instance_batches.clear();
state.last_item_index += index;
}

Expand Down Expand Up @@ -1567,7 +1567,9 @@ void RasterizerCanvasGLES3::_add_to_batch(uint32_t &r_index, bool &r_batch_broke

void RasterizerCanvasGLES3::_new_batch(bool &r_batch_broken) {
if (state.canvas_instance_batches.size() == 0) {
state.canvas_instance_batches.push_back(Batch());
Batch new_batch;
new_batch.instance_buffer_index = state.current_instance_buffer_index;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to start at the last instance buffer, even when starting the first batch. This is 0 when starting a new canvas draw, but will be non-zero if there are multiple draws in a single canvas draw.

state.canvas_instance_batches.push_back(new_batch);
return;
}

Expand Down
8 changes: 5 additions & 3 deletions servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,6 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
}

texture_info_map.clear();
state.current_batch_index = 0;
state.canvas_instance_batches.clear();
state.current_data_buffer_index = (state.current_data_buffer_index + 1) % BATCH_DATA_BUFFER_COUNT;
state.current_instance_buffer_index = 0;
}
Expand Down Expand Up @@ -2289,6 +2287,8 @@ void RendererCanvasRenderRD::_render_batch_items(RenderTarget p_to_render_target

RD::get_singleton()->draw_list_end();

state.current_batch_index = 0;
state.canvas_instance_batches.clear();
state.last_instance_index += instance_index;
}

Expand Down Expand Up @@ -3200,7 +3200,9 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, CanvasSha

RendererCanvasRenderRD::Batch *RendererCanvasRenderRD::_new_batch(bool &r_batch_broken) {
if (state.canvas_instance_batches.size() == 0) {
state.canvas_instance_batches.push_back(Batch());
Batch new_batch;
new_batch.instance_buffer_index = state.current_instance_buffer_index;
state.canvas_instance_batches.push_back(new_batch);
return state.canvas_instance_batches.ptr();
}

Expand Down