Reality Display Processor/Commands: Difference between revisions

Hazard: Alpha compare in COPY mode targeting 16-bit framebuffers is only valid for RGBA5551 textures
(rectangles are multiword...)
(Hazard: Alpha compare in COPY mode targeting 16-bit framebuffers is only valid for RGBA5551 textures)
 
(28 intermediate revisions by 3 users not shown)
Line 1:
 
====<span style="display:none;">0x24 - Texture_Rectangle ====
{| class="wikitable"
====<span style="display:none;">0x25 - Texture_Rectangle_Flip ====
! !! 0 !! 1 !! 2 !! 3 !! 4 !! 5 !! 6 !! 7
|-
| 0x00 || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation
|-
| 0x08 || Fill Triangle || Fill Triangle (Z) || Fill Triangle (T) || Fill Triangle (TZ) || Fill Triangle (S) || Fill Triangle (SZ) || Fill Triangle (ST) || Fill Triangle (STZ)
|-
| 0x10 || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation
|-
| 0x18 || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation || No Operation
|-
| 0x20 || No Operation || No Operation || No Operation || No Operation || Texture Rectangle || Texture Rectangle Flip || Sync Load || Sync Pipe
|-
| 0x28 || Sync Tile || Sync Full || Set Key GB || Set Key R || Set Convert || Set Scissor || Set Primitive Depth || Set Other Modes
|-
| 0x30 || Load TLUT || No Operation || Set Tile Size || Load Block || Load Tile || Set Tile || Fill Rectangle || Set Fill Color
|-
| 0x38 || Set Fog Color || Set Blend Color || Set Primitive Color || Set Environment Color || Set Combine Mode || Set Texture Image || Set Depth Image || Set Color Image
|}
 
=== 0x00 through 0x07, 0x10 through 0x23, 0x31 - No Operation ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="1817"|Texture_RectangleNo Operation <code>0x240x00-0x07</code> and Texture_Rectangle_Flip ,<code>0x10-0x23</code>,<code>0x250x31</code>
|-
| rowspan="4"|Word 0 || 63:48 || — || — || colspan=6| command[5:0] =|| 0x24 or|| 0x25 || colspan=8— || x.lo[11:4]— || — || — || — || —
|-
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
| 47:32 || colspan=4| x.lo[3:0] || colspan=12| y.lo[11:0]
|-
| 31:16 || — || — || — || — || — || colspan=3— || tile[2:0] || colspan=8— || — || — || — || — || — || — || — || x.hi[11:4]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
| 15:0 || colspan=4| x.hi[3:0] || colspan=12| y.hi[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x00-0x07,0x10-0x23,0x31
}}
 
Stalls the RDP pipeline for 1 cycle.
 
(TOVERIFY all of these command ids appear to behave as no-ops and take only 1 cycle to execute in testing so far, however this should be checked more extensively)
 
=== 0x08 through 0x0F - Fill Triangle ===
----
 
The Fill Triangle command varies in length depending on whether shade, texture or depth is enabled in the first word. For any of these properties that are enabled, additional words are appended to the base command words in order of shading, texturing, z-buffering.
 
==== Base Command ====
 
Every triangle type begins with a common base that describes the type, shape and other small properties of the triangle.
 
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="18"|Fill Triangle <code>0x08</code> through <code>0x0F</code> (base)
|-
| rowspan="4"|Word 0 || 63:48 || — || — || 0 || 0 || 1 || shade || texture || zbuffer || lmajor || — || colspan=3| level[2:0] || colspan=3| tile[2:0]
|-
| 47:32 || — || — || colspan=14| yl[13:0]
|-
| 31:16 || — || — || colspan=14| ym[13:0]
|-
| 15:0 || — || — || colspan=14| yh[13:0]
|-
| rowspan="4"|Word 1 || 63:48 || — || — || — || — || colspan=12| xl.i[11:0]
|-
| 47:32 || colspan=16| xl.f[15:0]
|-
| 31:16 || — || — || colspan=14| dxldy.i[13:0]
|-
| 15:0 || colspan=16| dxldy.f[15:0]
|-
| rowspan="4"|Word 2 || 63:48 || — || — || — || — || colspan=12| xh.i[15:0]
|-
| 47:32 || colspan=16| xh.f[15:0]
|-
| 31:16 || — || — || colspan=14| dxhdy.i[15:0]
|-
| 15:0 || colspan=16| dxhdy.f[15:0]
|-
| rowspan="4"|Word 3 || 63:48 || — || — || — || — || colspan=12| xm.i[15:0]
|-
| 47:32 || colspan=16| xm.f[15:0]
|-
| 31:16 || — || — || colspan=14| dxmdy.i[15:0]
|-
| 15:0 || colspan=16| dxmdy.f[15:0]
|}
'''Word 0'''
{{#invoke:Register table|definitions
| 61:56 | command | 0x08 through 0x0F depending on features specified
| 58 | shade | If 1, command is followed by 8 words specifying shading coefficients
| 57 | texture | If 1, command is followed by 8 words specifying texturing coefficients
| 56 | zbuffer | If 1, command is followed by 2 words specifying z-buffering coefficients
| 55 | lmajor | Left-major flag, if enabled rendering occurs from left-to-right, otherwise rendering occurs from right-to-left
| 53:51 | level[2:0] | Maximum LOD level
| 50:48 | tile[2:0] | Base tile descriptor index
| 45:32 | yl[13:0] | Lowest y coordinate (largest value), rasterization ends at this height (s11.2 format)
| 29:16 | ym[13:0] | Middle y coordinate (middle value), rasterization swaps dxmdy for dxldy (s11.2 format)
| 13:0 | yh[13:0] | Highest y coordinate (highest value), rasterization begins at this height (s11.2 format)
}}
'''Word 1'''
{{#invoke:Register table|definitions
| 59:48 | xl.i[11:0] | Integer part of x coordinate on dxldy line at height ym (s11.16 format)
| 47:32 | xl.f[15:0] | Fractional part of x coordinate on dxldy line at height ym (s11.16 format)
| 29:16 | dxldy.i[13:0] | Integer part of change in x per change in y of line connecting middle and lowest vertices (s13.16 format)
| 15:0 | dxldy.f[15:0] | Fractional part of change in x per change in y of line connecting middle and lowest vertices (s13.16 format)
}}
'''Word 2'''
{{#invoke:Register table|definitions
| 59:48 | xh.i[11:0] | Integer part of x coordinate on dxhdy line at height floor(yh) (s11.16 format)
| 47:32 | xh.f[15:0] | Fractional part of x coordinate on dxhdy line at height floor(yh) (s11.16 format)
| 29:16 | dxhdy.i[13:0] | Integer part of change in x per change in y of line connecting highest and lowest vertices (s13.16 format)
| 15:0 | dxhdy.f[15:0] | Fractional part of change in x per change in y of line connecting highest and lowest vertices (s13.16 format)
}}
'''Word 3'''
{{#invoke:Register table|definitions
| 59:48 | xm.i[11:0] | Integer part of x coordinate on dxmdy line at height floor(yh) (s11.16 format)
| 47:32 | xm.f[15:0] | Fractional part of x coordinate on dxmdy line at height floor(yh) (s11.16 format)
| 29:16 | dxmdy.i[13:0] | Integer part of change in x per change in y of line connecting highest and middle vertices (s13.16 format)
| 15:0 | dxmdy.f[15:0] | Fractional part of change in x per change in y of line connecting highest and middle vertices (s13.16 format)
}}
 
----
 
==== Optional Shading Properties ====
 
If the '''shade''' bit was set in the base triangle description, the above words will be followed by these 8 words describing triangle shading properties:
 
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="18"|Fill Shaded Triangle (suffix)
|-
| rowspan="4"|Word 0 || 63:48 || - || - || - || - || - || - || - || colspan=9| r.i[8:0]
|-
| 47:32 || - || - || - || - || - || - || - || colspan=9| g.i[8:0]
|-
| 31:16 || - || - || - || - || - || - || - || colspan=9| b.i[8:0]
|-
| 15:0 || - || - || - || - || - || - || - || colspan=9| a.i[8:0]
|-
| rowspan="4"|Word 1 || 63:48 || colspan=16| drdx.i[15:0]
|-
| 47:32 || colspan=16| dgdx.i[15:0]
|-
| 31:16 || colspan=16| dbdx.i[15:0]
|-
| 15:0 || colspan=16| dadx.i[15:0]
|-
| rowspan="4"|Word 2 || 63:48 || colspan=16| r.f[15:0]
|-
| 47:32 || colspan=16| g.f[15:0]
|-
| 31:16 || colspan=16| b.f[15:0]
|-
| 15:0 || colspan=16| a.f[15:0]
|-
| rowspan="4"|Word 3 || 63:48 || colspan=16| drdx.f[15:0]
|-
| 47:32 || colspan=16| dgdx.f[15:0]
|-
| 31:16 || colspan=16| dbdx.f[15:0]
|-
| 15:0 || colspan=16| dadx.f[15:0]
|-
| rowspan="4"|Word 4 || 63:48 || colspan=16| drde.i[15:0]
|-
| 47:32 || colspan=16| dgde.i[15:0]
|-
| 31:16 || colspan=16| dbde.i[15:0]
|-
| 15:0 || colspan=16| dade.i[15:0]
|-
| rowspan="4"|Word 5 || 63:48 || colspan=16| drdy.i[15:0]
|-
| 47:32 || colspan=16| dgdy.i[15:0]
|-
| 31:16 || colspan=16| dbdy.i[15:0]
|-
| 15:0 || colspan=16| dady.i[15:0]
|-
| rowspan="4"|Word 6 || 63:48 || colspan=16| drde.f[15:0]
|-
| 47:32 || colspan=16| dgde.f[15:0]
|-
| 31:16 || colspan=16| dbde.f[15:0]
|-
| 15:0 || colspan=16| dade.f[15:0]
|-
| rowspan="4"|Word 7 || 63:48 || colspan=16| drdy.f[15:0]
|-
| 47:32 || colspan=16| dgdy.f[15:0]
|-
| 31:16 || colspan=16| dbdy.f[15:0]
|-
| 15:0 || colspan=16| dady.f[15:0]
|}
'''Word 0'''
{{#invoke:Register table|definitions
| 56:48 | r.i[8:0] | Integer part of red channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 40:32 | g.i[8:0] | Integer part of green channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 24:16 | b.i[8:0] | Integer part of blue channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 8:0 | a.i[8:0] | Integer part of alpha channel shade color at '''(xh, floor(yh))''' (s8.16 format)
}}
'''Word 1'''
{{#invoke:Register table|definitions
| 63:48 | drdx.i[15:0] | Integer part of change in red channel shade color horizontally along a scanline (s15.16 format)
| 47:32 | dgdx.i[15:0] | Integer part of change in green channel shade color horizontally along a scanline (s15.16 format)
| 31:16 | dbdx.i[15:0] | Integer part of change in blue channel shade color horizontally along a scanline (s15.16 format)
| 15:0 | dadx.i[15:0] | Integer part of change in alpha channel shade color horizontally along a scanline (s15.16 format)
}}
'''Word 2'''
{{#invoke:Register table|definitions
| 63:48 | r.f[15:0] | Fractional part of red channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 47:32 | g.f[15:0] | Fractional part of green channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 31:16 | b.f[15:0] | Fractional part of blue channel shade color at '''(xh, floor(yh))''' (s8.16 format)
| 15:0 | a.f[15:0] | Fractional part of alpha channel shade color at '''(xh, floor(yh))''' (s8.16 format)
}}
'''Word 3'''
{{#invoke:Register table|definitions
| 63:48 | drdx.f[15:0] | Fractional part of change in red channel shade color horizontally along a scanline (s15.16 format)
| 47:32 | dgdx.f[15:0] | Fractional part of change in green channel shade color horizontally along a scanline (s15.16 format)
| 31:16 | dbdx.f[15:0] | Fractional part of change in blue channel shade color horizontally along a scanline (s15.16 format)
| 15:0 | dadx.f[15:0] | Fractional part of change in alpha channel shade color horizontally along a scanline (s15.16 format)
}}
'''Word 4'''
{{#invoke:Register table|definitions
| 63:48 | drde.i[15:0] | Integer part of change in red channel shade color along the major edge (s15.16 format)
| 47:32 | dgde.i[15:0] | Integer part of change in green channel shade color along the major edge (s15.16 format)
| 31:16 | dbde.i[15:0] | Integer part of change in blue channel shade color along the major edge (s15.16 format)
| 15:0 | dade.i[15:0] | Integer part of change in alpha channel shade color along the major edge (s15.16 format)
}}
'''Word 5'''
{{#invoke:Register table|definitions
| 63:48 | drdy.i[15:0] | Integer part of change in red channel shade color for each scanline (s15.16 format)
| 47:32 | dgdy.i[15:0] | Integer part of change in green channel shade color for each scanline (s15.16 format)
| 31:16 | dbdy.i[15:0] | Integer part of change in blue channel shade color for each scanline (s15.16 format)
| 15:0 | dady.i[15:0] | Integer part of change in alpha channel shade color for each scanline (s15.16 format)
}}
'''Word 6'''
{{#invoke:Register table|definitions
| 63:48 | drde.f[15:0] | Fractional part of change in red channel shade color along the major edge (s15.16 format)
| 47:32 | dgde.f[15:0] | Fractional part of change in green channel shade color along the major edge (s15.16 format)
| 31:16 | dbde.f[15:0] | Fractional part of change in blue channel shade color along the major edge (s15.16 format)
| 15:0 | dade.f[15:0] | Fractional part of change in alpha channel shade color along the major edge (s15.16 format)
}}
'''Word 7'''
{{#invoke:Register table|definitions
| 63:48 | drdy.f[15:0] | Fractional part of change in red channel shade color for each scanline (s15.16 format)
| 47:32 | dgdy.f[15:0] | Fractional part of change in green channel shade color for each scanline (s15.16 format)
| 31:16 | dbdy.f[15:0] | Fractional part of change in blue channel shade color for each scanline (s15.16 format)
| 15:0 | dady.f[15:0] | Fractional part of change in alpha channel shade color for each scanline (s15.16 format)
}}
 
