GPU/Internal Registers: Difference between revisions

Steveice10 (talk | contribs)
Steveice10 (talk | contribs)
Line 6,880: Line 6,880:


== Geometry pipeline registers ==
== Geometry pipeline registers ==
=== GPUREG_ATTRIBBUFFERS_LOC ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 1-28
| unsigned, Vertex arrays base address
|}
=== GPUREG_ATTRIBBUFFERS_FORMAT_LOW ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-1
| unsigned, Vertex attribute 0 type
|-
| 2-3
| unsigned, Vertex attribute 0 size
|-
| 4-5
| unsigned, Vertex attribute 1 type
|-
| 6-7
| unsigned, Vertex attribute 1 size
|-
| 8-9
| unsigned, Vertex attribute 2 type
|-
| 10-11
| unsigned, Vertex attribute 2 size
|-
| 12-13
| unsigned, Vertex attribute 3 type
|-
| 14-15
| unsigned, Vertex attribute 3 size
|-
| 16-17
| unsigned, Vertex attribute 4 type
|-
| 18-19
| unsigned, Vertex attribute 4 size
|-
| 20-21
| unsigned, Vertex attribute 5 type
|-
| 22-23
| unsigned, Vertex attribute 5 size
|-
| 24-25
| unsigned, Vertex attribute 6 type
|-
| 26-27
| unsigned, Vertex attribute 6 size
|-
| 28-29
| unsigned, Vertex attribute 7 type
|-
| 30-31
| unsigned, Vertex attribute 7 size
|}
Vertex attribute type values:
{| class="wikitable" border="1"
! Value
! Description
|-
| 0
| Byte
|-
| 1
| Unsigned byte
|-
| 2
| Short
|-
| 3
| Float
|}
Vertex attribute size values:
{| class="wikitable" border="1"
! Value
! Description
|-
| 0
| 8 bits
|-
| 1
| 16 bits
|-
| 2
| 24 bits
|-
| 3
| 32 bits
|}
=== GPUREG_ATTRIBBUFFERS_FORMAT_HIGH ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-1
| unsigned, Vertex attribute 8 type
|-
| 2-3
| unsigned, Vertex attribute 8 size
|-
| 4-5
| unsigned, Vertex attribute 9 type
|-
| 6-7
| unsigned, Vertex attribute 9 size
|-
| 8-9
| unsigned, Vertex attribute 10 type
|-
| 10-11
| unsigned, Vertex attribute 10 size
|-
| 12-13
| unsigned, Vertex attribute 11 type
|-
| 14-15
| unsigned, Vertex attribute 11 size
|-
| 16-27
| unsigned, Fixed vertex attribute mask
|-
| 28-31
| unsigned, Total vertex attribute count - 1
|}
See GPUREG_ATTRIBBUFFERS_FORMAT_LOW for vertex attribute type and size values.
=== GPUREG_ATTRIBBUFFER''i''_OFFSET ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-27
| unsigned, Offset from base vertex arrays address
|}
=== GPUREG_ATTRIBBUFFER''i''_CONFIG1 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Component 1
|-
| 4-7
| unsigned, Component 2
|-
| 8-11
| unsigned, Component 3
|-
| 12-15
| unsigned, Component 4
|-
| 16-19
| unsigned, Component 5
|-
| 20-23
| unsigned, Component 6
|-
| 24-27
| unsigned, Component 7
|-
| 28-31
| unsigned, Component 8
|}
Component values:
{| class="wikitable" border="1"
! Value
! Description
|-
| 0
| Vertex attribute 0
|-
| 1
| Vertex attribute 1
|-
| 2
| Vertex attribute 2
|-
| 3
| Vertex attribute 3
|-
| 4
| Vertex attribute 4
|-
| 5
| Vertex attribute 5
|-
| 6
| Vertex attribute 6
|-
| 7
| Vertex attribute 7
|-
| 8
| Vertex attribute 8
|-
| 9
| Vertex attribute 9
|-
| 10
| Vertex attribute 10
|-
| 11
| Vertex attribute 11
|-
| 12
| 4-byte padding
|-
| 13
| 8-byte padding
|-
| 14
| 12-byte padding
|-
| 15
| 16-byte padding
|}
=== GPUREG_ATTRIBBUFFER''i''_CONFIG2 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Component 9
|-
| 4-7
| unsigned, Component 10
|-
| 8-11
| unsigned, Component 11
|-
| 12-15
| unsigned, Component 12
|-
| 16-23
| unsigned, Bytes per vertex
|-
| 28-31
| unsigned, Total number of components
|}
See GPUREG_ATTRIBBUFFER''i''_CONFIG1 for component values.
=== GPUREG_INDEXBUFFER_CONFIG ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-27
| unsigned, Offset from base vertex arrays address
|-
| 31
| Index type (0 = unsigned byte, 1 = unsigned short or drawing arrays)
|}
=== GPUREG_NUMVERTICES ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Number of vertices to render
|}


