libctru  v1.6.0
Data Structures | Macros | Enumerations | Functions
gspgpu.h File Reference

GSPGPU service. More...

Go to the source code of this file.

Data Structures

struct  GSPGPU_FramebufferInfo
 Framebuffer information. More...
 
struct  GSPGPU_CaptureInfoEntry
 Capture info entry. More...
 
struct  GSPGPU_CaptureInfo
 Capture info. More...
 

Macros

#define GSPGPU_REBASE_REG(r)   ((r)-0x1EB00000)
 
#define gspWaitForPSC0()   gspWaitForEvent(GSPGPU_EVENT_PSC0, false)
 Waits for PSC0.
 
#define gspWaitForPSC1()   gspWaitForEvent(GSPGPU_EVENT_PSC1, false)
 Waits for PSC1.
 
#define gspWaitForVBlank()   gspWaitForVBlank0()
 Waits for VBlank.
 
#define gspWaitForVBlank0()   gspWaitForEvent(GSPGPU_EVENT_VBlank0, true)
 Waits for VBlank0.
 
#define gspWaitForVBlank1()   gspWaitForEvent(GSPGPU_EVENT_VBlank1, true)
 Waits for VBlank1.
 
#define gspWaitForPPF()   gspWaitForEvent(GSPGPU_EVENT_PPF, false)
 Waits for PPF.
 
#define gspWaitForP3D()   gspWaitForEvent(GSPGPU_EVENT_P3D, false)
 Waits for P3D.
 
#define gspWaitForDMA()   gspWaitForEvent(GSPGPU_EVENT_DMA, false)
 Waits for DMA.
 

Enumerations

enum  GSPGPU_FramebufferFormats {
  GSP_RGBA8_OES =0,
  GSP_BGR8_OES =1,
  GSP_RGB565_OES =2,
  GSP_RGB5_A1_OES =3,
  GSP_RGBA4_OES =4
}
 Framebuffer format. More...
 
enum  GSPGPU_Event {
  GSPGPU_EVENT_PSC0 = 0,
  GSPGPU_EVENT_PSC1,
  GSPGPU_EVENT_VBlank0,
  GSPGPU_EVENT_VBlank1,
  GSPGPU_EVENT_PPF,
  GSPGPU_EVENT_P3D,
  GSPGPU_EVENT_DMA,
  GSPGPU_EVENT_MAX
}
 GSPGPU events. More...
 

Functions

Result gspInit (void)
 Initializes GSPGPU.
 
void gspExit (void)
 Exits GSPGPU.
 
void gspSetEventCallback (GSPGPU_Event id, ThreadFunc cb, void *data, bool oneShot)
 Configures a callback to run when a GSPGPU event occurs. More...
 
Result gspInitEventHandler (Handle gspEvent, vu8 *gspSharedMem, u8 gspThreadId)
 Initializes the GSPGPU event handler. More...
 
void gspExitEventHandler (void)
 Exits the GSPGPU event handler.
 
void gspWaitForEvent (GSPGPU_Event id, bool nextEvent)
 Waits for a GSPGPU event to occur. More...
 
GSPGPU_Event gspWaitForAnyEvent (void)
 Waits for any GSPGPU event to occur. More...
 
Result gspSubmitGxCommand (u32 *sharedGspCmdBuf, u32 gxCommand[0x8])
 Submits a GX command. More...
 
Result GSPGPU_AcquireRight (u8 flags)
 Acquires GPU rights. More...
 
Result GSPGPU_ReleaseRight (void)
 Releases GPU rights.
 
Result GSPGPU_ImportDisplayCaptureInfo (GSPGPU_CaptureInfo *captureinfo)
 Retrieves display capture info. More...
 
Result GSPGPU_SaveVramSysArea (void)
 Sames the VRAM sys area.
 
Result GSPGPU_RestoreVramSysArea (void)
 Restores the VRAM sys area.
 
Result GSPGPU_SetLcdForceBlack (u8 flags)
 Sets whether to force the LCD to black. More...
 
Result GSPGPU_SetBufferSwap (u32 screenid, GSPGPU_FramebufferInfo *framebufinfo)
 Updates a screen's framebuffer state. More...
 
Result GSPGPU_FlushDataCache (const void *adr, u32 size)
 Flushes memory from the data cache. More...
 
Result GSPGPU_InvalidateDataCache (const void *adr, u32 size)
 Invalidates memory in the data cache. More...
 
Result GSPGPU_WriteHWRegs (u32 regAddr, u32 *data, u8 size)
 Writes to GPU hardware registers. More...
 
Result GSPGPU_WriteHWRegsWithMask (u32 regAddr, u32 *data, u8 datasize, u32 *maskdata, u8 masksize)
 Writes to GPU hardware registers with a mask. More...
 
Result GSPGPU_ReadHWRegs (u32 regAddr, u32 *data, u8 size)
 Reads from GPU hardware registers. More...
 
Result GSPGPU_RegisterInterruptRelayQueue (Handle eventHandle, u32 flags, Handle *outMemHandle, u8 *threadID)
 Registers the interrupt relay queue. More...
 
Result GSPGPU_UnregisterInterruptRelayQueue (void)
 Unregisters the interrupt relay queue.
 
Result GSPGPU_TriggerCmdReqQueue (void)
 Triggers a handling of commands written to shared memory.
 
Result GSPGPU_SetLedForceOff (bool disable)
 Sets 3D_LEDSTATE to the input state value. More...
 

Detailed Description

GSPGPU service.

Enumeration Type Documentation

◆ GSPGPU_Event

GSPGPU events.

Enumerator
GSPGPU_EVENT_PSC0 

Memory fill completed.

