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 259 of file StagingUtils.cpp.

264{
265 if (required <= target->get_size_bytes()) {
266 return;
267 }
268
269 const auto new_size = static_cast<size_t>(static_cast<float>(required) * growth_factor);
270
271 target->resize(new_size, false);
272
273 if (staging) {
274 staging->resize(new_size, false);
275 }
276}

Referenced by upload_resizing().

+ Here is the caller graph for this function: