MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
DescriptorBuffer.cpp
Go to the documentation of this file.
3
4namespace MayaFlux::Buffers {
5
7 const ShaderProcessorConfig& config,
8 size_t initial_size)
9 : VKBuffer(
10 initial_size,
11 Usage::UNIFORM, // Can hold both UBO and SSBO
12 Kakshya::DataModality::UNKNOWN)
13 , m_config(config)
14{
16 "Created DescriptorBuffer for shader '{}' ({} bytes)",
17 config.shader_path,
19}
20
22{
23 m_bindings_processor = std::make_shared<DescriptorBindingsProcessor>(m_config);
25}
26
28 const std::string& name,
29 const std::shared_ptr<Nodes::Node>& node,
30 const std::string& descriptor_name,
31 uint32_t set)
32{
34 error<std::logic_error>(
37 std::source_location::current(),
38 "DescriptorBuffer not initialized. Call initialize() first.");
39 }
40
41 auto& binding_config = m_config.bindings.at(descriptor_name);
42 m_bindings_processor->bind_scalar_node(name, node, descriptor_name, set, binding_config.type);
43}
44
46 const std::string& name,
47 const std::shared_ptr<Nodes::Node>& node,
48 const std::string& descriptor_name,
49 uint32_t set)
50{
52 error<std::logic_error>(
55 std::source_location::current(),
56 "DescriptorBuffer not initialized. Call initialize() first.");
57 }
58
59 auto& binding_config = m_config.bindings.at(descriptor_name);
60 m_bindings_processor->bind_vector_node(name, node, descriptor_name, set, binding_config.type);
61}
62
64 const std::string& name,
65 const std::shared_ptr<Nodes::Node>& node,
66 const std::string& descriptor_name,
67 uint32_t set)
68{
70 error<std::logic_error>(
73 std::source_location::current(),
74 "DescriptorBuffer not initialized. Call initialize() first.");
75 }
76
77 auto& binding_config = m_config.bindings.at(descriptor_name);
78 m_bindings_processor->bind_matrix_node(name, node, descriptor_name, set, binding_config.type);
79}
80
82 const std::string& name,
83 const std::shared_ptr<Nodes::Node>& node,
84 const std::string& descriptor_name,
85 uint32_t set)
86{
88 error<std::logic_error>(
91 std::source_location::current(),
92 "DescriptorBuffer not initialized. Call initialize() first.");
93 }
94
95 auto& binding_config = m_config.bindings.at(descriptor_name);
96 m_bindings_processor->bind_structured_node(name, node, descriptor_name, set, binding_config.type);
97}
98
99void DescriptorBuffer::unbind(const std::string& name)
100{
102 m_bindings_processor->unbind_node(name);
103 }
104}
105
106std::vector<std::string> DescriptorBuffer::get_binding_names() const
107{
108 return m_bindings_processor ? m_bindings_processor->get_binding_names() : std::vector<std::string> {};
109}
110
111} // namespace MayaFlux::Buffers
#define MF_INFO(comp, ctx,...)
std::shared_ptr< DescriptorBindingsProcessor > m_bindings_processor
std::vector< std::string > get_binding_names() const
Get all binding names.
void bind_scalar(const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set=0)
Bind scalar node output to uniform/SSBO.
DescriptorBuffer(const ShaderProcessorConfig &config, size_t initial_size=4096)
Create descriptor buffer with shader configuration.
void bind_vector(const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set=0)
Bind vector node output to SSBO.
void unbind(const std::string &name)
Remove a binding.
void bind_matrix(const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set=0)
Bind matrix node output to SSBO.
void initialize()
Initialize the buffer and its processors.
void bind_structured(const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set=0)
Bind structured node output to SSBO.
void set_default_processor(std::shared_ptr< Buffers::BufferProcessor > processor) override
Set the buffer's default processor.
Definition VKBuffer.cpp:265
vk::DeviceSize get_size_bytes() const
Definition VKBuffer.hpp:221
Vulkan-backed buffer wrapper used in processing chains.
Definition VKBuffer.hpp:52
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Init
Engine/subsystem initialization.
@ Buffers
Buffers, Managers, processors and processing chains.
std::unordered_map< std::string, ShaderBinding > bindings
std::string shader_path
Path to shader file.
Complete configuration for shader processor.