Changes

Jump to navigation Jump to search
2,167 bytes added ,  08:01, 19 December 2016
Correct register used for immediate-mode parameter count
Line 1: Line 1: −
This page is intended to contain more higher-level explanation of concepts and features provided by the 3DS GPU. For more detailed register-level information check [[GPU/Internal Registers]] or [[GPU/Commands]].
+
This page is intended to contain more higher-level explanation of concepts and features provided by the 3DS GPU. For more detailed register-level information check [[GPU/Internal Registers]].
    
= Geometry Pipeline =
 
= Geometry Pipeline =
Line 15: Line 15:  
Instead of using vertex arrays to supply vertex data, drawing can be done by directly writing vertex data to a register. This allows vertex data to be inlined directly in the command buffer. Since this is restricted to 4-component float data, it is more useful for small draws like UI elements or debug displays, to avoid using an unreasonable amount of memory and processing time appending the vertices to the command buffer.
 
Instead of using vertex arrays to supply vertex data, drawing can be done by directly writing vertex data to a register. This allows vertex data to be inlined directly in the command buffer. Since this is restricted to 4-component float data, it is more useful for small draws like UI elements or debug displays, to avoid using an unreasonable amount of memory and processing time appending the vertices to the command buffer.
   −
To use this feature, configure the number of attributes per vertex in [[GPU/Internal Registers#GPUREG_ATTRIBBUFFERS_FORMAT_HIGH|GPUREG_ATTRIBBUFFERS_FORMAT_HIGH]]. (All other settings in related registers seem to be ignored.) Then setup the GPU the same as if doing a regular draw call with GPUREG_DRAWARRAYS or GPUREG_DRAWELEMENTS, but instead of writing to either register, write the value 0xF to [[GPU/Internal Registers#GPUREG_FIXEDATTRIB_INDEX|GPUREG_FIXEDATTRIB_INDEX]] and then follow by repeatedly writing vertex data to [[GPU/Internal Registers#GPUREG_FIXEDATTRIB_DATA0|GPUREG_FIXEDATTRIB_DATA]].
+
To use this feature, configure the number of attributes per vertex in [[GPU/Internal Registers#GPUREG_VSH_NUM_ATTR|GPUREG_VSH_NUM_ATTR]]. (All settings in the registers related to the vertex loader are ignored.) Then setup the GPU and shaders the same as if doing a regular draw call with GPUREG_DRAWARRAYS or GPUREG_DRAWELEMENTS, but instead of writing to either register, write the value 0xF to [[GPU/Internal Registers#GPUREG_FIXEDATTRIB_INDEX|GPUREG_FIXEDATTRIB_INDEX]] and then follow by repeatedly writing vertex data to [[GPU/Internal Registers#GPUREG_FIXEDATTRIB_DATA0|GPUREG_FIXEDATTRIB_DATA]].
   −
Each set of writes to the 3 data registers specifies one attribute and all attributes (as configured in GPUREG_ATTRIBBUFFERS_FORMAT_HIGH) need to be written, in order, to specify a vertex. Drawing happens automatically as vertices are specified. After finishing specifying vertices, follow with the same writes used after a draw arrays/elements.
+
Each set of writes to the 3 data registers specifies one attribute and all attributes (as configured in GPUREG_VSH_NUM_ATTR) need to be written, in order, to specify a vertex. Drawing happens automatically as vertices are specified. After finishing specifying vertices, follow with the same writes used after a draw arrays/elements.
    
When drawing using triangle strips or fans, [[GPU/Internal Registers#GPUREG_RESTART_PRIMITIVE|GPUREG_RESTART_PRIMITIVE]] should be used to end the previous strip before (or while) drawing.
 
When drawing using triangle strips or fans, [[GPU/Internal Registers#GPUREG_RESTART_PRIMITIVE|GPUREG_RESTART_PRIMITIVE]] should be used to end the previous strip before (or while) drawing.
 +
 +
== Drawing elements ==
 +
 +
The 3DS GPU is capable of drawing vertex + index arrays, triggered by [[GPU/Internal_Registers#GPUREG_DRAWELEMENTS|GPUREG_DRAWELEMENTS]]. A set of commands commonly used by the standard GL implementation to accomplish this is as follows:
 +
 +
{| class="wikitable" border="1"
 +
!  Command Index
 +
!  Register
 +
!  Description
 +
|-
 +
| 0
 +
| [[GPU/Internal_Registers#GPUREG_GEOSTAGE_CONFIG|GPUREG_GEOSTAGE_CONFIG]]
 +
| Set whether drawing triangle elements
 +
|-
 +
| 1-2
 +
| [[GPU/Internal_Registers#GPUREG_GEOSTAGE_CONFIG2|GPUREG_GEOSTAGE_CONFIG2]]
 +
| Set whether drawing triangle elements
 +
|-
 +
| 3
 +
| [[GPU/Internal_Registers#GPUREG_PRIMITIVE_CONFIG|GPUREG_PRIMITIVE_CONFIG]]
 +
| Set primitive mode
 +
|-
 +
| 4
 +
| [[GPU/Internal_Registers#GPUREG_PRIMITIVE_CONFIG|GPUREG_PRIMITIVE_CONFIG]]
 +
| Set number of output map registers
 +
|-
 +
| 5
 +
| [[GPU/Internal_Registers#GPUREG_RESTART_PRIMITIVE|GPUREG_RESTART_PRIMITIVE]]
 +
| Trigger reset
 +
|-
 +
| 6
 +
| [[GPU/Internal_Registers#GPUREG_GEOSTAGE_CONFIG2|GPUREG_GEOSTAGE_CONFIG2]]
 +
| Set function indicator to 0
 +
|-
 +
| 7
 +
| [[GPU/Internal_Registers#GPUREG_INDEXBUFFER_CONFIG|GPUREG_INDEXBUFFER_CONFIG]]
 +
| Set offset and type
 +
|-
 +
| 8
 +
| [[GPU/Internal_Registers#GPUREG_NUMVERTICES|GPUREG_NUMVERTICES]]
 +
| Set vertex count
 +
|-
 +
| 9
 +
| [[GPU/Internal_Registers#GPUREG_START_DRAW_FUNC0|GPUREG_START_DRAW_FUNC0]]
 +
| Set mode to drawing
 +
|-
 +
| 10
 +
| [[GPU/Internal_Registers#GPUREG_DRAWELEMENTS|GPUREG_DRAWELEMENTS]]
 +
| Trigger draw
 +
|-
 +
| 11
 +
| [[GPU/Internal_Registers#GPUREG_START_DRAW_FUNC0|GPUREG_START_DRAW_FUNC0]]
 +
| Set mode to configuration
 +
|-
 +
| 12
 +
| [[GPU/Internal_Registers#GPUREG_VTX_FUNC|GPUREG_VTX_FUNC]]
 +
| Trigger post-vertex cache clear
 +
|-
 +
| 13
 +
| [[GPU/Internal_Registers#GPUREG_FRAMEBUFFER_FLUSH|GPUREG_FRAMEBUFFER_FLUSH]]
 +
| Flush framebuffer
 +
|-
 +
| 14
 +
| [[GPU/Internal_Registers#GPUREG_GEOSTAGE_CONFIG|GPUREG_GEOSTAGE_CONFIG]]
 +
| Clear drawing triangle elements
 +
|-
 +
| 15
 +
| [[GPU/Internal_Registers#GPUREG_GEOSTAGE_CONFIG2|GPUREG_GEOSTAGE_CONFIG2]]
 +
| Clear drawing triangle elements
 +
|-
 +
| 16
 +
| [[GPU/Internal_Registers#GPUREG_PRIMITIVE_CONFIG|GPUREG_PRIMITIVE_CONFIG]]
 +
| Clear primitive mode
 +
|-
 +
| 17
 +
| [[GPU/Internal_Registers#GPUREG_VSH_ENTRYPOINT|GPUREG_VSH_ENTRYPOINT]]
 +
| Clear entry point
 +
|}
    
[[Category:GPU]]
 
[[Category:GPU]]
110

edits

Navigation menu