----
 
==== Optional Texturing Properties ====
 
If the '''texture''' bit was set in the base triangle description, the above words will be followed by these 8 words describing triangle texturing properties:
 
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="18"|Fill Textured Triangle (suffix)
|-
| rowspan="4"|Word 10 || 63:48 || colspan=16| s.i[15:0]
|-
| 47:32 || colspan=16| t.i[15:0]
|-
| 31:16 || colspan=16| sw.fi[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
| 15:0 || colspan=16| t.f[15:0]
|-
| rowspan="4"|Word 1 || 63:48 || colspan=16| dsdx.i[15:0]
|-
| 47:32 || colspan=16| dtdx.i[15:0]
|-
| 31:16 || colspan=16| dwdx.i[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 2 || 63:48 || colspan=16| s.f[15:0]
|-
| 47:32 || colspan=16| t.f[15:0]
|-
| 31:16 || colspan=16| w.f[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 3 || 63:48 || colspan=16| dsdx.f[15:0]
|-
| 47:32 || colspan=16| dtdx.f[15:0]
|-
| 31:16 || colspan=16| dwdx.f[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 4 || 63:48 || colspan=16| dsde.i[15:0]
|-
| 47:32 || colspan=16| dtde.i[15:0]
|-
| 31:16 || colspan=16| dwde.i[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 5 || 63:48 || colspan=16| dsdy.i[15:0]
|-
| 47:32 || colspan=16| dtdy.i[15:0]
|-
| 31:16 || colspan=16| dwdy.i[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 6 || 63:48 || colspan=16| dsde.f[15:0]
|-
| 47:32 || colspan=16| dtde.f[15:0]
|-
| 31:16 || colspan=16| dwde.f[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| rowspan="4"|Word 7 || 63:48 || colspan=16| dsdy.f[15:0]
|-
| 47:32 || colspan=16| dtdy.f[15:0]
|-
| 31:16 || colspan=16| dwdy.f[15:0]
|-
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|}
'''Word 0'''
{{#invoke:Register table|definitions
| 63:48 | s.i[15:0] | Integer part of s-axis texture coordinate at '''(xh, floor(yh))'''
| 47:32 | t.i[15:0] | Integer part of t-axis texture coordinate at '''(xh, floor(yh))'''
| 31:16 | w.i[15:0] | Integer part of perspective scale at '''(xh, floor(yh))'''
}}
'''Word 1'''
{{#invoke:Register table|definitions
| 63:48 | dsdx.i[15:0] | Integer part of change in s-axis texture coordinate horizontally along a scanline
| 47:32 | dtdx.i[15:0] | Integer part of change in t-axis texture coordinate horizontally along a scanline
| 31:16 | dwdx.i[15:0] | Integer part of change in perspective scale horizontally along a scanline
}}
'''Word 2'''
{{#invoke:Register table|definitions
| 63:48 | s.f[15:0] | Fractional part of s-axis texture coordinate at '''(xh, floor(yh))'''
| 47:32 | t.f[15:0] | Fractional part of t-axis texture coordinate at '''(xh, floor(yh))'''
| 31:16 | w.f[15:0] | Fractional part of perspective scale at '''(xh, floor(yh))'''
}}
'''Word 3'''
{{#invoke:Register table|definitions
| 63:48 | dsdx.f[15:0] | Fractional part of change in s-axis texture coordinate horizontally along a scanline
| 47:32 | dtdx.f[15:0] | Fractional part of change in t-axis texture coordinate horizontally along a scanline
| 31:16 | dwdx.f[15:0] | Fractional part of change in perspective scale horizontally along a scanline
}}
'''Word 4'''
{{#invoke:Register table|definitions
| 63:48 | dsde.i[15:0] | Integer part of change in s-axis texture coordinate along the major edge
| 47:32 | dtde.i[15:0] | Integer part of change in t-axis texture coordinate along the major edge
| 31:16 | dwde.i[15:0] | Integer part of change in perspective scale along the major edge
}}
'''Word 5'''
{{#invoke:Register table|definitions
| 63:48 | dsdy.i[15:0] | Integer part of change in s-axis texture coordinate for each scanline
| 47:32 | dtdy.i[15:0] | Integer part of change in t-axis texture coordinate for each scanline
| 31:16 | dwdy.i[15:0] | Integer part of change in perspective scale for each scanline
}}
'''Word 6'''
{{#invoke:Register table|definitions
| 63:48 | dsde.f[15:0] | Fractional part of change in s-axis texture coordinate along the major edge
| 47:32 | dtde.f[15:0] | Fractional part of change in t-axis texture coordinate along the major edge
| 31:16 | dwde.f[15:0] | Fractional part of change in perspective scale along the major edge
}}
'''Word 7'''
{{#invoke:Register table|definitions
| 63:48 | dsdy.f[15:0] | Fractional part of change in s-axis texture coordinate for each scanline
| 47:32 | dtdy.f[15:0] | Fractional part of change in t-axis texture coordinate for each scanline
| 31:16 | dwdy.f[15:0] | Fractional part of change in perspective scale for each scanline
}}
 
----
=====Word 0=====
 
==== Optional Depth Properties ====
 
If the '''zbuffer''' bit was set in the base triangle description, the above words will be followed by these 2 words describing triangle depth properties:
 
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="18"| Fill Z-Buffered Triangle (suffix)
|-
| rowspan="4"|Word 0 || 63:48 || colspan=16| z.i[15:0]
|-
| 47:32 || colspan=16| z.f[15:0]
|-
| 31:16 || colspan=16| dzdx.i[15:0]
|-
| 15:0 || colspan=16| dzdx.f[15:0]
|-
| rowspan="4"|Word 1 || 63:48 || colspan=16| dzde.i[15:0]
|-
| 47:32 || colspan=16| dzde.f[15:0]
|-
| 31:16 || colspan=16| dzdy.i[15:0]
|-
| 15:0 || colspan=16| dzdy.f[15:0]
|}
'''Word 0'''
{{#invoke:Register table|definitions
| 63:48 | z.i[15:0] | Integer part of depth at '''(xh, floor(yh))'''
| 47:32 | z.f[15:0] | Fractional part of depth at '''(xh, floor(yh))'''
| 31:16 | dzdx.i[15:0] | Integer part of change in depth horizontally along a scanline
| 15:0 | dzdx.f[15:0] | Fractional part of change in depth horizontally along a scanline
}}
'''Word 1'''
{{#invoke:Register table|definitions
| 63:48 | dzde.i[15:0] | Integer part of change in depth along the major edge
| 47:32 | dzde.f[15:0] | Fractional part of change in depth along the major edge
| 31:16 | dzdy.i[15:0] | Integer part of change in depth for each scanline
| 15:0 | dzdy.f[15:0] | Fractional part of change in depth for each scanline
}}
 
=== 0x24 and 0x25 - Texture Rectangle ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="18"|Texture Rectangle <code>0x24</code> and Texture Rectangle Flip <code>0x25</code>
|-
| rowspan="4"|Word 0 || 63:48 || — || — || colspan=6| command[5:0] = 0x24 or 0x25 || colspan=8| lrx[11:4]
|-
| 47:32 || colspan=4| lrx[3:0] || colspan=12| lry[11:0]
|-
| 31:16 || — || — || — || — || — || colspan=3| tile[2:0] || colspan=8| ulx[11:4]
|-
| 15:0 || colspan=4| ulx[3:0] || colspan=12| uly[11:0]
|-
| rowspan="4"|Word 1 || 63:48 || colspan=16| s[15:0]
|-
| 47:32 || colspan=16| t[15:0]
|-
| 31:16 || colspan=16| dsdx[15:0]
|-
| 15:0 || colspan=16| dtdy[15:0]
|}
 
'''Word 0'''
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x24 (Texture_Rectangle) or 0x25 (Texture_Rectangle_Flip)
| 55:44 | x.lolrx[11:0] | Lower-right x screen coordinate (u10.2 format)
| 43:32 | y.lolry[11:0] | Lower-right y screen coordinate (u10.2 format)
| 26:24 | tile[2:0] | -Tile descriptor index
| 23:12 | x.hiulx[11:0] | Upper-left x screen coordinate (u10.2 format)
| 11:0 | y.hiuly[11:0] | Upper-left y screen coordinate (u10.2 format)
}}
====='''Word 1====='''
{{#invoke:Register table|definitions
| 63:48 | s.i[15:0] | Upper-left s coordinate (s10.5 format)
| 47:32 | t.i[15:0] | Upper-left t coordinate (s10.5 format)
| 31:16 | s.fdsdx[15:0] | -Change in s per x (s5.10 format)
| 15:0 | t.fdtdy[15:0] | -Change in t per y (s5.10 format)
}}
 
Renders a textured rectangle between upper-left coordinate '''(ulx,uly)''' and lower-right coordinate '''(lrx,lry)''', sampling texels using the tile descriptor indexed by '''tile'''. The coordinates '''(s,t)''' are the texture coordinates for the pixel at '''(ulx,uly)''', the derivatives '''dsdx''' and '''dtdy''' are added to these initial coordinates to determine the texture coordinates for every other pixel.
====<span style="display:none;">0x26 - Sync_Load ====
 
The screen coordinates are subpixel precise, integer values correspond to single pixels. In COPY and FILL mode the fractional bits are ignored and the lower-right bounds are inclusive, while in 1-Cycle and 2-Cycle modes the lower-right bounds are exclusive.
 
In COPY mode, since several pixels are written per cycle the '''dsdx''' parameter must account for this. It should be set such that it steps 64-bits worth of texels at a time, for example for a 16-bit color image it should be set to 4.0(s10.5) so that the s coordinate is incremented by 4 pixels (64 bits).
 
In FILL mode this behaves identically to '''Fill Rectangle''', the texturing properties are ignored.
 
Internally, this command is equivalent to a left-major triangle where <code>dxhdy = dxmdy = dxldy = 0, yl = ym = lry, yh = uly, xl = xm = lrx, xh = ulx</code>
 
'''Hazards'''
* In 1-Cycle and 2-Cycle mode using attributes such as shade color and per-pixel depth may be ill-defined. (TOVERIFY: It's either always 0 or uses the last value from previous primitives, check which)
 
=== 0x26 - Sync Load ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Sync_LoadSync Load <code>0x26</code>
|-
| 63:48 || — || — || colspan=6| command = 0x26[5:0] || — || — || — || — || — || — || — || —
Line 56 ⟶ 481:
}}
 
Stalls the RDP pipeline for exactly 25 GCLK cycles. This guarantees that the loading pipeline will be available for use following any prior operation.
====<span style="display:none;">0x27 - Sync_Pipe ====
 
The stall is always 25 cycles and does not wait on any particular internal signal(s), if a Sync Load is queued when it is not needed it simply wastes the full length of time.
 
=== 0x27 - Sync Pipe ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Sync_PipeSync Pipe <code>0x27</code>
|-
| 63:48 || — || — || colspan=6| command = 0x27[5:0] || — || — || — || — || — || — || — || —
Line 73 ⟶ 502:
}}
 
Stalls the RDP pipeline for exactly 50 GCLK cycles. This guarantees that any preceding primitives will be fully rendered and it is safe to modify rendering attributes such as color registers, othermodes and combine mode.
====<span style="display:none;">0x28 - Sync_Tile ====
 
The stall is always 50 cycles and does not wait on any particular internal signal(s), if a Sync Pipe is queued when it is not needed it simply wastes the full length of time.
 
(TOVERIFY/Speculation: Changing an attribute without a sync typically corrupts only up to at most 24 pixels of the last primitive, suggesting the RDP pixel pipeline is ~24 cycles deep. Can a tile sync account for all or at least almost all attribute changes?)
 
=== 0x28 - Sync Tile ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Sync_TileSync Tile <code>0x28</code>
|-
| 63:48 || — || — || colspan=6| command = 0x28[5:0] || — || — || — || — || — || — || — || —
Line 90 ⟶ 525:
}}
 
Stalls the RDP pipeline for exactly 33 GCLK cycles. This guarantees that any preceding primitives will have finished using tile information and that it is now safe to modify tile descriptors without affecting prior primitives.
====<span style="display:none;">0x29 - Sync_Full ====
 
The stall is always 33 cycles and does not wait on any particular internal signal(s), if a Sync Tile is queued when it is not needed it simply wastes the full length of time.
 
=== 0x29 - Sync Full ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Sync_FullSync Full <code>0x29</code>
|-
| 63:48 || — || — || colspan=6| command = 0x29[5:0] || — || — || — || — || — || — || — || —
Line 107 ⟶ 546:
}}
 
Waits for all currently staged pipeline and memory operations to complete before halting the RDP pipeline counter and raising the DP interrupt in the [[MIPS Interface]].
====<span style="display:none;">0x2a - Set_Key_GB ====
 
'''Hazards'''
* Ensure this is the final command consumed before hitting DP_END, otherwise the RDP may hang.
* Ensure no other commands are sent to RDP (via DP_START/DP_END) while a Sync Full is in progress, otherwise the RDP may hang.
 
=== 0x2A - Set Key GB ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Key_GBSet Key GB <code>0x2a</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2a[5:0] || colspan=8| key.g.widthwidth_G[11:4]
|-
| 47:32 || colspan=4| key.g.widthwidth_G[3:0] || colspan=12| key.b.widthwidth_B[11:0]
|-
| 31:16 || colspan=8| key.g.centercenter_G[7:0] || colspan=8| key.g.scalescale_G[7:0]
|-
| 15:0 || colspan=8| key.b.centercenter_B[7:0] || colspan=8| key.b.scalescale_B[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2a
| 55:44 | key.g.widthwidth_G[11:0] | Keying window half-width for green channel (4.8 format)
| 43:32 | key.b.widthwidth_B[11:0] | Keying window half-width for blue channel (4.8 format)
| 31:24 | key.g.centercenter_G[7:0] | -Center Color Combiner input for green channel
| 23:16 | key.g.scalescale_G[7:0] | -Scale Color Combiner input for green channel
| 15:8 | key.b.centercenter_B[7:0] | -Center Color Combiner input for blue channel
| 7:0 | key.b.scalescale_B[7:0] | -Scale Color Combiner input for blue channel
}}
 
Sets chroma Key parameters for the green and blue color channels.
====<span style="display:none;">0x2b - Set_Key_R ====
 
Key width is used exclusively in the chroma key pipeline stage following the Color Combiner (if enabled in othermodes)
 
<math>\mathrm{key\_alpha} = \mathrm{clamp}(-\mathrm{abs}(\mathrm{Combined}) + \mathrm{Width}, 0.0, 1.0)</math>
 
Key center and scale are Color Combiner inputs, the expectation is that the Color Combiner is configured to <math>(X - \mathrm{Center}) \cdot \mathrm{Scale}</math> when chroma keying, where <math>X</math> is any color source. If not chroma keying, these may be used as general-purpose Color Combiner inputs.
 
=== 0x2B - Set Key R ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Key_RSet Key R <code>0x2b</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2b[5:0] || — || — || — || — || — || — || — || —
Line 139 ⟶ 592:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || — || — || — || — || colspan=12| key.r.widthwidth_R[11:0]
|-
| 15:0 || colspan=8| key.r.centercenter_R[7:0] || colspan=8| key.r.scalescale_R[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2b
| 27:16 | key.r.widthwidth_R[11:0] | Keying window half-width for red channel (4.8 format)
| 15:8 | key.r.centercenter_R[7:0] | -Center Color Combiner input for red channel
| 7:0 | key.r.scalescale_R[7:0] | -Scale Color Combiner input for red channel
}}
 
Sets Chroma Key parameters for the red color channel. See '''Set Key GB''' for discussion.
====<span style="display:none;">0x2c - Set_Convert ====
 
=== 0x2C - Set Convert ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_ConvertSet Convert <code>0x2c</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2c[5:0] || — || — || colspan=6| convert.k[0]K0[8:3]
|-
| 47:32 || colspan=3| convert.k[0]K0[2:0] || colspan=9| convert.k[1]K1[8:0] || colspan=4| convert.k[2]K2[8:5]
|-
| 31:16 || colspan=5| convert.k[2]K2[4:0] || colspan=9| convert.k[3]K3[8:0] || colspan=2| convert.k[4]K4[8:7]
|-
| 15:0 || colspan=7| convert.k[4]K4[6:0] || — || colspan=89| convert.kK5[5][78:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2c
| 53:45 | convert.k[0]K0[8:0] | -Color conversion constant K0
| 44:36 | convert.k[1]K1[8:0] | -Color conversion constant K1
| 35:27 | convert.k[2]K2[8:0] | -Color conversion constant K2
| 26:18 | convert.k[3]K3[8:0] | -Color conversion constant K3
| 17:9 | convert.k[4]K4[8:0] | -Color conversion constant K4
| 78:0 | convert.kK5[5][78:0] | -Color conversion constant K5
}}
 
Sets colorspace conversion coefficients intended for YUV -> RGB conversion.
====<span style="display:none;">0x2d - Set_Scissor ====
 
K0 through K3 are used in the Texture Filter color conversion step:
 
<math>
\begin{pmatrix}
R \\
G \\
B \\
A \\
\end{pmatrix}
=
\begin{pmatrix}
1 & 0 & K_0 \\
1 & K_1 & K_2 \\
1 & K_3 & 0 \\
1 & 0 & 0 \\
\end{pmatrix}
\begin{pmatrix}
Y \\
U \\
V \\
\end{pmatrix}
</math>
 
K4 and K5 are made available as Color Combiner inputs, with the intention that the CC complete the colorspace conversion process after receiving values from the Texture Filter.
 
K4 and K5 may also simply be used as additional general-purpose CC inputs.
 
=== 0x2D - Set Scissor ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_ScissorSet Scissor <code>0x2d</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2d[5:0] || colspan=8| scissorupper_left.x.hi[11:4]
|-
| 47:32 || colspan=4| scissorupper_left.x.hi[3:0] || colspan=12| scissorupper_left.y.hi[11:0]
|-
| 31:16 || — || — || — || — || — || — || scissor.field || scissor.odd || colspan=8| scissorlower_right.x.lo[11:4]
|-
| 15:0 || colspan=4| scissor.x.lo[3:0] || colspan=12| scissorlower_right.y.lo[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2d
| 55:44 | scissorupper_left.x.hi[11:0] | -Upper left x coordinate (u10.2 format)
| 43:32 | scissorupper_left.y.hi[11:0] | -Upper left y coordinate (u10.2 format)
| 25 | field | Whether to perform interlaced rendering, only even or odd lines will be processed
| 25 | scissor.field | ?
| 24 | odd | Whether to keep even (0) or odd (1) lines when interlaced rendering is enabled
| 24 | scissor.odd | ?
| 23:12 | scissorlower_right.x.lo[11:0] | -Lower right x coordinate (u10.2 format)
| 11:0 | scissorlower_right.y.lo[11:0] | -Lower right y coordinate (u10.2 format)
}}
 
