40 const auto* src =
static_cast<const uint8_t*
>(data);
81 auto vk = std::dynamic_pointer_cast<VKBuffer>(buffer);
83 error<std::invalid_argument>(
86 std::source_location::current(),
87 "DataWriteProcessor requires a VKBuffer");
93 if (!vk->is_host_visible()) {
118 "DataWriteProcessor attached (modality: {}, staging: {})",
139 auto vk = std::dynamic_pointer_cast<VKBuffer>(buffer);
142 "DataWriteProcessor attached to non-VKBuffer");
149 if (
auto rp = vk->get_render_processor()) {
163 if (
auto rp = vk->get_render_processor()) {
184 for (
size_t i = 1; i <
m_active.size(); ++i) {
206 auto bytes = Kakshya::convert_variant<uint8_t>(slot);
213 std::optional<Kakshya::VertexAccess> access;
231 "DataWriteProcessor: vertex access failed for modality {}",
238 vk->set_vertex_layout(access->layout);
246 "DataWriteProcessor: as_texture_access failed for modality {}",
255 "DataWriteProcessor: setup_pixel_target() not called before texture upload");
265 "DataWriteProcessor: failed to create GPU texture {}x{}",
270 if (
auto rp = vk->get_render_processor()) {
289 if (required <= vk->get_size_bytes()) {
293 vk->resize(
static_cast<size_t>(
static_cast<float>(required) * 1.5F),
false);
#define MF_RT_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
ProcessingToken m_processing_token
void upload_secondary(const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
std::vector< Kakshya::DataVariant > m_data_pending
void set_pixel_data(Kakshya::DataVariant variant)
Supply pixel data for the co-resident texture on the next cycle.
void processing_function(const std::shared_ptr< Buffer > &buffer) override
The core processing function that must be implemented by derived classes.
Kakshya::DataVariant m_pixel_pending
bool m_tex_binding_confirmed
void on_detach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is detached from a buffer.
static bool is_vertex_modality(Kakshya::DataModality m) noexcept
std::atomic_flag m_texture_dirty
Portal::Graphics::ImageFormat m_tex_format
std::atomic_flag m_pixel_dirty
void set_vertices(const void *data, size_t byte_count)
Supply pre-packed interleaved vertex bytes for the next cycle.
std::string m_tex_binding
Kakshya::GpuDataFormat m_last_texture_format
void upload_texture(const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
void ensure_capacity(const std::shared_ptr< VKBuffer > &vk, size_t required)
Portal::Graphics::PrimitiveTopology m_topology
void set_data(Kakshya::DataVariant variant)
Supply a single data value for the next cycle (slot 0).
std::atomic_flag m_data_dirty
std::shared_ptr< Core::VKImage > m_gpu_texture
void upload_raw(const std::shared_ptr< VKBuffer > &vk, Kakshya::DataVariant &slot)
Kakshya::DataModality m_modality
std::optional< PendingTexture > m_pending_texture
void upload_vertex(const std::shared_ptr< VKBuffer > &vk, std::vector< Kakshya::DataVariant > &slots)
Kakshya::DataVariant m_pixel_active
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.
void on_attach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is attached to a buffer.
std::vector< Kakshya::DataVariant > m_active
std::shared_ptr< VKBuffer > m_staging
void upload_primary(const std::shared_ptr< VKBuffer > &vk, std::vector< Kakshya::DataVariant > &slots)
void set_texture(std::shared_ptr< Core::VKImage > image, std::string binding)
Supply a texture to bind on the next graphics tick.
Kakshya::GpuDataFormat last_texture_format() const noexcept
Returns the GpuDataFormat resolved on the last texture upload.
bool has_pending() const noexcept
Returns true if a snapshot has been set and not yet consumed.
std::shared_ptr< VKBuffer > m_image_staging
static bool is_texture_modality(Kakshya::DataModality m) noexcept
auto gpu_buffer() const
Get raw buffer info for GPU upload.
Type-erased accessor for NDData with semantic view construction.
std::shared_ptr< VKBuffer > create_image_staging_buffer(size_t size)
Allocate a persistent host-visible staging buffer sized for repeated streaming uploads to an image of...
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
std::optional< VertexAccess > as_line_vertex_access(std::span< const DataVariant > channels, const VertexAccessConfig &config)
Assemble line-vertex-compatible bytes from one or more data channels.
std::optional< VertexAccess > as_point_vertex_access(std::span< const DataVariant > channels, const VertexAccessConfig &config)
Assemble point-vertex-compatible bytes from one or more data channels.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
DataModality
Data modality types for cross-modal analysis.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ UNKNOWN
Unknown or undefined modality.
@ VERTICES_3D
3D vertex data (positions, normals, etc.)
@ VIDEO_GRAYSCALE
3D video (time + 2D grayscale)
@ VIDEO_COLOR
4D video (time + 2D + color)
@ TEXTURE_2D
2D texture data
@ IMAGE_COLOR
2D RGB/RGBA image
@ IMAGE_2D
2D image (grayscale or single channel)
GpuDataFormat
GPU data formats with explicit precision levels.
std::string_view modality_to_string(DataModality modality)
Convert DataModality enum to string representation.
std::optional< VertexAccess > as_mesh_vertex_access(std::span< const DataVariant > channels, const VertexAccessConfig &config)
Assemble mesh-vertex-compatible bytes from one or more data channels.
std::optional< TextureAccess > as_texture_access(const DataVariant &variant)
Extract a TextureAccess from a DataVariant.
MAYAFLUX_API TextureLoom & get_texture_manager()
Get the global texture manager instance.
ImageFormat
User-friendly image format enum.
std::shared_ptr< Core::VKImage > image
static VertexLayout for_raw(uint32_t stride=60)
Factory: layout for raw vertex data with common attributes.
static VertexLayout for_lines(uint32_t stride=60)
Factory: layout for LineVertex (position, color, thickness, uv, normal, tangent)
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)
static VertexLayout for_points(uint32_t stride=60)
Factory: layout for PointVertex (position, color, size, uv, normal, tangent)