Texture/PlayStation 3

From Burnout Wiki

Structures

The majority of this information is from the SCE PS3 SDK: CellGcmTexture datatype reference, though Burnout's debugging symbols were also referenced.

renderengine::Texture

Offset Length Type Name Description Comments
0x0 0x1 uint8_t m_format Texture format See format
0x1 0x1 uint8_t m_mipmap Number of mipmap levels (1-13) Sum of the maximum number of mipmap levels for the texture + 1
0x2 0x1 uint8_t m_dimension Texture dimension See dimension
0x3 0x1 uint8_t m_cubemap Enable or disable cube mapping See CubeMapEnable
0x4 0x4 uint32_t m_remap Method of selecting each element of the color value See remap
0x8 0x2 uint16_t m_width Width of texture (1-4096)
0xA 0x2 uint16_t m_height Height of texture (1-4096)
0xC 0x2 uint16_t m_depth Depth of texture (1-512) Always 1 in Burnout as 3D textures are not used
0xE 0x1 uint8_t m_location Location of texture data (main memory or local memory) See location
0xF 0x1 uint8_t m_padding Padding
0x10 0x4 uint32_t m_pitch Pitch size of texture See pitch
0x14 0x4 uint32_t m_offset Offset value from the base address of the texture data location
0x18 0x4 void* m_buffer Texture
0x1C 0x4 Type m_storeType Store type
0x20 0x4 uint32_t m_storeFlags Store flags Seemingly unused

Format

Swizzling and normalization is not used in Burnout, so these flags are unused.

Below is the bitwise structure for the format field.

Offset (bits) Length (bits) Name Description Comments
0 1 Unused, always 1
1 1 Normalization flag See normalization flag
2 1 Swizzle flag See swizzle flag
3 5 Color format See color format

For example, the following is the DXT5 format as found in Burnout:

Format 0x88
Bit value 1 0 0 0 1 0 0 0
Parsed value 1 0 0 8
Description Unused CELL_GCM_TEXTURE_NR CELL_GCM_TEXTURE_SZ CELL_GCM_TEXTURE_COMPRESSED_DXT45

Remap

The remap order is only used when one of the following color formats is specified:

  • CELL_GCM_TEXTURE_COMPRESSED_HILO8
  • CELL_GCM_TEXTURE_COMPRESSED_HILO_S8
  • CELL_GCM_TEXTURE_X16
  • CELL_GCM_TEXTURE_Y16_X16
  • CELL_GCM_TEXTURE_Y16_X16_FLOAT

These are not used in Burnout, so the remap field is unused.

Below is the bitwise structure for the remap field. It is unclear whether this is in MSB 0 or LSB 0 notation.

Offset (bits) Length (bits) Name Description Comments
0 16 Remap order
16 2 Output blue element
18 2 Output green element
20 2 Output red element
22 2 Output alpha element
24 2 Input blue element
26 2 Input green element
28 2 Input red element
30 2 Input alpha element

Pitch

Pitch is the texture width multiplied by the bytes per texel. It must be specified when using linear texture formats or DXT compression. If the texture is swizzled or the DXT texture width is a power of 2, pitch is ignored. Otherwise, it must be 16 or more.

Burnout only uses textures with widths at powers of 2, so pitch is unused. However, if it becomes necessary to calculate pitch, the following formula may be used for DXT textures:

pitch = floor((width+3)/4)* block_size

Where block_size is 8 for DXT1 and 16 for DXT2 through DXT5.

Enumerations

Much of this information is from the SCE PS3 SDK: GCM Method Macros Overview, section 6.4: TextureFormat. Some information is also from the CellGcmTexture datatype documentation. Various other sources are used.

Color format

Name Value Comments
CELL_GCM_TEXTURE_B8 0x81 One 8-bit unsigned integer
CELL_GCM_TEXTURE_A1R5G5B5 0x82 One 1-bit value and three unsigned 5-bit integers
CELL_GCM_TEXTURE_A4R4G4B4 0x83 Four unsigned 4-bit values
CELL_GCM_TEXTURE_R5G6B5 0x84 5-bit, 6-bit, and 5-bit unsigned integers
CELL_GCM_TEXTURE_A8R8G8B8 0x85 Four 8-bit unsigned integers
CELL_GCM_TEXTURE_COMPRESSED_DXT1 0x86 4x4 pixels compressed to 8 bytes
CELL_GCM_TEXTURE_COMPRESSED_DXT23 0x87 4x4 pixels compressed to 16 bytes
CELL_GCM_TEXTURE_COMPRESSED_DXT45 0x88 4x4 pixels compressed to 16 bytes
CELL_GCM_TEXTURE_G8B8 0x8B Two 8-bit unsigned integers
CELL_GCM_TEXTURE_R6G5B5 0x8F 6-bit, 5-bit, and 5-bit unsigned integers
CELL_GCM_TEXTURE_DEPTH24_D8 0x90 One 24-bit fixed, and 8-bit dummy data
CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT 0x91 One 24-bit float, and 8-bit dummy data
CELL_GCM_TEXTURE_DEPTH16 0x92 One 16-bit fixed
CELL_GCM_TEXTURE_DEPTH16_FLOAT 0x93 One 16-bit float value
CELL_GCM_TEXTURE_X16 0x94 One 16-bit integer
CELL_GCM_TEXTURE_Y16_X16 0x95 Two 16-bit integer
CELL_GCM_TEXTURE_R5G5B5A1 0x97 Three 5-bit unsigned integers, and one 1-bit value
CELL_GCM_TEXTURE_COMPRESSED_HILO8 0x98 Two unsigned 16-bit values compressed to two 8-bit values
CELL_GCM_TEXTURE_COMPRESSED_HILO_S8 0x99 Two signed 16-bit values compressed to two 8-bit values
CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT 0x9A Four 16-bit float values
CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT 0x9B Four 32-bit float values
CELL_GCM_TEXTURE_X32_FLOAT 0x9C One 32-bit float value
CELL_GCM_TEXTURE_D1R5G5B5 0x9D 1-bit dummy data, and three 5-bit unsigned integers
CELL_GCM_TEXTURE_D8R8G8B8 0x9E 8-bit dummy data, and three 8-bit unsigned integers
CELL_GCM_TEXTURE_Y16_X16_FLOAT 0x9F Two 16-bit float values
CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8 0xAD Two pixels compressed in the YUV format to 32 bits
CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8 0xAE Two pixels compressed in the YUV format to 32 bits

Swizzle flag

Swizzle can only be used when the width is not a power of two. Pitch must be specified.

Name Value Comments
CELL_GCM_TEXTURE_SZ 0x0 Use the swizzle format
CELL_GCM_TEXTURE_LN 0x20 Use the linear format

Normalization flag

Name Value Comments
CELL_GCM_TEXTURE_NR 0x0 Normalize texture coordinates
CELL_GCM_TEXTURE_UN 0x40 Do not normalize texture coordinates

Dimension

Depth textures cannot be 3D.

Name Value Comments
CELL_GCM_TEXTURE_DIMENSION_1 1 1D texture
CELL_GCM_TEXTURE_DIMENSION_2 2 2D texture
CELL_GCM_TEXTURE_DIMENSION_3 3 3D texture

CubeMapEnable

Name Value Comments
CELL_GCM_FALSE 0 Disable
CELL_GCM_TRUE 1 Enable

Location

Name Value Comments
CELL_GCM_LOCATION_LOCAL + 1 1 Local memory
CELL_GCM_LOCATION_MAIN + 1 2 Main memory

renderengine::Texture::Type

Name Value Comments
TYPE_NA -1
TYPE_1D 1
TYPE_2D 2
TYPE_3D 3
TYPE_CUBE 0x10002
TYPE_FORCEENUMSIZEINT 0x7FFFFFFF