rdp

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: BSD-3-Clause Imports: 11 Imported by: 1

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

View Source
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

func Busy

func Busy() (cmd, pipe, tmem uint32)

Busy returns the number of GCLK cycles in which the specified component was busy since the last call to Busy.

func MaxTileSize

func MaxTileSize(format texture.Format) image.Rectangle

MaxTileSize returns the largest tile that fits into TMEM for the given bitdepth.

Types

type AlphaDither

type AlphaDither uint64
const (
	AlphaDitherPattern AlphaDither = iota << 36
	AlphaDitherInvPattern
	AlphaDitherNoise
	AlphaDitherNone
)

type BlendMode

type BlendMode struct {
	P1, P2 BlenderPM
	M1, M2 BlenderPM
	A1, A2 BlenderA
	B1, B2 BlenderB
}

type BlenderA

type BlenderA uint64
const (
	BlenderAColorCombinerAlpha BlenderA = iota
	BlenderAFogAlpha
	BlenderAShadeAlpha
	BlenderAZero
)

type BlenderB

type BlenderB uint64
const (
	BlenderBOneMinusAlphaA BlenderB = iota
	BlenderBFramebufferCvg
	BlenderBOne
	BlenderBZero
)

type BlenderPM

type BlenderPM uint64
const (
	BlenderPMColorCombiner BlenderPM = iota
	BlenderPMFramebuffer
	BlenderPMBlendColor
	BlenderPMFogColor
)

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 CvgDest

type CvgDest uint64
const (
	CvgDestClamp CvgDest = iota << 8
	CvgDestWrap
	CvgDestZap
	CvgDestSave
)

type CycleType

type CycleType uint64
const (
	CycleTypeOne CycleType = iota << 52
	CycleTypeTwo
	CycleTypeCopy
	CycleTypeFill
)

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 RGBDither

type RGBDither uint64
const (
	RGBDitherMagicSquare RGBDither = iota << 38
	RGBDitherBayer
	RGBDitherNoise
	RGBDitherNone
)

type TileDescFlags

type TileDescFlags uint64
const (
	MirrorS TileDescFlags = 1 << 8
	ClampS  TileDescFlags = 1 << 9
	MirrorT TileDescFlags = 1 << 18
	ClampT  TileDescFlags = 1 << 19
)

type TileDescriptor

type TileDescriptor struct {
	Format texture.Format
	Line   uint16 // 9 bit; line length in qwords
	Addr   uint16 // 9 bit; TMEM address in qwords

	Palette        uint8 // 4 bit; Palette index
	MaskT, MaskS   uint8 // 4 bit
	ShiftT, ShiftS uint8 // 4 bit
	Flags          TileDescFlags
	// contains filtered or unexported fields
}

type ZMode

type ZMode uint64
const (
	ZmodeOpaque ZMode = iota << 10
	ZmodeInterpenetrating
	ZmodeTransparent
	ZmodeDecal
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL