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

Compute pass that writes UV and optionally samples colour into a vertex SSBO. More...

#include <UVFieldProcessor.hpp>

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

Classes

struct  PushConstants
 

Public Member Functions

void clear_texture ()
 Remove the texture source.
 
std::string_view get_type_name () const
 
void set_aux (float aux)
 Set auxiliary projection parameter.
 
void set_axis (const glm::vec3 &axis)
 Set projection axis.
 
void set_origin (const glm::vec3 &origin)
 Set world-space origin of the projection.
 
void set_projection (UVProjectionMode mode)
 Set projection mode.
 
void set_scale (float scale)
 Set UV scale.
 
void set_texture (std::shared_ptr< Core::VKImage > image, const Portal::Graphics::SamplerConfig &config={})
 Bind a texture to sample colour from at computed UV coordinates.
 
 UVFieldProcessor ()
 
 ~UVFieldProcessor () override=default
 
- Public Member Functions inherited from MayaFlux::Buffers::ComputeProcessor
 ComputeProcessor (const std::string &shader_path, uint32_t workgroup_x=256)
 Construct processor with shader path.
 
const ShaderDispatchConfigget_dispatch_config () const
 Get current dispatch configuration.
 
bool is_pipeline_ready () const
 Check if pipeline is created.
 
void set_custom_dispatch (std::function< std::array< uint32_t, 3 >(const std::shared_ptr< VKBuffer > &)> calculator)
 Set custom dispatch calculator.
 
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_workgroup_size (uint32_t x, uint32_t y=1, uint32_t z=1)
 Set workgroup size (should match shader local_size)
 
- Public Member Functions inherited from MayaFlux::Buffers::ShaderProcessor
void add_binding (const std::string &descriptor_name, const ShaderBinding &binding)
 Add descriptor binding configuration.
 
bool are_bindings_complete () const
 Check if all required bindings are satisfied.
 
bool are_descriptors_ready () const
 Check if descriptors are initialized.
 
void auto_bind_buffer (const std::shared_ptr< VKBuffer > &buffer)
 Auto-bind buffer based on attachment order.
 
void bind_buffer (const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
 Bind a VKBuffer to a named shader descriptor.
 
void clear_specialization_constants ()
 Clear all specialization constants.
 
std::vector< std::string > get_binding_names () const
 Get all configured descriptor names.
 
std::shared_ptr< VKBufferget_bound_buffer (const std::string &descriptor_name) const
 Get bound buffer for a descriptor name.
 
size_t get_bound_buffer_count () const
 Get number of bound buffers.
 
virtual BufferUsageHint get_buffer_usage_hint (const std::string &descriptor_name) const
 Get buffer usage hint for a descriptor.
 
const ShaderConfigget_config () const
 Get current configuration.
 
virtual std::shared_ptr< VKBufferget_output_buffer () const
 Get the output buffer after compute dispatch.
 
std::vector< uint8_t > & get_push_constant_data ()
 
const std::vector< uint8_t > & get_push_constant_data () const
 Get current push constant data.
 
const std::string & get_shader_path () const
 Get current shader path.
 
bool has_binding (const std::string &descriptor_name) const
 Check if a descriptor binding exists.
 
virtual bool has_executed () const
 Check if compute has been executed at least once.
 
bool hot_reload_shader ()
 Hot-reload shader from ShaderFoundry.
 
bool is_compatible_with (const std::shared_ptr< Buffer > &buffer) const override
 Checks if this processor can handle the specified buffer type.
 
virtual bool is_in_place_operation (const std::string &descriptor_name) const
 Check if shader modifies a specific buffer in-place.
 
bool is_shader_loaded () const
 Check if shader is loaded.
 
void on_detach (const std::shared_ptr< Buffer > &buffer) override
 Called when this processor is detached from a buffer.
 
void processing_function (const std::shared_ptr< Buffer > &buffer) override
 The core processing function that must be implemented by derived classes.
 
void set_config (const ShaderConfig &config)
 Update entire configuration.
 
template<typename T >
void set_push_constant_data (const T &data)
 Update push constant data (type-safe)
 
virtual void set_push_constant_data_raw (const void *data, size_t size)
 Update push constant data (raw bytes)
 
template<typename T >
void set_push_constant_size ()
 Set push constant size from type.
 
void set_push_constant_size (size_t size)
 Set push constant size.
 
void set_shader (const std::string &shader_path)
 Update shader path and reload.
 
void set_specialization_constant (uint32_t constant_id, uint32_t value)
 Set specialization constant.
 
 ShaderProcessor (const std::string &shader_path)
 Construct processor with shader path.
 
 ShaderProcessor (ShaderConfig config)
 Construct processor with full configuration.
 
void unbind_buffer (const std::string &descriptor_name)
 Unbind a buffer from a descriptor.
 
 ~ShaderProcessor () override
 
- Public Member Functions inherited from MayaFlux::Buffers::BufferProcessor
virtual ProcessingToken get_processing_token () const
 Gets the current processing token for this buffer.
 
void process (const 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 ~BufferProcessor ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Protected Member Functions

void on_attach (const std::shared_ptr< Buffer > &buffer) override
 Called when this processor is attached to a buffer.
 
bool on_before_execute (Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer) override
 Called before each process callback.
 
void on_descriptors_created () override
 Called after descriptor sets are created.
 
- Protected Member Functions inherited from MayaFlux::Buffers::ComputeProcessor
virtual std::array< uint32_t, 3 > calculate_dispatch_size (const std::shared_ptr< VKBuffer > &buffer)
 Calculate dispatch size from buffer.
 
void cleanup () override
 
void initialize_descriptors (const std::shared_ptr< VKBuffer > &buffer) override
 
void initialize_pipeline (const std::shared_ptr< VKBuffer > &buffer) override
 
- Protected Member Functions inherited from MayaFlux::Buffers::ShaderProcessor
virtual void on_after_execute (Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer)
 Called after each process callback.
 
virtual void on_before_compile (const std::string &shader_path)
 Called before shader compilation.
 
virtual void on_before_descriptors_create ()
 Called before descriptor sets are created.
 
virtual void on_before_pipeline_create (Portal::Graphics::ComputePipelineID pipeline_id)
 Called before pipeline creation.
 
virtual void on_pipeline_created (Portal::Graphics::ComputePipelineID pipeline_id)
 Called after pipeline is created.
 
virtual void on_shader_loaded (Portal::Graphics::ShaderID shader_id)
 Called after shader is loaded.
 
std::optional< uint32_t > resolve_ds_index (uint32_t set) const
 Resolve logical descriptor set index to actual index.
 
virtual void update_descriptors (const std::shared_ptr< VKBuffer > &buffer)
 
- Protected Member Functions inherited from MayaFlux::Buffers::VKBufferProcessor
void ensure_initialized (const std::shared_ptr< VKBuffer > &buffer)
 
void initialize_buffer_service ()
 
void initialize_compute_service ()
 

Private Attributes

PushConstants m_pc
 
vk::Sampler m_sampler
 
Portal::Graphics::SamplerConfig m_sampler_config
 
std::shared_ptr< Core::VKImagem_texture
 

Additional Inherited Members

- 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...
 
- Protected Attributes inherited from MayaFlux::Buffers::ShaderProcessor
size_t m_auto_bind_index {}
 
std::unordered_map< std::string, std::shared_ptr< VKBuffer > > m_bound_buffers
 
ShaderConfig m_config
 
std::vector< Portal::Graphics::DescriptorSetIDm_descriptor_set_ids
 
bool m_engine_owns_set_zero {}
 Whether the engine reserves set=0 for global resources.
 
bool m_initialized {}
 
Portal::Graphics::CommandBufferID m_last_command_buffer = Portal::Graphics::INVALID_COMMAND_BUFFER
 
std::shared_ptr< VKBufferm_last_processed_buffer
 
bool m_needs_descriptor_rebuild = true
 
bool m_needs_pipeline_rebuild = true
 
std::vector< uint8_t > m_push_constant_data
 
Portal::Graphics::ShaderID m_shader_id = Portal::Graphics::INVALID_SHADER
 
- 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

Compute pass that writes UV and optionally samples colour into a vertex SSBO.

Runs after NetworkGeometryProcessor has uploaded vertex data and before RenderProcessor draws. The vertex buffer (Usage::VERTEX, already carries eStorageBuffer) is bound as an SSBO at binding 0. A VKImage is bound as a combined image sampler at binding 1.

The compute shader evaluates the chosen projection for every vertex in one dispatch, writing glm::vec2 UV at byte offset 28 and, when a texture source is present, glm::vec3 colour (sampled from the image at the computed UV) at byte offset 12.

Push constant layout (uv_field.comp must match exactly, 80 bytes): offset 0 uint vertex_count offset 4 uint mode (UVProjectionMode) offset 8 uint write_colour (0 = UV only, 1 = also write sampled colour) offset 12 uint _pad offset 16 vec3 param_origin offset 28 float param_scale offset 32 vec3 param_axis offset 44 float param_aux (cylindrical height / triplanar blend)

Usage:

auto uv_proc = std::make_shared<UVFieldProcessor>();
uv_proc->set_projection(UVProjectionMode::CYLINDRICAL);
uv_proc->set_axis(glm::vec3(0.0F, 1.0F, 0.0F));
uv_proc->set_origin(glm::vec3(0.0F));
uv_proc->set_scale(1.0F);
uv_proc->set_aux(2.0F); // cylinder height
uv_proc->set_texture(vk_image); // optional: also writes colour
chain->add_postprocessor(uv_proc, self);

Definition at line 57 of file UVFieldProcessor.hpp.


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