Sets the scissor region, pixels that are outside of this region will not be processed in the pixel pipeline and will not be written to memory. Note that only the scissor determines this, the color image width has no effect. Typically the scissor width should not be larger than the color image width.
====<span style="display:none;">0x2e - Set_Primitive_Depth ====
 
The RDP is capable of efficiently rejecting pixels that lie outside the left, right and lower scissor boundaries at no cost in time. The same cannot be said of pixels lying above the scissor region: for every line for which a primitive extends above the scissor region the RDP spends one cycle advancing each line, since it must update the attribute start values for each line.
 
'''Hazards'''
* The scissor region is '''inclusive''' on the lower-right edges in FILL and COPY modes, while it is '''exclusive''' on the lower-right edges in 1-Cycle and 2-Cycle modes.
* The scissor region must be configured before rendering anything. There is no way to disable the scissor, if it is not configured it will use whatever configuration was last in the registers.
* In COPY mode, upper_left.x should be 0 (TOVERIFY Is this always true? It appears to be an unavoidable crash, but needs further investigation)
* In COPY mode, lower_right.x should be a multiple of 4 pixels (-1) to prevent possible memory corruption
* In FILL mode, upper_left.x and lower_right.x should be multiples of 4 pixels (-1 for lower_right.x) to prevent possible memory corruption
* FILL mode triangles interact bizarrely with the scissor bounds, avoid drawing such triangles that extend off-screen (TODO understand this better)
* In FILL mode sometimes scissor works at the level of individual pixels while sometimes it only works at 4-pixel boundaries. (TODO understand this better, probably to do with memory alignment)
 
=== 0x2E - Set Primitive Depth ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Primitive_DepthSet Primitive Depth <code>0x2e</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2e[5:0] || — || — || — || — || — || — || — || —
Line 205 ⟶ 702:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || colspan=16| primitiveDepth.z[15:0]
|-
| 15:0 || colspan=16| primitiveDepth.deltaZdz[15:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2e
| 31:16 | primitiveDepth.z[15:0] | -Primitive depth value
| 15:0 | primitiveDepth.deltaZdz[15:0] | -Primitive dz value
}}
 
Sets the primitive depth registers to the provided values. Primitive depth may be selected for depth compare instead of using per-pixel depth in the othermodes configuration. This is the only way to set a depth value for rectangle commands.
====<span style="display:none;">0x2f - Set_Other_Modes ====
 
When used, the primitive depth value is taken to be the integer part of the s15.3 fixed-point z value, the fractional bits will be zero. Notably, due to not having control over the fractional bits it is impossible to configure a primitive depth value that writes the maximum possible depth value into the z-buffer.
 
Unlike the majority of other attribute-setters, primitive depth operates correctly even in the absence of pipeline synchronizations. Primitive depth may be changed between primitive rendering without corrupting prior primitives.
 
'''Hazards'''
* The dz value provided should be a power of 2 to ensure correct operation. RDP hardware uses a cheap integer log2 algorithm for computing log2(dz) that is only guaranteed to produce correct results when the input is a power of 2. Notably, the value 0xFFFF happens to work correctly.
 
=== 0x2F - Set Other Modes ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Other_ModesSet Other Modes <code>0x2f</code>
|-
| 63:48 || — || — || colspan=6| command = 0x2f[5:0] || other.atomicPrimitiveatomic_prim || other.reserved1- || colspan=2| other.cycleTypecycle_type[1:0] || other.perspectivepersp_tex_en || other.detailTexturedetail_tex_en || other.sharpenTexturesharpen_tex_en || other.lodTexturetex_lod_en
|-
| 47:32 || other.tluttlut_en || other.tlutTypetlut_type || other.sampleTypesample_type || other.midTexelmid_texel || other.bilerp[0]bi_lerp_0 || other.bilerp[1]bi_lerp_1 || other.convertOneconvert_one || other.colorKeykey_en || colspan=2| other.colorDitherModergb_dither_sel[1:0] || colspan=2| other.alphaDitherModealpha_dither_sel[1:0] || colspan=4| other.reserved2[3:0]-
|-
| 31:16 || colspan=2| other.blend1a[0]bl_m1a_0[1:0] || colspan=2| other.blend1a[1]bl_m1a_1[1:0] || colspan=2| other.blend1b[0]bl_m1b_0[1:0] || colspan=2| other.blend1b[1]bl_m1b_1[1:0] || colspan=2| other.blend2a[0]bl_m2a_0[1:0] || colspan=2| other.blend2a[1]bl_m2a_1[1:0] || colspan=2| other.blend2b[0]bl_m2b_0[1:0] || colspan=2| other.blend2b[1]bl_m2b_1[1:0]
|-
| 15:0 || other.reserved3- || other.forceBlendforce_blend || other.alphaCoveragealpha_cvg_select || other.coverageXalphacvg_x_alpha || colspan=2| other.zModez_mode[1:0] || colspan=2| other.coverageModecvg_dest[1:0] || other.colorOnCoveragecolor_on_cvg || other.imageReadimage_read_en || other.zUpdatez_update_en || other.zComparez_compare_en || other.antialiasantialias_en || other.zSourcez_source_sel || other.ditherAlphadither_alpha_en || other.alphaComparealpha_compare_en
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x2f
| 55 | atomic_prim | Enables span buffer coherency, forces active span segments to be written to the frame buffer before reading new span segments
| 55 | other.atomicPrimitive | ?
| 54 | other.reserved1- | ?
| 53:52 | cycle_type[1:0] | Determines pipeline mode. Either 1-Cycle (0), 2-Cycle (1), COPY (2), FILL (3)
| 53:52 | other.cycleType[1:0] | -
| 51 | persp_tex_en | Enables perspective correction of texture coordinates
| 51 | other.perspective | ?
| 50 | detail_tex_en | Enables "detail texture" mode in Texture LOD
| 50 | other.detailTexture | ?
| 49 | sharpen_tex_en | Enables "sharpen texture" mode in Texture LOD
| 49 | other.sharpenTexture | ?
| 48 | tex_lod_en | Enables Texture Level of Detail (LOD)
| 48 | other.lodTexture | ?
| 47 | tlut_en | Enables Texture Look-Up Table (TLUT) sampling. Texels are first fetched from low TMEM that are then used to index a palette in high TMEM to find the final color values.
| 47 | other.tlut | ?
| 46 | tlut_type | Determines TLUT texel format. Either RGBA16 (0) or IA16 (1)
| 46 | other.tlutType | ?
| 45 | sample_type | Determines texel sampling mode. Either point-sampled (0) or 2x2 bilinear (1)
| 45 | other.sampleType | ?
| 44 | mid_texel | Determines bilinear filter mode. Either 3-point (0) or average mode (1)
| 44 | other.midTexel | ?
| 43 | bi_lerp_0 | Determines texture filter mode for the first cycle. Either YUV to RGB conversion (See '''Set Convert''') (0) or bilinear filter (1)
| 43 | other.bilerp[0] | ?
| 42 | bi_lerp_1 | Determines texture filter mode for the second cycle. Either YUV to RGB conversion (See '''Set Convert''') (0) or bilinear filter (1)
| 42 | other.bilerp[1] | ?
| 41 | convert_one | Determines the input to the second texture filter stage. Either the sample from the second stage of texture sampling (0) or the result from the first texture filter cycle (1)
| 41 | other.convertOne | ?
| 40 | key_en | Enables chroma keying following the Color Combiner stage
| 40 | other.colorKey | ?
| 39:38 | other.colorDitherModergb_dither_sel[1:0] | -Set RGB dither mode
| 37:36 | other.alphaDitherModealpha_dither_sel[1:0] | -Set Alpha dither mode
| 35:32 | other.reserved2[3:0]- | -?
| 31:30 | other.blend1a[0]bl_m1a_0[1:0] | -Blender input P (first cycle)
| 29:28 | other.blend1a[1]bl_m1a_1[1:0] | -Blender input P (second cycle)
| 27:26 | other.blend1b[0]bl_m1b_0[1:0] | -Blender input A (first cycle)
| 25:24 | other.blend1b[1]bl_m1b_1[1:0] | -Blender input A (second cycle)
| 23:22 | other.blend2a[0]bl_m2a_0[1:0] | -Blender input M (first cycle)
| 21:20 | other.blend2a[1]bl_m2a_1[1:0] | -Blender input M (second cycle)
| 19:18 | other.blend2b[0]bl_m2b_0[1:0] | -Blender input B (first cycle)
| 17:16 | other.blend2b[1]bl_m2b_1[1:0] | -Blender input B (second cycle)
| 15 | other.reserved3- | ?
| 14 | force_blend | Enables blending for all pixels rather than only edge pixels
| 14 | other.forceBlend | ?
| 13 | alpha_cvg_select | Use coverage (or coverage multiplied by CC alpha) for alpha input to blender rather than alpha output from CC
| 13 | other.alphaCoverage | ?
| 12 | cvg_x_alpha | Multiply coverage and alpha from CC (used in conjunction with alpha_cvg_sel)
| 12 | other.coverageXalpha | ?
| 11:10 | other.zModez_mode[1:0] | Determines z-buffer comparator mode
| 9:8 | other.coverageModecvg_dest[1:0] | -Determines coverage output mode
| 7 | color_on_cvg | If enabled, writes the blender output only if coverage overflowed, otherwise write the 2B input verbatim
| 7 | other.colorOnCoverage | ?
| 6 | image_read_en | Enable color image reading
| 6 | other.imageRead | ?
| 5 | z_update_en | Enable z-buffer writing
| 5 | other.zUpdate | ?
| 4 | z_compare_en | Enable z-buffer reading and depth comparison
| 4 | other.zCompare | ?
| 3 | antialias_en | Enable anti-aliasing, which may enable blending on edge pixels
| 3 | other.antialias | ?
| 2 | z_source_sel | Selects either per-pixel (0) or primitive (1) depth as depth source to compare against the z-buffer
| 2 | other.zSource | ?
| 1 | dither_alpha_en | Determines alpha compare threshold source. (0 blend color register alpha, 1 random)
| 1 | other.ditherAlpha | ?
| 0 | alpha_compare_en | Enables alpha compare, pixels below the alpha threshold (compared against CC alpha output) are not written
| 0 | other.alphaCompare | ?
}}
 
Configures the RDP "Other Modes", a collection of global settings.
====<span style="display:none;">0x30 - Load_Texture_LUT ====
 
----
'''RGB dither modes'''
{| class="wikitable" style="text-align: center; white-space:nowrap;"
 
! colspan="17"|Load_Texture_LUT <code>0x30</code>
{| class="wikitable"
! Value !! Description
|-
| 0 || 4x4 Magic Square dither matrix
| 63:48 || — || — || colspan=6| command = 0x30[5:0] || colspan=8| tlut.s.lo[11:4]
|-
| 1 || 4x4 Bayer dither matrix
| 47:32 || colspan=4| tlut.s.lo[3:0] || colspan=12| tlut.t.lo[11:0]
|-
| 2 || Random noise
| 31:16 || — || — || — || — || — || colspan=3| tlut.index[2:0] || colspan=8| tlut.s.hi[11:4]
|-
| 3 || Disabled, no dithering applied
| 15:0 || colspan=4| tlut.s.hi[3:0] || colspan=12| tlut.t.hi[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x30
| 55:44 | tlut.s.lo[11:0] | -
| 43:32 | tlut.t.lo[11:0] | -
| 26:24 | tlut.index[2:0] | -
| 23:12 | tlut.s.hi[11:0] | -
| 11:0 | tlut.t.hi[11:0] | -
}}
 
'''Alpha dither modes'''
====<span style="display:none;">0x31 - Invalid_31 ====
 
{| class="wikitable"
! Value !! Description
|-
| 0 || Same pattern as chosen in RGB. If noise was chosen, use magic square. If RGB dither was disabled, use bayer.
|-
| 1 || Inverse of the same pattern as chosen in RGB. Same rules as above if RGB was noise or disabled.
|-
| 2 || Random noise
|-
| 3 || Disabled, no dithering applied
|}
 
'''Z modes'''
 
{| class="wikitable"
! Value !! Description
|-
| 0 || Opaque surface mode.
|-
| 1 || Interpenetrating surface mode.
|-
| 2 || Transparent surface mode.
|-
| 3 || Decal surface mode.
|}
 
'''Coverage destination modes'''
 
{| class="wikitable"
! Value !! Description
|-
| 0 || Clamp. Sums new and old coverage, clamps to full if there is an overflow.
|-
| 1 || Wrap. Sums new and old coverage, writes this sum modulo 8.
|-
| 2 || Full. Always write full coverage.
|-
| 3 || Save. Always write old coverage, discard new coverage. Requires image_read_en, otherwise it will behave like Full.
|}
 
'''Blender Configuration'''
 
Other modes include the blender input configuration. The blender computes either
 
<math>p \cdot a + m \cdot b</math>
 
or
 
<math>\frac{p \cdot a + m \cdot b}{a + b}</math>
 
The latter is performed only when force_blend is disabled and anti-aliasing is enabled, where it is performed only on edge pixels.
 
'''Blender P and M Inputs'''
 
{| class="wikitable"
! Value !! Description
|-
| 0 || First cycle: output color from Color Combiner final stage; Second cycle: output color from first blender cycle
|-
| 1 || Memory color from framebuffer
|-
| 2 || Blend color register RGB
|-
| 3 || Fog color register RGB
|}
 
'''Blender A Inputs'''
 
{| class="wikitable"
! Value !! Description
|-
| 0 || Output alpha from Color Combiner final stage
|-
| 1 || Fog color register Alpha
|-
| 2 || Shade Alpha (interpolated per-pixel)
|-
| 3 || Fixed 0.0
|}
 
'''Blender B Inputs'''
 
{| class="wikitable"
! Value !! Description
|-
| 0 || 1.0 - A, where A is the other alpha input
|-
| 1 || Memory coverage from framebuffer
|-
| 2 || Fixed 1.0
|-
| 3 || Fixed 0.0
|}
 
'''Hazards'''
* This is a pipeline configuration command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old other modes configuration and the new other modes configuration.
* Alpha compare in COPY mode targeting 16-bit framebuffers is only valid for RGBA5551 textures, it only considers the least-significant bit in the sampled texel for determining whether to write it.
* Blender hazards:
** If memory color was set as a blender input, image_read_en should be enabled for proper operation.
** If memory coverage was set as a blender input, image_read_en should be enabled for proper operation. If it is left disabled, memory coverage is set to full.
** 2-Cycle mode pipeline bug: In the first cycle of 2-cycle mode, memory color is read from the previous pixel.
** 2-Cycle mode pipeline bug: In the first cycle of 2-cycle mode, memory coverage is read from the previous pixel.
** 2-Cycle mode pipeline bug: In the second cycle of 2-cycle mode, shade alpha is read from the next pixel.
 
=== 0x30 - Load TLUT ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Invalid_31Load TLUT <code>0x310x30</code>
|-
| 63:48 || — || — || colspan=6| command = 0x310x34[5:0] || — |colspan=8| — || — || — || — || — || — || —upper_left.s[11:4]
|-
| 47:32 || colspan=4| upper_left.s[3:0] || colspan=12| upper_left.t[11:0]
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || — || — || — || — || — || — |colspan=3| tile[2:0] || — || — || — || — || — || — || — || — |colspan=8| lower_right.s[11:4]
|-
| 15:0 || colspan=4| lower_right.s[3:0] || colspan=12| lower_right.t[11:0]
| 15:0 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x310x30
| 55:44 | upper_left.s[11:0] | Upper-left s coordinate (u10.2)
| 43:32 | upper_left.t[11:0] | Upper-left t coordinate (u10.2)
| 26:24 | tile[2:0] | Tile descriptor index
| 23:12 | lower_right.s[11:0] | Lower-right s coordinate (u10.2)
| 11:0 | lower_right.t[11:0] | Lower-right t coordinate (u10.2)
}}
 
Loads a Texture Look-Up Table (TLUT) into TMEM.
====<span style="display:none;">0x32 - Set_Tile_Size ====
 
When loading with Load TLUT, every texel loaded from RDRAM is quadrupled and placed adjacently in TMEM. A 256-color TLUT therefore takes up <math>\mathrm{256} \times \mathrm{2} \times \mathrm{4} = \mathrm{0x800}</math> bytes of TMEM, which is the maximum size of a TLUT as it must fit in high TMEM. A 16-color TLUT takes up only <math>\mathrm{16} \times \mathrm{2} \times \mathrm{4} = \mathrm{0x80}</math> bytes of TMEM, 16 of these may reside in high TMEM at the same time.
 
Typical usage of Load TLUT may resemble <code>(uls=0, ult=0, lrs=count-1, lrt=0)</code> where <code>count</code> is the number of texels making up the TLUT, e.g. 255 for a 256-color palette.
 
'''Hazards'''
* For correct sampling, the base TMEM address for a TLUT must reside in the upper half of TMEM, that is at TMEM word address 0x100 (byte address 0x800) or greater.
* For correct sampling, the base TMEM address for a TLUT must be aligned to 16 TMEM words or 128 bytes.
 
=== 0x32 - Set Tile Size ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Tile_SizeSet Tile Size <code>0x32</code>
|-
| 63:48 || — || — || colspan=6| command = 0x32[5:0] || colspan=8| tileSizeupper_left.s.lo[11:4]
|-
| 47:32 || colspan=4| tileSizeupper_left.s.lo[3:0] || colspan=12| tileSizeupper_left.t.lo[11:0]
|-
| 31:16 || — || — || — || — || — || colspan=3| tileSize.index[2:0] || colspan=8| tileSizelower_right.s.hi[11:4]
|-
| 15:0 || colspan=4| tileSizelower_right.s.hi[3:0] || colspan=12| tileSizelower_right.t.hi[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x32
| 55:44 | tileSizeupper_left.s.lo[11:0] | Upper-left s coordinate (u10.2 format)
| 43:32 | tileSizeupper_left.t.lo[11:0] | Upper-left t coordinate (u10.2 format)
| 26:24 | tileSize.index[2:0] | -Tile descriptor index
| 23:12 | tileSizelower_right.s.hi[11:0] | Lower-right s coordinate (u10.2 format)
| 11:0 | tileSizelower_right.t.hi[11:0] | Lower-right t coordinate (u10.2 format)
}}
 
Updates the tile extents for the tile descriptor specified by the index parameter.
====<span style="display:none;">0x33 - Load_Block ====
 
The upper-left coordinate specifies the origin of the tile, where texture coordinates (0,0) would sample from, and sets the lower extents for clamp/mask/mirror in texture sampling.
 
The lower-right coordinate specifies the upper extents for clamp/mask/mirror in texture sampling.
 
=== 0x33 - Load Block ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Load_BlockLoad Block <code>0x33</code>
|-
| 63:48 || — || — || colspan=6| command = 0x33[5:0] || colspan=8| load_.blockupper_left.s.lo[11:4]
|-
| 47:32 || colspan=4| load_.blockupper_left.s.lo[3:0] || colspan=12| load_.blockupper_left.t.lo[11:0]
|-
| 31:16 || — || — || — || — || — || colspan=3| load_.block.indextile[2:0] || colspan=8| load_.blocklower_right.s.hi[11:4]
|-
| 15:0 || colspan=4| load_.blocklower_right.s.hi[3:0] || colspan=12| load_.block.t.hidxt[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x33
| 55:44 | load_.blockupper_left.s.lo[11:0] | Upper-left s coordinate (u10.2)
| 43:32 | load_.blockupper_left.t.lo[11:0] | Upper-left t coordinate (u10.2)
| 26:24 | load_.block.indextile[2:0] | -Tile descriptor index
| 23:12 | load_.blocklower_right.s.hi[11:0] | Lower-right s coordinate (u10.2)
| 11:0 | load_.block.t.hidxt[11:0] | -Change in x per t (u1.11)
}}
 
Load Block loads texels to the TMEM address specified by the selected tile descriptor from the RDRAM location pointed to by the current texture image (see '''Set Texture Image''').
====<span style="display:none;">0x34 - Load_Tile ====
 
Only 2048 texels of any size can be loaded at once, loads configured to read more than 2048 texels will fail resulting in nothing being written into TMEM. For 4 and 8 bit types the texture image texel size can be set to 16-bit to facilitate loading more than 2048 texels, it is not possible to use the 32-bit texel size in this way without advance preparation as 32-bit texels have a different TMEM layout. <code>lower_right.s - upper_left.s</code> determines the number of texels to load.
 
Load Block is the fastest way to move data from RDRAM into TMEM, however not all width/height combinations are valid. Texture lines loaded with Load Block must be a multiple of 64 bits in size, either naturally or by explicitly padding each line in RDRAM. Further, for a given width there is a maximum height based on imprecision in the dxt value. For each 64-bit TMEM word loaded with Load Block, an internal counter is incremented by dxt. This counter can be thought of as a 1.11 fixed-point value; when the counter holds a value greater than one the current word being loaded belongs to an odd-numbered line, otherwise it belongs to an even-numbered line. For texture sampling reasons odd lines must have their 32-bit words swapped when loaded from RDRAM, this is done automatically by the loading hardware hence why it tracks which lines are even or odd. However if dxt is sufficiently imprecise the counter may miss a word at the end of a line, leading to corruptions as that word will not be swapped correctly.
 
