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

◆ download_back_buffer_async()

MAYAFLUX_API TransferHandle MayaFlux::Buffers::download_back_buffer_async ( const VKBufferResources::GenerationSlot &  slot,
size_t  size,
std::shared_ptr< VKBuffer > &  staging,
size_t  staging_offset = 0 
)

Record a slot-to-staging copy without waiting for completion.

Parameters
slotSource slot, typically from VKBuffer::get_back_buffer().
sizeByte count to copy.
stagingStaging buffer, already large enough for staging_offset + size. Not grown here: reallocating mid-batch would orphan copies already recorded against the old allocation. Size it with create_staging_buffer before the batch.
staging_offsetByte offset within staging the copy lands at, so several reads share one staging buffer and their transfers overlap instead of serialising one round trip each.
Returns
Handle to pass to resolve_back_buffer_read, or null for host-visible slots where no transfer was recorded.

Mirrors upload_back_buffer_async with the direction reversed, and with one asymmetry: an upload's memcpy precedes the fence, a download's follows it, so the host copy lives in resolve_back_buffer_read rather than here. download_back_buffer is the two called back to back.

Note the naming clash with download_from_gpu_async, which is a different family: that one operates on a whole VKBuffer, waits internally, and means only that it avoids queue.waitIdle.

Definition at line 298 of file StagingUtils.cpp.

303{
304 if (size == 0 || slot.mapped_ptr)
305 return {};
306
307 auto buffer_service = Registry::BackendRegistry::instance()
308 .get_service<Registry::Service::BufferService>();
309
310 if (!buffer_service
311 || !buffer_service->execute_fenced
312 || !buffer_service->wait_fenced
313 || !buffer_service->release_fenced
314 || !buffer_service->invalidate_range) {
315 error<std::runtime_error>(
316 Journal::Component::Buffers,
317 Journal::Context::BufferProcessing,
318 std::source_location::current(),
319 "download_back_buffer_async: BufferService unavailable");
320 }
321
322 if (!staging || staging->get_size_bytes() < staging_offset + size)
323 staging = create_staging_buffer(staging_offset + size);
324
325 return buffer_service->copy_buffer_fenced(
326 static_cast<void*>(slot.buffer),
327 static_cast<void*>(staging->get_buffer()),
328 size, 0, staging_offset);
329}
bool size
Backend buffer management service interface.

References MayaFlux::Buffers::VKBufferResources::GenerationSlot::buffer, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, create_staging_buffer(), MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Registry::BackendRegistry::instance(), MayaFlux::Buffers::VKBufferResources::GenerationSlot::mapped_ptr, and size.

Referenced by download_back_buffer(), MayaFlux::Buffers::VolumeGridBuffer::read_fields(), and MayaFlux::Buffers::DataReadProcessor::submit_read().

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