Difference between revisions of "GPU Textures"

From 3dbrew
Jump to navigation Jump to search
(Rewrote format section - most of the prior content was wrong or misleading)
(Mention z-order curves.)
Line 1: Line 1:
 
This page describes the [[GPU_Commands|GPU commands]] used for textures.
 
This page describes the [[GPU_Commands|GPU commands]] used for textures.
 +
 +
== General information ==
 +
Individual texels in a texture are laid out in memory as a [http://en.wikipedia.org/wiki/Z-order_curve Z-order curve].
  
 
== Texture unit setup: Register 0x80 ==
 
== Texture unit setup: Register 0x80 ==

Revision as of 15:48, 11 April 2015

This page describes the GPU commands used for textures.

General information

Individual texels in a texture are laid out in memory as a Z-order curve.

Texture unit setup: Register 0x80

Register 0x80 is used to enable individual texture units.

Bit Description
0 Enable texture unit 0.
1 Enable texture unit 1.
2 Enable texture unit 2.

Configuration of texture unit 0

Register ID Description
0x0081 Border color (unverified)
0x0082 Bits 16-31 are the texture width. Bits 0-15 are the texture height. The maximum texture size in either direction is 1024.
0x0083 Texture parameters (filtering, wrapping), see below.
0x0084 LOD setup?
0x0085 Physical address of texture data (divided by 8).
0x0086 Physical address of texture data for cube mapping?
0x0087 Physical address of texture data for cube mapping?
0x0088 Physical address of texture data for cube mapping?
0x0089 Physical address of texture data for cube mapping?
0x008A Physical address of texture data for cube mapping?
0x008B Shadow related?
0x008E Texture format (see below)

Configuration of texture units 1 and 2

Texture units 1 and 2 use a configuration block similar to the one of texture unit 0. They are based at registers 0x0091 and 0x0099.

Index word Description
0-4 Same as for texture unit 0
5 Texture format (see below)

Configuration of texture unit 3

The configuration block for texture unit 3 seems to be vastly different from the other texture units. Instead, registers 0x00A8 through 0x00B7 are used to configure procedural texturing features.

Texture parameters

Bit Description GL parameter name
0 Normally this is value 0.
1 0 = GL_NEAREST, 1 = GL_LINEAR. GL_TEXTURE_MAG_FILTER
2 1 = GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, or GL_LINEAR_MIPMAP_LINEAR. Value zero otherwise. GL_TEXTURE_MIN_FILTER
3 Unused? ?
5-4 2 = texture color type 0xC, 0 otherwise.(Enable/disable texture data compression?) 0 = unknown, 1 = unknown, 3 = same effect as value 2.
7-6 Unused
11-8 0 = GL_CLAMP_TO_EDGE, 1=unknown, 2=GL_REPEAT, 3=unknown. GL_TEXTURE_WRAP_S
15-12 Same values as GL_TEXTURE_WRAP_S. GL_TEXTURE_WRAP_T
24 1 = GL_NEAREST_MIPMAP_LINEAR, or GL_LINEAR_MIPMAP_LINEAR. Value zero otherwise. GL_TEXTURE_MIN_FILTER
27-25 Unused?
30-28 When some flag=1: value1=GL_TEXTURE_2D, value0 when the input parameter is not GL_TEXTURE_2D. When some flag=0: 0=GL_TEXTURE_2D, 1-4=unknown. ?
31 Unused? ?

Texture color types

Value Description GL Format GL Data Type
0x0 RGBA8888 GL_RGBA GL_UNSIGNED_BYTE
0x1 RGB888 GL_RGB GL_UNSIGNED_BYTE
0x2 RGBA5551 GL_RGBA GL_UNSIGNED_SHORT_5_5_5_1
0x3 RGB565 GL_RGB GL_UNSIGNED_SHORT_5_6_5
0x4 RGBA4444 GL_RGBA GL_UNSIGNED_SHORT_4_4_4_4
0x5 IA8 GL_LUMINANCE_ALPHA GL_UNSIGNED_BYTE
0x6
0x7 I8 GL_LUMINANCE GL_UNSIGNED_BYTE
0x8 A8 GL_ALPHA GL_UNSIGNED_BYTE
0x9 IA44 GL_LUMINANCE_ALPHA GL_UNSIGNED_BYTE_4_4_EXT
0xA
0xB A4 GL_ALPHA GL_UNSIGNED_NIBBLE_EXT
0xC ETC1 GL_ETC1_RGB8_OES
0xD ETC1A4