Extract preview main pass orchestration

This commit is contained in:
2026-06-13 18:31:42 +02:00
parent 86777b26b5
commit fe16a6a270
5 changed files with 197 additions and 39 deletions

View File

@@ -234,6 +234,60 @@ struct LegacyNodeStrokePreviewPassOrchestrationPlan {
bool background_colorize = false;
};
template <typename Frame>
struct LegacyNodeStrokePreviewMainLivePassRequestT {
std::function<void()> setup_blend_uniforms;
std::function<void()> bind_main_pass_textures;
std::function<void()> clear_target;
std::function<std::vector<Frame>()> compute_frames;
std::function<void(Frame&)> before_frame;
std::function<void(Frame&)> setup_sample_shader;
std::function<void(Frame&)> draw_sample;
std::function<void()> copy_pass_result;
std::function<void()> finish_main_pass;
};
template <typename Frame>
[[nodiscard]] inline bool execute_legacy_node_stroke_preview_main_live_pass(
const LegacyNodeStrokePreviewMainLivePassRequestT<Frame>& request)
{
if (!request.setup_blend_uniforms ||
!request.bind_main_pass_textures ||
!request.clear_target ||
!request.compute_frames ||
!request.before_frame ||
!request.setup_sample_shader ||
!request.draw_sample ||
!request.copy_pass_result ||
!request.finish_main_pass) {
return false;
}
request.setup_blend_uniforms();
request.bind_main_pass_textures();
pp::panopainter::execute_legacy_stroke_preview_live_pass(
[&] {
request.clear_target();
},
[&] {
return request.compute_frames();
},
[&](Frame& frame) {
request.before_frame(frame);
},
[&](Frame& frame) {
request.setup_sample_shader(frame);
},
[&](Frame& frame) {
request.draw_sample(frame);
},
[&] {
request.copy_pass_result();
});
request.finish_main_pass();
return true;
}
struct LegacyNodeStrokePreviewPassOrchestrationRequest {
pp::renderer::RenderDeviceFeatures features {};
glm::vec2 preview_size {};

View File

@@ -779,47 +779,66 @@ void NodeStrokePreview::draw_stroke_immediate()
pass_orchestration.composite.uses_mixer);
},
.execute_main_pass = [&] {
pp::panopainter::execute_legacy_stroke_preview_live_pass(
[&] {
m_rtt.clear();
},
[&] {
return stroke_draw_compute(m_stroke, zoom);
},
[&](auto& frame) {
if (b->m_tip_mix > 0.f)
{
stroke_draw_mix(xy(frame.m_mixer_rect), zw(frame.m_mixer_rect));
}
[[maybe_unused]] const bool main_live_ok =
pp::panopainter::execute_legacy_node_stroke_preview_main_live_pass(
pp::panopainter::LegacyNodeStrokePreviewMainLivePassRequestT<StrokeFrame> {
.setup_blend_uniforms = [&] {
pp::panopainter::apply_legacy_stroke_blend_uniforms(
material.stroke_pass.uses_pattern,
b->m_tip_mix,
b->m_tip_wet,
b->m_tip_noise);
},
.bind_main_pass_textures = [&] {
bind_stroke_preview_main_pass_textures(
*b,
m_tex,
m_rtt_mixer,
copy_stroke_destination,
material.stroke_pass.uses_mixer);
},
.clear_target = [&] {
m_rtt.clear();
},
.compute_frames = [&] {
return stroke_draw_compute(m_stroke, zoom);
},
.before_frame = [&](auto& frame) {
if (b->m_tip_mix > 0.f)
{
stroke_draw_mix(xy(frame.m_mixer_rect), zw(frame.m_mixer_rect));
}
frame.col = b->m_blend_mode != 0 || b->m_tip_mix > 0.f ?
glm::vec4 { .7, .4, .1, 1 } :
glm::vec4 { 0, 0, 0, 1 };
frame.flow = glm::max(frame.flow, m_min_flow);
},
[&](auto& frame) {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = frame.col,
.alpha = frame.flow,
.opacity = frame.opacity,
});
},
[&](auto& frame) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
},
[&] {
copy_stroke_preview_framebuffer_to_texture(
m_tex,
size,
stroke_preview_composite_slots::kStroke);
frame.col = b->m_blend_mode != 0 || b->m_tip_mix > 0.f ?
glm::vec4 { .7, .4, .1, 1 } :
glm::vec4 { 0, 0, 0, 1 };
frame.flow = glm::max(frame.flow, m_min_flow);
},
.setup_sample_shader = [&](auto& frame) {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = frame.col,
.alpha = frame.flow,
.opacity = frame.opacity,
});
},
.draw_sample = [&](auto& frame) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
},
.copy_pass_result = [&] {
copy_stroke_preview_framebuffer_to_texture(
m_tex,
size,
stroke_preview_composite_slots::kStroke);
},
.finish_main_pass = [&] {
set_active_texture_unit(stroke_preview_live_slots::kMixer);
m_rtt_mixer.unbindTexture();
},
});
},
.finish_main_pass = [&] {
set_active_texture_unit(stroke_preview_live_slots::kMixer);
m_rtt_mixer.unbindTexture();
},
.finish_main_pass = [&] {},
.execute_final_composite = [&] {
execute_stroke_preview_final_composite_pass(
StrokePreviewCompositePassInputs {