Skip to main content

quantized_target_key

Function quantized_target_key 

Source
pub fn quantized_target_key(w: u32, h: u32, ceiling: u32) -> (u32, u32)
Expand description

The (width, height) a shader-effect target requested at (w, h) is actually keyed and created at: w/h quantized up to the next multiple of crate::pool::SIZE_QUANTUM (256px, via quantize_extent) and never past ceiling (the caller’s own device-validity floor — ShaderEffects::ensure_target passes the device’s real max_texture_dimension_2d).

Reusing the pool’s own quantum rather than inventing a second one means a shader-quad target collapses a pixel-by-pixel resize drag onto the same handful of keys frust_gpu::pool::TexturePool already collapses every other scratch texture onto, so ShaderEffects::ensure_target mints a fresh texture only when a request crosses a 256px boundary instead of on every frame a quad’s destination fractionally changes. Both axes are floored at 1 (a zero-sized texture is invalid) and the result never exceeds ceiling: quantize_extent alone passes an already-oversized request through unclamped (so its own caller can detect and warn about the clamp — see ShaderEffects::ensure_target’s doc comment), so the final min here is what actually keeps a shader-effect target within the device’s real limit.