From 0a01523212e849efb1e80c2cbfcfc7f2b05e1d0a Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 05:01:31 +0200 Subject: [PATCH] Route stroke mixer composite setup through helper --- docs/modernization/debt.md | 6 ++++ docs/modernization/roadmap.md | 4 +++ src/canvas.cpp | 28 +++++++++---------- src/legacy_canvas_stroke_composite_services.h | 15 ++++++---- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index b93e1e6..0294060 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,12 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::stroke_draw_mix` now + reuses `legacy_canvas_stroke_composite_services.h` for mixer-pass retained + `kShader::CompDraw` binding and blend uniform writes, with the helper now + preserving caller-specific texture slot uniforms. Mixer framebuffer, + viewport/scissor/capability state, sampler binding, texture binding, and draw + execution remain retained Canvas code. - 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge` checkerboard background shader setup and final merged-texture redraw setup now route through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index c58b4e3..45c666d 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -2992,6 +2992,10 @@ Results: checkerboard backgrounds and the final merged texture redraw over the grid; layer traversal, blend destination copies, sampler/texture binding, and draw ordering remain in the legacy Canvas path. +- `Canvas::stroke_draw_mix` now shares the retained stroke composite shader + helper for mixer-pass `CompDraw` setup, while preserving its caller-specific + texture slot uniforms. Mixer framebuffer/scissor state, sampler and texture + binding, and draw execution remain retained. - Canvas thumbnail layer blending now uses the same canvas destination-feedback plan for framebuffer-fetch versus texture-copy decisions; the thumbnail draw itself still executes through retained OpenGL canvas code under DEBT-0036. diff --git a/src/canvas.cpp b/src/canvas.cpp index 69677e1..5f15750 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -437,21 +437,19 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz) m_sampler.bind(1); m_sampler.bind(2); const auto& b = m_current_stroke->m_brush; - ShaderManager::use(kShader::CompDraw); - ShaderManager::u_int(kShaderUniform::Tex, 0); - //ShaderManager::u_int(kShaderUniform::TexA, 0); - ShaderManager::u_int(kShaderUniform::TexStroke, 1); - ShaderManager::u_int(kShaderUniform::TexMask, 2); - ShaderManager::u_vec2(kShaderUniform::Resolution, m_size); - ShaderManager::u_int(kShaderUniform::TexPattern, 3); - ShaderManager::u_float(kShaderUniform::Alpha, 1); - ShaderManager::u_int(kShaderUniform::Lock, false/*m_layers[layer_index]->m_alpha_locked*/); - ShaderManager::u_int(kShaderUniform::Mask, false/*m_smask_active*/); - ShaderManager::u_int(kShaderUniform::UseFragcoord, false); - ShaderManager::u_int(kShaderUniform::UseDual, false); - ShaderManager::u_int(kShaderUniform::UsePattern, false); - ShaderManager::u_int(kShaderUniform::BlendMode, b->m_blend_mode); - ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z); + pp::panopainter::setup_legacy_stroke_composite_shader( + pp::panopainter::LegacyStrokeCompositeUniforms { + .resolution = m_size, + .mvp = plane_mvp_z, + .pattern_texture_slot = 3, + .layer_alpha = 1.0f, + .alpha_lock = false, /*m_layers[layer_index]->m_alpha_locked*/ + .mask_enabled = false, /*m_smask_active*/ + .use_fragcoord = false, + .blend_mode = b->m_blend_mode, + .use_dual = false, + .use_pattern = false, + }); set_active_texture_unit(0); m_layers[layer_index]->rtt(plane_index).bindTexture(); set_active_texture_unit(1); diff --git a/src/legacy_canvas_stroke_composite_services.h b/src/legacy_canvas_stroke_composite_services.h index 262768f..59770b2 100644 --- a/src/legacy_canvas_stroke_composite_services.h +++ b/src/legacy_canvas_stroke_composite_services.h @@ -21,6 +21,11 @@ struct LegacyStrokeCompositeUniforms { glm::vec2 resolution {}; LegacyStrokeCompositePatternUniforms pattern; glm::mat4 mvp { 1.0f }; + int texture_slot = 0; + int stroke_texture_slot = 1; + int mask_texture_slot = 2; + int dual_texture_slot = 3; + int pattern_texture_slot = 4; float layer_alpha = 1.0f; bool alpha_lock = false; bool mask_enabled = false; @@ -69,11 +74,11 @@ inline void setup_legacy_stroke_composite_shader( const LegacyStrokeCompositeShaderExecution& execution) noexcept { execution.use_shader(kShader::CompDraw); - execution.set_int(kShaderUniform::Tex, 0); - execution.set_int(kShaderUniform::TexStroke, 1); - execution.set_int(kShaderUniform::TexMask, 2); - execution.set_int(kShaderUniform::TexDual, 3); - execution.set_int(kShaderUniform::TexPattern, 4); + execution.set_int(kShaderUniform::Tex, uniforms.texture_slot); + execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot); + execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot); + execution.set_int(kShaderUniform::TexDual, uniforms.dual_texture_slot); + execution.set_int(kShaderUniform::TexPattern, uniforms.pattern_texture_slot); execution.set_vec2(kShaderUniform::Resolution, uniforms.resolution); execution.set_float(kShaderUniform::Alpha, uniforms.layer_alpha); execution.set_int(kShaderUniform::Lock, uniforms.alpha_lock);