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

◆ ensure_gpu_capacity()

MAYAFLUX_API void MayaFlux::Buffers::ensure_gpu_capacity ( const std::shared_ptr< VKBuffer > &  target,
const std::shared_ptr< VKBuffer > &  staging,
size_t  required,
float  growth_factor = k_buffer_growth_factor 
)

Grow a GPU buffer (and its paired staging buffer) to fit required bytes.

Parameters
targetDevice-local or host-visible GPU buffer to resize.
stagingPaired staging buffer, or nullptr if the target is host-visible.
requiredBytes needed for the next upload.
growth_factorMultiplier applied when a resize is triggered (default 1.5).

No-op when target already has sufficient capacity. When a resize is necessary both buffers are grown to required * growth_factor so subsequent small increments do not trigger further allocations. Existing GPU data is not preserved (preserve_data = false) because the caller is about to overwrite it.

Definition at line 393 of file StagingUtils.cpp.

398{
399 if (required <= target->get_size_bytes()) {
400 return;
401 }
402
403 const auto new_size = static_cast<size_t>(static_cast<float>(required) * growth_factor);
404
405 target->resize(new_size, false);
406
407 if (staging) {
408 staging->resize(new_size, false);
409 }
410}

Referenced by upload_resizing().

+ Here is the caller graph for this function: