Share retained stroke preview mix executor
This commit is contained in:
@@ -124,18 +124,6 @@ struct StrokePreviewCompositePassInputs {
|
||||
std::function<void()> draw_composite;
|
||||
};
|
||||
|
||||
struct StrokePreviewMixPassInputs {
|
||||
glm::vec2 scissor_min;
|
||||
glm::vec2 scissor_size;
|
||||
RTT& mixer_rtt;
|
||||
Texture2D& background_texture;
|
||||
RTT& stroke_rtt;
|
||||
Texture2D& dual_texture;
|
||||
const Brush& brush;
|
||||
Sampler& linear_sampler;
|
||||
std::function<void()> draw_mix;
|
||||
};
|
||||
|
||||
pp::panopainter::LegacyNodeStrokePreviewMixPassRequest make_stroke_preview_mix_pass_request(
|
||||
const Brush& brush,
|
||||
glm::vec2 resolution) noexcept
|
||||
@@ -190,40 +178,6 @@ pp::panopainter::LegacyStrokeCompositeUniforms make_stroke_preview_mix_composite
|
||||
};
|
||||
}
|
||||
|
||||
void execute_stroke_preview_mix_pass(const StrokePreviewMixPassInputs& inputs)
|
||||
{
|
||||
gl_state gl;
|
||||
gl.save();
|
||||
|
||||
inputs.mixer_rtt.bindFramebuffer();
|
||||
|
||||
apply_stroke_preview_viewport(0, 0, inputs.mixer_rtt.getWidth(), inputs.mixer_rtt.getHeight());
|
||||
apply_stroke_preview_capability(pp::renderer::gl::depth_test_state(), false);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::scissor_test_state(), true);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
|
||||
apply_stroke_preview_scissor(
|
||||
static_cast<int>(inputs.scissor_min.x),
|
||||
static_cast<int>(inputs.scissor_min.y),
|
||||
static_cast<int>(inputs.scissor_size.x),
|
||||
static_cast<int>(inputs.scissor_size.y));
|
||||
|
||||
inputs.linear_sampler.bind(stroke_preview_composite_slots::kBackground);
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kBackground);
|
||||
inputs.background_texture.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kStroke);
|
||||
inputs.stroke_rtt.bindTexture();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kDual);
|
||||
inputs.dual_texture.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kPattern);
|
||||
inputs.brush.m_pattern_texture ?
|
||||
inputs.brush.m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
inputs.draw_mix();
|
||||
|
||||
inputs.mixer_rtt.unbindFramebuffer();
|
||||
gl.restore();
|
||||
}
|
||||
|
||||
void execute_stroke_preview_final_composite_pass(const StrokePreviewCompositePassInputs& inputs)
|
||||
{
|
||||
pp::panopainter::execute_legacy_stroke_preview_final_composite(
|
||||
@@ -607,23 +561,67 @@ void NodeStrokePreview::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2
|
||||
const auto& b = m_brush;
|
||||
const auto mix_pass = pp::panopainter::plan_legacy_node_stroke_preview_mix_pass(
|
||||
make_stroke_preview_mix_pass_request(*b, m_size));
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
make_stroke_preview_mix_composite_uniforms(mix_pass.shader));
|
||||
|
||||
execute_stroke_preview_mix_pass(
|
||||
StrokePreviewMixPassInputs {
|
||||
.scissor_min = bb_min,
|
||||
.scissor_size = bb_sz,
|
||||
.mixer_rtt = m_rtt_mixer,
|
||||
.background_texture = m_tex_background,
|
||||
.stroke_rtt = m_rtt,
|
||||
.dual_texture = m_tex_dual,
|
||||
.brush = *b,
|
||||
.linear_sampler = m_sampler_linear,
|
||||
gl_state gl;
|
||||
[[maybe_unused]] const bool mix_ok = pp::panopainter::execute_legacy_node_stroke_preview_mix_pass(
|
||||
pp::panopainter::LegacyNodeStrokePreviewMixExecutionRequest {
|
||||
.shader = mix_pass.shader,
|
||||
.mixer_width = m_rtt_mixer.getWidth(),
|
||||
.mixer_height = m_rtt_mixer.getHeight(),
|
||||
.scissor_x = static_cast<int>(bb_min.x),
|
||||
.scissor_y = static_cast<int>(bb_min.y),
|
||||
.scissor_width = static_cast<int>(bb_sz.x),
|
||||
.scissor_height = static_cast<int>(bb_sz.y),
|
||||
.save_state = [&] {
|
||||
gl.save();
|
||||
},
|
||||
.setup_mix_shader = [&](const pp::panopainter::LegacyNodeStrokePreviewMixPassPlan::ShaderPlan& shader_plan) {
|
||||
pp::panopainter::setup_legacy_stroke_composite_shader(
|
||||
make_stroke_preview_mix_composite_uniforms(shader_plan));
|
||||
},
|
||||
.bind_mixer_framebuffer = [&] {
|
||||
m_rtt_mixer.bindFramebuffer();
|
||||
},
|
||||
.configure_mix_target_state = [&](
|
||||
int mixer_width,
|
||||
int mixer_height,
|
||||
int scissor_x,
|
||||
int scissor_y,
|
||||
int scissor_width,
|
||||
int scissor_height) {
|
||||
apply_stroke_preview_viewport(0, 0, mixer_width, mixer_height);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::depth_test_state(), false);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::scissor_test_state(), true);
|
||||
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
|
||||
apply_stroke_preview_scissor(
|
||||
scissor_x,
|
||||
scissor_y,
|
||||
scissor_width,
|
||||
scissor_height);
|
||||
},
|
||||
.bind_mix_inputs = [&] {
|
||||
m_sampler_linear.bind(stroke_preview_composite_slots::kBackground);
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kBackground);
|
||||
m_tex_background.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kStroke);
|
||||
m_rtt.bindTexture();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kDual);
|
||||
m_tex_dual.bind();
|
||||
set_active_texture_unit(stroke_preview_composite_slots::kPattern);
|
||||
b->m_pattern_texture ?
|
||||
b->m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.draw_mix = [&] {
|
||||
m_plane.draw_fill();
|
||||
},
|
||||
.unbind_mixer_framebuffer = [&] {
|
||||
m_rtt_mixer.unbindFramebuffer();
|
||||
},
|
||||
.restore_state = [&] {
|
||||
gl.restore();
|
||||
},
|
||||
});
|
||||
assert(mix_ok);
|
||||
}
|
||||
|
||||
glm::vec4 NodeStrokePreview::stroke_draw_samples(
|
||||
|
||||
Reference in New Issue
Block a user