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

Wrapper for Vulkan compute pipeline with simplified interface. More...

#include <VKComputePipeline.hpp>

+ Collaboration diagram for MayaFlux::Core::VKComputePipeline:

Public Member Functions

 VKComputePipeline ()=default
 
 ~VKComputePipeline ()
 
 VKComputePipeline (const VKComputePipeline &)=delete
 
VKComputePipelineoperator= (const VKComputePipeline &)=delete
 
 VKComputePipeline (VKComputePipeline &&) noexcept
 
VKComputePipelineoperator= (VKComputePipeline &&) noexcept
 
bool create (vk::Device device, const ComputePipelineConfig &config)
 Create compute pipeline from configuration.
 
void cleanup (vk::Device device)
 Cleanup pipeline resources.
 
vk::Pipeline get () const
 Get raw Vulkan pipeline handle.
 
vk::PipelineLayout get_layout () const
 Get pipeline layout handle.
 
void bind (vk::CommandBuffer cmd) const
 Bind pipeline to command buffer.
 
void bind_descriptor_sets (vk::CommandBuffer cmd, const std::vector< vk::DescriptorSet > &descriptor_sets, uint32_t first_set=0, const std::vector< uint32_t > &dynamic_offsets={}) const
 Bind descriptor sets to pipeline.
 
void push_constants (vk::CommandBuffer cmd, vk::ShaderStageFlags stage_flags, uint32_t offset, uint32_t size, const void *data) const
 Update push constants.
 
void dispatch (vk::CommandBuffer cmd, uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z) const
 Dispatch compute workgroups.
 
void dispatch_1d (vk::CommandBuffer cmd, uint32_t element_count, uint32_t local_size_x) const
 Dispatch compute workgroups with automatic calculation.
 
void dispatch_2d (vk::CommandBuffer cmd, uint32_t width_elements, uint32_t height_elements, uint32_t local_size_x, uint32_t local_size_y) const
 Dispatch compute workgroups in 2D with automatic calculation.
 
void dispatch_3d (vk::CommandBuffer cmd, uint32_t width_elements, uint32_t height_elements, uint32_t depth_elements, uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z) const
 Dispatch compute workgroups in 3D with automatic calculation.
 
std::optional< std::array< uint32_t, 3 > > get_workgroup_size () const
 Get shader workgroup size from reflection.
 
bool create_specialized (vk::Device device, const ComputePipelineConfig &config, const std::unordered_map< uint32_t, uint32_t > &specialization_data)
 Create pipeline with specialization constants.
 
template<typename T >
void push_constants_typed (vk::CommandBuffer cmd, const T &data)
 Push constants with type safety.
 
void dispatch_indirect (vk::CommandBuffer cmd, vk::Buffer buffer, vk::DeviceSize offset=0)
 Dispatch compute shader indirectly from GPU buffer.
 
bool is_valid () const
 Get pipeline statistics (if available)
 
const ShaderReflectionget_shader_reflection () const
 Get shader module reflection data.
 

Static Public Member Functions

static std::array< uint32_t, 3 > calculate_dispatch_1d (uint32_t element_count, uint32_t workgroup_size)
 Calculate dispatch size from element count.
 
static std::array< uint32_t, 3 > calculate_dispatch_2d (uint32_t width, uint32_t height, uint32_t workgroup_x, uint32_t workgroup_y)
 Calculate 2D dispatch size.
 
static std::array< uint32_t, 3 > calculate_dispatch_3d (uint32_t width, uint32_t height, uint32_t depth, uint32_t workgroup_x, uint32_t workgroup_y, uint32_t workgroup_z)
 Calculate 3D dispatch size.
 

Private Member Functions

vk::PipelineLayout create_pipeline_layout (vk::Device device, const ComputePipelineConfig &config)
 Create pipeline layout from configuration.
 

Static Private Member Functions

static uint32_t calculate_workgroups (uint32_t element_count, uint32_t workgroup_size)
 Calculate number of workgroups needed.
 

Private Attributes

vk::Pipeline m_pipeline = nullptr
 
vk::PipelineLayout m_layout = nullptr
 
std::shared_ptr< VKShaderModulem_shader
 
std::optional< std::array< uint32_t, 3 > > m_workgroup_size
 

Detailed Description

Wrapper for Vulkan compute pipeline with simplified interface.

Responsibilities:

  • Create compute pipeline from shader and configuration
  • Manage pipeline layout (descriptor sets + push constants)
  • Bind pipeline to command buffer
  • Bind descriptor sets
  • Update push constants
  • Dispatch compute workgroups
  • Handle pipeline recreation (for hot-reload)

Does NOT handle:

Design:

  • Immutable after creation (recreation required for changes)
  • Lightweight wrapper around vk::Pipeline
  • Can be used directly or via VKComputeProcessor

Thread Safety:

  • NOT thread-safe - caller must synchronize access
  • Safe to use same pipeline on different command buffers (sequentially)

Definition at line 85 of file VKComputePipeline.hpp.


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