nn::gd::CTR::Resource::Helper::GenerateMipMapsCPU Member Function

Syntax

static nnResult GenerateMipMapsCPU(
     NativeFormat format,
     u32 width,
     u32 height,
     const u8 * dataSrc,
     u8 * dataDst,
     u32 countMipLevelToGenerate
);

Parameters

Name Description
in format Specifies the source data format.
in width Specifies the source data width. Must be a power of 2 that is 8 or greater.
in height Specifies the source data height. Must be a power of 2 that is 8 or greater.
in dataSrc Specifies the address of the source data for generating the mipmap.
in dataDst Specifies a pointer to the address where the generated mipmap data is stored.
in countMipLevelToGenerate Specifies the number of mipmaps to generate.

Return Values

Returns the result of the operation.
Value Description
Result::IsSuccess Process was successful.
ResultNullParameter NULL was specified in an argument.
ResultInvalidTextureResolution The resolution of the source data must be 8x8 or better and a multiple of 2.
ResultInvalidTextureMipLevelIndex Invalid number of mipmaps to generate.
ResultInvalidTextureFormat The source data has an invalid pixel format.

Description

This helper function generates mipmaps using the CPU.

This function is used the same way as the MemoryGenerateMipMaps function. However, the MemoryGenerateMipMaps function executes the mipmap generation request command using the GPU, but the ResourceHelper::GenerateMipMapsCPU function performs mipmap calculations on the CPU. The drawback is that the Resource::Helper::GenerateMipMapsCPU function is slower than the MemoryGenerateMipMaps function.If the 3D command or data transfer command to be executed will change the source data, the current command buffer execution must finish before the ResourceHelper::GenerateMipMapsCPU function is executed. Advantages: For the Memory::GenerateMipMaps function, the resolution of the generated mipmap must be 32 or better. However, for the ResourceHelper::GenerateMipMapsCPU function, the minimum generated mipmap resolution is 8. The memory layout of the data source is LAYOUT_BLOCK_8 and the format of the data source is native format. The formats that can be used are:

NATIVE_FORMAT_RGBA_8888
NATIVE_FORMAT_RGB_888
NATIVE_FORMAT_RGBA_4444
NATIVE_FORMAT_RGBA_5551
NATIVE_FORMAT_RGB_565
NATIVE_FORMAT_LUMINANCE_ALPHA_88
NATIVE_FORMAT_HILO_88
NATIVE_FORMAT_LUMINANCE_8
NATIVE_FORMAT_ALPHA_8
NATIVE_FORMAT_LUMINANCE_ALPHA_44

All mipmaps are created contiguously in memory. You must allocate enough memory to the address area for mipmap generation to store all the mipmaps. The memory area size required to store one mipmap level is as follows: memSize = (srcWidth >> 1) * (srcHeight >> 1) * formatBpp
memSize is the size of the memory in bytes; srcWidth and srcHeight are the source resolution. formatBpp is the number of pixel bytes used for pixel encoding. For example, if the number of mipmaps to generate is 2, then you must allocate at least enough memory for mipmap generation to hold the size calculated below.
memSize = ((srcWidth >> 1) * (srcHeight >> 1) * formatBpp) + ((srcWidth >> 2) * (srcHeight >> 2) * formatBpp)

Revision History

2011/06/03
Initial version.

CONFIDENTIAL