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

Modality-aware multi-slot write processor for plain VKBuffer. More...

#include <DataWriteProcessor.hpp>

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

Classes

struct  PendingTexture
 

Public Member Functions

 DataWriteProcessor ()
 
bool has_pending () const noexcept
 Returns true if a snapshot has been set and not yet consumed.
 
Kakshya::GpuDataFormat last_texture_format () const noexcept
 Returns the GpuDataFormat resolved on the last texture upload.
 
void set_data (Kakshya::DataVariant variant)
 Supply a single data value for the next cycle (slot 0).
 
void set_data (std::vector< Kakshya::DataVariant > variants)
 Supply multiple data values for the next cycle.
 
void set_pixel_data (Kakshya::DataVariant variant)
 Supply pixel data for the co-resident texture on the next cycle.
 
void set_texture (std::shared_ptr< Core::VKImage > image, std::string binding)
 Supply a texture to bind on the next graphics tick.
 
void set_vertices (const void *data, size_t byte_count)
 Supply pre-packed interleaved vertex bytes for the next cycle.
 
template<typename T >
void set_vertices (std::span< const T > vertices)
 Supply typed vertex data for the next cycle.
 
void setup_pixel_target (uint32_t width, uint32_t height, Portal::Graphics::ImageFormat format, std::string binding="texSampler")
 Configure the pixel upload path for texture modalities.
 
 ~DataWriteProcessor () override=default
 
- Public Member Functions inherited from MayaFlux::Buffers::BufferProcessor
virtual ProcessingToken get_processing_token () const
 Gets the current processing token for this buffer.
 
virtual bool is_compatible_with (const std::shared_ptr< Buffer > &) const
 Checks if this processor can handle the specified buffer type.
 
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.
 
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.
 
- 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 Member Functions

void ensure_capacity (const std::shared_ptr< VKBuffer > &vk, size_t required)
 
void upload_primary (const std::shared_ptr< VKBuffer > &vk, std::vector< Kakshya::DataVariant > &slots)
 
void upload_raw (const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
 
void upload_secondary (const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
 
void upload_texture (const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
 
void upload_vertex (const std::shared_ptr< VKBuffer > &vk, std::vector< Kakshya::DataVariant > &slots)
 

Static Private Member Functions

static bool is_texture_modality (Kakshya::DataModality m) noexcept
 
static bool is_vertex_modality (Kakshya::DataModality m) noexcept
 

Private Attributes

std::vector< Kakshya::DataVariantm_active
 
std::atomic_flag m_data_dirty
 
std::vector< Kakshya::DataVariantm_data_pending
 
std::shared_ptr< Core::VKImagem_gpu_texture
 
std::shared_ptr< VKBufferm_image_staging
 
Kakshya::GpuDataFormat m_last_texture_format { Kakshya::GpuDataFormat::VEC4_F32 }
 
Kakshya::DataModality m_modality { Kakshya::DataModality::UNKNOWN }
 
std::optional< PendingTexturem_pending_texture
 
Kakshya::DataVariant m_pixel_active
 
std::atomic_flag m_pixel_dirty
 
Kakshya::DataVariant m_pixel_pending
 
std::shared_ptr< VKBufferm_staging
 
std::string m_tex_binding
 
bool m_tex_binding_confirmed {}
 
Portal::Graphics::ImageFormat m_tex_format { Portal::Graphics::ImageFormat::RGBA32F }
 
uint32_t m_tex_height {}
 
uint32_t m_tex_width {}
 
std::atomic_flag m_texture_dirty
 
Portal::Graphics::PrimitiveTopology m_topology { Portal::Graphics::PrimitiveTopology::POINT_LIST }
 

Additional Inherited Members

- 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

Modality-aware multi-slot write processor for plain VKBuffer.

Accepts one or more DataVariant values per cycle. Slot 0 is the primary upload path and is routed by the attached buffer's DataModality:

  • VERTICES_3D and single-attribute vertex modalities (VERTEX_POSITIONS_3D, VERTEX_NORMALS_3D, VERTEX_TANGENTS_3D, VERTEX_COLORS_RGB, VERTEX_COLORS_RGBA, TEXTURE_COORDS_2D): all slots are passed as an ordered channel span to as_*_vertex_access(). Full 60-byte vertices are always assembled; partial channel sets are completed from VertexAccessConfig defaults.
  • Texture modalities (IMAGE_2D, IMAGE_COLOR, TEXTURE_2D): routed through Kakshya::as_texture_access(). GpuDataFormat from the result is available via last_texture_format() for pipeline configuration.
  • All other modalities: raw bytes via DataAccess::gpu_buffer(). Zero-copy when the variant type matches the target layout.

Slot 1..N are uploaded raw via DataAccess::gpu_buffer() regardless of modality. These are intended for secondary data (e.g. a texture payload alongside vertex data) where the caller has configured the corresponding descriptor bindings on the RenderProcessor.

Modality is read from the attached VKBuffer in on_attach(). The processor warns if the supplied DataVariant is incompatible with that modality.

Dirty gating: upload occurs only when set_data() has been called since the last cycle. No stale re-upload.

Thread safety: set_data() and the graphics thread may run concurrently. Lock-free double-buffer swap via atomic_flag ensures the graphics thread never blocks on the supplier thread.

Staging: a persistent host-visible staging buffer is allocated on on_attach() when the target is device-local, and reused every cycle.

Intended for use with plain VKBuffer where no specialised child class exists for the data being contributed. The caller is responsible for configuring a matching RenderProcessor via VKBuffer::setup_rendering().

Definition at line 51 of file DataWriteProcessor.hpp.


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