MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ on_attach()

void MayaFlux::Buffers::DataWriteProcessor::on_attach ( const std::shared_ptr< Buffer > &  )
overrideprotectedvirtual

Called when this processor is attached to a buffer.

Parameters
bufferBuffer this processor is being attached to

Provides an opportunity for the processor to initialize buffer-specific state, allocate resources, or perform validation. With expanded processor capabilities, this method can also:

  • Analyze Buffer Characteristics: Examine data type, size, and format requirements
  • Select Optimal Backend: Choose the most appropriate processing backend for the buffer
  • Initialize Hardware Resources: Set up GPU contexts, CUDA streams, or other acceleration
  • Configure Processing Parameters: Adapt algorithm parameters to buffer characteristics
  • Establish Processing Strategy: Determine whether to use sequential or parallel execution
  • Validate Compatibility: Ensure the processor can handle the buffer's data type and format

Default implementation does nothing, but derived classes should override this method to leverage the full capabilities of the expanded processor architecture.

Reimplemented from MayaFlux::Buffers::BufferProcessor.

Definition at line 79 of file DataWriteProcessor.cpp.

80{
81 auto vk = std::dynamic_pointer_cast<VKBuffer>(buffer);
82 if (!vk) {
83 error<std::invalid_argument>(
86 std::source_location::current(),
87 "DataWriteProcessor requires a VKBuffer");
88 }
89
90 m_modality = vk->get_modality();
91 m_topology = vk->get_render_config().topology;
92
93 if (!vk->is_host_visible()) {
94 m_staging = create_staging_buffer(vk->get_size_bytes());
95 }
96
99 vk->set_vertex_layout(Kakshya::VertexLayout::for_raw());
100 } else {
101 switch (m_topology) {
104 vk->set_vertex_layout(Kakshya::VertexLayout::for_lines());
105 break;
108 vk->set_vertex_layout(Kakshya::VertexLayout::for_meshes());
109 break;
110 default:
111 vk->set_vertex_layout(Kakshya::VertexLayout::for_points());
112 break;
113 }
114 }
115 }
116
118 "DataWriteProcessor attached (modality: {}, staging: {})",
120 m_staging ? "yes" : "no");
121}
#define MF_DEBUG(comp, ctx,...)
static bool is_vertex_modality(Kakshya::DataModality m) noexcept
Portal::Graphics::PrimitiveTopology m_topology
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ VERTICES_3D
3D vertex data (positions, normals, etc.)
std::string_view modality_to_string(DataModality modality)
Convert DataModality enum to string representation.
Definition NDData.cpp:83
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)

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::create_staging_buffer(), MayaFlux::Kakshya::VertexLayout::for_lines(), MayaFlux::Kakshya::VertexLayout::for_meshes(), MayaFlux::Kakshya::VertexLayout::for_points(), MayaFlux::Kakshya::VertexLayout::for_raw(), is_vertex_modality(), MayaFlux::Portal::Graphics::LINE_LIST, MayaFlux::Portal::Graphics::LINE_STRIP, m_modality, m_staging, m_topology, MF_DEBUG, MayaFlux::Kakshya::modality_to_string(), MayaFlux::Portal::Graphics::TRIANGLE_LIST, MayaFlux::Portal::Graphics::TRIANGLE_STRIP, and MayaFlux::Kakshya::VERTICES_3D.

+ Here is the call graph for this function: