Difference between revisions of "GPU/Commands"

From 3dbrew
< GPU
Jump to navigation Jump to search
m (Replaced content with "Merged with GPU/Internal_Registers")
 
(175 intermediate revisions by 10 users not shown)
Line 1: Line 1:
This page describes the structure of the buffer for [[GSP_Shared_Memory|GX command]] 1 with the registers at [[GPU|0x1EF018E0]]. This buffer is used for GPU commands including OpenGL commands, each 8-byte entry in the buffer is a command. Cmd+0 is the command parameter, and cmd+4 is the command header.
+
Merged with [[GPU/Internal_Registers]]
 
 
Invalid GPU command parameters can cause the GPU to hang, this then causes the GSP module to hang as well.
 
 
 
=== Command Header ===
 
{| class="wikitable" border="1"
 
!  Bit
 
!  Description
 
|-
 
| 19-0
 
| Command ID
 
|-
 
| 30-20
 
| Total words following the command, if any.
 
|-
 
| 31
 
| ?
 
|}
 
The first word in the parameter data structure is the command parameter value, the rest of the data structure is from the data following the command. The word after the last data structure word is padding when needed for 8-byte alignment, for the following command.
 
 
 
=== Commands ===
 
{| class="wikitable" border="1"
 
!  CommandID
 
!  Parameter
 
!  Description
 
|-
 
| 0x000F0010
 
| Value is 0x12345678
 
| This command is always the last command in the buffer.
 
|-
 
| 0x000F0110
 
| Value 0x1
 
| This command is immediately before CmdID 0x000F0010, this is also used elsewhere for beginning rendering of object(s) as well.
 
|-
 
| 0x000F0111
 
| Value 0x1
 
| This command is immediately before CmdID 0x000F0110, however CmdID 0x000F0110 doesn't always follow this command.
 
|-
 
| 0x000F0040
 
| u32, valid values are 0x1 and 0x2, values 0x0 and 0x3 have the same effect as value 0x2. Only bits 1-0 are used.
 
| Disable/enable alpha testing. Parameter value 0x1 disables GL_ALPHA_TEST, while value 0x2 enables GL_ALPHA_TEST.
 
|-
 
| 0x000F0041
 
| float
 
| This is used to initialize the projection matrix?
 
|-
 
| 0x000F0042
 
| float
 
| This is used immediately after CmdID 0x000F0043, for the third parameter for CmdID 0x000F0041.
 
|-
 
| 0x000F0043
 
| float
 
| This is used immediately after CmdID 0x000F0041, for the second parameter.
 
|-
 
| 0x000F0044
 
| float
 
| This is used immediately after CmdID 0x000F0042, for the fourth parameter for CmdID 0x000F0041.
 
|-
 
| 0x801F004D
 
| First word in parameter structure
 
| ?
 
|-
 
| 0x0002025E
 
| u32, val<<8. Val3 = GL_TRIANGLES, val5 = GL_TRIANGLE_STRIP, val6 = GL_TRIANGLE_FAN. Val0 and val4 are unknown, these seem to have the same effect.
 
| This sets the GL rendering mode.
 
|-
 
| 0x000F0068
 
| u32
 
| This is used immediately after CmdID 0x000F0044.
 
|-
 
| 0x000F006E
 
| u32
 
| This is used immediately after CmdID 0x000F011E, with the same input parameter value as CmdID 0x000F011E.
 
|-
 
| 0x809F0081
 
|
 
| This is used to set the current texture info used for rendering.
 
|-
 
| 0x000F008E
 
| u32
 
| This texture-related command is used immediately after CmdID 0x809F0081.
 
|-
 
| 0x00020100
 
| u32, value is 0x00E40100
 
| This command is used immediately before CmdID 0x000F0101.
 
|-
 
| 0x000F0101
 
| u32
 
| Color related?
 
|-
 
| 0x000F0116
 
| u32
 
| Unknown, this is used immediately after CmdID 0x000F011D.
 
|-
 
| 0x000F0117
 
| u32
 
| Unknown, normally the input parameter is value 0x2.
 
|-
 
| 0x000F011C
 
| Physical address>>3
 
| Normally this address is located in VRAM, this seems to be the GPU data storage end address. This command is used immediately after 0x000F0116.
 
|-
 
| 0x000F011D
 
| Physical address>>3
 
| This initializes the framebuffer address used for rendering, this framebuffer is used for the input framebuffer with [[GSP_Shared_Memory|GX command]] 3 and 4. This is also the GPU data storage start address, this data storage likely contains vertex arrays, etc. This command is used immediately after CmdID 0x000F0117.
 
|-
 
| 0x000F011E
 
| u32
 
| This sets the width and height for the framebuffer used for rendering. Therefore this is glViewport() with x=0 and y=0. This is used immediately after CmdID 0x000F011C.
 
|-
 
| 0x8XXF0200
 
|
 
| The first word in the parameter buffer structure seems to have a similar same effect as CmdID 0x000F0040, where param0 = val<<24.(Val 0x3 enables alpha testing, while other values disables it)
 
|-
 
| 0x000F0227
 
| u32, bit31 is unknown. Bits30-0 is the address, where address is relative to VRAM.
 
| This specifies the address of an array containing vertex array indices, used for rendering primitives. Each index entry is an u16.
 
|-
 
| 0x000F0228
 
| u32 total elements in the array to use for rendering.
 
| This command is used immediately after CmdID 0x000F0227. This command and CmdID 0x000F0227 are some of the commands used for glDrawElements().
 
|-
 
| 0x000F02B0
 
| u32, value is <nowiki>0x7FFF0000 | val</nowiki>.
 
| Texture related?
 
|-
 
| 0x000F02C0
 
| <nowiki>0x80000000 | Type</nowiki>
 
| This is used immediately before CmdID 0xXXXF02C1. This type field controls the command parameter buffer type.
 
|-
 
| 0xXXXF02C1
 
| First word in the first entry
 
| A list of entries follow this command.
 
|}
 
 
 
=== Parameter value format for CmdID 0x000F011E ===
 
{| class="wikitable" border="1"
 
!  Bit
 
!  Description
 
|-
 
| 11-0
 
| Framebuffer width
 
|-
 
| 23-12
 
| Framebuffer height - 1
 
|-
 
| 24
 
| Must be set
 
|-
 
| 31-25
 
| Unused?
 
|}
 
 
 
Normally the width and height is set to the same [[GPU|dimensions]] used with GX [[GSP_Shared_Memory|command]] 3 and 4.
 
 
 
=== Texture info parameter structure for CmdID 0x809F0081 ===
 
{| class="wikitable" border="1"
 
!  Index Word
 
!  Description
 
|-
 
| 0
 
| ?
 
|-
 
| 1
 
| The low u16 is the texture image width, and the high u16 is the texture image height.
 
|-
 
| 2-3
 
| ?
 
|-
 
| 4
 
| Texture data physical address >> 3. This is normally located in the VRAM GPU data storage region.
 
|-
 
| 5-9
 
| ?
 
|}
 
 
 
=== Entries for CmdID 0xXXXF02C1 ===
 
{| class="wikitable" border="1"
 
!  Index Word
 
!  Description
 
|-
 
| 0
 
| float
 
|-
 
| 1
 
| float
 
|-
 
| 2
 
| float
 
|}
 
 
 
==== Color Entry ====
 
{| class="wikitable" border="1"
 
!  Index Word
 
!  Description
 
|-
 
| 0
 
| float Red component
 
|-
 
| 1
 
| float Blue component
 
|-
 
| 2
 
| float Green component
 
|-
 
| 3
 
| float Alpha?
 
|-
 
| 4
 
| float
 
|-
 
| 5
 
| float
 
|}
 
 
 
==== Vertex Entry ====
 
{| class="wikitable" border="1"
 
!  Index Word
 
!  Description
 
|-
 
| 0
 
| float X coordinate
 
|-
 
| 1
 
| float Y coordinate
 
|-
 
| 2
 
| float Z coordinate
 
|}
 
 
 
Type 0x14 seems to used for rendering quads, mainly for the skybox/sub screen etc. The rest of the rendered objects are likely rendered via vertex arrays, however it's unknown how the vertex arrays are initialized.
 
 
 
=== Types for CmdID 0x000F02C0 ===
 
{| class="wikitable" border="1"
 
!  Value
 
!  Entries per chunk
 
!  Description
 
|-
 
| 0x00
 
| 4
 
| Related to model-view matrix translation?
 
|-
 
| 0x04
 
| 4
 
| Unknown, this is used immediately after type 0x00.
 
|-
 
| 0x08
 
| One color entry via two CmdID 0xXXXF02C1 entries.
 
| Sets the color.
 
|-
 
| 0x0A
 
| 4
 
| Texture coordinates related?
 
|-
 
| 0x0B
 
| 3
 
| ?
 
|-
 
| 0x0C, 0x0D
 
| 3
 
| Related to type 0x0A?
 
|-
 
| 0x0E
 
| 4
 
| Related to type 0x0A?
 
|-
 
| 0x14
 
| <=30
 
| Geometry vertices
 
|-
 
| 0x4C
 
| 4
 
| ?
 
|-
 
| 0x50, 0x53, and 0x56
 
| 1
 
| ?
 
|-
 
| 0x51, 0x54, and 0x57
 
| 1
 
| ?
 
|-
 
| 0x52, 0x55, and 0x58
 
| 1
 
| ?
 
|-
 
| 0x59
 
| 1
 
| Unknown, the entry data is floats converted from s32s.
 
|-
 
| 0x5A
 
| 2
 
| Color related?
 
|-
 
| 0x5C
 
| 1
 
| ?
 
|}
 

Latest revision as of 08:06, 5 December 2015