Route stroke mixer composite setup through helper

This commit is contained in:
2026-06-13 05:01:31 +02:00
parent 65d084ad8e
commit 0a01523212
4 changed files with 33 additions and 20 deletions

View File

@@ -18,6 +18,12 @@ agent or engineer to remove them without reconstructing context from chat.
## Recent Reductions ## 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 - 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge` checkerboard
background shader setup and final merged-texture redraw setup now route background shader setup and final merged-texture redraw setup now route
through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still

View File

@@ -2992,6 +2992,10 @@ Results:
checkerboard backgrounds and the final merged texture redraw over the grid; checkerboard backgrounds and the final merged texture redraw over the grid;
layer traversal, blend destination copies, sampler/texture binding, and draw layer traversal, blend destination copies, sampler/texture binding, and draw
ordering remain in the legacy Canvas path. 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 - Canvas thumbnail layer blending now uses the same canvas destination-feedback
plan for framebuffer-fetch versus texture-copy decisions; the thumbnail draw plan for framebuffer-fetch versus texture-copy decisions; the thumbnail draw
itself still executes through retained OpenGL canvas code under DEBT-0036. itself still executes through retained OpenGL canvas code under DEBT-0036.

View File

@@ -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(1);
m_sampler.bind(2); m_sampler.bind(2);
const auto& b = m_current_stroke->m_brush; const auto& b = m_current_stroke->m_brush;
ShaderManager::use(kShader::CompDraw); pp::panopainter::setup_legacy_stroke_composite_shader(
ShaderManager::u_int(kShaderUniform::Tex, 0); pp::panopainter::LegacyStrokeCompositeUniforms {
//ShaderManager::u_int(kShaderUniform::TexA, 0); .resolution = m_size,
ShaderManager::u_int(kShaderUniform::TexStroke, 1); .mvp = plane_mvp_z,
ShaderManager::u_int(kShaderUniform::TexMask, 2); .pattern_texture_slot = 3,
ShaderManager::u_vec2(kShaderUniform::Resolution, m_size); .layer_alpha = 1.0f,
ShaderManager::u_int(kShaderUniform::TexPattern, 3); .alpha_lock = false, /*m_layers[layer_index]->m_alpha_locked*/
ShaderManager::u_float(kShaderUniform::Alpha, 1); .mask_enabled = false, /*m_smask_active*/
ShaderManager::u_int(kShaderUniform::Lock, false/*m_layers[layer_index]->m_alpha_locked*/); .use_fragcoord = false,
ShaderManager::u_int(kShaderUniform::Mask, false/*m_smask_active*/); .blend_mode = b->m_blend_mode,
ShaderManager::u_int(kShaderUniform::UseFragcoord, false); .use_dual = false,
ShaderManager::u_int(kShaderUniform::UseDual, false); .use_pattern = false,
ShaderManager::u_int(kShaderUniform::UsePattern, false); });
ShaderManager::u_int(kShaderUniform::BlendMode, b->m_blend_mode);
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
set_active_texture_unit(0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture(); m_layers[layer_index]->rtt(plane_index).bindTexture();
set_active_texture_unit(1); set_active_texture_unit(1);

View File

@@ -21,6 +21,11 @@ struct LegacyStrokeCompositeUniforms {
glm::vec2 resolution {}; glm::vec2 resolution {};
LegacyStrokeCompositePatternUniforms pattern; LegacyStrokeCompositePatternUniforms pattern;
glm::mat4 mvp { 1.0f }; 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; float layer_alpha = 1.0f;
bool alpha_lock = false; bool alpha_lock = false;
bool mask_enabled = false; bool mask_enabled = false;
@@ -69,11 +74,11 @@ inline void setup_legacy_stroke_composite_shader(
const LegacyStrokeCompositeShaderExecution& execution) noexcept const LegacyStrokeCompositeShaderExecution& execution) noexcept
{ {
execution.use_shader(kShader::CompDraw); execution.use_shader(kShader::CompDraw);
execution.set_int(kShaderUniform::Tex, 0); execution.set_int(kShaderUniform::Tex, uniforms.texture_slot);
execution.set_int(kShaderUniform::TexStroke, 1); execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot);
execution.set_int(kShaderUniform::TexMask, 2); execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot);
execution.set_int(kShaderUniform::TexDual, 3); execution.set_int(kShaderUniform::TexDual, uniforms.dual_texture_slot);
execution.set_int(kShaderUniform::TexPattern, 4); execution.set_int(kShaderUniform::TexPattern, uniforms.pattern_texture_slot);
execution.set_vec2(kShaderUniform::Resolution, uniforms.resolution); execution.set_vec2(kShaderUniform::Resolution, uniforms.resolution);
execution.set_float(kShaderUniform::Alpha, uniforms.layer_alpha); execution.set_float(kShaderUniform::Alpha, uniforms.layer_alpha);
execution.set_int(kShaderUniform::Lock, uniforms.alpha_lock); execution.set_int(kShaderUniform::Lock, uniforms.alpha_lock);