=== GPUREG_GEOSTAGE_CONFIG ===
=== GPUREG_GEOSTAGE_CONFIG ===
Line 6,887: Line 7,175:
! Description
! Description
|-
|-
| 0-7
| 0-1
| unsigned, Geometry stage mode. (0=Vertex shader only, 2=Vertex shader + geometry shader)
| unsigned, Geometry shader in use (0 = not in use, 2 = in use)
|-
|-
| 8
| 8
| Unknown. Seems to skip every other triangle when used with indexed rendering and without geoshaders. Has no effect with non-indexed rendering without geoshaders. '''If this is 0, you don't need to use GPU_UNKPRIM with DrawElements.'''
| unsigned, Drawing triangle elements (0 = not, 1 = drawing triangle elements)
|-
|-
| 9-15
| 9
| No effect.
| 0x0
|-
|-
| 16-23
| 16-23
| Unknown.
| 0x0
|-
|-
| 24-31
| 31
| Unknown. Often set to 0.
| unsigned, Use reserved geometry shader subdivision (0 = don't use, 1 = use)
|}
|}


This register configures the geometry stage of the GPU pipeline.
This register configures the geometry stage of the GPU pipeline.
=== GPUREG_VERTEX_OFFSET ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Starting vertex offset
|}
=== GPUREG_POST_VERTEX_CACHE_NUM ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-7
| unsigned, Number of entries in the post-vertex cache (usually 0x4 or 0x84)
|}
=== GPUREG_DRAWARRAYS ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Trigger (0 = idle, non-zero = draw arrays)
|}
=== GPUREG_DRAWELEMENTS ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Trigger (0 = idle, non-zero = draw elements)
|}
=== GPUREG_VTX_FUNC ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Trigger (0 = idle, non-zero = clear post-vertex cache)
|}


=== GPUREG_FIXEDATTRIB_INDEX ===
=== GPUREG_FIXEDATTRIB_INDEX ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Fixed attribute index (0-11, 0xF = immediate-mode submission)
|}


See [[GPU/Fixed Vertex Attributes]] and [[GPU/Immediate-Mode Vertex Submission]] for usage info.
See [[GPU/Fixed Vertex Attributes]] and [[GPU/Immediate-Mode Vertex Submission]] for usage info.
=== GPUREG_FIXEDATTRIB_DATA0 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-23
| float1.7.16, Vertex attribute element 1
|-
| 24-31
| float1.7.16, Vertex attribute element 2 (lower 8 bits)
|}
Accepts the first part of the four 24-bit floating-point values that make up a vertex attribute. Stored in the fixed attribute currently specified with GPUREG_FIXEDATTRIB_INDEX. If immediate-mode vertex submission is enabled (by writing 0xF to the index register) then vertex data is input here directly.
=== GPUREG_FIXEDATTRIB_DATA1 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-23
| float1.7.16, Vertex attribute element 2 (upper 16 bits)
|-
| 24-31
| float1.7.16, Vertex attribute element 3 (lower 16 bits)
|}
Accepts the second part of the four 24-bit floating-point values that make up a vertex attribute. Stored in the fixed attribute currently specified with GPUREG_FIXEDATTRIB_INDEX. If immediate-mode vertex submission is enabled (by writing 0xF to the index register) then vertex data is input here directly.
=== GPUREG_FIXEDATTRIB_DATA2 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-23
| float1.7.16, Vertex attribute element 3 (upper 8 bits)
|-
| 24-31
| float1.7.16, Vertex attribute element 4
|}
Accepts the third part of the four 24-bit floating-point values that make up a vertex attribute. Stored in the fixed attribute currently specified with GPUREG_FIXEDATTRIB_INDEX. If immediate-mode vertex submission is enabled (by writing 0xF to the index register) then vertex data is input here directly.
=== GPUREG_CMDBUF_SIZE0 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-20
| unsigned, Size of command buffer 0 >> 3
|}
=== GPUREG_CMDBUF_SIZE1 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-20
| unsigned, Size of command buffer 1 >> 3
|}
=== GPUREG_CMDBUF_ADDR0 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-28
| unsigned, Physical address of command buffer 0 >> 3
|}
=== GPUREG_CMDBUF_ADDR1 ===
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-28
| unsigned, Physical address of command buffer 1 >> 3
|}
=== GPUREG_CMDBUF_JUMP0 ===


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 6,914: Line 7,348:
|-
|-
| 0-31
| 0-31
| Sets the active fixed attribute index. This is the fixed attribute which will be set when writing to [[#GPUREG_FIXEDATTRIB_DATA|GPUREG_FIXEDATTRIB_DATA]]. Valid values are 0-11. If the special value 0xF is written here, this sets up immediate-mode vertex submission instead, and writes to the data register will input vertex data directly into the pipeline.
| unsigned, Trigger (0 = idle, non-zero = execute command buffer 0)
|}
|}


=== GPUREG_FIXEDATTRIB_DATA ===
=== GPUREG_CMDBUF_JUMP1 ===


Accepts a packed 4-tuple of float24 values (in the same format used for [[#GPUREG_VSH_FLOATUNIFORM_DATA|specifying shader uniforms]]). This is stored as the fixed attribute value for the attribute currently specified in the index register. Attributes are always specified as a 4-tuple of floats, regardless of the format configured in [[#GPUREG_ATTRIBBUFFERS_FORMAT_HIGH|GPUREG_ATTRIBBUFFERS_FORMAT_HIGH]].
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Trigger (0 = idle, non-zero = execute command buffer 1)
|}


If immediate-mode vertex submission is enabled (by writing 0xF to the index register) then vertex data is input here directly. The index register does not need to be re-set after each write.
=== GPUREG_VSH_NUM_ATTR ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Number of vertex shader input attributes - 1
|}
 
=== GPUREG_VSH_COM_MODE ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0
| unsigned, Geometry shader configuration enabled (0 = disabled, 1 = enabled)
|-
| 8-31
| 0x0
|}
 
=== GPUREG_START_DRAW_FUNC0 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0
| unsigned, Mode (0 = drawing, 1 = configuration)
|-
| 1-31
| 0x0
|}
 
When the mode value is set to 1, rendering is not performed properly. When set to 0, changes to the vertex shader configuration registers are not applied correctly.
 
=== GPUREG_VSH_OUTMAP_TOTAL1 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Number of vertex shader output map registers - 1
|}
 
=== GPUREG_VSH_OUTMAP_TOTAL2 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned, Number of vertex shader output map registers - 1
|}
 
=== GPUREG_GSH_MISC0 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-31
| unsigned, Misc data (0x00000001 = Reserved geometry shader subdivision in use, 0x01004302 = Particle system in use, 0 otherwise)
|}
 
=== GPUREG_GEOSTAGE_CONFIG2 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0
| unsigned, Draw command active (0 = not active, 1 = active)
|-
| 8
| unsigned, Drawing triangle elements (0 = not, 1 = drawing triangle elements)
|-
| 9
| 0x0
|-
| 16-31
| 0x0
|}
 
This register is set to 1 before draw arrays/elements calls and cleared immediately after. While set to 1, some register writes out side of the 0x200-0x254 and
0x280-0x2DF ranges may be processed incorrectly.
 
=== GPUREG_GSH_MISC1 ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-4
| unsigned, Reserved geometry shader subdivision type (2 = Loop, 3 = Catmull-Clark)
|}
 
=== GPUREG_PRIMITIVE_CONFIG ===
 
{| class="wikitable" border="1"
! Bits
! Description
|-
| 0-3
| unsigned,  Number of vertex shader output map registers - 1
|-
| 8-9
| unsigned, Primitive mode
|-
| 16
| 0x0
|}
 
Primitive mode value:
 
{| class="wikitable" border="1"
! Value
! Description
|-
| 0
| Triangles
|-
| 1
| Triangle strip
|-
| 2
| Triangle fan
|-
| 3
| Geometry primitive
|}


=== GPUREG_RESTART_PRIMITIVE ===
=== GPUREG_RESTART_PRIMITIVE ===
Line 6,929: Line 7,502:
! Description
! Description
|-
|-
| 0-7
| 0
| Writing 0x01 to this field ends the current triangle strip or fan. This is necessary before using these kinds of primitives with [[GPU:Immediate-Mode Vertex Submission|immediate-mode]], but most games seem to write to it before every draw call.
| unsigned, Trigger (0 = idle, 1 = reset primitive)
|-
| 1-31
| 0x0
|}
|}