'''Hazards'''
* Some texture image addresses may hang the RDP if an attempt is made to load from it. See '''Set Texture Image''' hazards.
* Load Block sets the tile size for the associated tile descriptor to (upper_left.s, upper_left.t, lower_right.s, dxt). This is generally not a useful configuration for rendering the image.
 
=== 0x34 - Load Tile ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Load_TileLoad Tile <code>0x34</code>
|-
| 63:48 || — || — || colspan=6| command = 0x34[5:0] || colspan=8| load_.tileupper_left.s.lo[11:4]
|-
| 47:32 || colspan=4| load_.tileupper_left.s.lo[3:0] || colspan=12| load_.tileupper_left.t.lo[11:0]
|-
| 31:16 || — || — || — || — || — || colspan=3| load_.tile.index[2:0] || colspan=8| load_.tilelower_right.s.hi[11:4]
|-
| 15:0 || colspan=4| load_.tilelower_right.s.hi[3:0] || colspan=12| load_.tilelower_right.t.hi[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x34
| 55:44 | load_.tileupper_left.s.lo[11:0] | Upper-left s coordinate (u10.2)
| 43:32 | load_.tileupper_left.t.lo[11:0] | Upper-left t coordinate (u10.2)
| 26:24 | load_.tile.index[2:0] | -Tile descriptor index
| 23:12 | load_.tilelower_right.s.hi[11:0] | Lower-right s coordinate (u10.2)
| 11:0 | load_.tilelower_right.t.hi[11:0] | Lower-right t coordinate (u10.2)
}}
 
Load Tile loads an arbitrary rectangle of texels to the TMEM address specified by the selected tile descriptor from the RDRAM location pointed to by the current texture image (see '''Set Texture Image'''). The rectangle in RDRAM to load from is specified by the provided upper_left and lower_right coordinates and the line parameter in the tile descriptor, the RDRAM width is <code>lower_right.s - upper_left.s</code> while the TMEM width is the tile line parameter. The upper_left location in RDRAM is mapped to the tile TMEM address.
====<span style="display:none;">0x35 - Set_Tile ====
 
Load Tile is slower than Load Block, however it is more flexible as there is no need to explicitly pad texture lines in RDRAM to 8-byte boundaries, and there are no issues with word-swapping.
 
Load Tile updates the tile size for the selected tile descriptor to <code>(upper_left.s, upper_left.t, lower_right.s, lower_right.t)</code> which may be used for subsequent rendering.
 
'''Hazards'''
* The texel size specified in Set Texture Image should match the texel size in the tile descriptor used for loading, otherwise operation is not guaranteed.
* Loads that extend past the end of TMEM will wrap back to the start.
 
=== 0x35 - Set Tile ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_TileSet Tile <code>0x35</code>
|-
| 63:48 || — || — || colspan=6| command = 0x35[5:0] || colspan=3| tile.format[2:0] || colspan=2| tile.size[1:0] || — || colspan=2| tile.line[8:7]
|-
| 47:32 || colspan=7| tile.line[6:0] || colspan=9| tile.address[8:0]
|-
| 31:16 || — || — || — || — || — || colspan=3| tile.index[2:0] || colspan=4| tile.palette[3:0] || tile.t.clampclamp_T || tile.t.mirrormirror_T || colspan=2| tile.t.maskmask_T[3:2]
|-
| 15:0 || colspan=2| tile.t.maskmask_T[1:0] || colspan=4| tile.t.shiftshift_T[3:0] || tile.s.clampclamp_S || tile.s.mirrormirror_S || colspan=4| tile.s.maskmask_S[3:0] || colspan=4| tile.s.shiftshift_S[3:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x35
| 55:53 | tile.format[2:0] | -Tile texel format
| 52:51 | tile.size[1:0] | -Tile texel size
| 49:41 | tile.line[8:0] | -Tile line length in TMEM words
| 40:32 | tile.address[8:0] | -TMEM address in TMEM words
| 26:24 | tile.index[2:0] | -Tile index
| 23:20 | tile.palette[3:0] | -Palette index
| 19 | tile.t.clampclamp_T | ?Clamp enable (T-axis)
| 18 | tile.t.mirrormirror_T | ?Mirror enable (T-axis)
| 17:14 | tile.t.maskmask_T[3:0] | Mask (T-axis)
| 13:10 | tile.t.shiftshift_T[3:0] | Shift (T-axis)
| 9 | tile.s.clampclamp_S | ?Clamp enable (S-axis)
| 8 | tile.s.mirrormirror_S | ?Mirror enable (S-axis)
| 7:4 | tile.s.maskmask_S[3:0] | Mask (S-axis)
| 3:0 | tile.s.shiftshift_S[3:0] | Shift (S-axis)
}}
 
Configures the tile descriptor specified by the index parameter.
====<span style="display:none;">0x36 - Fill_Rectangle ====
 
The texel '''format''' parameter is selected from
{| class="wikitable"
! Format Name !! Format Value
|-
| RGBA || 0
|-
| YUV || 1
|-
| Color-Indexed (CI) || 2
|-
| Intensity-Alpha (IA) || 3
|-
| Intensity (I) || 4+
|}
 
The texel '''size''' parameter is selected from
{| class="wikitable"
! Bits per pixel !! Size Value
|-
| 4 || 0
|-
| 8 || 1
|-
| 16 || 2
|-
| 32 || 3
|}
 
Officially supported format/size combinations
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! !! RGBA !! YUV !!CI !! IA !! I
|-
| '''4''' || - || - || {{tick|color=black}} || {{tick|color=black}} || {{tick|color=black}}
|-
| '''8''' || - || - || {{tick|color=black}} || {{tick|color=black}} || {{tick|color=black}}
|-
| '''16''' || {{tick|color=black}} || {{tick|color=black}} || - || {{tick|color=black}} || -
|-
| '''32''' || {{tick|color=black}} || - || - || - || -
|}
 
The '''line''' parameter indicates the number of TMEM (64-bit) words in a single row of the tile. This quantity is typically calculated from the tile width in texels and texel size as <code>(width * NBITS(size) + 63) / 64</code> where <code>NBITS(size)</code> is the number of bits per texel. If a texture width is not an integral number of TMEM words, each row must be padded to begin on a new TMEM word; Load Tile performs this padding transparently when loading texture data from RDRAM into TMEM, for Load Block the data must already be padded in RDRAM.
 
The '''address''' is a TMEM word (64-bit) address. For example an address of 0x100 resolves to byte address 0x800, half way through TMEM.
 
The '''palette''' parameter is for CI4 formatted tiles, for CI formats of other sizes it is ignored altogether. It is the upper half of a TMEM address, indicating where the tile can find the associated color palette. The lower half of the TMEM address is populated by the color index in the CI4 texture data.
 
The '''clamp/mirror/mask/shift''' parameters for each texture coordinate axis influence how texels are sampled from the tile during texture sampling. (TODO link texture sampling article)
* '''clamp''': Enables clamping. When the tile is sampled with coordinates that fall outside the tile boundaries, the nearest texel that is within the tile bounds will be used. If disabled, coordinates are brought into the tile range by wrapping based on the mask value, which operates on powers of 2. Therefore, if a tile extent is not a power of 2 clamping should typically be used.
* '''mirror''': Enables mirroring. When oversampling the tile, flip the axis.
* '''mask''': Determines how many bits of the integer part of the texture coordinate should be considered for sampling from this tile. A mask of 0 indicates all bits should be considered.
* '''shift''': Optional shift amount for texture coordinates. Values 1-10 shift right while 11-15 shift left.
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! Shift value !! Operation
|-
| 0 || N/A
|-
| 1 || >> 1
|-
| 2 || >> 2
|-
| colspan=2| ...
|-
| 10 || >> 10
|-
| 11 || << 5
|-
| 12 || << 4
|-
| 13 || << 3
|-
| 14 || << 2
|-
| 15 || << 1
|}
 
=== 0x36 - Fill Rectangle ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Fill_RectangleFill Rectangle <code>0x36</code>
|-
| 63:48 || — || — || colspan=6| command = 0x36[5:0] || colspan=8| fillRectangle_lower_right.x.lo[11:4]
|-
| 47:32 || colspan=4| fillRectangle_lower_right.x.lo[3:0] || colspan=12| fillRectangle_lower_right.y.lo[11:0]
|-
| 31:16 || — || — || — || — || — || — || — || — || colspan=8| fillRectangle_upper_left.x.hi[11:4]
|-
| 15:0 || colspan=4| fillRectangle_upper_left.x.hi[3:0] || colspan=12| fillRectangle_upper_left.y.hi[11:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x36
| 55:44 | fillRectangle_lower_right.x.lo[11:0] | Lower-right x coordinate (u10.2 format)
| 43:32 | fillRectangle_lower_right.y.lo[11:0] | Lower-right y coordinate (u10.2 format)
| 23:12 | fillRectangle_upper_left.x.hi[11:0] | Upper-left x coordinate (u10.2 format)
| 11:0 | fillRectangle_upper_left.y.hi[11:0] | Upper-right y coordinate (u10.2 format)
}}
 
Renders a solid-color rectangle.
====<span style="display:none;">0x37 - Set_Fill_Color ====
 
In FILL and COPY mode, the rectangle coordinates are inclusive on the right and lower edges while in 1-Cycle and 2-Cycle mode they are exclusive.
 
In 1-Cycle or 2-Cycle mode, the rectangle is rendered with subpixel accuracy and can be anti-aliased if pixels are only partially covered. The color is determined by the blender output as with triangles and texture rectangles, not the fill color register.
 
In FILL mode, the rectangle is rendered without subpixel accuracy (upper-left coordinates are rounded down, lower-right coordinates are rounded up) and the color is determined solely by the fill color register.
 
Internally, this command is equivalent to a left-major triangle where <code>dxhdy = dxmdy = dxldy = 0, yl = ym = lry, yh = uly, xl = xm = lrx, xh = ulx</code>
 
'''Hazards'''
* In 1-Cycle and 2-Cycle mode using attributes such as shade color, texture coordinates and per-pixel depth may be ill-defined. (TOVERIFY: It's either always 0 or uses the last value from previous primitives, check which)
* In COPY mode, fill rectangle behaves like texture rectangle with all texture attributes (tile, s, t, dsdx, dtdy) set to 0. (TOVERIFY: as above, is it always 0 or is it left over values from previous primitives?)
 
=== 0x37 - Set Fill Color ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Fill_ColorSet Fill Color <code>0x37</code>
|-
| 63:48 || — || — || colspan=6| command = 0x37[5:0] || — || — || — || — || — || — || — || —
Line 438 ⟶ 1,177:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || colspan=16| set.fill.color[31:16]
|-
| 15:0 || colspan=16| set.fill.color[15:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x37
| 31:0 | set.fill.color[31:0] | -Fill Color. Format varies based on color image pixel size, see below
}}
 
