MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Buffers::DescriptorBindingsProcessor Class Reference

ShaderProcessor that uploads node outputs to descriptor sets. More...

#include <DescriptorBindingsProcessor.hpp>

+ Inheritance diagram for MayaFlux::Buffers::DescriptorBindingsProcessor:
+ Collaboration diagram for MayaFlux::Buffers::DescriptorBindingsProcessor:

Classes

struct  DescriptorBinding
 

Public Types

enum class  BindingType : uint8_t { SCALAR , VECTOR , MATRIX , STRUCTURED }
 
- Public Types inherited from MayaFlux::Buffers::ShaderProcessor
enum class  BufferUsageHint : uint8_t { NONE = 0 , INPUT_READ = 1 << 0 , OUTPUT_WRITE = 1 << 1 , BIDIRECTIONAL = INPUT_READ | OUTPUT_WRITE }
 Get buffer usage characteristics needed for safe data flow. More...
 

Public Member Functions

 DescriptorBindingsProcessor (const std::string &shader_path, uint32_t workgroup_x=256)
 Create DescriptorBindingsProcessor with shader path.
 
 DescriptorBindingsProcessor (ShaderProcessorConfig config)
 Create DescriptorBindingsProcessor with shader config.
 
void bind_scalar_node (const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set, vk::DescriptorType type=vk::DescriptorType::eUniformBuffer)
 Bind scalar node output to descriptor.
 
void bind_vector_node (const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set, vk::DescriptorType type=vk::DescriptorType::eStorageBuffer)
 Bind vector node (VectorContext) to descriptor.
 
void bind_matrix_node (const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set, vk::DescriptorType type=vk::DescriptorType::eStorageBuffer)
 Bind matrix node (MatrixContext) to descriptor.
 
void bind_structured_node (const std::string &name, const std::shared_ptr< Nodes::Node > &node, const std::string &descriptor_name, uint32_t set, vk::DescriptorType type=vk::DescriptorType::eStorageBuffer)
 Bind structured node (arrays of POD structs) to descriptor.
 
void unbind_node (const std::string &name)
 Remove a binding.
 
bool has_binding (const std::string &name) const
 Check if binding exists.
 
std::vector< std::string > get_binding_names () const
 Get all binding names.
 
- Public Member Functions inherited from MayaFlux::Buffers::ShaderProcessor
 ShaderProcessor (const std::string &shader_path, uint32_t workgroup_x=256)
 Construct processor with shader path.
 
 ShaderProcessor (ShaderProcessorConfig config)
 Construct processor with full configuration.
 
 ~ShaderProcessor () override
 
void processing_function (std::shared_ptr< Buffer > buffer) override
 The core processing function that must be implemented by derived classes.
 
void on_attach (std::shared_ptr< Buffer > buffer) override
 Called when this processor is attached to a buffer.
 
void on_detach (std::shared_ptr< Buffer > buffer) override
 Called when this processor is detached from a buffer.
 
bool is_compatible_with (std::shared_ptr< Buffer > buffer) const override
 Checks if this processor can handle the specified buffer type.
 
