libctru  v2.3.1
Data Structures | Macros | Enumerations | Functions
gx.h File Reference

GX commands. More...

Go to the source code of this file.

Data Structures

union  gxCmdEntry_s
 GX command entry. More...
 
struct  gxCmdQueue_s
 GX command queue structure. More...
 

Macros

#define GX_BUFFER_DIM(w, h)   (((h)<<16)|((w)&0xFFFF))
 Creates a buffer dimension parameter from width and height values. More...
 
#define GX_TRANSFER_FLIP_VERT(x)   ((x)<<0)
 Creates a transfer vertical flip flag.
 
#define GX_TRANSFER_OUT_TILED(x)   ((x)<<1)
 Creates a transfer tiled output flag.
 
#define GX_TRANSFER_RAW_COPY(x)   ((x)<<3)
 Creates a transfer raw copy flag.
 
#define GX_TRANSFER_IN_FORMAT(x)   ((x)<<8)
 Creates a transfer input format flag.
 
#define GX_TRANSFER_OUT_FORMAT(x)   ((x)<<12)
 Creates a transfer output format flag.
 
#define GX_TRANSFER_SCALING(x)   ((x)<<24)
 Creates a transfer scaling flag.
 
#define GX_CMDLIST_UPDATE_GAS_ACC   BIT(0)
 Updates gas additive blend results.
 
#define GX_CMDLIST_FLUSH   BIT(1)
 Flushes the command list.
 

Enumerations

enum  GX_TRANSFER_FORMAT {
  GX_TRANSFER_FMT_RGBA8 = 0 ,
  GX_TRANSFER_FMT_RGB8 = 1 ,
  GX_TRANSFER_FMT_RGB565 = 2 ,
  GX_TRANSFER_FMT_RGB5A1 = 3 ,
  GX_TRANSFER_FMT_RGBA4 = 4
}
 Supported transfer pixel formats. More...
 
enum  GX_TRANSFER_SCALE {
  GX_TRANSFER_SCALE_NO = 0 ,
  GX_TRANSFER_SCALE_X = 1 ,
  GX_TRANSFER_SCALE_XY = 2
}
 Anti-aliasing modes. More...
 
enum  GX_FILL_CONTROL {
  GX_FILL_TRIGGER = 0x001 ,
  GX_FILL_FINISHED = 0x002 ,
  GX_FILL_16BIT_DEPTH = 0x000 ,
  GX_FILL_24BIT_DEPTH = 0x100 ,
  GX_FILL_32BIT_DEPTH = 0x200
}
 GX transfer control flags. More...
 

Functions

void gxCmdQueueClear (gxCmdQueue_s *queue)
 Clears a GX command queue. More...
 
void gxCmdQueueAdd (gxCmdQueue_s *queue, const gxCmdEntry_s *entry)
 Adds a command to a GX command queue. More...
 
void gxCmdQueueRun (gxCmdQueue_s *queue)
 Runs a GX command queue, causing it to begin processing incoming commands as they arrive. More...
 
void gxCmdQueueStop (gxCmdQueue_s *queue)
 Stops a GX command queue from processing incoming commands. More...
 
bool gxCmdQueueWait (gxCmdQueue_s *queue, s64 timeout)
 Waits for a GX command queue to finish executing pending commands. More...
 
static void gxCmdQueueSetCallback (gxCmdQueue_s *queue, void(*callback)(gxCmdQueue_s *), void *user)
 Sets the completion callback for a GX command queue. More...
 
void GX_BindQueue (gxCmdQueue_s *queue)
 Selects a command queue to which GX_* functions will add commands instead of immediately submitting them to GX. More...
 
Result GX_RequestDma (u32 *src, u32 *dst, u32 length)
 Requests a DMA. More...
 
Result GX_ProcessCommandList (u32 *buf0a, u32 buf0s, u8 flags)
 Processes a GPU command list. More...
 
Result GX_MemoryFill (u32 *buf0a, u32 buf0v, u32 *buf0e, u16 control0, u32 *buf1a, u32 buf1v, u32 *buf1e, u16 control1)
 Fills the memory of two buffers with the given values. More...
 
Result GX_DisplayTransfer (u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 flags)
 Initiates a display transfer. More...
 
Result GX_TextureCopy (u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 size, u32 flags)
 Initiates a texture copy. More...
 
Result GX_FlushCacheRegions (u32 *buf0a, u32 buf0s, u32 *buf1a, u32 buf1s, u32 *buf2a, u32 buf2s)
 Flushes the cache regions of three buffers. More...
 

Detailed Description

GX commands.

Macro Definition Documentation

◆ GX_BUFFER_DIM

#define GX_BUFFER_DIM (   w,
 
)    (((h)<<16)|((w)&0xFFFF))

Creates a buffer dimension parameter from width and height values.

Parameters
wbuffer width for GX_DisplayTransfer, linesize for GX_TextureCopy
hbuffer height for GX_DisplayTransfer, gap for GX_TextureCopy

Enumeration Type Documentation

◆ GX_FILL_CONTROL

GX transfer control flags.

Enumerator
GX_FILL_TRIGGER 

Trigger the PPF event.

GX_FILL_FINISHED 

Indicates if the memory fill is complete. You should not use it when requesting a transfer.

GX_FILL_16BIT_DEPTH 

The buffer has a 16 bit per pixel depth.

GX_FILL_24BIT_DEPTH 

The buffer has a 24 bit per pixel depth.

GX_FILL_32BIT_DEPTH 

The buffer has a 32 bit per pixel depth.

◆ GX_TRANSFER_FORMAT

Supported transfer pixel formats.

See also
GSPGPU_FramebufferFormat
Enumerator
GX_TRANSFER_FMT_RGBA8 

8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha

GX_TRANSFER_FMT_RGB8 

8-bit Red + 8-bit Green + 8-bit Blue

GX_TRANSFER_FMT_RGB565 

5-bit Red + 6-bit Green + 5-bit Blue

GX_TRANSFER_FMT_RGB5A1 

5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha

GX_TRANSFER_FMT_RGBA4 

4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha

◆ GX_TRANSFER_SCALE

Anti-aliasing modes.

Please remember that the framebuffer is sideways. Hence if you activate 2x1 anti-aliasing the destination dimensions are w = 240*2 and h = 400

Enumerator
GX_TRANSFER_SCALE_NO 

No anti-aliasing.

GX_TRANSFER_SCALE_X 

2x1 anti-aliasing

GX_TRANSFER_SCALE_XY 

2x2 anti-aliasing

Function Documentation

◆ GX_BindQueue()

void GX_BindQueue ( gxCmdQueue_s queue)

Selects a command queue to which GX_* functions will add commands instead of immediately submitting them to GX.

Parameters
queueThe GX command queue. (Pass NULL to remove the bound command queue)

◆ GX_DisplayTransfer()

Result GX_DisplayTransfer ( u32 inadr,
u32  indim,
u32 outadr,
u32  outdim,
u32  flags 
)

Initiates a display transfer.

Note
The PPF event will be signaled on completion.
Parameters
inadrAddress of the input.
indimDimensions of the input.
outadrAddress of the output.
outdimDimensions of the output.
flagsFlags to transfer with.

◆ GX_FlushCacheRegions()

Result GX_FlushCacheRegions ( u32 buf0a,
u32  buf0s,
u32 buf1a,
u32  buf1s,
u32 buf2a,
u32  buf2s 
)

Flushes the cache regions of three buffers.

(This command cannot be queued in a GX command queue)

Parameters
buf0aAddress of the first buffer.
buf0sSize of the first buffer.
buf1aAddress of the second buffer.
buf1sSize of the second buffer.
buf2aAddress of the third buffer.
buf2sSize of the third buffer.

◆ GX_MemoryFill()

Result GX_MemoryFill ( u32 buf0a,
u32  buf0v,
u32 buf0e,
u16  control0,
u32 buf1a,
u32  buf1v,
u32 buf1e,
u16  control1 
)

Fills the memory of two buffers with the given values.

Parameters
buf0aStart address of the first buffer.
buf0vDimensions of the first buffer.
buf0eEnd address of the first buffer.
control0Value to fill the first buffer with.
buf1aStart address of the second buffer.
buf1vDimensions of the second buffer.
buf1eEnd address of the second buffer.
control1Value to fill the second buffer with.

◆ GX_ProcessCommandList()

Result GX_ProcessCommandList ( u32 buf0a,
u32  buf0s,
u8  flags 
)

Processes a GPU command list.

Parameters
buf0aCommand list address.
buf0sCommand list size.
flagsFlags to process with.

◆ GX_RequestDma()

Result GX_RequestDma ( u32 src,
u32 dst,
u32  length 
)

Requests a DMA.

Parameters
srcSource to DMA from.
dstDestination to DMA to.
lengthLength of data to transfer.

◆ GX_TextureCopy()

Result GX_TextureCopy ( u32 inadr,
u32  indim,
u32 outadr,
u32  outdim,
u32  size,
u32  flags 
)

Initiates a texture copy.

Note
The PPF event will be signaled on completion.
Parameters
inadrAddress of the input.
indimDimensions of the input.
outadrAddress of the output.
outdimDimensions of the output.
sizeSize of the data to transfer.
flagsFlags to transfer with.

◆ gxCmdQueueAdd()

void gxCmdQueueAdd ( gxCmdQueue_s queue,
const gxCmdEntry_s entry 
)

Adds a command to a GX command queue.

Parameters
queueThe GX command queue.
entryThe GX command to add.

◆ gxCmdQueueClear()

void gxCmdQueueClear ( gxCmdQueue_s queue)

Clears a GX command queue.

Parameters
queueThe GX command queue.

◆ gxCmdQueueRun()

void gxCmdQueueRun ( gxCmdQueue_s queue)

Runs a GX command queue, causing it to begin processing incoming commands as they arrive.

Parameters
queueThe GX command queue.

◆ gxCmdQueueSetCallback()

static void gxCmdQueueSetCallback ( gxCmdQueue_s queue,
void(*)(gxCmdQueue_s *)  callback,
void *  user 
)
inlinestatic

Sets the completion callback for a GX command queue.

Parameters
queueThe GX command queue.
callbackThe completion callback.
userUser data.

◆ gxCmdQueueStop()

void gxCmdQueueStop ( gxCmdQueue_s queue)

Stops a GX command queue from processing incoming commands.

Parameters
queueThe GX command queue.

◆ gxCmdQueueWait()

bool gxCmdQueueWait ( gxCmdQueue_s queue,
s64  timeout 
)

Waits for a GX command queue to finish executing pending commands.

Parameters
queueThe GX command queue.
timeoutOptional timeout (in nanoseconds) to wait (specify -1 for no timeout).
Returns
false if timeout expired, true otherwise.