Skip to main content

Module mipmap

Module mipmap 

Source
Expand description

Backend-agnostic mip-chain generation for streamed RGBA8 textures. Each backend’s texture upload calls generate_mip_chain and uploads every level, so albedo and normal maps minify through a proper trilinear chain instead of aliasing from a single mip-0 sample at a distance.

Levels are produced by a 2x2 box filter in stored (RGBA8) space, halving each axis with floor division so every level’s dimensions match the GPU mip convention max(1, base >> level). That keeps the CPU chain in lockstep with the image’s allocated mip levels on all three backends.

Structs§

MipLevel
One level of a mip chain: dimensions plus tightly packed RGBA8 pixels (width * height * 4 bytes, no row padding).

Functions§

generate_mip_chain
Build the full mip chain for a width x height RGBA8 image. Level 0 is the input copied verbatim; each subsequent level halves both axes (floored, min 1) and box-filters the level above it. rgba8 must hold at least width * height * 4 bytes (the backend uploads validate this before calling).