Share retained stroke sample dirty tracking

This commit is contained in:
2026-06-13 10:01:56 +02:00
parent 7b99dabb33
commit c1724edc47
4 changed files with 139 additions and 55 deletions

View File

@@ -625,7 +625,6 @@ void Canvas::stroke_draw()
}
m_dirty = true;
std::array<bool, 6> merge_faces;
const auto vp = query_canvas_viewport();
const auto cc = query_canvas_clear_color();
@@ -689,47 +688,39 @@ void Canvas::stroke_draw()
std::array<glm::vec4, 6> box_face = SIXPLETTE(glm::vec4(m_size, 0, 0));
std::array<bool, 6> box_dirty = SIXPLETTE(false);
const std::array<bool, 6> include_main_dirty = SIXPLETTE(true);
glm::vec4 pad_color;
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
pp::panopainter::execute_legacy_canvas_stroke_frame_samples_with_dirty_tracking(
frames,
stroke_extent,
std::span<glm::vec4>(m_dirty_box),
std::span<glm::vec4>(box_face),
std::span<const bool>(include_main_dirty),
[&](auto& f) {
if (brush->m_tip_mix > 0.f)
{
stroke_draw_mix(xy(f.m_mixer_rect), zw(f.m_mixer_rect));
}
pad_color = f.col;
},
[&](auto&, int i, auto&) {
m_dirty_face[i] = true;
box_dirty[i] = true;
m_tmp[i].bindFramebuffer();
},
[&](auto& f, int i, auto& P) {
m_dirty_face[i] = true;
merge_faces[i] = true;
box_dirty[i] = true;
[[maybe_unused]] const auto dirty_update = pp::panopainter::execute_legacy_canvas_stroke_face_sample(
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
.extent = stroke_extent,
.previous_accumulated_dirty_box = m_dirty_box[i],
.previous_pass_dirty_box = box_face[i],
.include_in_committed_dirty_box = true,
},
[&] {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = f.col,
.alpha = f.flow,
.opacity = f.opacity,
});
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&] {
m_tmp[i].bindFramebuffer();
},
[&](auto&) {},
[&](glm::vec4) {
m_tmp[i].unbindFramebuffer();
},
&m_dirty_box[i],
&box_face[i]);
pad_color = f.col;
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = f.col,
.alpha = f.flow,
.opacity = f.opacity,
});
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&](auto&, int, auto&, auto&) {},
[&](auto&, int i, auto&, glm::vec4) {
m_tmp[i].unbindFramebuffer();
});
set_active_texture_unit(3);
@@ -806,8 +797,14 @@ void Canvas::stroke_draw()
dual_brush->m_tip_texture->bind() :
unbind_texture_2d();
auto frames_dual = stroke_draw_compute(*m_dual_stroke);
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
const std::array<bool, 6> include_dual_dirty =
SIXPLETTE(stroke_material.composite_pass.dual_blend_mode == 0);
pp::panopainter::execute_legacy_canvas_stroke_frame_samples_with_dirty_tracking(
frames_dual,
stroke_extent,
std::span<glm::vec4>(m_dirty_box),
std::span<glm::vec4>(),
std::span<const bool>(include_dual_dirty),
[&](auto& f) {
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
@@ -816,28 +813,17 @@ void Canvas::stroke_draw()
.opacity = f.opacity,
});
},
[&](auto&, int i, auto&) {
m_tmp_dual[i].bindFramebuffer();
},
[&](auto&, int i, auto& P) {
[[maybe_unused]] const auto dirty_update = pp::panopainter::execute_legacy_canvas_stroke_face_sample(
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
.extent = stroke_extent,
.previous_accumulated_dirty_box = m_dirty_box[i],
.previous_pass_dirty_box = glm::vec4(0.0f),
.include_in_committed_dirty_box =
stroke_material.composite_pass.dual_blend_mode == 0,
},
[&] {
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&] {
m_tmp_dual[i].bindFramebuffer();
},
[&](auto& request) {
request.previous_pass_dirty_box = request.sample_dirty_box;
},
[&](glm::vec4) {
m_tmp_dual[i].unbindFramebuffer();
},
&m_dirty_box[i]);
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&](auto&, int, auto&, auto& request) {
request.previous_pass_dirty_box = request.sample_dirty_box;
},
[&](auto&, int i, auto&, glm::vec4) {
m_tmp_dual[i].unbindFramebuffer();
});
}