GPU/Internal Registers
(this page is hugely WIP)
Overview
GPU internal registers are written to through GPU commands. They are used to control the GPU's behavior, that is to say tell it to draw stuff and how we want it drawn.
Types
There are three main types of registers :
- configuration registers, which directly map to various rendering properties (for example : GPUREG_FACECULLING_CONFIG)
- data transfer registers, which can be seen as FIFOs that let us send sequential chunks of data to the GPU, such as shader code or 1D samplers (for example : GPUREG_GSH_CODE_DATA)
- action triggering registers, which tell the GPU to do something, like draw a primitive (for example : GPUREG_DRAWARRAYS)
Aliases
It is possible for multiple register (sequential) IDs to correspond to the same register. This is done to leverage the consecutive writing mode for GPU Commands, which makes it possible for a single command to write data to multiple sequential register IDs. For example, register IDs 02C1 through 02C8 all correspond to GPUREG_VSH_FLOATUNIFORM_DATA so that a consecutively writing command based at 02C0 will write its first parameter to GPUREG_VSH_FLOATUNIFORM_CONFIG and ever subsequent ones to GPUREG_VSH_FLOATUNIFORM_DATA
Register list
GPUREG_FINALIZE
Writing to this register seems to signal the GPU to stop processing GPU commands from the current buffer; any command following a write to this register will be ignored. The value written to this register does not appear to matter, although 0x12345678 is the value typically written by commercial software. Failure to write to this register in any command buffer will result in the GPU hanging.
GPUREG_GEOSTAGE_CONFIG
Bits | Description |
---|---|
0-7 | Geometry stage mode. (0=Vertex shader only, 2=Vertex shader + geometry shader) |
0-7 | Unknown. Often set to 1. |
0-7 | Unknown. |
0-7 | Unknown. Often set to 0. |
This register configures the geometry stage of the GPU pipeline.
Geometry shader registers
GPUREG_GSH_BOOLUNIFORM
Bits | Description |
---|---|
0 | Value of geometry shader unit's b0 boolean register. (0=true, 1=false) |
1 | Value of geometry shader unit's b1 boolean register. (0=true, 1=false) |
2 | Value of geometry shader unit's b2 boolean register. (0=true, 1=false) |
3 | Value of geometry shader unit's b3 boolean register. (0=true, 1=false) |
4 | Value of geometry shader unit's b4 boolean register. (0=true, 1=false) |
5 | Value of geometry shader unit's b5 boolean register. (0=true, 1=false) |
6 | Value of geometry shader unit's b6 boolean register. (0=true, 1=false) |
7 | Value of geometry shader unit's b7 boolean register. (0=true, 1=false) |
8 | Value of geometry shader unit's b8 boolean register. (0=true, 1=false) |
9 | Value of geometry shader unit's b9 boolean register. (0=true, 1=false) |
10 | Value of geometry shader unit's b10 boolean register. (0=true, 1=false) |
11 | Value of geometry shader unit's b11 boolean register. (0=true, 1=false) |
12 | Value of geometry shader unit's b12 boolean register. (0=true, 1=false) |
13 | Value of geometry shader unit's b13 boolean register. (0=true, 1=false) |
14 | Value of geometry shader unit's b14 boolean register. (0=true, 1=false) |
15 | Value of geometry shader unit's b15 boolean register. (0=true, 1=false) |
16-31 | Unknown. This seems to always be set to 0x7FFF, and other values may cause the GPU to hang |
This register is used to set the geometry shader unit's boolean registers.
GPUREG_GSH_INTUNIFORM_I0
Bits | Description |
---|---|
0-7 | Value for geometry shader's i0.x (u8, 0-255) |
8-15 | Value for geometry shader's i0.y (u8, 0-255) |
16-23 | Value for geometry shader's i0.z (u8, 0-255) |
24-31 | Value for geometry shader's i0.w (u8, 0-255) |
This register is used to set the geometry shader's i0 integer register.
GPUREG_GSH_INTUNIFORM_I1
Bits | Description |
---|---|
0-7 | Value for geometry shader's i1.x (u8, 0-255) |
8-15 | Value for geometry shader's i1.y (u8, 0-255) |
16-23 | Value for geometry shader's i1.z (u8, 0-255) |
24-31 | Value for geometry shader's i1.w (u8, 0-255) |
This register is used to set the geometry shader's i1 integer register.
GPUREG_GSH_INTUNIFORM_I2
Bits | Description |
---|---|
0-7 | Value for geometry shader's i2.x (u8, 0-255) |
8-15 | Value for geometry shader's i2.y (u8, 0-255) |
16-23 | Value for geometry shader's i2.z (u8, 0-255) |
24-31 | Value for geometry shader's i2.w (u8, 0-255) |
This register is used to set the geometry shader's i2 integer register.
GPUREG_GSH_INTUNIFORM_I3
Bits | Description |
---|---|
0-7 | Value for geometry shader's i3.x (u8, 0-255) |
8-15 | Value for geometry shader's i3.y (u8, 0-255) |
16-23 | Value for geometry shader's i3.z (u8, 0-255) |
24-31 | Value for geometry shader's i3.w (u8, 0-255) |
This register is used to set the geometry shader's i3 integer register.
GPUREG_GSH_ENTRYPOINT
Bits | Description |
---|---|
0-15 | Geometry shader unit entrypoint, in words. |
16-31 | Unknown. This seems to always be set to 0x7FFF, and other values may cause the GPU to hang |
This sets the entrypoint for the program running on the single shader unit which can be dedicated to running geometry shaders, regardless of the current geometry stage mode. This is means that while this register is normally used to set the geometry shader entrypoint, it can also be used to set this single shader unit to run from a different entrypoint than the other three even when running a vertex shader.
Vertex shader registers
GPUREG_VSH_BOOLUNIFORM
Bits | Description |
---|---|
0 | Value of vertex shader unit's b0 boolean register. (0=true, 1=false) |
1 | Value of vertex shader unit's b1 boolean register. (0=true, 1=false) |
2 | Value of vertex shader unit's b2 boolean register. (0=true, 1=false) |
3 | Value of vertex shader unit's b3 boolean register. (0=true, 1=false) |
4 | Value of vertex shader unit's b4 boolean register. (0=true, 1=false) |
5 | Value of vertex shader unit's b5 boolean register. (0=true, 1=false) |
6 | Value of vertex shader unit's b6 boolean register. (0=true, 1=false) |
7 | Value of vertex shader unit's b7 boolean register. (0=true, 1=false) |
8 | Value of vertex shader unit's b8 boolean register. (0=true, 1=false) |
9 | Value of vertex shader unit's b9 boolean register. (0=true, 1=false) |
10 | Value of vertex shader unit's b10 boolean register. (0=true, 1=false) |
11 | Value of vertex shader unit's b11 boolean register. (0=true, 1=false) |
12 | Value of vertex shader unit's b12 boolean register. (0=true, 1=false) |
13 | Value of vertex shader unit's b13 boolean register. (0=true, 1=false) |
14 | Value of vertex shader unit's b14 boolean register. (0=true, 1=false) |
15 | Value of vertex shader unit's b15 boolean register. (0=true, 1=false) |
16-31 | Unknown. This seems to always be set to 0x7FFF, and other values may cause the GPU to hang |
This register is used to set the vertex shader unit's boolean registers.
GPUREG_VSH_INTUNIFORM_I0
Bits | Description |
---|---|
0-7 | Value for vertex shader's i0.x (u8, 0-255) |
8-15 | Value for vertex shader's i0.y (u8, 0-255) |
16-23 | Value for vertex shader's i0.z (u8, 0-255) |
24-31 | Value for vertex shader's i0.w (u8, 0-255) |
This register is used to set the vertex shader's i0 integer register.
GPUREG_VSH_INTUNIFORM_I1
Bits | Description |
---|---|
0-7 | Value for vertex shader's i1.x (u8, 0-255) |
8-15 | Value for vertex shader's i1.y (u8, 0-255) |
16-23 | Value for vertex shader's i1.z (u8, 0-255) |
24-31 | Value for vertex shader's i1.w (u8, 0-255) |
This register is used to set the vertex shader's i1 integer register.
GPUREG_VSH_INTUNIFORM_I2
Bits | Description |
---|---|
0-7 | Value for vertex shader's i2.x (u8, 0-255) |
8-15 | Value for vertex shader's i2.y (u8, 0-255) |
16-23 | Value for vertex shader's i2.z (u8, 0-255) |
24-31 | Value for vertex shader's i2.w (u8, 0-255) |
This register is used to set the vertex shader's i2 integer register.
GPUREG_VSH_INTUNIFORM_I3
Bits | Description |
---|---|
0-7 | Value for vertex shader's i3.x (u8, 0-255) |
8-15 | Value for vertex shader's i3.y (u8, 0-255) |
16-23 | Value for vertex shader's i3.z (u8, 0-255) |
24-31 | Value for vertex shader's i3.w (u8, 0-255) |
This register is used to set the vertex shader's i3 integer register.
GPUREG_VSH_ENTRYPOINT
Bits | Description |
---|---|
0-15 | Vertex shader entrypoint, in words. |
16-31 | Unknown. This seems to always be set to 0x7FFF, and other values may cause the GPU to hang |
This sets the entrypoint for the program running on shader units set to vertex shader mode. Depending on the current geometry stage mode this can include either all 4 shader units or just 3 of them.