Sets the fill color register, the color to use when rendering primitives in FILL mode. This is the only color sampled by FILL mode as all other pipeline stages are bypassed. This color is not made available to the Color Combiner or the Blender, and Fill Rectangle outside of FILL mode does not use it.
====<span style="display:none;">0x38 - Set_Fog_Color ====
 
Since FILL mode simply repeats the 32-bit value verbatim out to memory, proper usage of the color parameter will depend on the color image configuration:
* 32-bit: A single RGBA32 color occupying all 32 bits.
* 16-bit: Two RGBA16 colors occupying the upper and lower 16 bits respectively. Even pixels sample the upper half and odd pixels sample the lower half. For filling the color image with a solid color, simply let the upper and lower halves hold the same value.
* 8-bit: Four 8-bit intensity values, repeating every four pixels.
* 4-bit: N/A, crash
 
'''Hazards'''
* This is an attribute-setting command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old fill color and the new fill color, if it was used.
 
=== 0x38 - Set Fog Color ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Fog_ColorSet Fog Color <code>0x38</code>
|-
| 63:48 || — || — || colspan=6| command = 0x38[5:0] || — || — || — || — || — || — || — || —
Line 456 ⟶ 1,206:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || colspan=8| fog.red[7:0] || colspan=8| fog.green[7:0]
|-
| 15:0 || colspan=8| fog.blue[7:0] || colspan=8| fog.alpha[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x38
| 31:24 | fog.red[7:0] | -Fog Red Value
| 23:16 | fog.green[7:0] | -Fog Green Value
| 15:8 | fog.blue[7:0] | -Fog Blue Value
| 7:0 | fog.alpha[7:0] | -Fog Alpha Value
}}
 
Sets the "Fog" color register to the provided RGBA value. This color is accessible from the Blender as an input.
====<span style="display:none;">0x39 - Set_Blend_Color ====
 
The name "Fog" reflects only one particular usage of how the color may be used, the name does not relate to any particular meaning in the hardware.
 
'''Hazards'''
* This is an attribute-setting command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old fog color and the new fog color, if it was used.
 
=== 0x39 - Set Blend Color ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Blend_ColorSet Blend Color <code>0x39</code>
|-
| 63:48 || — || — || colspan=6| command = 0x39[5:0] || — || — || — || — || — || — || — || —
Line 477 ⟶ 1,234:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || colspan=8| blend.red[7:0] || colspan=8| blend.green[7:0]
|-
| 15:0 || colspan=8| blend.blue[7:0] || colspan=8| blend.alpha[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x39
| 31:24 | blend.red[7:0] | -Blend Red Value
| 23:16 | blend.green[7:0] | -Blend Green Value
| 15:8 | blend.blue[7:0] | -Blend Blue Value
| 7:0 | blend.alpha[7:0] | -Blend Alpha Value
}}
 
Sets the "Blend" color register to the provided RGBA value. This color is accessible from the Blender as an input.
====<span style="display:none;">0x3a - Set_Primitive_Color ====
 
The name "Blend" reflects only one particular usage of how the color may be used, the name does not relate to any particular meaning in the hardware.
 
'''Hazards'''
* This is an attribute-setting command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old blend color and the new blend color, if it was used.
 
=== 0x3A - Set Primitive Color ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Primitive_ColorSet Primitive Color <code>0x3a</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3a[5:0] || — || — || — || — || — || — || — || —
|-
| 47:32 || — || — || — || — || colspan=48| primitive.minimummin_level[37:0] || colspan=8| primitive.fractionprim_lod_frac[7:0]
|-
| 31:16 || colspan=8| primitive.red[7:0] || colspan=8| primitive.green[7:0]
|-
| 15:0 || colspan=8| primitive.blue[7:0] || colspan=8| primitive.alpha[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3a
| 4347:40 | primitive.minimummin_level[37:0] | -Minimum LOD level
| 39:32 | primitive.fractionprim_lod_frac[7:0] | -Primitive LOD Fraction Color Combiner input
| 31:24 | primitive.red[7:0] | -Primitive Red Value
| 23:16 | primitive.green[7:0] | -Primitive Green Value
| 15:8 | primitive.blue[7:0] | -Primitive Blue Value
| 7:0 | primitive.alpha[7:0] | -Primitive Alpha Value
}}
 
Sets the "Primitive" color register to the provided RGBA value, and some LOD parameters. The color is accessible from the Color Combiner as an input.
====<span style="display:none;">0x3b - Set_Environment_Color ====
 
The name "Primitive" reflects only one particular usage of how the color may be used, the name does not relate to any particular meaning in the hardware.
 
'''prim_lod_frac''' is simply another Color Combiner input, despite the name it is not used by the texture LOD hardware feature. It may be used as a fixed interpolation factor.
 
'''min_level''' is used in the texture LOD hardware, it bounds the LOD tile selection from below. The LOD value selecting a particular tile '''N''' can be computed by
 
<math>L = 32 \cdot 2^{(N - T_{\mathrm{base}})}</math>
 
where '''T<sub>base</sub>''' is the tile number set in the triangle command. For texture rectangles this is tile 0.
 
If the LOD computed for a particular pixel during texture sampling is less than the minimum LOD level, tile 0 is used. Detail and sharpen modes may still apply. (TODO link to more detailed Texture LOD article)
 
Unlike the majority of other attribute-setters, primitive color operates correctly even in the absence of pipeline synchronizations. The primitive color may be changed between primitive rendering without corrupting prior primitives.
 
=== 0x3B - Set Environment Color ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Environment_ColorSet Environment Color <code>0x3b</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3b[5:0] || — || — || — || — || — || — || — || —
Line 521 ⟶ 1,301:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || colspan=8| environment.red[7:0] || colspan=8| environment.green[7:0]
|-
| 15:0 || colspan=8| environment.blue[7:0] || colspan=8| environment.alpha[7:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3b
| 31:24 | environment.red[7:0] | -Environment Red value
| 23:16 | environment.green[7:0] | -Environment Green value
| 15:8 | environment.blue[7:0] | -Environment Blue value
| 7:0 | environment.alpha[7:0] | -Environment Alpha value
}}
 
Sets the "Environment" color register to the provided RGBA value. This color is accessible from the Color Combiner as an input.
====<span style="display:none;">0x3c - Set_Combine_Mode ====
 
The name "Environment" reflects only one particular usage of how the color may be used, the name does not relate to any particular meaning in the hardware.
 
'''Hazards'''
* This is an attribute-setting command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old environment color and the new environment color, if it was used.
 
=== 0x3C - Set Combine Mode ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Combine_ModeSet Combine Mode <code>0x3c</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3c[5:0] || colspan=4| combine.sba.color[0]RGB_A_0[3:0] || colspan=4| combine.mul.color[0]RGB_C_0[4:1]
|-
| 47:32 || combine.mul.colorRGB_C_0[0] || colspan=3| combine.sba.alpha[0]Alpha_A_0[2:0] || colspan=3| combine.mul.alpha[0]Alpha_C_0[2:0] || colspan=4| combine.sba.color[1]RGB_A_1[3:0] || colspan=5| combine.mul.color[1]RGB_C_1[4:0]
|-
| 31:16 || colspan=4| combine.sbb.color[0]RGB_B_0[3:0] || colspan=4| combine.sbb.color[1]RGB_B_1[3:0] || colspan=3| combine.sba.alpha[1]Alpha_A_1[2:0] || colspan=3| combine.mul.alpha[1]Alpha_C_1[2:0] || colspan=2| combine.add.color[0]RGB_D_0[2:1]
|-
| 15:0 || combine.add.colorRGB_D_0[0] || colspan=3| combine.sbb.alpha[0]Alpha_B_0[2:0] || colspan=3| combine.add.alpha[0]Alpha_D_0[2:0] || colspan=3| combine.add.color[1]RGB_D_1[2:0] || colspan=3| combine.sbb.alpha[1]Alpha_B_1[2:0] || colspan=3| combine.add.alpha[1]Alpha_D_1[2:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3c
| 55:52 | combine.sba.color[0]RGB_A_0[3:0] | -RGB A Input (First Cycle)
| 51:47 | combine.mul.color[0]RGB_C_0[4:0] | -RGB C Input (First Cycle)
| 46:44 | combine.sba.alpha[0]Alpha_A_0[2:0] | -Alpha A Input (First Cycle)
| 43:41 | combine.mul.alpha[0]Alpha_C_0[2:0] | -Alpha C Input (First Cycle)
| 40:37 | combine.sba.color[1]RGB_A_1[3:0] | -RGB A Input (Second Cycle)
| 36:32 | combine.mul.color[1]RGB_C_1[4:0] | -RGB C Input (Second Cycle)
| 31:28 | combine.sbb.color[0]RGB_B_0[3:0] | -RGB B Input (First Cycle)
| 27:24 | combine.sbb.color[1]RGB_B_1[3:0] | -RGB B Input (Second Cycle)
| 23:21 | combine.sba.alpha[1]Alpha_A_1[2:0] | -Alpha A Input (Second Cycle)
| 20:18 | combine.mul.alpha[1]Alpha_C_1[2:0] | -Alpha C Input (Second Cycle)
| 17:15 | combine.add.color[0]RGB_D_0[2:0] | -RGB D Input (First Cycle)
| 14:12 | combine.sbb.alpha[0]Alpha_B_0[2:0] | -Alpha B Input (First Cycle)
| 11:9 | combine.add.alpha[0]Alpha_D_0[2:0] | -Alpha D Input (First Cycle)
| 8:6 | combine.add.color[1]RGB_D_1[2:0] | -RGB D Input (Second Cycle)
| 5:3 | combine.sbb.alpha[1]Alpha_B_1[2:0] | -Alpha B Input (Second Cycle)
| 2:0 | combine.add.alpha[1]Alpha_D_1[2:0] | -Alpha D Input (Second Cycle)
}}
 
Configures the inputs to the Color Combiner pipeline stage. The Color Combiner stage computes the following equation
====<span style="display:none;">0x3d - Set_Texture_Image ====
 
<math>(A - B) \cdot C + D</math>
 
This equation can be configured differently for
* Cycle 1 RGB
* Cycle 1 Alpha
* Cycle 2 RGB
* Cycle 2 Alpha
 
In 1-Cycle mode only the Cycle 2 configuration is computed, while in 2-Cycle mode both are computed and the output from Cycle 1 can be used as an input to Cycle 2. Besides some inputs behaving differently the second cycle of 2-Cycle mode and the only cycle of 1-Cycle mode behave identically, the first cycle of 2-Cycle mode is greatly simplified with no clamping occurring between combiner cycles.
 