void bind_buffer (const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
 Bind a VKBuffer to a named shader descriptor.
 
void unbind_buffer (const std::string &descriptor_name)
 Unbind a buffer from a descriptor.
 
std::shared_ptr< VKBufferget_bound_buffer (const std::string &descriptor_name) const
 Get bound buffer for a descriptor name.
 
void auto_bind_buffer (const std::shared_ptr< VKBuffer > &buffer)
 Auto-bind buffer based on attachment order.
 
bool hot_reload_shader ()
 Hot-reload shader from ShaderFoundry.
 
void set_shader (const std::string &shader_path)
 Update shader path and reload.
 
const std::string & get_shader_path () const
 Get current shader path.
 
void set_workgroup_size (uint32_t x, uint32_t y=1, uint32_t z=1)
 Set workgroup size (should match shader local_size)
 
void set_dispatch_mode (ShaderDispatchConfig::DispatchMode mode)
 Set dispatch mode.
 
void set_manual_dispatch (uint32_t x, uint32_t y=1, uint32_t z=1)
 Set manual dispatch group counts.
 
void set_custom_dispatch (std::function< std::array< uint32_t, 3 >(const std::shared_ptr< VKBuffer > &)> calculator)
 Set custom dispatch calculator.
 
const ShaderDispatchConfigget_dispatch_config () const
 Get current dispatch configuration.
 
void set_push_constant_size (size_t size)
 Set push constant size.
 
template<typename T >
void set_push_constant_size ()
 Set push constant size from type.
 
template<typename T >
void set_push_constant_data (const T &data)
 Update push constant data (type-safe)
 
void set_push_constant_data_raw (const void *data, size_t size)
 Update push constant data (raw bytes)
 
const std::vector< uint8_t > & get_push_constant_data () const
 Get current push constant data.
 
std::vector< uint8_t > & get_push_constant_data ()
 
void set_specialization_constant (uint32_t constant_id, uint32_t value)
 Set specialization constant.
 
void clear_specialization_constants ()
 Clear all specialization constants.
 
void set_config (const ShaderProcessorConfig &config)
 Update entire configuration.
 
const ShaderProcessorConfigget_config () const
 Get current configuration.
 
void add_binding (const std::string &descriptor_name, const ShaderBinding &binding)
 Add descriptor binding configuration.
 
virtual BufferUsageHint get_buffer_usage_hint (const std::string &descriptor_name) const
 Get buffer usage hint for a descriptor.
 
virtual bool is_in_place_operation (const std::string &descriptor_name) const
 Check if shader modifies a specific buffer in-place.
 
bool has_binding (const std::string &descriptor_name) const
 Check if a descriptor binding exists.
 
std::vector< std::string > get_binding_names () const
 Get all configured descriptor names.
 
bool are_bindings_complete () const
 Check if all required bindings are satisfied.
 
bool is_shader_loaded () const
 Check if shader is loaded.
 
bool is_pipeline_ready () const
 Check if pipeline is created.
 
bool are_descriptors_ready () const
 Check if descriptors are initialized.
 
size_t get_bound_buffer_count () const
 Get number of bound buffers.
 
virtual std::shared_ptr< VKBufferget_output_buffer () const
 Get the output buffer after compute dispatch.
 
virtual bool has_executed () const
 Check if compute has been executed at least once.
 
- Public Member Functions inherited from MayaFlux::Buffers::BufferProcessor
virtual ~BufferProcessor ()=default
 Virtual destructor for proper cleanup of derived classes.
 
void process (std::shared_ptr< Buffer > buffer)
 Applies a computational transformation to the data in the provided buffer.
 
virtual void set_processing_token (ProcessingToken token)
 Gets the preferred processing backend for this processor.
 
virtual ProcessingToken get_processing_token () const
 Gets the current processing token for this buffer.
 

Protected Member Functions

void on_before_dispatch (Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer) override
 Called before shader dispatch - updates all descriptors.
 
void on_pipeline_created (Portal::Graphics::ComputePipelineID pipeline_id) override
 Called after pipeline creation - allocates GPU buffers for descriptors.
 
- Protected Member Functions inherited from MayaFlux::Buffers::ShaderProcessor
virtual void on_before_compile (const std::string &shader_path)
 Called before shader compilation.
 
virtual void on_shader_loaded (Portal::Graphics::ShaderID shader_id)
 Called after shader is loaded.
 
virtual void on_before_pipeline_create (Portal::Graphics::ComputePipelineID pipeline_id)
 Called before pipeline creation.
 
virtual void on_before_descriptors_create ()
 Called before descriptor sets are created.
 
virtual void on_descriptors_created ()
 Called after descriptor sets are created.
 
virtual void on_after_dispatch (Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer)
 Called after each dispatch.
 
virtual std::array< uint32_t, 3 > calculate_dispatch_size (const std::shared_ptr< VKBuffer > &buffer)
 Calculate dispatch size from buffer.
 
virtual void initialize_pipeline (const std::shared_ptr< Buffer > &buffer)
 
virtual void cleanup ()
 
- Protected Member Functions inherited from MayaFlux::Buffers::VKBufferProcessor
void initialize_buffer_service ()
 
void initialize_compute_service ()
 

Private Member Functions

void ensure_buffer_capacity (DescriptorBinding &binding, size_t required_size)
 Ensure descriptor buffer has sufficient capacity.
 
void update_descriptor_from_node (DescriptorBinding &binding)
 Update descriptor from node context.
 
std::shared_ptr< VKBuffercreate_descriptor_buffer (size_t size, vk::DescriptorType type)
 Create GPU buffer for a descriptor binding.
 

Private Attributes

std::unordered_map< std::string, DescriptorBindingm_bindings
 

Additional Inherited Members

- Protected Attributes inherited from MayaFlux::Buffers::ShaderProcessor
ShaderProcessorConfig m_config
 
Portal::Graphics::ShaderID m_shader_id = Portal::Graphics::INVALID_SHADER
 
Portal::Graphics::ComputePipelineID m_pipeline_id = Portal::Graphics::INVALID_COMPUTE_PIPELINE
 
std::vector< Portal::Graphics::DescriptorSetIDm_descriptor_set_ids
 
Portal::Graphics::CommandBufferID m_last_command_buffer = Portal::Graphics::INVALID_COMMAND_BUFFER
 
std::unordered_map< std::string, std::shared_ptr< VKBuffer > > m_bound_buffers
 
std::shared_ptr< VKBufferm_last_processed_buffer
 
std::vector< uint8_t > m_push_constant_data
 
bool m_initialized {}
 
bool m_needs_pipeline_rebuild = true
 
bool m_needs_descriptor_rebuild = true
 
size_t m_auto_bind_index {}
 
- Protected Attributes inherited from MayaFlux::Buffers::VKBufferProcessor
Registry::Service::BufferServicem_buffer_service = nullptr
 
Registry::Service::ComputeServicem_compute_service = nullptr
 
- Protected Attributes inherited from MayaFlux::Buffers::BufferProcessor
ProcessingToken m_processing_token { ProcessingToken::AUDIO_BACKEND }
 

Detailed Description

ShaderProcessor that uploads node outputs to descriptor sets.

Binds nodes to UBO/SSBO descriptors. Supports:

  • Scalar nodes (single value)
  • Vector nodes (contiguous arrays via VectorContext)
  • Matrix nodes (2D grids via MatrixContext)
  • Structured nodes (arrays of POD structs)

Usage: auto processor = std::make_shared<DescriptorBindingsProcessor>(shader_config);

// Bind scalar node to UBO processor->bind_scalar_node("frequency", freq_node, "params", 0, vk::DescriptorType::eUniformBuffer);

// Bind vector node to SSBO processor->bind_vector_node("spectrum", spectrum_node, "spectrum_data", 0, vk::DescriptorType::eStorageBuffer);

Definition at line 32 of file DescriptorBindingsProcessor.hpp.


The documentation for this class was generated from the following files: