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

259{
260 if (required <= target->get_size_bytes()) {
261 return;
262 }
263
264 const auto new_size = static_cast<size_t>(static_cast<float>(required) * growth_factor);
265
266 target->resize(new_size, false);
267
268 if (staging) {
269 staging->resize(new_size, false);
270 }
271}

Referenced by upload_resizing().

+ Here is the caller graph for this function: