Reality Display Processor/Commands

Revision as of 23:28, 15 March 2024 by Tharo (talk | contribs) (Set Tile, Set Tile Size)
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

0x08 through 0x0F - Triangle


Triangle 0x08 through 0x0F
Word 0 63:48 0 0 1 shade texture zbuffer lmajor level[2:0] tile[2:0]
47:32 y.lo[13:0]
31:16 y.md[13:0]
15:0 y.hi[13:0]
Word 1 63:48 x.lo.c.i[15:0]
47:32 x.lo.c.f[15:0]
31:16 x.lo.s.i[15:0]
15:0 x.lo.s.f[15:0]
Word 2 63:48 x.hi.c.i[15:0]
47:32 x.hi.c.f[15:0]
31:16 x.hi.s.i[15:0]
15:0 x.hi.s.f[15:0]
Word 3 63:48 x.md.c.i[15:0]
47:32 x.md.c.f[15:0]
31:16 x.md.s.i[15:0]
15:0 x.md.s.f[15:0]

Word 0

bit 61:56 command: 0x08 through 0x0F depending on features specified
bit 58 shade: if 1, command is followed by 8 words specifying shading instructions
bit 57 texture: if 1, command is followed by 8 words specifying texturing instructions
bit 56 zbuffer: if 1, command is followed by 2 words specifying zbuffering instructions
bit 55 lmajor: ?
bit 53:51 level[2:0]: -
bit 50:48 tile[2:0]: -
bit 45:32 y.lo[13:0]: -
bit 29:16 y.md[13:0]: -
bit 13:0 y.hi[13:0]: -

Word 1

bit 63:48 x.lo.c.i[15:0]: -
bit 47:32 x.lo.c.f[15:0]: -
bit 31:16 x.lo.s.i[15:0]: -
bit 15:0 x.lo.s.f[15:0]: -

Word 2

bit 63:48 x.hi.c.i[15:0]: -
bit 47:32 x.hi.c.f[15:0]: -
bit 31:16 x.hi.s.i[15:0]: -
bit 15:0 x.hi.s.f[15:0]: -

Word 3

bit 63:48 x.md.c.i[15:0]: -
bit 47:32 x.md.c.f[15:0]: -
bit 31:16 x.md.s.i[15:0]: -
bit 15:0 x.md.s.f[15:0]: -

0x0C through 0x0F - Shaded Triangle


After above 4 words describing a triangle, if requested by the command, these 8 words describing shading instructions:

Shaded Triangle (suffix) 0x0C0x0F
Word 0 63:48 r.c.i[15:0]
47:32 g.c.i[15:0]
31:16 b.c.i[15:0]
15:0 a.c.i[15:0]
Word 1 63:48 r.x.i[15:0]
47:32 g.x.i[15:0]
31:16 b.x.i[15:0]
15:0 a.x.i[15:0]
Word 2 63:48 r.c.f[15:0]
47:32 g.c.f[15:0]
31:16 b.c.f[15:0]
15:0 a.c.f[15:0]
Word 3 63:48 r.x.f[15:0]
47:32 g.x.f[15:0]
31:16 b.x.f[15:0]
15:0 a.x.f[15:0]
Word 4 63:48 r.e.i[15:0]
47:32 g.e.i[15:0]
31:16 b.e.i[15:0]
15:0 a.e.i[15:0]
Word 5 63:48 r.y.i[15:0]
47:32 g.y.i[15:0]
31:16 b.y.i[15:0]
15:0 a.y.i[15:0]
Word 6 63:48 r.e.f[15:0]
47:32 g.e.f[15:0]
31:16 b.e.f[15:0]
15:0 a.e.f[15:0]
Word 7 63:48 r.y.f[15:0]
47:32 g.y.f[15:0]
31:16 b.y.f[15:0]
15:0 a.y.f[15:0]

Word 0

bit 63:48 r.c.i[15:0]: -
bit 47:32 g.c.i[15:0]: -
bit 31:16 b.c.i[15:0]: -
bit 15:0 a.c.i[15:0]: -

Word 1

bit 63:48 r.x.i[15:0]: -
bit 47:32 g.x.i[15:0]: -
bit 31:16 b.x.i[15:0]: -
bit 15:0 a.x.i[15:0]: -

Word 2

bit 63:48 r.c.f[15:0]: -
bit 47:32 g.c.f[15:0]: -
bit 31:16 b.c.f[15:0]: -
bit 15:0 a.c.f[15:0]: -

Word 3

bit 63:48 r.x.f[15:0]: -
bit 47:32 g.x.f[15:0]: -
bit 31:16 b.x.f[15:0]: -
bit 15:0 a.x.f[15:0]: -

Word 4

bit 63:48 r.e.i[15:0]: -
bit 47:32 g.e.i[15:0]: -
bit 31:16 b.e.i[15:0]: -
bit 15:0 a.e.i[15:0]: -

Word 5

bit 63:48 r.y.i[15:0]: -
bit 47:32 g.y.i[15:0]: -
bit 31:16 b.y.i[15:0]: -
bit 15:0 a.y.i[15:0]: -

Word 6

bit 63:48 r.e.f[15:0]: -
bit 47:32 g.e.f[15:0]: -
bit 31:16 b.e.f[15:0]: -
bit 15:0 a.e.f[15:0]: -

Word 7

bit 63:48 r.y.f[15:0]: -
bit 47:32 g.y.f[15:0]: -
bit 31:16 b.y.f[15:0]: -
bit 15:0 a.y.f[15:0]: -

0x0A, 0x0B, 0x0E, 0x0F - Textured Triangle


After above 4 words describing a triangle, and optional 8 words describing shading, these 8 words describing texturing instructions:

Textured Triangle (A,B,E,F)
Word 0 63:48 s.c.i[15:0]
47:32 t.c.i[15:0]
31:16 w.c.i[15:0]
15:0
Word 1 63:48 s.x.i[15:0]
47:32 t.x.i[15:0]
31:16 w.x.i[15:0]
15:0
Word 2 63:48 s.c.f[15:0]
47:32 t.c.f[15:0]
31:16 w.c.f[15:0]
15:0
Word 3 63:48 s.x.f[15:0]
47:32 t.x.f[15:0]
31:16 w.x.f[15:0]
15:0
Word 4 63:48 s.e.i[15:0]
47:32 t.e.i[15:0]
31:16 w.e.i[15:0]
15:0
Word 5 63:48 s.y.i[15:0]
47:32 t.y.i[15:0]
31:16 w.y.i[15:0]
15:0
Word 6 63:48 s.e.f[15:0]
47:32 t.e.f[15:0]
31:16 w.e.f[15:0]
15:0
Word 7 63:48 s.y.f[15:0]
47:32 t.y.f[15:0]
31:16 w.y.f[15:0]
15:0

Word 0

bit 63:48 s.c.i[15:0]: -
bit 47:32 t.c.i[15:0]: -
bit 31:16 w.c.i[15:0]: -

Word 1

bit 63:48 s.x.i[15:0]: -
bit 47:32 t.x.i[15:0]: -
bit 31:16 w.x.i[15:0]: -

Word 2

bit 63:48 s.c.f[15:0]: -
bit 47:32 t.c.f[15:0]: -
bit 31:16 w.c.f[15:0]: -

Word 3

bit 63:48 s.x.f[15:0]: -
bit 47:32 t.x.f[15:0]: -
bit 31:16 w.x.f[15:0]: -

Word 4

bit 63:48 s.e.i[15:0]: -
bit 47:32 t.e.i[15:0]: -
bit 31:16 w.e.i[15:0]: -

Word 5

bit 63:48 s.y.i[15:0]: -
bit 47:32 t.y.i[15:0]: -
bit 31:16 w.y.i[15:0]: -

Word 6

bit 63:48 s.e.f[15:0]: -
bit 47:32 t.e.f[15:0]: -
bit 31:16 w.e.f[15:0]: -

Word 7

bit 63:48 s.y.f[15:0]: -
bit 47:32 t.y.f[15:0]: -
bit 31:16 w.y.f[15:0]: -

0x09, 0x0B, 0x0D, 0x0F - Zbuffered Triangle


After above 4 words describing a triangle, optional 8 words describing shading, and optional 8 words describing texturing, these two words describing Zbuffering:

Zbuffered Triangle (9,B,D,F)
Word 0 63:48 d.i[15:0]
47:32 d.f[15:0]
31:16 x.i[15:0]
15:0 x.f[15:0]
Word 1 63:48 e.i[15:0]
47:32 e.f[15:0]
31:16 y.i[15:0]
15:0 y.f[15:0]

Word 0

bit 63:48 d.i[15:0]: -
bit 47:32 d.f[15:0]: -
bit 31:16 x.i[15:0]: -
bit 15:0 x.f[15:0]: -

Word 1

bit 63:48 e.i[15:0]: -
bit 47:32 e.f[15:0]: -
bit 31:16 y.i[15:0]: -
bit 15:0 y.f[15:0]: -

0x24 and 0x25 - Texture_Rectangle


Texture_Rectangle 0x24 and Texture_Rectangle_Flip 0x25
Word 0 63:48 command[5:0] = 0x24 or 0x25 x.lo[11:4]
47:32 x.lo[3:0] y.lo[11:0]
31:16 tile[2:0] x.hi[11:4]
15:0 x.hi[3:0] y.hi[11:0]
Word 1 63:48 s.i[15:0]
47:32 t.i[15:0]
31:16 s.f[15:0]
15:0 t.f[15:0]

Word 0

bit 61:56 command[5:0]: 0x24 (Texture_Rectangle) or 0x25 (Texture_Rectangle_Flip)
bit 55:44 x.lo[11:0]: -
bit 43:32 y.lo[11:0]: -
bit 26:24 tile[2:0]: -
bit 23:12 x.hi[11:0]: -
bit 11:0 y.hi[11:0]: -

Word 1

bit 63:48 s.i[15:0]: -
bit 47:32 t.i[15:0]: -
bit 31:16 s.f[15:0]: -
bit 15:0 t.f[15:0]: -

0x26 - Sync Load


Sync Load 0x26
63:48 command = 0x26[5:0]
47:32
31:16
15:0
bit 61:56 command[5:0]: 0x26

Stalls the RDP pipeline for exactly 25 GCLK cycles. This guarantees that the loading pipeline will be available for use following any prior operation.

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


Sync Pipe 0x27
63:48 command = 0x27[5:0]
47:32
31:16
15:0
bit 61:56 command[5:0]: 0x27

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.

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


Sync Tile 0x28
63:48 command = 0x28[5:0]
47:32
31:16
15:0
bit 61:56 command[5:0]: 0x28

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.

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


Sync Full 0x29
63:48 command = 0x29[5:0]
47:32
31:16
15:0
bit 61:56 command[5:0]: 0x29

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.

Hazards

  • Ensure this is the final command consumed before hitting DP_END, otherwise the RDP may hang.

0x2a - Set Key GB


Set Key GB 0x2a
63:48 command = 0x2a[5:0] width_G[11:4]
47:32 width_G[3:0] width_B[11:0]
31:16 center_G[7:0] scale_G[7:0]
15:0 center_B[7:0] scale_B[7:0]
bit 61:56 command[5:0]: 0x2a
bit 55:44 width_G[11:0]: Keying window half-width for green channel (4.8 format)
bit 43:32 width_B[11:0]: Keying window half-width for blue channel (4.8 format)
bit 31:24 center_G[7:0]: Center Color Combiner input for green channel
bit 23:16 scale_G[7:0]: Scale Color Combiner input for green channel
bit 15:8 center_B[7:0]: Center Color Combiner input for blue channel
bit 7:0 scale_B[7:0]: Scale Color Combiner input for blue channel

Sets chroma Key parameters for the green and blue color channels.

Key width is used exclusively in the chroma key pipeline stage following the Color Combiner (if enabled in othermodes)

 

Key center and scale are Color Combiner inputs, the expectation is that the Color Combiner is configured to   when chroma keying, where   is any color source. If not chroma keying, these may be used as general-purpose Color Combiner inputs.

0x2b - Set Key R


Set Key R 0x2b
63:48 command = 0x2b[5:0]
47:32
31:16 width_R[11:0]
15:0 center_R[7:0] scale_R[7:0]
bit 61:56 command[5:0]: 0x2b
bit 27:16 width_R[11:0]: Keying window half-width for red channel (4.8 format)
bit 15:8 center_R[7:0]: Center Color Combiner input for red channel
bit 7:0 scale_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.

0x2c - Set Convert


Set Convert 0x2c
63:48 command = 0x2c[5:0] K0[8:3]
47:32 K0[2:0] K1[8:0] K2[8:5]
31:16 K2[4:0] K3[8:0] K4[8:7]
15:0 K4[6:0] K5[8:0]
bit 61:56 command[5:0]: 0x2c
bit 53:45 K0[8:0]: Color conversion constant K0
bit 44:36 K1[8:0]: Color conversion constant K1
bit 35:27 K2[8:0]: Color conversion constant K2
bit 26:18 K3[8:0]: Color conversion constant K3
bit 17:9 K4[8:0]: Color conversion constant K4
bit 8:0 K5[8:0]: Color conversion constant K5

Sets colorspace conversion coefficients intended for YUV -> RGB conversion.

K0 through K3 are used in the Texture Filter color conversion step:

 

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


Set Scissor 0x2d
63:48 command = 0x2d[5:0] upper_left.x[11:4]
47:32 upper_left.x[3:0] upper_left.y[11:0]
31:16 field odd lower_right.x[11:4]
15:0 scissor.x.lo[3:0] lower_right.y[11:0]
bit 61:56 command[5:0]: 0x2d
bit 55:44 upper_left.x[11:0]: Upper left x coordinate (u10.2 format)
bit 43:32 upper_left.y[11:0]: Upper left y coordinate (u10.2 format)
bit 25 field: Whether to perform interlaced rendering, only even or odd lines will be processed
bit 24 odd: Whether to keep even (0) or odd (1) lines when interlaced rendering is enabled
bit 23:12 lower_right.x[11:0]: Lower right x coordinate (u10.2 format)
bit 11:0 lower_right.y[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.

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


Set Primitive Depth 0x2e
63:48 command = 0x2e[5:0]
47:32
31:16 z[15:0]
15:0 dz[15:0]
bit 61:56 command[5:0]: 0x2e
bit 31:16 z[15:0]: Primitive depth value
bit 15:0 dz[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.

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


Set_Other_Modes 0x2f
63:48 command = 0x2f[5:0] other.atomicPrimitive other.reserved1 other.cycleType[1:0] other.perspective other.detailTexture other.sharpenTexture other.lodTexture
47:32 other.tlut other.tlutType other.sampleType other.midTexel other.bilerp[0] other.bilerp[1] other.convertOne other.colorKey other.colorDitherMode[1:0] other.alphaDitherMode[1:0] other.reserved2[3:0]
31:16 other.blend1a[0][1:0] other.blend1a[1][1:0] other.blend1b[0][1:0] other.blend1b[1][1:0] other.blend2a[0][1:0] other.blend2a[1][1:0] other.blend2b[0][1:0] other.blend2b[1][1:0]
15:0 other.reserved3 other.forceBlend other.alphaCoverage other.coverageXalpha other.zMode[1:0] other.coverageMode[1:0] other.colorOnCoverage other.imageRead other.zUpdate other.zCompare other.antialias other.zSource other.ditherAlpha other.alphaCompare
bit 61:56 command[5:0]: 0x2f
bit 55 other.atomicPrimitive: ?
bit 54 other.reserved1: ?
bit 53:52 other.cycleType[1:0]: -
bit 51 other.perspective: ?
bit 50 other.detailTexture: ?
bit 49 other.sharpenTexture: ?
bit 48 other.lodTexture: ?
bit 47 other.tlut: ?
bit 46 other.tlutType: ?
bit 45 other.sampleType: ?
bit 44 other.midTexel: ?
bit 43 other.bilerp[0]: ?
bit 42 other.bilerp[1]: ?
bit 41 other.convertOne: ?
bit 40 other.colorKey: ?
bit 39:38 other.colorDitherMode[1:0]: -
bit 37:36 other.alphaDitherMode[1:0]: -
bit 35:32 other.reserved2[3:0]: -
bit 31:30 other.blend1a[0][1:0]: -
bit 29:28 other.blend1a[1][1:0]: -
bit 27:26 other.blend1b[0][1:0]: -
bit 25:24 other.blend1b[1][1:0]: -
bit 23:22 other.blend2a[0][1:0]: -
bit 21:20 other.blend2a[1][1:0]: -
bit 19:18 other.blend2b[0][1:0]: -
bit 17:16 other.blend2b[1][1:0]: -
bit 15 other.reserved3: ?
bit 14 other.forceBlend: ?
bit 13 other.alphaCoverage: ?
bit 12 other.coverageXalpha: ?
bit 11:10 other.zMode[1:0]: -
bit 9:8 other.coverageMode[1:0]: -
bit 7 other.colorOnCoverage: ?
bit 6 other.imageRead: ?
bit 5 other.zUpdate: ?
bit 4 other.zCompare: ?
bit 3 other.antialias: ?
bit 2 other.zSource: ?
bit 1 other.ditherAlpha: ?
bit 0 other.alphaCompare: ?

0x30 - Load_Texture_LUT


Load_Texture_LUT 0x30
63:48 command = 0x30[5:0] tlut.s.lo[11:4]
47:32 tlut.s.lo[3:0] tlut.t.lo[11:0]
31:16 tlut.index[2:0] tlut.s.hi[11:4]
15:0 tlut.s.hi[3:0] tlut.t.hi[11:0]
bit 61:56 command[5:0]: 0x30
bit 55:44 tlut.s.lo[11:0]: -
bit 43:32 tlut.t.lo[11:0]: -
bit 26:24 tlut.index[2:0]: -
bit 23:12 tlut.s.hi[11:0]: -
bit 11:0 tlut.t.hi[11:0]: -

0x31 - Invalid_31


Invalid_31 0x31
63:48 command = 0x31[5:0]
47:32
31:16
15:0
bit 61:56 command[5:0]: 0x31

0x32 - Set Tile Size


Set Tile Size 0x32
63:48 command = 0x32[5:0] upper_left.s[11:4]
47:32 upper_left.s[3:0] upper_left.t[11:0]
31:16 index[2:0] lower_right.s[11:4]
15:0 lower_right.s[3:0] lower_right.t[11:0]
bit 61:56 command[5:0]: 0x32
bit 55:44 upper_left.s[11:0]: (u10.2 format)
bit 43:32 upper_left.t[11:0]: (u10.2 format)
bit 26:24 index[2:0]: Tile index
bit 23:12 lower_right.s[11:0]: (u10.2 format)
bit 11:0 lower_right.t[11:0]: (u10.2 format)

Updates the tile extents for the tile descriptor specified by the index parameter.

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


Load_Block 0x33
63:48 command = 0x33[5:0] load_.block.s.lo[11:4]
47:32 load_.block.s.lo[3:0] load_.block.t.lo[11:0]
31:16 load_.block.index[2:0] load_.block.s.hi[11:4]
15:0 load_.block.s.hi[3:0] load_.block.t.hi[11:0]
bit 61:56 command[5:0]: 0x33
bit 55:44 load_.block.s.lo[11:0]: -
bit 43:32 load_.block.t.lo[11:0]: -
bit 26:24 load_.block.index[2:0]: -
bit 23:12 load_.block.s.hi[11:0]: -
bit 11:0 load_.block.t.hi[11:0]: -

0x34 - Load_Tile


Load_Tile 0x34
63:48 command = 0x34[5:0] load_.tile.s.lo[11:4]
47:32 load_.tile.s.lo[3:0] load_.tile.t.lo[11:0]
31:16 load_.tile.index[2:0] load_.tile.s.hi[11:4]
15:0 load_.tile.s.hi[3:0] load_.tile.t.hi[11:0]
bit 61:56 command[5:0]: 0x34
bit 55:44 load_.tile.s.lo[11:0]: -
bit 43:32 load_.tile.t.lo[11:0]: -
bit 26:24 load_.tile.index[2:0]: -
bit 23:12 load_.tile.s.hi[11:0]: -
bit 11:0 load_.tile.t.hi[11:0]: -

0x35 - Set Tile


Set Tile 0x35
63:48 command = 0x35[5:0] format[2:0] size[1:0] line[8:7]
47:32 line[6:0] address[8:0]
31:16 index[2:0] palette[3:0] clamp_T mirror_T mask_T[3:2]
15:0 mask_T[1:0] shift_T[3:0] clamp_S mirror_S mask_S[3:0] shift_S[3:0]
bit 61:56 command[5:0]: 0x35
bit 55:53 format[2:0]: Tile texel format
bit 52:51 size[1:0]: Tile texel size
bit 49:41 line[8:0]: Tile line length in TMEM words
bit 40:32 address[8:0]: TMEM address in TMEM words
bit 26:24 index[2:0]: Tile index
bit 23:20 palette[3:0]: Palette index
bit 19 clamp_T: Clamp enable (T-axis)
bit 18 mirror_T: Mirror enable (T-axis)
bit 17:14 mask_T[3:0]: Mask (T-axis)
bit 13:10 shift_T[3:0]: Shift (T-axis)
bit 9 clamp_S: Clamp enable (S-axis)
bit 8 mirror_S: Mirror enable (S-axis)
bit 7:4 mask_S[3:0]: Mask (S-axis)
bit 3:0 shift_S[3:0]: Shift (S-axis)

Configures the tile descriptor specified by the index parameter.

The texel format parameter is selected from

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

Bits per pixel Size Value
4 0
8 1
16 2
32 3

Officially supported format/size combinations

RGBA YUV CI IA I
4 - -  Y  Y  Y
8 - -  Y  Y  Y
16  Y  Y -  Y -
32  Y - - - -

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 (width * NBITS(size) + 63) / 64 where NBITS(size) 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.
Shift value Operation
0 N/A
1 >> 1
2 >> 2
...
10 >> 10
11 << 5
12 << 4
13 << 3
14 << 2
15 << 1

0x36 - Fill Rectangle


Fill Rectangle 0x36
63:48 command = 0x36[5:0] lower_right.x[11:4]
47:32 lower_right.x[3:0] lower_right.y[11:0]
31:16 upper_left.x[11:4]
15:0 upper_left.x[3:0] upper_left.y[11:0]
bit 61:56 command[5:0]: 0x36
bit 55:44 lower_right.x[11:0]: Lower-right x coordinate (u10.2 format)
bit 43:32 lower_right.y[11:0]: Lower-right y coordinate (u10.2 format)
bit 23:12 upper_left.x[11:0]: Upper-left x coordinate (u10.2 format)
bit 11:0 upper_left.y[11:0]: Upper-right y coordinate (u10.2 format)

Renders a solid-color rectangle.

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.

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


Set Fill Color 0x37
63:48 command = 0x37[5:0]
47:32
31:16 color[31:16]
15:0 color[15:0]
bit 61:56 command[5:0]: 0x37
bit 31:0 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.

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


Set Fog Color 0x38
63:48 command = 0x38[5:0]
47:32
31:16 red[7:0] green[7:0]
15:0 blue[7:0] alpha[7:0]
bit 61:56 command[5:0]: 0x38
bit 31:24 red[7:0]: Fog Red Value
bit 23:16 green[7:0]: Fog Green Value
bit 15:8 blue[7:0]: Fog Blue Value
bit 7:0 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.

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


Set Blend Color 0x39
63:48 command = 0x39[5:0]
47:32
31:16 red[7:0] green[7:0]
15:0 blue[7:0] alpha[7:0]
bit 61:56 command[5:0]: 0x39
bit 31:24 red[7:0]: Blend Red Value
bit 23:16 green[7:0]: Blend Green Value
bit 15:8 blue[7:0]: Blend Blue Value
bit 7:0 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.

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


Set Primitive Color 0x3a
63:48 command = 0x3a[5:0]
47:32 min_level[7:0] prim_lod_frac[7:0]
31:16 red[7:0] green[7:0]
15:0 blue[7:0] alpha[7:0]
bit 61:56 command[5:0]: 0x3a
bit 47:40 min_level[7:0]: Minimum LOD level
bit 39:32 prim_lod_frac[7:0]: Primitive LOD Fraction Color Combiner input
bit 31:24 red[7:0]: Primitive Red Value
bit 23:16 green[7:0]: Primitive Green Value
bit 15:8 blue[7:0]: Primitive Blue Value
bit 7:0 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.

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

 

where Tbase 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


Set Environment Color 0x3b
63:48 command = 0x3b[5:0]
47:32
31:16 red[7:0] green[7:0]
15:0 blue[7:0] alpha[7:0]
bit 61:56 command[5:0]: 0x3b
bit 31:24 red[7:0]: Environment Red value
bit 23:16 green[7:0]: Environment Green value
bit 15:8 blue[7:0]: Environment Blue value
bit 7:0 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.

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


Set_Combine_Mode 0x3c
63:48 command = 0x3c[5:0] combine.sba.color[0][3:0] combine.mul.color[0][4:1]
47:32 combine.mul.color[0] combine.sba.alpha[0][2:0] combine.mul.alpha[0][2:0] combine.sba.color[1][3:0] combine.mul.color[1][4:0]
31:16 combine.sbb.color[0][3:0] combine.sbb.color[1][3:0] combine.sba.alpha[1][2:0] combine.mul.alpha[1][2:0] combine.add.color[0][2:1]
15:0 combine.add.color[0] combine.sbb.alpha[0][2:0] combine.add.alpha[0][2:0] combine.add.color[1][2:0] combine.sbb.alpha[1][2:0] combine.add.alpha[1][2:0]
bit 61:56 command[5:0]: 0x3c
bit 55:52 combine.sba.color[0][3:0]: -
bit 51:47 combine.mul.color[0][4:0]: -
bit 46:44 combine.sba.alpha[0][2:0]: -
bit 43:41 combine.mul.alpha[0][2:0]: -
bit 40:37 combine.sba.color[1][3:0]: -
bit 36:32 combine.mul.color[1][4:0]: -
bit 31:28 combine.sbb.color[0][3:0]: -
bit 27:24 combine.sbb.color[1][3:0]: -
bit 23:21 combine.sba.alpha[1][2:0]: -
bit 20:18 combine.mul.alpha[1][2:0]: -
bit 17:15 combine.add.color[0][2:0]: -
bit 14:12 combine.sbb.alpha[0][2:0]: -
bit 11:9 combine.add.alpha[0][2:0]: -
bit 8:6 combine.add.color[1][2:0]: -
bit 5:3 combine.sbb.alpha[1][2:0]: -
bit 2:0 combine.add.alpha[1][2:0]: -

0x3d - Set Texture Image


Set Texture Image 0x3d
63:48 command = 0x3d[5:0] format[2:0] size[1:0]
47:32 width[9:0]
31:16 dramAddress[23:16]
15:0 dramAddress[15:0]
bit 61:56 command[5:0]: 0x3d
bit 55:53 format[2:0]: Texture image format
bit 52:51 size[1:0]: Texture image pixel size
bit 41:32 width[9:0]: Texture image width in pixels (-1) (possible range of 1 to 4096 pixels)
bit 23:0 dramAddress[23: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.

The texture image format parameter seems to have no function, it has no effect on any operation unlike the tile format.

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.

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


Set Depth Image 0x3e
63:48 command = 0x3e[5:0]
47:32
31:16 dramAddress[23:16]
15:0 dramAddress[15:0]
bit 61:56 command[5:0]: 0x3e
bit 23:0 dramAddress[23: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.

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


Set Color Image 0x3f
63:48 command = 0x3f[5:0] format[2:0] size[1:0]
47:32 width[9:0]
31:16 dramAddress[23:16]
15:0 dramAddress[15:0]
bit 61:56 command[5:0]: 0x3f
bit 55:53 format[2:0]: Pixel format (same meaning as in texture format)
bit 52:51 size[1:0]: Pixel size (same meaning as in texture size)
bit 41:32 width[9:0]: Image width in pixels (-1) (possible range of 1 to 4096 pixels)
bit 23:0 dramAddress[23: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.