GXGetTexBufferSize

Syntax

#include <revolution/gx.h>

u32 GXGetTexBufferSize(
    u16       width,
    u16       height,
    u32       format,
    GXBool    mipmap,
    u8        max_lod );

Arguments

width Texture width (in texels)
height Texture height (in texels)
format Texture format. Select either GXTexFmt or GXCITexFmt.
mipmap Flag indicating that the texture is a mipmap.
max_lod Maximum LOD value.

Return Values

Number of bytes required for the texture including tile padding.

Description

This is a convenient function that returns the amount of memory in bytes needed to store a texture of the given size and format, format. If the mipmap flag is GX_TRUE, then the size of buffer needed for the mipmap pyramid up to max_lod will be returned. Max_lod will be clamped to the number of LODs possible given the map width and height. For mipmaps, width and height must be a power of two.

This function takes into account the tiling and padding required by the Wii texture format. The resulting size can be used along with the OSAlloc function to allocate texture buffers.( See GXCopyTex.)

// allocate a non-mipmap buffer
tex_buf = OSAlloc(GXGetTexBufferSize(123, 65, GX_TF_RGB5A3, GX_FALSE, 0));
// allocate a mipmap, all LODs
tex_buf = OSAlloc(GXGetTexBufferSize(256, 256, GX_TF_RGB5A3, GX_TRUE, 100));
// determine the address of LOD 3
size = GXGetTexBufferSize(256, 256, GX_TF_RGB5A3, GX_TRUE, 3);
lod_3_addr = tex_buf + size;

See Also

None.

Revision History

2006/03/01 Initial version.


CONFIDENTIAL