MayaFlux 0.4.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 272 of file StagingUtils.cpp.

277{
278 if (required <= target->get_size_bytes()) {
279 return;
280 }
281
282 const auto new_size = static_cast<size_t>(static_cast<float>(required) * growth_factor);
283
284 target->resize(new_size, false);
285
286 if (staging) {
287 staging->resize(new_size, false);
288 }
289}

Referenced by upload_resizing().

+ Here is the caller graph for this function: