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

Reads selected buffer storage into owned host data, one snapshot per request. More...

#include <DataReadProcessor.hpp>

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

Classes

struct  PendingRead
 
struct  ReadRequest
 

Public Member Functions

 DataReadProcessor ()
 
bool has_result () const noexcept
 Whether a requested read has been submitted.
 
bool is_compatible_with (const std::shared_ptr< Buffer > &buffer) const override
 Checks if this processor can handle the specified buffer type.
 
bool is_pending () const noexcept
 Whether a read is armed, or its result has not been resolved yet.
 
void read_back_buffer (size_t index, size_t byte_count)
 Read a raw back_buffers slot of the attached buffer.
 
void read_buffer (std::shared_ptr< VKBuffer > source, size_t byte_count=0)
 Read another VKBuffer, such as a descriptor-bound or instance buffer.
 
void read_bytes (size_t byte_count=0)
 Read the attached buffer's primary storage.
 
void read_field (std::string name)
 Read the current read slot of a named field on the attached buffer.
 
void read_host_pixels ()
 Read the host pixel data a TextureBuffer retains.
 
void read_mesh ()
 Read the attached mesh.
 
void read_texture_pixels ()
 Download the base level of a TextureBuffer or NodeTextureBuffer image.
 
void read_vertices ()
 Read the attached buffer's declared vertices; the layout count may represent capacity.
 
std::optional< Kakshya::DataVariant > resolve_bytes ()
 Finish the read as raw bytes.
 
std::optional< Kakshya::MeshData > resolve_mesh ()
 Finish a read_mesh() read as MeshData.
 
std::optional< Kakshya::ImageData > resolve_pixels ()
 Finish a pixel read as typed ImageData with its format and dimensions.
 
std::optional< std::vector< Kakshya::DataVariant > > resolve_vertices ()
 Finish a read_vertices() read as typed channels.
 
void set_skip_while_pending (bool skip) noexcept
 Drop read_* calls while a read is armed or unresolved.
 
 ~DataReadProcessor () 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.
 
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 Types

using ReadFill = std::function< bool(DataReadProcessor &, const std::shared_ptr< VKBuffer > &, PendingRead &)>
 
enum class  ReadKind { Bytes , Vertices , Mesh , Pixels }
 

Private Member Functions

void arm (ReadFill fill)
 
std::unique_ptr< PendingRead > collect_result (ReadKind kind)
 

Static Private Member Functions

static bool submit_read (PendingRead &pending, std::shared_ptr< VKBuffer > &staging, size_t available_bytes, size_t byte_count, bool mapped, bool transferable)
 

Private Attributes

Memory::SweepList< ReadRequest > m_request
 
Memory::SweepList< std::unique_ptr< PendingRead > > m_result
 
std::atomic< bool > m_result_occupied { false }
 
std::atomic< bool > m_result_ready { false }
 
bool m_skip_while_pending {}
 
std::shared_ptr< VKBuffer > m_staging
 
std::shared_ptr< VKBuffer > m_texture_staging
 

Additional Inherited Members

- Protected Attributes inherited from MayaFlux::Buffers::VKBufferProcessor
Registry::Service::BufferService * m_buffer_service = nullptr
 
Registry::Service::ComputeService * m_compute_service = nullptr
 
- Protected Attributes inherited from MayaFlux::Buffers::BufferProcessor
ProcessingToken m_processing_token { ProcessingToken::AUDIO_BACKEND }
 

Detailed Description

Reads selected buffer storage into owned host data, one snapshot per request.

Each read_* call arms one request that runs on the next graphics cycle; the matching resolve_* call finishes it on the consuming thread, waiting for a device-local copy when one is in flight. Arm again after resolving to read every frame.

Geometry: read_vertices, read_mesh. Pixels: read_host_pixels, read_texture_pixels. Data: read_bytes, read_buffer, read_field, read_back_buffer.

Definition at line 23 of file DataReadProcessor.hpp.


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