The nn::gd::Memory
class defines functions that convert layouts from block format to linear format and vice versa.
5.1. Converting From Block Format to Linear Format
The following functions are provided for converting from block format to linear format.
static nnResult nn::gd::Memory::CopyTexture2DResourceBlockToLinear( const nn::gd::Texture2DResource* source, s32 srcMipLevelIndex, u32 srcOffsetY, s32 srcCountRow, const nn::gd::Texture2DResource* dest, s32 dstMipLevelIndex, u32 dstOffsetY, nn::gd::Memory::DownScalingMode downScalingMode, gdBool yFlip); static nnResult nn::gd::Memory::CopyTexture2DResourceBlockToLinear( const nn::gd::Texture2DResource* source, s32 srcMipLevelIndex, u32 srcOffsetY, u8* dstAddr, u32 dstWidth, u32 dstHeight, u32 dstFormat, nn::gd::Memory::DownScalingMode downScalingMode, gdBool yFlip);
The resource data in the Texture2DResource
object specified for the source
parameter is converted from block format to linear format and then transferred. You can use the srcMipLevelIndex
parameter to specify which mipmap level to convert. If you specify a value of -1
, the largest mipmap level of the Texture2DResource
object is used.
Use the srcOffsetY
parameter to specify the y-coordinate at which to start converting. Specify the raw resource data coordinates. These functions take care of addressing differences.
When you call the function that takes a Texture2DResource
object as the destination, use the srcCountRow
parameter to specify the number of lines to convert. If you specify a value of -1
, the height of the Texture2DResource
object is used. Use the dstMipLevelIndex
parameter and the dstOffsetY
parameter to specify the mipmap level and starting y-coordinate, respectively, at the destination.
When you call the function that takes an address as the destination, specify the starting address in the dstAddr
parameter, the width in the dstWidth
parameter, the height in the dstHeight
parameter, and the pixel format in the dstFormat
parameter.
Configure anti-aliasing using the downScalingMode
parameter. To enable vertical flipping, specify GD_TRUE
in the yFlip
parameter.
Data is actually converted when the command list is executed, because these functions call the nngxAddB2LTransferCommand
function.
These functions, which convert from block format to linear format, are mainly used when the color buffer is transferred to the display buffer. For sample code, see 2.7. Displaying the Rendered Results.
5.2. Converting From Linear Format to Block Format
The following functions have been provided for converting from linear format to block format.
static nnResult nn::gd::Memory::CopyTexture2DResourceLinearToBlock( const nn::gd::Texture2DResource* source, s32 srcMipLevelIndex, u32 srcOffsetY, s32 srcCountRow, const nn::gd::Texture2DResource* dest, s32 dstMipLevelIndex, u32 dstOffsetY); static nnResult nn::gd::Memory::CopyTexture2DResourceLinearToBlock( u8* srcAddr, u32 width, u32 height, const nn::gd::Texture2DResource* dest, s32 dstMipLevelIndex, u32 dstOffsetY);
The original data is converted from linear format to block format and then transferred to the Texture2DResource
object specified for the dest
parameter. You can use the dstMipLevelIndex
parameter to specify the mipmap level in which to receive the converted data. If you specify a value of -1
, the largest mipmap level of the Texture2DResource
object is used. Use dstOffsetY
to specify the y-coordinate at which to start receiving data. Specify the raw resource data coordinates. These functions take care of addressing differences.
When you call the function that takes a Texture2DResource
object as the source, use the srcCountRow
parameter to specify the number of lines to convert. If you specify a value of -1
, the height of the Texture2DResource
object is used. Use the srcMipLevelIndex
parameter and the srcOffsetY
parameter to specify the mipmap level and starting y-coordinate, respectively, at the source.
When you call the function that takes an address as the source, specify the starting address in the srcAddr
parameter, the width in the width
parameter, and the height in the height
parameter.
Data is actually converted when the command list is executed, because these functions call the nngxAddL2BTransferCommand
function.