Documentation
¶
Overview ¶
Package rdp provides writing commands to the display processor.
The diplay processor is a hardware rasterizer. It controls the texture cache and draws primitives directly into a framebuffer in RDRAM. It's usually not used directly but through the RSP instead.
This package gives direct access to some of the low-level RDP commands, which can be used for simple 2D graphics. For 3D graphics the RSP with a suitable microcode will be necessary.
Index ¶
- Constants
- func Busy() (cmd, pipe, tmem uint32)
- func MaxTileSize(format texture.Format) image.Rectangle
- type AlphaDither
- type BlendMode
- type BlenderA
- type BlenderB
- type BlenderPM
- type CombineMode
- type CombineParams
- type CombinePass
- type CombineSource
- type CvgDest
- type CycleType
- type DisplayList
- func (dl *DisplayList) FillRectangle(r image.Rectangle)
- func (dl *DisplayList) Flush()
- func (dl *DisplayList) LoadTLUT(idx uint8, r image.Rectangle)
- func (dl *DisplayList) LoadTile(idx uint8, r image.Rectangle)
- func (dl *DisplayList) Push(cmds ...command)
- func (dl *DisplayList) SetBlendColor(c color.Color)
- func (dl *DisplayList) SetColorImage(img *texture.Texture)
- func (dl *DisplayList) SetCombineMode(m CombineMode)
- func (dl *DisplayList) SetDepthImage(img *texture.Texture)
- func (dl *DisplayList) SetEnvironmentColor(c color.Color)
- func (dl *DisplayList) SetFillColor(c color.Color)
- func (dl *DisplayList) SetOtherModes(flags ModeFlags, ct CycleType, cDith RGBDither, aDith AlphaDither, zMode ZMode, ...)
- func (dl *DisplayList) SetPrimitiveColor(c color.Color)
- func (dl *DisplayList) SetScissor(r image.Rectangle, il InterlaceFrame)
- func (dl *DisplayList) SetTextureImage(img *texture.Texture)
- func (dl *DisplayList) SetTile(ts TileDescriptor) (loadIdx, drawIdx uint8)
- func (dl *DisplayList) SetTileSize(idx uint8, r image.Rectangle)
- func (dl *DisplayList) TextureRectangle(r image.Rectangle, p image.Point, scale image.Point, tileIdx uint8)
- type InterlaceFrame
- type ModeFlags
- type RGBDither
- type TileDescFlags
- type TileDescriptor
- type ZMode
Constants ¶
const ( // Waits until all previous commands have finished reading and writing // to RDRAM. Additionally raises the RDP interrupt. Use to sync memory // access between RDP and other components (e.g. switching framebuffers) // or when changing RDPs RDRAM buffers (e.g. Render to texture). SyncFull command = 0xe9 << 56 // Stalls pipeline for exactly 25 GCLK cycles. Guarantees loading // pipeline is safe for use. SyncLoad command = 0xf1 << 56 // Stalls pipeline for exactly 50 GCLK cycles. Guarantees any // preceeding primitives have finished rendering and it's safe to change // rendering modes. SyncPipe command = 0xe7 << 56 // Stalls pipeline for exactly 33 GCLK cycles. Guarantees that any // preceding primitives have finished using tile information and // it's safe to modify tile descriptors. SyncTile command = 0xe8 << 56 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlphaDither ¶
type AlphaDither uint64
const ( AlphaDitherPattern AlphaDither = iota << 36 AlphaDitherInvPattern AlphaDitherNoise AlphaDitherNone )
type CombineMode ¶
type CombineMode struct{ One, Two CombinePass }
The ColorCombiner computes it's output with the equation `(A-B)*C + D`, where the inputs A, B, C and D can be choosen from the predefined CombineSource values. Color and alpha are calculated separately. If CycleTypeTwo is active two passes can be defined, where the second pass can use the first pass output as it's input.
type CombineParams ¶
type CombineParams struct{ A, B, C, D CombineSource }
type CombinePass ¶
type CombinePass struct{ RGB, Alpha CombineParams }
type CombineSource ¶
type CombineSource uint64
const ( CombineCombined CombineSource = iota CombineTex0 CombineTex1 CombinePrimitive CombineShade CombineEnvironment CombineAColorOne CombineSource = 6 CombineAColorNoise CombineSource = 7 CombineAColorZero CombineSource = 8 CombineAAlphaOne CombineSource = 6 CombineAAlphaZero CombineSource = 7 CombineBColorCenter CombineSource = 6 CombineBColorK4 CombineSource = 7 CombineBColorZero CombineSource = 8 CombineBAlphaOne CombineSource = 6 CombineBAlphaZero CombineSource = 7 CombineCColorCenter CombineSource = 6 CombineCColorCombinedAlpha CombineSource = 7 CombineCColorTex0Alpha CombineSource = 8 CombineCColorTex1Alpha CombineSource = 9 CombineCColorPrimitiveAlpha CombineSource = 10 CombineCColorShadeAlpha CombineSource = 11 CombineCColorEnvironmentAlpha CombineSource = 12 CombineCColorLODFraction CombineSource = 13 CombineCColorPrimitiveLODFraction CombineSource = 14 CombineCColorK5 CombineSource = 15 CombineCColorZero CombineSource = 16 CombineCAlphaPrimitiveLODFraction CombineSource = 6 CombineCAlphaZero CombineSource = 7 CombineDColorOne CombineSource = 6 CombineDColorZero CombineSource = 7 CombineDAlphaOne CombineSource = 6 CombineDAlphaZero CombineSource = 7 )
type DisplayList ¶
type DisplayList struct {
// contains filtered or unexported fields
}
var RDP DisplayList
func (*DisplayList) FillRectangle ¶
func (dl *DisplayList) FillRectangle(r image.Rectangle)
Draws a rectangle filled with the color set by SetFillColor().
func (*DisplayList) Flush ¶
func (dl *DisplayList) Flush()
Flush blocks until all enqueued commands are fully processed. After a Flush, commands must not rely on any state from before the flush.
func (*DisplayList) LoadTLUT ¶
func (dl *DisplayList) LoadTLUT(idx uint8, r image.Rectangle)
Copies a color palette into TMEM. The palette is copied from the texture image, which must be set prior via SetTextureImage().
func (*DisplayList) LoadTile ¶
func (dl *DisplayList) LoadTile(idx uint8, r image.Rectangle)
Copies a tile into TMEM. The tile is copied from the texture image, which must be set prior via SetTextureImage().
func (*DisplayList) Push ¶
func (dl *DisplayList) Push(cmds ...command)
func (*DisplayList) SetBlendColor ¶
func (dl *DisplayList) SetBlendColor(c color.Color)
func (*DisplayList) SetColorImage ¶
func (dl *DisplayList) SetColorImage(img *texture.Texture)
Sets the framebuffer to render the final image into.
func (*DisplayList) SetCombineMode ¶
func (dl *DisplayList) SetCombineMode(m CombineMode)
func (*DisplayList) SetDepthImage ¶
func (dl *DisplayList) SetDepthImage(img *texture.Texture)
Sets the zbuffer. Width is taken from SetColorImage, bpp is always 18.
func (*DisplayList) SetEnvironmentColor ¶
func (dl *DisplayList) SetEnvironmentColor(c color.Color)
func (*DisplayList) SetFillColor ¶
func (dl *DisplayList) SetFillColor(c color.Color)
Sets the color for subsequent FillRectangle() calls.
func (*DisplayList) SetOtherModes ¶
func (dl *DisplayList) SetOtherModes( flags ModeFlags, ct CycleType, cDith RGBDither, aDith AlphaDither, zMode ZMode, cvgDest CvgDest, blend BlendMode, )
func (*DisplayList) SetPrimitiveColor ¶
func (dl *DisplayList) SetPrimitiveColor(c color.Color)
func (*DisplayList) SetScissor ¶
func (dl *DisplayList) SetScissor(r image.Rectangle, il InterlaceFrame)
Everything outside `r` is skipped when rendering. Additionally odd or even lines can be skipped to render interlaced frames.
func (*DisplayList) SetTextureImage ¶
func (dl *DisplayList) SetTextureImage(img *texture.Texture)
Sets the image where LoadTile and LoadBlock will copy their data from.
func (*DisplayList) SetTile ¶
func (dl *DisplayList) SetTile(ts TileDescriptor) (loadIdx, drawIdx uint8)
Sets a tile's properties. There are a total of eight tiles, identified by the Idx field, which can later be referenced in other commands, e.g. LoadTile().
func (*DisplayList) SetTileSize ¶
func (dl *DisplayList) SetTileSize(idx uint8, r image.Rectangle)
Tile size is automatically set on LoadTile(), but can be overidden with SetTileSize().
func (*DisplayList) TextureRectangle ¶
func (dl *DisplayList) TextureRectangle(r image.Rectangle, p image.Point, scale image.Point, tileIdx uint8)
Draws a textured rectangle.
type InterlaceFrame ¶
type InterlaceFrame uint64
const ( InterlaceNone InterlaceFrame = iota << 24 // draw all lines InterlaceOdd // skip odd lines InterlaceEven // skip even lines )
type ModeFlags ¶
type ModeFlags uint64
Mode flags for the SetOtherModes() command.
const ( AlphaCompare ModeFlags = 1 << iota DitherAlpha ZPerPrimitive // Use depth value from SetPrimitiveDepth instead per-pixel calculation AntiAlias ZCompare // Compare zbuffer ZUpdate // Update zbuffer ImageRead ColorOnCoverage CvgTimesAlphaVG ModeFlags = 1 << (iota + 4) AlphaCvgSelect ForceBlend ChromaKeying ModeFlags = 1 << (iota + 29) ConvertOne BiLerp1 BiLerp0 MidTexel SampleType TLUTType TLUT TextureLOD TextureSharpen TextureDetail TexturePerpective AtomicPrimitive = 1 << 55 )
type TileDescFlags ¶
type TileDescFlags uint64
const ( MirrorS TileDescFlags = 1 << 8 ClampS TileDescFlags = 1 << 9 MirrorT TileDescFlags = 1 << 18 ClampT TileDescFlags = 1 << 19 )