Module tegra_swizzle::surface

source ·
Expand description

Functions for working with surfaces stored in a combined buffer for all array layers and mipmaps.

It’s common for texture surfaces to be represented as a single allocated region of memory that contains all array layers and mipmaps. This also applies to the swizzled surfaces used for textures on the Tegra X1.

Use deswizzle_surface for reading swizzled surfaces into a single deswizzled Vec<u8>. This output can be used as is for creating DDS files. Modern graphics APIs like Vulkan also support this dense layout for initializing all array layers and mipmaps for a texture in a single API call.

Use swizzle_surface for writing a swizzled surface from a combined buffer like the result of deswizzle_surface or a DDS file. The result of swizzle_surface is the layout expected for many texture file formats for console games targeting the Tegra X1.

Examples

Array layers and mipmaps are ordered by layer and then mipmap. A surface with L layers and M mipmaps would have the following layout.

Layer 0 Mip 0
Layer 0 Mip 1
...
Layer 0 Mip M-1
Layer 1 Mip 0
Layer 1 Mip 1
...
Layer L-1 Mip M-1

The convention is for the non swizzled layout to be tightly packed. Swizzled surfaces add additional padding and alignment between layers and mipmaps.

Structs

  • The dimensions of a compressed block. Compressed block sizes are usually 4x4 pixels.

Functions