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

◆ try_incremental_upload()

bool MayaFlux::Buffers::NetworkGeometryProcessor::try_incremental_upload ( Nodes::Network::GraphicsOperator *  primary_op,
uint32_t  primary_stride_bytes,
NetworkBinding &  binding,
const std::shared_ptr< VKBuffer > &  vk_buffer,
size_t  expected_total_bytes,
const std::string &  name 
)
private

Upload only the vertex sub-ranges a multi-group primary operator reports as dirty, instead of rebuilding the whole buffer.

Returns
True when every dirty range was uploaded and the operator was marked clean, so the caller skips its full-buffer path. False when incremental upload does not apply (operator does not support it, aggregate size changed since the last full upload, a range fell outside the buffer) and the caller must fall back.

An empty dirty-range list still returns true, skipping the upload entirely, so the caller must not invoke this while a downstream pass rewrites those vertex bytes in place each cycle.

Definition at line 317 of file NetworkGeometryProcessor.cpp.

324{
325 if (!primary_op || !primary_op->supports_incremental_upload()
326 || primary_stride_bytes == 0
327 || expected_total_bytes != binding.last_total_bytes) {
328 return false;
329 }
330
331 const auto ranges = primary_op->dirty_vertex_ranges();
332
333 for (const auto& r : ranges) {
334 const auto pack = primary_op->get_vertex_data_for_collection(r.group_index);
335 const size_t offset = static_cast<size_t>(r.vertex_offset) * primary_stride_bytes;
336 const size_t length = static_cast<size_t>(r.vertex_count) * primary_stride_bytes;
337
338 if (length == 0)
339 continue;
340
341 if (pack.size() < length || offset + length > vk_buffer->get_size_bytes())
342 return false;
343
344 ensure_staging(binding, length);
345 upload_to_gpu(pack.data(), length, vk_buffer, binding.staging_buffer, offset);
346 }
347
348 primary_op->mark_vertex_data_clean();
349
351 "Network '{}': incremental upload, {} dirty range(s)", name, ranges.size());
352
353 return true;
354}
#define MF_RT_TRACE(comp, ctx,...)
uint64_t length
Definition Composite.cpp:11
uint64_t offset
Definition Composite.cpp:10
std::string name
Definition VKDevice.cpp:123
void ensure_staging(NetworkBinding &binding, size_t bytes)
Grow a binding's staging buffer to hold at least bytes.
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, size_t dst_offset)
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.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Nodes::Network::GraphicsOperator::dirty_vertex_ranges(), ensure_staging(), MayaFlux::Nodes::Network::GraphicsOperator::get_vertex_data_for_collection(), MayaFlux::Buffers::NetworkGeometryProcessor::NetworkBinding::last_total_bytes, length, MayaFlux::Nodes::Network::GraphicsOperator::mark_vertex_data_clean(), MF_RT_TRACE, name, offset, MayaFlux::Buffers::NetworkGeometryProcessor::NetworkBinding::staging_buffer, MayaFlux::Nodes::Network::GraphicsOperator::supports_incremental_upload(), and MayaFlux::Buffers::upload_to_gpu().

Referenced by processing_function().

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