'''Inputs for A (RGB)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined color from first cycle
|-
| 1 || TEX0 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (rgb)
|-
| 4 || SHADE || Shade color interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (rgb)
|-
| 6 || 1 || Fixed 1
|-
| 7 || NOISE || Per-pixel noise
|-
| 8+ || 0 || Fixed 0
|}
 
'''Inputs for A (Alpha)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined alpha from first cycle
|-
| 1 || TEX0 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (alpha)
|-
| 4 || SHADE || Shade alpha interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (alpha)
|-
| 6 || 1 || Fixed 1
|-
| 7 || 0 || Fixed 0
|}
 
'''Inputs for B (RGB)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined color from first cycle
|-
| 1 || TEX0 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (rgb)
|-
| 4 || SHADE || Shade color interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (rgb)
|-
| 6 || CENTER || Chroma key center (see '''Set Key R''' and '''Set Key GB''')
|-
| 7 || K4 || K4 value (see '''Set Convert''')
|-
| 8+ || 0 || Fixed 0
|}
 
'''Inputs for B (Alpha)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined alpha from first cycle
|-
| 1 || TEX0 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (alpha)
|-
| 4 || SHADE || Shade alpha interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (alpha)
|-
| 6 || 1 || Fixed 1
|-
| 7 || 0 || Fixed 0
|}
 
'''Inputs for C (RGB)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined color from first cycle
|-
| 1 || TEX0 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (rgb)
|-
| 4 || SHADE || Shade color interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (rgb)
|-
| 6 || CENTER || Chroma key center (see '''Set Key R''' and '''Set Key GB''')
|-
| 7 || COMBINED_ALPHA || Combined alpha from first cycle
|-
| 8 || TEX0_ALPHA || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 9 || TEX1_ALPHA || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 10 || PRIMITIVE_ALPHA || Primitive color register (alpha)
|-
| 11 || SHADE_ALPHA || Shade alpha interpolated per-pixel from shade coefficients
|-
| 12 || ENVIRONMENT_ALPHA || Environment color register (alpha)
|-
| 13 || LOD_FRACTION || LOD Fraction computed as part of Texture LOD
|-
| 14 || PRIM_LOD_FRAC || Primitive LOD Fraction (see '''Set Primitive Color''')
|-
| 15 || K5 || K5 value (see '''Set Convert''')
|-
| 16+ || 0 || Fixed 0
|}
 
'''Inputs for C (Alpha)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || LOD_FRACTION || LOD Fraction computed as part of Texture LOD
|-
| 1 || TEX0 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (alpha)
|-
| 4 || SHADE || Shade alpha interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (alpha)
|-
| 6 || PRIM_LOD_FRAC || Primitive LOD Fraction (see '''Set Primitive Color''')
|-
| 7 || 0 || Fixed 0
|}
 
'''Inputs for D (RGB)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined color from first cycle
|-
| 1 || TEX0 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture color sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (rgb)
|-
| 4 || SHADE || Shade color interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (rgb)
|-
| 6 || 1 || Fixed 1
|-
| 7 || 0 || Fixed 0
|}
 
'''Inputs for D (Alpha)'''
 
{| class="wikitable"
! Value !! Name !! Description
|-
| 0 || COMBINED || Combined alpha from first cycle
|-
| 1 || TEX0 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled
|-
| 2 || TEX1 || Texture alpha sampled from the tile set in the primitive command, after texture LOD if enabled, plus one
|-
| 3 || PRIMITIVE || Primitive color register (alpha)
|-
| 4 || SHADE || Shade alpha interpolated per-pixel from shade coefficients
|-
| 5 || ENVIRONMENT || Environment color register (alpha)
|-
| 6 || 1 || Fixed 1
|-
| 7 || 0 || Fixed 0
|}
 
'''Hazards'''
* This is a pipeline configuration command that requires pipeline synchronization before use, otherwise currently rendering primitives may be partially rendered using both the old combiner configuration and the new combiner configuration.
* In 1-Cycle mode only the second cycle configuration is used, the first cycle configuration is ignored.
* COMBINED in the first cycle (or in 1-Cycle mode) is ill-defined. It will (generally) read the previous pixel combiner output.
* If using the SHADE input the primitive must have provided shade coefficients. The SHADE input is therefore always invalid for rectangle commands as there is no option for providing shade coefficients for those.
* If using the TEX0/1 inputs the primitive must have provided texture coordinates and a tile number. Fill Rectangles cannot provide either of these so these options are always invalid for those.
* If using the LOD_FRACTION input, Texture LOD must have been enabled in othermodes.
* In 1-Cycle mode, LOD_FRACTION is not valid. (TOVERIFY in what way is it not valid? Does the 1-Cycle pipeline bypass LOD altogether, so does not update this input?)
* In 1-Cycle mode, TEX1 reads next pixel TEX0 (with some ambiguity at scanline edges)
* In 2-Cycle mode there is a pipeline bug involving TEX0 and TEX1. In the second cycle of 2-Cycle mode, TEX0 refers to TEX1 and TEX1 refers to next pixel TEX0 (with some ambiguity at scanline edges)
* The color combiner is quick to overflow. Values between 256 and 383 saturate to 255 while 384 to 511 overflow to 0. Values greater than or equal to 512 overflow the 9-bit color completely.
* Sign-extension properties differ between the A,B,D and C inputs. C is more prone to overflow, it is advisable to keep the COMBINED input out of the C input as much as possible.
* The 1 input is valued at 256, not 255. This may contribute to overflow issues.
 
=== 0x3D - Set Texture Image ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Texture_ImageSet Texture Image <code>0x3d</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3d[5:0] || colspan=3| set.texture.format[2:0] || colspan=2| set.texture.size[1:0] || — || — || —
|-
| 47:32 || — || — || — || — || — || — || colspan=10| set.texture.width[9:0]
|-
| 31:16 || — || — || — || — || — || — || — || — || colspan=108| set.texture.dramAddress[2523:16]
|-
| 15:0 || colspan=16| set.texture.dramAddress[15:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3d
| 55:53 | set.texture.format[2:0] | -Texture image format
| 52:51 | set.texture.size[1:0] | -Texture image pixel size
| 41:32 | set.texture.width[9:0] | Texture image width in pixels (-1) (possible range of 1 to 4096 pixels)
| 2523:0 | set.texture.dramAddress[2523:0] | -RDRAM physical address of the buffer containing texture data
}}
 
Sets the texture image, the location in RDRAM where the texture loading pipeline should source image data, and related properties.
====<span style="display:none;">0x3e - Set_Mask_Image ====
 
The texture image format parameter seems to have no function, it has no effect on any operation unlike the tile format.
{| class="wikitable"
! Format Name !! Format Value
|-
| RGBA || 0
|-
| YUV || 1
|-
| Color-Indexed (CI) || 2
|-
| Intensity-Alpha (IA) || 3
|-
| Intensity (I) || 4+
|}
 
The size parameter is used to increment the RDRAM address during texture loading.
{| class="wikitable"
! Bits per pixel !! Size Value
|-
| 4 || 0
|-
| 8 || 1
|-
| 16 || 2
|-
| 32 || 3
|}
 
The width parameter is used to calculate the start address of each texture image row during loading.
 
This is an attribute-setting command but is not used in the rendering pipeline so does not require a pipeline synchronization before changing it. (TOVERIFY is a sync required if changing it following a load command?)
 
'''Hazards'''
* Memory alignment should be 8-byte to guarantee operation. If the address falls into the range [1,7] mod 64, the RDP may hang when loading from it.
 
=== 0x3E - Set Depth Image ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Mask_ImageSet Depth Image <code>0x3e</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3e[5:0] || — || — || — || — || — || — || — || —
Line 596 ⟶ 1,644:
| 47:32 || — || — || — || — || — || — || — || — || — || — || — || — || — || — || — || —
|-
| 31:16 || — || — || — || — || — || — || — || — || colspan=108| set.mask.dramAddress[2523:16]
|-
| 15:0 || colspan=16| set.mask.dramAddress[15:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3e
| 2523:0 | set.mask.dramAddress[2523:0] | -RDRAM physical address of the buffer to store depth information
}}
 
Sets the depth image, the region in RDRAM where depth information will be stored. The depth image width is the same as the image width for the current color image. The depth buffer format is a fixed 18-bit-per-pixel format irrespective of the color image format.
====<span style="display:none;">0x3f - Set_Color_Image ====
 
'''Hazards'''
* This attribute must be set before rendering any primitives that read or write depth, else it will read/write depth data at an unspecified location.
* Memory alignment must be 64-byte for all rendering operations to behave as expected.
 
=== 0x3F - Set Color Image ===
----
{| class="wikitable" style="text-align: center; white-space:nowrap;"
! colspan="17"|Set_Color_ImageSet Color Image <code>0x3f</code>
|-
| 63:48 || — || — || colspan=6| command = 0x3f[5:0] || colspan=3| set.color.format[2:0] || colspan=2| set.color.size[1:0] || — || — || —
|-
| 47:32 || — || — || — || — || — || — || colspan=10| set.color.width[9:0]
|-
| 31:16 || — || — || — || — || — || — || — || — || colspan=108| set.color.dramAddress[2523:16]
|-
| 15:0 || colspan=16| set.color.dramAddress[15:0]
|}
{{#invoke:Register table|definitions
| 61:56 | command[5:0] | 0x3f
| 55:53 | set.color.format[2:0] | -Pixel format (same meaning as in texture format)
| 52:51 | set.color.size[1:0] | -Pixel size (same meaning as in texture size)
| 41:32 | set.color.width[9:0] | Image width in pixels (-1) (possible range of 1 to 4096 pixels)
| 2523:0 | set.color.dramAddress[2523:0] | -RDRAM physical address of the buffer where pixels will be written
}}
 
Sets the color image address and properties, the region in RDRAM where primitives will be rendered to as pixels.
 
The image is arrayed in row-order, that is rows are adjacent in memory. It is generally more efficient to draw wide triangles rather than horizontally thin triangles that overlap many rows; for single rows span buffers are employed to alleviate stalls due to waiting on memory read/write requests while there is no such buffering across multiple rows.
 
Valid format/size combinations are RGBA32, RGBA16, I8. 4-bit modes only write 0s as bytes, all 8-bit modes behave identically, 16-bit and 32-bit RGBA modes differ from other modes.
 
'''Hazards'''
* This attribute must be set before rendering any primitives, else it will render to an unspecified location.
* This is an attribute-setting command that requires pipeline synchronization before use, otherwise currently rendering primitives may be split partially between the old color image and new color image. (TOVERIFY there are conflicting accounts of whether Set Color Image requires a sync, the current consensus is that sync is required to avoid all edge cases)
* Memory alignment must be 64-byte for all rendering operations to behave as expected.
* Rendering any primitive in FILL mode to a 4-bit color image will crash the RDP.
* Copying a 4-bit or 8-bit texture with COPY mode is only possible if the destination color image is 8-bit.
* Copying a 16-bit texture with COPY mode is only possible if the destination color image is 16-bit. (Note that CI textures are treated as 16-bit in COPY mode as the TLUT is 16-bit)
* COPY mode is unavailable when a 32-bit color image is configured.
56

edits