Skip to main content

with_padded_alphas

Function with_padded_alphas 

Source
pub fn with_padded_alphas<R>(
    alphas: &mut Vec<u8>,
    width: u32,
    height: u32,
    upload: impl FnOnce(&[u8]) -> R,
) -> R
Expand description

Runs upload over alphas padded with zeroes to the full byte footprint of a width x height alpha texture, then truncates it back to its original length.

A queue write covers the whole texture extent, so the source slice must be the full footprint even when the frame produced fewer alphas. Padding in place and truncating afterwards keeps the caller’s buffer (and its grown capacity) reusable across frames instead of allocating a staging copy per frame.