Extract live stroke face framebuffer helper

This commit is contained in:
2026-06-13 17:48:56 +02:00
parent 07a14fdd56
commit f4176aa234
3 changed files with 131 additions and 1 deletions

View File

@@ -383,6 +383,101 @@ void retained_stroke_destination_texture_dispatch_helper_builds_expected_callbac
PP_EXPECT(h, events == expected_events);
}
void retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order(pp::tests::Harness& h)
{
struct Frame {
int id = -1;
std::array<std::vector<vertex_t>, 6> shapes {};
};
struct Framebuffer {
std::vector<std::string>* events = nullptr;
int face_index = -1;
void bindFramebuffer()
{
events->push_back("bind:" + std::to_string(face_index));
}
void unbindFramebuffer()
{
events->push_back("unbind:" + std::to_string(face_index));
}
};
auto make_frame = [](int id, int face_index) {
Frame frame { .id = id };
frame.shapes[face_index] = {
vertex_t(glm::vec2(0.0F, 0.0F)),
vertex_t(glm::vec2(1.0F, 0.0F)),
vertex_t(glm::vec2(0.5F, 1.0F)),
};
return frame;
};
const std::array<Frame, 2> frames {
make_frame(0, 0),
make_frame(1, 1),
};
std::array<Framebuffer, 2> framebuffers {
Framebuffer { .events = nullptr, .face_index = 0 },
Framebuffer { .events = nullptr, .face_index = 1 },
};
std::vector<std::string> events;
framebuffers[0].events = &events;
framebuffers[1].events = &events;
std::array<glm::vec4, 2> accumulated_dirty_boxes {
glm::vec4(0.0F),
glm::vec4(0.0F),
};
std::array<glm::vec4, 2> pass_dirty_boxes {
glm::vec4(0.0F),
glm::vec4(0.0F),
};
const std::array<bool, 2> include_dirty_faces { true, true };
std::array<bool, 2> committed_dirty_faces { false, false };
std::array<bool, 2> pass_dirty_faces { false, false };
const auto executed_faces = pp::panopainter::execute_legacy_canvas_stroke_live_pass_face_framebuffers(
frames,
pp::renderer::Extent2D { 64U, 32U },
accumulated_dirty_boxes,
pass_dirty_boxes,
include_dirty_faces,
[&](auto& frame) {
events.emplace_back("begin-frame:" + std::to_string(frame.id));
},
[&](auto& frame, int face_index, auto&) {
events.emplace_back("begin-face:" + std::to_string(frame.id) + ":" + std::to_string(face_index));
},
[&](auto& frame, int face_index, auto&) {
events.emplace_back("sample:" + std::to_string(frame.id) + ":" + std::to_string(face_index));
return glm::vec4(0.0F);
},
framebuffers,
true,
committed_dirty_faces,
pass_dirty_faces);
const std::vector<std::string> expected_events {
"begin-frame:0",
"begin-face:0:0",
"bind:0",
"sample:0:0",
"unbind:0",
"begin-frame:1",
"begin-face:1:1",
"bind:1",
"sample:1:1",
"unbind:1",
};
PP_EXPECT(h, executed_faces == 2U);
PP_EXPECT(h, events == expected_events);
PP_EXPECT(h, committed_dirty_faces[0]);
PP_EXPECT(h, committed_dirty_faces[1]);
PP_EXPECT(h, pass_dirty_faces[0]);
PP_EXPECT(h, pass_dirty_faces[1]);
}
void retained_stroke_sample_executor_copies_destination_and_expands_quads(pp::tests::Harness& h)
{
const auto vertices = make_quad_vertices();
@@ -1475,6 +1570,9 @@ int main()
harness.run(
"retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring",
retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring);
harness.run(
"retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order",
retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order);
harness.run(
"retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring",
retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring);