MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ setup_rendering()

void MayaFlux::Buffers::TextureBuffer::setup_rendering ( const RenderConfig &  config)
virtual

Setup rendering with RenderProcessor.

Parameters
configRendering configuration

Reimplemented in MayaFlux::Buffers::TextBuffer, and MayaFlux::Buffers::TextureArrayBuffer.

Definition at line 70 of file TextureBuffer.cpp.

71{
72 if (!user_config.vertex_shader.empty()) {
73 m_render_config.vertex_shader = user_config.vertex_shader;
74 }
75 if (!user_config.fragment_shader.empty()) {
76 m_render_config.fragment_shader = user_config.fragment_shader;
77 }
78 if (!user_config.default_texture_binding.empty()) {
79 m_render_config.default_texture_binding = user_config.default_texture_binding;
80 }
81 if (user_config.topology != Portal::Graphics::PrimitiveTopology::TRIANGLE_STRIP) {
83 "TextureBuffer only supports TRIANGLE_STRIP topology. Ignoring provided topology.");
84 } else {
85 if (user_config.topology != m_render_config.topology) {
86 m_render_config.topology = user_config.topology;
87 }
88 }
89 m_render_config.target_window = user_config.target_window;
90
91 if (!user_config.additional_textures.empty()) {
92 for (const auto& [name, texture] : user_config.additional_textures) {
93 m_render_config.additional_textures.emplace_back(name, texture);
94 }
95 }
96
97 ShaderConfig shader_config { m_render_config.vertex_shader };
98 shader_config.bindings[m_render_config.default_texture_binding] = ShaderBinding(
99 0, 1, vk::DescriptorType::eCombinedImageSampler);
100
101 uint32_t binding_index = 2;
102 for (const auto& [name, _] : m_render_config.additional_textures) {
103 shader_config.bindings[name] = ShaderBinding(
104 0, binding_index++, vk::DescriptorType::eCombinedImageSampler);
105 }
106
107 apply_render_config(m_render_config, shader_config);
108
110
111 for (const auto& [name, texture] : m_render_config.additional_textures) {
112 m_render_processor->bind_texture(name, texture);
113 }
114
115 get_processing_chain()->add_final_processor(m_render_processor, shared_from_this());
116}
#define MF_WARN(comp, ctx,...)
std::string name
Definition VKDevice.cpp:123
std::shared_ptr< Core::VKImage > get_texture() const
Get GPU texture image Suitable for binding to shaders via RenderProcessor::bind_texture()
std::shared_ptr< Buffers::BufferProcessingChain > get_processing_chain() override
Access the buffer's processing chain.
Definition VKBuffer.cpp:271
void apply_render_config(const RenderConfig &config, const ShaderConfig &shader_config)
Configure the internal m_render_processor from a RenderConfig.
Definition VKBuffer.cpp:344
std::shared_ptr< RenderProcessor > m_render_processor
Definition VKBuffer.hpp:654
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
std::shared_ptr< Core::Window > target_window
std::vector< std::pair< std::string, std::shared_ptr< Core::VKImage > > > additional_textures

References MayaFlux::Portal::Graphics::RenderConfig::additional_textures, MayaFlux::Buffers::VKBuffer::apply_render_config(), MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Portal::Graphics::RenderConfig::default_texture_binding, MayaFlux::Portal::Graphics::RenderConfig::fragment_shader, MayaFlux::Buffers::VKBuffer::get_processing_chain(), get_texture(), MayaFlux::Buffers::VKBuffer::m_render_config, MayaFlux::Buffers::VKBuffer::m_render_processor, MF_WARN, name, MayaFlux::Portal::Graphics::RenderConfig::target_window, MayaFlux::Portal::Graphics::RenderConfig::topology, MayaFlux::Portal::Graphics::TRIANGLE_STRIP, and MayaFlux::Portal::Graphics::RenderConfig::vertex_shader.

Referenced by MayaFlux::Yantra::Vision::VisionWorkflow::process_to_buffer(), MayaFlux::Buffers::TextBuffer::setup_rendering(), and MayaFlux::Buffers::TextureArrayBuffer::setup_rendering().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: