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

◆ on_attach()

void MayaFlux::Buffers::MeshProcessor::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 21 of file MeshProcessor.cpp.

22{
23 if (!m_buffer_service) {
25 .get_service<Registry::Service::BufferService>();
26 }
27
28 if (!m_buffer_service) {
29 error<std::runtime_error>(
32 std::source_location::current(),
33 "MeshProcessor requires a valid BufferService");
34 }
35
36 auto mesh_buf = std::dynamic_pointer_cast<MeshBuffer>(buffer);
37 if (!mesh_buf) {
39 "MeshProcessor: attached to non-MeshBuffer — detaching");
40 return;
41 }
42
43 if (!mesh_buf->m_mesh_data.is_valid()) {
45 "MeshProcessor: MeshData is not valid on attach — no GPU resources allocated");
46 return;
47 }
48
49 m_mesh_buffer = mesh_buf;
50
51 ensure_initialized(mesh_buf);
52
53 allocate_gpu_buffers(mesh_buf);
54 upload_vertices(mesh_buf);
55 upload_indices(mesh_buf);
57
58 mesh_buf->clear_vertices_dirty();
59 mesh_buf->clear_indices_dirty();
60
61 mesh_buf->set_vertex_layout(mesh_buf->m_mesh_data.layout);
62
64 "MeshProcessor: initialised — {} vertices, {} indices ({} faces), stride {}",
65 mesh_buf->get_vertex_count(),
66 mesh_buf->get_index_count(),
67 mesh_buf->get_face_count(),
68 mesh_buf->m_mesh_data.layout.stride_bytes);
69}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
void allocate_gpu_buffers(const std::shared_ptr< MeshBuffer > &buf)
void upload_vertices(const std::shared_ptr< MeshBuffer > &buf)
std::shared_ptr< MeshBuffer > m_mesh_buffer
void upload_indices(const std::shared_ptr< MeshBuffer > &buf)
Registry::Service::BufferService * m_buffer_service
Definition VKBuffer.hpp:651
void ensure_initialized(const std::shared_ptr< VKBuffer > &buffer)
Definition VKBuffer.cpp:462
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References allocate_gpu_buffers(), MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::VKBufferProcessor::ensure_initialized(), MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Registry::BackendRegistry::instance(), link_index_resources(), MayaFlux::Buffers::VKBufferProcessor::m_buffer_service, m_mesh_buffer, MF_ERROR, MF_INFO, upload_indices(), and upload_vertices().

+ Here is the call graph for this function: