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

◆ read_mesh()

void MayaFlux::Buffers::DataReadProcessor::read_mesh ( )

Read the attached mesh.

A MeshBuffer, a GeometryBuffer driven by a MeshWriterNode, and a MeshNetworkBuffer yield a copy of their CPU-authoritative geometry with no transfer; a network is merged into one mesh with a submesh per slot, in local space with no transforms applied. A ComputeMeshBuffer or a VolumeGridBuffer with a surface yields its live vertices as non-indexed triangles, sized by its live counter rather than its capacity.

Definition at line 150 of file DataReadProcessor.cpp.

151{
152 arm([](DataReadProcessor& self, const std::shared_ptr<VKBuffer>& vk, PendingRead& pending) {
153 const auto keep_cpu_mesh = [&pending](std::optional<Kakshya::MeshData> mesh) {
154 if (!mesh) {
156 "DataReadProcessor read_mesh found no geometry to read");
157 return false;
158 }
159 pending.mesh = std::move(mesh);
160 return true;
161 };
162
163 if (const auto mesh_buffer = std::dynamic_pointer_cast<MeshBuffer>(vk)) {
164 return keep_cpu_mesh(mesh_buffer->get_mesh_data());
165 }
166
167 if (const auto network_buffer = std::dynamic_pointer_cast<MeshNetworkBuffer>(vk)) {
168 const auto network = network_buffer->get_network();
169 return keep_cpu_mesh(network ? network->get_mesh_data() : std::nullopt);
170 }
171
172 if (const auto geometry_buffer = std::dynamic_pointer_cast<GeometryBuffer>(vk)) {
173 const auto node = std::dynamic_pointer_cast<Nodes::GpuSync::MeshWriterNode>(
174 geometry_buffer->get_geometry_node());
175 return keep_cpu_mesh(node ? node->get_mesh_data() : std::nullopt);
176 }
177
178 std::optional<uint32_t> live_count;
179 if (const auto compute_mesh = std::dynamic_pointer_cast<ComputeMeshBuffer>(vk)) {
180 live_count = compute_mesh->get_live_vertex_count();
181 } else if (const auto volume = std::dynamic_pointer_cast<VolumeGridBuffer>(vk)) {
182 live_count = volume->get_live_vertex_count();
183 }
184
185 if (!live_count || *live_count == 0) {
187 "DataReadProcessor read_mesh requires a mesh, geometry or mesh network buffer, "
188 "or a compute mesh or volume surface with live vertices");
189 return false;
190 }
191 pending.triangle_soup = true;
192 pending.handle = gpu_buffer_handle(vk);
193 return submit_read(pending, self.m_staging, vk->get_size_bytes(),
194 static_cast<size_t>(*live_count) * sizeof(Kakshya::MeshVertex),
195 vk->is_host_visible(), is_transfer_source(vk));
196 });
197}
#define MF_RT_ERROR(comp, ctx,...)
Core::GlobalNetworkConfig network
Definition Config.cpp:43
static bool submit_read(PendingRead &pending, std::shared_ptr< VKBuffer > &staging, size_t available_bytes, size_t byte_count, bool mapped, bool transferable)
Portal::Graphics::GpuBufferHandle gpu_buffer_handle(const std::shared_ptr< VKBuffer > &buffer)
View a buffer's primary GPU storage without reading it back.
bool is_transfer_source(const std::shared_ptr< VKBuffer > &buffer)
Whether a buffer's memory can be the source of a transfer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References arm(), MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::gpu_buffer_handle(), MayaFlux::Buffers::DataReadProcessor::PendingRead::handle, MayaFlux::Buffers::is_transfer_source(), m_staging, MayaFlux::Buffers::DataReadProcessor::PendingRead::mesh, MF_RT_ERROR, network, submit_read(), and MayaFlux::Buffers::DataReadProcessor::PendingRead::triangle_soup.

Referenced by MayaFlux::Kriya::detail::arm_graphics_read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: