From c0a648de76f5a2cd9000205b561904919c0e9a4b Mon Sep 17 00:00:00 2001 From: Mounir Tohami Date: Sun, 1 Mar 2026 06:57:34 +0200 Subject: [PATCH] Fix textures repeat mode for GLES3 renderer. Co-authored-by: kleonc <9283098+kleonc@users.noreply.github.com> --- drivers/gles3/rasterizer_canvas_gles3.cpp | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index b34b0f8dff..904e0be782 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -820,14 +820,6 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].filter = texture_filter; } - RSE::CanvasItemTextureRepeat texture_repeat = p_item->texture_repeat == RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? state.default_repeat : p_item->texture_repeat; - - if (texture_repeat != state.canvas_instance_batches[state.current_batch_index].repeat) { - _new_batch(r_batch_broken); - - state.canvas_instance_batches[state.current_batch_index].repeat = texture_repeat; - } - Transform2D base_transform = p_item->final_transform; if (p_item->repeat_source_item && (p_repeat_offset.x || p_repeat_offset.y)) { base_transform.columns[2] += p_item->repeat_source_item->final_transform.basis_xform(p_repeat_offset); @@ -882,6 +874,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].specialization ^= CanvasShaderGLES3::DISABLE_LIGHTING; } + const RSE::CanvasItemTextureRepeat base_texture_repeat = p_item->texture_repeat == RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? state.default_repeat : p_item->texture_repeat; const Item::Command *c = p_item->commands; while (c) { if (skipping && c->type != Item::Command::TYPE_ANIMATION_SLICE) { @@ -915,12 +908,21 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend Color blend_color = base_color; GLES3::CanvasShaderData::BlendMode blend_mode = p_blend_mode; + RSE::CanvasItemTextureRepeat texture_repeat = base_texture_repeat; if (c->type == Item::Command::TYPE_RECT) { const Item::CommandRect *rect = static_cast(c); if (rect->flags & CANVAS_RECT_LCD) { blend_mode = GLES3::CanvasShaderData::BLEND_MODE_LCD; blend_color = rect->modulate * base_color; } + + if (rect->flags & CANVAS_RECT_TILE) { + texture_repeat = RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; + } + } + if (texture_repeat != state.canvas_instance_batches[state.current_batch_index].repeat) { + _new_batch(r_batch_broken); + state.canvas_instance_batches[state.current_batch_index].repeat = texture_repeat; } if (blend_mode != state.canvas_instance_batches[state.current_batch_index].blend_mode || blend_color != state.canvas_instance_batches[state.current_batch_index].blend_color) { @@ -932,12 +934,6 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend switch (c->type) { case Item::Command::TYPE_RECT: { const Item::CommandRect *rect = static_cast(c); - - if (rect->flags & CANVAS_RECT_TILE && state.canvas_instance_batches[state.current_batch_index].repeat != RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED) { - _new_batch(r_batch_broken); - state.canvas_instance_batches[state.current_batch_index].repeat = RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; - } - if (rect->texture != state.canvas_instance_batches[state.current_batch_index].tex || state.canvas_instance_batches[state.current_batch_index].command_type != Item::Command::TYPE_RECT) { _new_batch(r_batch_broken); state.canvas_instance_batches[state.current_batch_index].tex = rect->texture;