Extract retained stroke preview pass orchestration plan

This commit is contained in:
2026-06-13 11:43:31 +02:00
parent 67c594129d
commit cf92181ae4
9 changed files with 306 additions and 129 deletions

View File

@@ -27,35 +27,6 @@ pp::renderer::RenderDeviceFeatures stroke_preview_render_device_features() noexc
return ShaderManager::render_device_features();
}
pp::paint_renderer::CanvasStrokeFeedbackPlan stroke_preview_destination_feedback_plan(
int width,
int height) noexcept
{
return pp::panopainter::plan_legacy_node_stroke_preview_feedback(
stroke_preview_render_device_features(),
width,
height);
}
pp::paint_renderer::CanvasStrokeMaterialPlan stroke_preview_material_plan(
const Brush& brush,
bool destination_feedback_needed) noexcept
{
return pp::panopainter::plan_legacy_canvas_stroke_material(
pp::paint_renderer::CanvasStrokeMaterialRequest {
.destination_feedback_needed = destination_feedback_needed,
.pattern_enabled = brush.m_pattern_enabled,
.pattern_eachsample = brush.m_pattern_eachsample,
.wet_blend = brush.m_tip_wet > 0.F,
.mix_blend = brush.m_tip_mix > 0.F,
.noise_enabled = brush.m_tip_noise > 0.F,
.dual_brush_enabled = brush.m_dual_enabled,
.dual_blend_mode = brush.m_dual_blend_mode,
.pattern_blend_mode = brush.m_pattern_blend_mode,
.dual_alpha = brush.m_dual_opacity,
});
}
void set_active_texture_unit(std::uint32_t unit_index)
{
pp::legacy::ui_gl::activate_texture_unit(unit_index, "NodeStrokePreview");
@@ -761,33 +732,33 @@ void NodeStrokePreview::draw_stroke_immediate()
const glm::vec2 patt_scale = stroke_setup.pattern_scale;
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
const auto stroke_feedback = stroke_preview_destination_feedback_plan(m_rtt.getWidth(), m_rtt.getHeight());
const bool copy_stroke_destination = !stroke_feedback.reads_destination_color;
const auto material = stroke_preview_material_plan(*b, copy_stroke_destination);
const auto preview_composite_plan = pp::panopainter::plan_legacy_node_stroke_preview_composite(
b->m_tip_mix > 0.0f,
material.composite_pass.use_dual,
material.composite_pass.use_pattern);
pp::panopainter::setup_legacy_stroke_shader(
pp::panopainter::LegacyStrokeShaderSetupUniforms {
.resolution = size,
.pattern = {
.scale = patt_scale,
.invert = static_cast<float>(b->m_pattern_invert),
.brightness = b->m_pattern_brightness,
.contrast = b->m_pattern_contrast,
.depth = b->m_pattern_depth,
.blend_mode = b->m_pattern_blend_mode,
.offset = glm::vec2(b->m_pattern_rand_offset ? 0.5f : 0.0f),
},
const auto pass_orchestration = pp::panopainter::plan_legacy_node_stroke_preview_pass_orchestration(
pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationRequest {
.features = stroke_preview_render_device_features(),
.preview_size = size,
.pattern_scale = b->m_pattern_scale,
.pattern_flipx = b->m_pattern_flipx,
.pattern_flipy = b->m_pattern_flipy,
.pattern_invert = b->m_pattern_invert,
.pattern_brightness = b->m_pattern_brightness,
.pattern_contrast = b->m_pattern_contrast,
.pattern_depth = b->m_pattern_depth,
.pattern_rand_offset = b->m_pattern_rand_offset,
.pattern_enabled = b->m_pattern_enabled,
.pattern_eachsample = b->m_pattern_eachsample,
.tip_mix = b->m_tip_mix,
.tip_wet = b->m_tip_wet,
.tip_noise = b->m_tip_noise,
.dual_enabled = b->m_dual_enabled,
.dual_blend_mode = b->m_dual_blend_mode,
.dual_opacity = b->m_dual_opacity,
.pattern_blend_mode = b->m_pattern_blend_mode,
.blend_mode = b->m_blend_mode,
.mvp = ortho_proj,
.uses_destination_feedback = copy_stroke_destination,
.uses_pattern = false,
.mix_alpha = 0.0f,
.wet = 0.0f,
.noise = 0.0f,
.set_opacity = false,
});
const bool copy_stroke_destination = pass_orchestration.copy_stroke_destination;
const auto& material = pass_orchestration.material;
pp::panopainter::setup_legacy_stroke_shader(pass_orchestration.stroke_shader);
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_pass_sequence(
pp::panopainter::LegacyNodeStrokePreviewPassSequenceRequest {
@@ -817,7 +788,7 @@ void NodeStrokePreview::draw_stroke_immediate()
.capture_background = [&] {
execute_stroke_preview_background_capture_pass(
size,
b->m_tip_mix > 0.f || b->m_blend_mode != 0,
pass_orchestration.background_colorize,
m_tex_background,
[&] {
m_plane.draw_fill();
@@ -836,7 +807,7 @@ void NodeStrokePreview::draw_stroke_immediate()
m_tex,
m_rtt_mixer,
copy_stroke_destination,
preview_composite_plan.uses_mixer);
pass_orchestration.composite.uses_mixer);
},
.execute_main_pass = [&] {
execute_stroke_preview_live_pass(