GSPGPU_EVENT_PSC1 

TODO.

GSPGPU_EVENT_VBlank0 

TODO.

GSPGPU_EVENT_VBlank1 

TODO.

GSPGPU_EVENT_PPF 

Display transfer finished.

GSPGPU_EVENT_P3D 

Command list processing finished.

GSPGPU_EVENT_DMA 

TODO.

GSPGPU_EVENT_MAX 

Used to know how many events there are.

◆ GSPGPU_FramebufferFormats

Framebuffer format.

Enumerator
GSP_RGBA8_OES 

RGBA8. (4 bytes)

GSP_BGR8_OES 

BGR8. (3 bytes)

GSP_RGB565_OES 

RGB565. (2 bytes)

GSP_RGB5_A1_OES 

RGB5A1. (2 bytes)

GSP_RGBA4_OES 

RGBA4. (2 bytes)

Function Documentation

◆ GSPGPU_AcquireRight()

Result GSPGPU_AcquireRight ( u8  flags)

Acquires GPU rights.

Parameters
flagsFlags to acquire with.

◆ GSPGPU_FlushDataCache()

Result GSPGPU_FlushDataCache ( const void *  adr,
u32  size 
)

Flushes memory from the data cache.

Parameters
adrAddress to flush.
sizeSize of the memory to flush.
Examples
audio/mic/source/main.c, and mvd/source/main.c.

◆ GSPGPU_ImportDisplayCaptureInfo()

Result GSPGPU_ImportDisplayCaptureInfo ( GSPGPU_CaptureInfo captureinfo)

Retrieves display capture info.

Parameters
captureinfoPointer to output capture info to.

◆ GSPGPU_InvalidateDataCache()

Result GSPGPU_InvalidateDataCache ( const void *  adr,
u32  size 
)

Invalidates memory in the data cache.

Parameters
adrAddress to invalidate.
sizeSize of the memory to invalidate.

◆ GSPGPU_ReadHWRegs()

Result GSPGPU_ReadHWRegs ( u32  regAddr,
u32 data,
u8  size 
)

Reads from GPU hardware registers.

Parameters
regAddrRegister address to read from.
dataBuffer to read data to.
sizeSize of the buffer.

◆ GSPGPU_RegisterInterruptRelayQueue()

Result GSPGPU_RegisterInterruptRelayQueue ( Handle  eventHandle,
u32  flags,
Handle outMemHandle,
u8 threadID 
)

Registers the interrupt relay queue.

Parameters
eventHandleHandle of the GX command event.
flagsFlags to register with.
outMemHandlePointer to output the shared memory handle to.
threadIDPointer to output the GSP thread ID to.

◆ GSPGPU_SetBufferSwap()

Result GSPGPU_SetBufferSwap ( u32  screenid,
GSPGPU_FramebufferInfo framebufinfo 
)

Updates a screen's framebuffer state.

Parameters
screenidID of the screen to update.
framebufinfoFramebuffer information to update with.

◆ GSPGPU_SetLcdForceBlack()

Result GSPGPU_SetLcdForceBlack ( u8  flags)

Sets whether to force the LCD to black.

Parameters
flagsWhether to force the LCD to black. (0 = no, non-zero = yes)

◆ GSPGPU_SetLedForceOff()

Result GSPGPU_SetLedForceOff ( bool  disable)

Sets 3D_LEDSTATE to the input state value.

Parameters
disableFalse = 3D LED enable, true = 3D LED disable.

◆ GSPGPU_WriteHWRegs()

Result GSPGPU_WriteHWRegs ( u32  regAddr,
u32 data,
u8  size 
)

Writes to GPU hardware registers.

Parameters
regAddrRegister address to write to.
dataData to write.
sizeSize of the data to write.

◆ GSPGPU_WriteHWRegsWithMask()

Result GSPGPU_WriteHWRegsWithMask ( u32  regAddr,
u32 data,
u8  datasize,
u32 maskdata,
u8  masksize 
)

Writes to GPU hardware registers with a mask.

Parameters
regAddrRegister address to write to.
dataData to write.
datasizeSize of the data to write.
maskdataData of the mask.
masksizeSize of the mask.

◆ gspInitEventHandler()

Result gspInitEventHandler ( Handle  gspEvent,
vu8 gspSharedMem,
u8  gspThreadId 
)

Initializes the GSPGPU event handler.

Parameters
gspEventEvent handle to use.
gspSharedMemGSP shared memory.
gspThreadIdID of the GSP thread.

◆ gspSetEventCallback()

void gspSetEventCallback ( GSPGPU_Event  id,
ThreadFunc  cb,
void *  data,
bool  oneShot 
)

Configures a callback to run when a GSPGPU event occurs.

Parameters
idID of the event.
cbCallback to run.
dataData to be passed to the callback.
oneShotWhen true, the callback is only executed once. When false, the callback is executed every time the event occurs.

◆ gspSubmitGxCommand()

Result gspSubmitGxCommand ( u32 sharedGspCmdBuf,
u32  gxCommand[0x8] 
)

Submits a GX command.

Parameters
sharedGspCmdBufCommand buffer to use.
gxCommandGX command to execute.

◆ gspWaitForAnyEvent()

GSPGPU_Event gspWaitForAnyEvent ( void  )

Waits for any GSPGPU event to occur.

Returns
The ID of the event that occurred.

The function returns immediately if there are unprocessed events at the time of call.

◆ gspWaitForEvent()

void gspWaitForEvent ( GSPGPU_Event  id,
bool  nextEvent 
)

Waits for a GSPGPU event to occur.

Parameters
idID of the event.
nextEventWhether to discard the current event and wait for the next event.
Examples
sdmc/source/main.c.