Extract preview main pass texture dispatch
This commit is contained in:
@@ -234,6 +234,49 @@ struct LegacyNodeStrokePreviewPassOrchestrationPlan {
|
||||
bool background_colorize = false;
|
||||
};
|
||||
|
||||
struct LegacyNodeStrokePreviewMainPassTextureDispatch {
|
||||
std::function<void(int)> activate_texture_unit;
|
||||
std::function<void()> bind_brush_tip;
|
||||
std::function<void()> bind_stroke_destination;
|
||||
std::function<void()> bind_pattern;
|
||||
std::function<void()> bind_mixer;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline LegacyNodeStrokePreviewMainPassTextureDispatch make_legacy_node_stroke_preview_main_pass_texture_dispatch(
|
||||
std::function<void(int)> activate_texture_unit,
|
||||
std::function<void()> bind_brush_tip,
|
||||
std::function<void()> bind_stroke_destination,
|
||||
std::function<void()> bind_pattern,
|
||||
std::function<void()> bind_mixer)
|
||||
{
|
||||
return LegacyNodeStrokePreviewMainPassTextureDispatch {
|
||||
.activate_texture_unit = std::move(activate_texture_unit),
|
||||
.bind_brush_tip = std::move(bind_brush_tip),
|
||||
.bind_stroke_destination = std::move(bind_stroke_destination),
|
||||
.bind_pattern = std::move(bind_pattern),
|
||||
.bind_mixer = std::move(bind_mixer),
|
||||
};
|
||||
}
|
||||
|
||||
inline void bind_legacy_node_stroke_preview_main_pass_textures(
|
||||
const LegacyNodeStrokePreviewMainPassTextureDispatch& dispatch,
|
||||
bool copy_stroke_destination,
|
||||
bool uses_mixer)
|
||||
{
|
||||
dispatch.activate_texture_unit(0);
|
||||
dispatch.bind_brush_tip();
|
||||
if (copy_stroke_destination) {
|
||||
dispatch.activate_texture_unit(1);
|
||||
dispatch.bind_stroke_destination();
|
||||
}
|
||||
dispatch.activate_texture_unit(2);
|
||||
dispatch.bind_pattern();
|
||||
dispatch.activate_texture_unit(3);
|
||||
if (uses_mixer) {
|
||||
dispatch.bind_mixer();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Frame>
|
||||
struct LegacyNodeStrokePreviewMainLivePassRequestT {
|
||||
std::function<void()> setup_blend_uniforms;
|
||||
|
||||
@@ -244,24 +244,29 @@ void bind_stroke_preview_main_pass_textures(
|
||||
bool copy_stroke_destination,
|
||||
bool uses_mixer)
|
||||
{
|
||||
set_active_texture_unit(stroke_preview_live_slots::kTip);
|
||||
brush.m_tip_texture ?
|
||||
brush.m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
|
||||
if (copy_stroke_destination)
|
||||
{
|
||||
set_active_texture_unit(stroke_preview_live_slots::kDestination);
|
||||
stroke_destination_texture.bind();
|
||||
}
|
||||
|
||||
set_active_texture_unit(stroke_preview_live_slots::kPattern);
|
||||
brush.m_pattern_texture ?
|
||||
brush.m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
|
||||
set_active_texture_unit(stroke_preview_live_slots::kMixer);
|
||||
uses_mixer ? mixer_rtt.bindTexture() : unbind_texture_2d();
|
||||
pp::panopainter::bind_legacy_node_stroke_preview_main_pass_textures(
|
||||
pp::panopainter::make_legacy_node_stroke_preview_main_pass_texture_dispatch(
|
||||
[&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
[&] {
|
||||
brush.m_tip_texture ?
|
||||
brush.m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
[&] {
|
||||
stroke_destination_texture.bind();
|
||||
},
|
||||
[&] {
|
||||
brush.m_pattern_texture ?
|
||||
brush.m_pattern_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
[&] {
|
||||
mixer_rtt.bindTexture();
|
||||
}),
|
||||
copy_stroke_destination,
|
||||
uses_mixer);
|
||||
}
|
||||
|
||||
void bind_stroke_preview_destination_texture(Texture2D& texture)
|
||||
|
||||
Reference in New Issue
Block a user