MayaFlux 0.5.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 284 of file NetworkGeometryProcessor.cpp.

291{
292 if (!primary_op || !primary_op->supports_incremental_upload()
293 || primary_stride_bytes == 0
294 || expected_total_bytes != binding.last_total_bytes) {
295 return false;
296 }
297
298 const auto ranges = primary_op->dirty_vertex_ranges();
299
300 for (const auto& r : ranges) {
301 const auto pack = primary_op->get_vertex_data_for_collection(r.group_index);
302 const size_t offset = static_cast<size_t>(r.vertex_offset) * primary_stride_bytes;
303 const size_t length = static_cast<size_t>(r.vertex_count) * primary_stride_bytes;
304
305 if (length == 0)
306 continue;
307
308 if (pack.size() < length || offset + length > vk_buffer->get_size_bytes())
309 return false;
310
311 ensure_staging(binding, length);
312 upload_to_gpu(pack.data(), length, vk_buffer, binding.staging_buffer, offset);
313 }
314
315 primary_op->mark_vertex_data_clean();
316
318 "Network '{}': incremental upload, {} dirty range(s)", name, ranges.size());
319
320 return true;
321}
#define MF_RT_TRACE(comp, ctx,...)
std::string name
Definition VKDevice.cpp:143
float offset
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, 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: