20 const void* data,
size_t byte_count,
24 snap.
bytes.resize(byte_count);
25 std::memcpy(snap.
bytes.data(), data, byte_count);
39 auto vk = std::dynamic_pointer_cast<VKBuffer>(buffer);
41 error<std::invalid_argument>(
44 std::source_location::current(),
45 "GeometryWriteProcessor requires a VKBuffer");
48 if (!vk->is_host_visible()) {
64 auto vk = std::dynamic_pointer_cast<VKBuffer>(buffer);
67 "GeometryWriteProcessor attached to non-VKBuffer");
77 const size_t available = vk->get_size_bytes();
79 if (required > available) {
80 vk->resize(
static_cast<size_t>((
float)required * 1.5F),
false);
87 std::min<size_t>(required, vk->get_size_bytes()),
106 std::optional<Kakshya::VertexAccess> access;
119 if (!access.has_value()) {
121 "GeometryWriteProcessor: as_vertex_access returned nullopt — unsupported variant type");
127 vk->set_vertex_layout(access->layout);
#define MF_RT_ERROR(comp, ctx,...)
ProcessingToken m_processing_token
void set_data(Kakshya::DataVariant variant)
Supply vertex data for the next cycle.
bool has_pending() const noexcept
Returns true if a snapshot has been set and not yet consumed.
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_vertices(const void *data, size_t byte_count, const Kakshya::VertexLayout &layout)
Supply pre-resolved vertex bytes for the next cycle.
std::shared_ptr< VKBuffer > m_staging
std::optional< Kakshya::DataVariant > m_pending_data
std::atomic_flag m_vertices_dirty
std::atomic_flag m_data_dirty
void on_attach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is attached to a buffer.
std::optional< Kakshya::DataVariant > m_active_data
std::optional< VertexSnapshot > m_pending_vertices
std::optional< VertexSnapshot > m_active_vertices
Kakshya::VertexAccessConfig m_config
void upload_resizing(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, float growth_factor)
Upload size bytes to target, growing both buffers first if needed.
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
@ LINE
Interpret vertex data as Nodes::LineVertex.
@ MESH
Interpret vertex data as Nodes::MeshVertex.
@ POINT
Interpret vertex data as Nodes::PointVertex.
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(const DataVariant &variant, const VertexAccessConfig &config)
Convert DataVariant to line-vertex-compatible bytes.
std::optional< VertexAccess > as_mesh_vertex_access(const DataVariant &variant, const VertexAccessConfig &config)
Convert DataVariant to mesh-vertex-compatible bytes.
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.
std::optional< VertexAccess > as_point_vertex_access(const DataVariant &variant, const VertexAccessConfig &config)
Convert DataVariant to point-vertex-compatible bytes.
Kakshya::VertexLayout layout
std::vector< std::byte > bytes
Owned copy of pre-resolved vertex bytes and their layout.
Complete description of vertex data layout in a buffer.