Move canvas merge GL mappings to renderer gl

This commit is contained in:
2026-06-02 09:20:18 +02:00
parent 737c29cca4
commit f7d32f2835
3 changed files with 34 additions and 28 deletions

View File

@@ -221,6 +221,9 @@ Known local toolchain state:
Canvas stroke commit also consumes backend-owned saved viewport/clear/blend Canvas stroke commit also consumes backend-owned saved viewport/clear/blend
state, history readback format/type, active texture units, fallback 2D state, history readback format/type, active texture units, fallback 2D
texture unbind targets, and layer compositing copy targets. texture unbind targets, and layer compositing copy targets.
Canvas layer merge rendering also consumes backend-owned depth/blend state,
active texture units, fallback 2D texture unbind targets, and merge
framebuffer copy targets.
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test - `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
for the current headless component matrix; see DEBT-0007 for remaining app for the current headless component matrix; see DEBT-0007 for remaining app
and platform triplet migration. and platform triplet migration.

View File

@@ -765,6 +765,9 @@ Results:
- Canvas stroke commit now routes saved viewport/clear/blend state, history - Canvas stroke commit now routes saved viewport/clear/blend state, history
readbacks, active texture units, fallback 2D texture unbinds, and layer readbacks, active texture units, fallback 2D texture unbinds, and layer
compositing copy targets through the renderer GL backend mapping. compositing copy targets through the renderer GL backend mapping.
- Canvas layer merge rendering now routes depth/blend state, active texture
units, fallback 2D texture unbinds, and merge framebuffer copy targets through
the renderer GL backend mapping.
- Known remaining warnings: legacy project/vendor diagnostics, Visual Studio - Known remaining warnings: legacy project/vendor diagnostics, Visual Studio
vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime
library conflict from retained vendor binaries. library conflict from retained vendor binaries.

View File

@@ -1076,7 +1076,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
use_blend |= Canvas::I->m_current_stroke->m_brush->m_blend_mode != 0; use_blend |= Canvas::I->m_current_stroke->m_brush->m_blend_mode != 0;
// if not using shader blend, use gl rasterizer blend // if not using shader blend, use gl rasterizer blend
glDisable(GL_DEPTH_TEST); glDisable(depth_test_state());
for (int plane_index = 0; plane_index < 6; plane_index++) for (int plane_index = 0; plane_index < 6; plane_index++)
{ {
@@ -1088,7 +1088,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
if (use_blend) if (use_blend)
{ {
glDisable(GL_BLEND); glDisable(blend_state());
m_layers_merge.rtt(plane_index).clear(); m_layers_merge.rtt(plane_index).clear();
} }
else else
@@ -1100,7 +1100,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
ShaderManager::u_mat4(kShaderUniform::MVP, ortho); ShaderManager::u_mat4(kShaderUniform::MVP, ortho);
m_plane.draw_fill(); m_plane.draw_fill();
} }
glEnable(GL_BLEND); glEnable(blend_state());
} }
for (int layer_index = 0; layer_index < m_layers.size(); layer_index++) for (int layer_index = 0; layer_index < m_layers.size(); layer_index++)
@@ -1132,17 +1132,17 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
//ShaderManager::u_int(kShaderUniform::Lock, m_layers[layer_index]->m_alpha_locked); //ShaderManager::u_int(kShaderUniform::Lock, m_layers[layer_index]->m_alpha_locked);
ShaderManager::u_int(kShaderUniform::Mask, m_smask_active); ShaderManager::u_int(kShaderUniform::Mask, m_smask_active);
ShaderManager::u_mat4(kShaderUniform::MVP, ortho); ShaderManager::u_mat4(kShaderUniform::MVP, ortho);
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture(); m_layers[layer_index]->rtt(plane_index).bindTexture();
glActiveTexture(GL_TEXTURE1); set_active_texture_unit(1);
m_tmp[plane_index].bindTexture(); m_tmp[plane_index].bindTexture();
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture(); m_smask.rtt(plane_index).bindTexture();
m_plane.draw_fill(); m_plane.draw_fill();
m_smask.rtt(plane_index).unbindTexture(); m_smask.rtt(plane_index).unbindTexture();
glActiveTexture(GL_TEXTURE1); set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture(); m_tmp[plane_index].unbindTexture();
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).unbindTexture(); m_layers[layer_index]->rtt(plane_index).unbindTexture();
} }
else if (m_current_stroke && m_show_tmp && m_current_layer_idx == layer_index) else if (m_current_stroke && m_show_tmp && m_current_layer_idx == layer_index)
@@ -1182,28 +1182,28 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
ShaderManager::u_vec2(kShaderUniform::PatternOffset, Canvas::I->m_pattern_offset); ShaderManager::u_vec2(kShaderUniform::PatternOffset, Canvas::I->m_pattern_offset);
ShaderManager::u_float(kShaderUniform::DualAlpha, b->m_dual_opacity); ShaderManager::u_float(kShaderUniform::DualAlpha, b->m_dual_opacity);
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture(); m_layers[layer_index]->rtt(plane_index).bindTexture();
glActiveTexture(GL_TEXTURE1); set_active_texture_unit(1);
m_tmp[plane_index].bindTexture(); m_tmp[plane_index].bindTexture();
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture(); m_smask.rtt(plane_index).bindTexture();
glActiveTexture(GL_TEXTURE3); set_active_texture_unit(3);
if (b->m_dual_enabled) if (b->m_dual_enabled)
m_tmp_dual[plane_index].bindTexture(); m_tmp_dual[plane_index].bindTexture();
glActiveTexture(GL_TEXTURE4); set_active_texture_unit(4);
b->m_pattern_texture ? b->m_pattern_texture ?
b->m_pattern_texture->bind() : b->m_pattern_texture->bind() :
glBindTexture(GL_TEXTURE_2D, 0); unbind_texture_2d();
m_plane.draw_fill(); m_plane.draw_fill();
glActiveTexture(GL_TEXTURE3); set_active_texture_unit(3);
if (b->m_dual_enabled) if (b->m_dual_enabled)
m_tmp_dual[plane_index].unbindTexture(); m_tmp_dual[plane_index].unbindTexture();
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_smask.rtt(plane_index).unbindTexture(); m_smask.rtt(plane_index).unbindTexture();
glActiveTexture(GL_TEXTURE1); set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture(); m_tmp[plane_index].unbindTexture();
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).unbindTexture(); m_layers[layer_index]->rtt(plane_index).unbindTexture();
} }
else else
@@ -1215,7 +1215,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
ShaderManager::u_int(kShaderUniform::Highlight, m_layers[layer_index]->m_hightlight); ShaderManager::u_int(kShaderUniform::Highlight, m_layers[layer_index]->m_hightlight);
ShaderManager::u_mat4(kShaderUniform::MVP, ortho); ShaderManager::u_mat4(kShaderUniform::MVP, ortho);
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_layers[layer_index]->rtt(plane_index).bindTexture(); m_layers[layer_index]->rtt(plane_index).bindTexture();
m_plane.draw_fill(); m_plane.draw_fill();
m_layers[layer_index]->rtt(plane_index).unbindTexture(); m_layers[layer_index]->rtt(plane_index).unbindTexture();
@@ -1243,35 +1243,35 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
ShaderManager::u_int(kShaderUniform::TexBG, 2); ShaderManager::u_int(kShaderUniform::TexBG, 2);
} }
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_merge_rtt.bindTexture(); m_merge_rtt.bindTexture();
if (!ShaderManager::ext_framebuffer_fetch) if (!ShaderManager::ext_framebuffer_fetch)
{ {
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_merge_tex.bind(); m_merge_tex.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height); glCopyTexSubImage2D(texture_2d_target(), 0, 0, 0, 0, 0, m_width, m_height);
} }
m_plane.draw_fill(); m_plane.draw_fill();
if (!ShaderManager::ext_framebuffer_fetch) if (!ShaderManager::ext_framebuffer_fetch)
{ {
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_merge_tex.unbind(); m_merge_tex.unbind();
} }
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_merge_rtt.unbindTexture(); m_merge_rtt.unbindTexture();
} }
} }
glActiveTexture(GL_TEXTURE2); set_active_texture_unit(2);
m_merge_tex.bind(); m_merge_tex.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height); glCopyTexSubImage2D(texture_2d_target(), 0, 0, 0, 0, 0, m_width, m_height);
// draw the grid behind the layers using a temporary copy // draw the grid behind the layers using a temporary copy
if (use_blend) if (use_blend)
{ {
glEnable(GL_BLEND); glEnable(blend_state());
//draw the grid //draw the grid
if (draw_checkerboard) if (draw_checkerboard)
@@ -1284,7 +1284,7 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
// draw the layers // draw the layers
m_sampler.bind(0); m_sampler.bind(0);
glActiveTexture(GL_TEXTURE0); set_active_texture_unit(0);
m_merge_tex.bind(); m_merge_tex.bind();
ShaderManager::use(kShader::Texture); ShaderManager::use(kShader::Texture);
ShaderManager::u_int(kShaderUniform::Tex, 0); ShaderManager::u_int(kShaderUniform::Tex, 0);