citro3d
Data Structures | Macros | Typedefs | Enumerations | Functions
renderqueue.h File Reference

Set up rendertarget and render frame. More...

#include "framebuffer.h"

Go to the source code of this file.

Data Structures

struct  C3D_RenderTarget_tag
 
union  C3D_DEPTHTYPE
 

Macros

#define C3D_DEPTHTYPE_OK(_x)   ((_x).__i >= 0)
 
#define C3D_DEPTHTYPE_VAL(_x)   ((_x).__e)
 

Typedefs

typedef struct C3D_RenderTarget_tag C3D_RenderTarget
 Render target structure.
 

Enumerations

enum  {
  C3D_FRAME_SYNCDRAW = BIT(0) ,
  C3D_FRAME_NONBLOCK = BIT(1)
}
 Flags for C3D_FrameBegin. More...
 

Functions

float C3D_FrameRate (float fps)
 Specifies framerate cap. Specifies target framerate for C3D_FrameSync(). More...
 
void C3D_FrameSync (void)
 Performs framerate limiting. Waits for the required amount of vblanks specified by C3D_FrameRate(). More...
 
u32 C3D_FrameCounter (int id)
 Returns total number of frames drawn. More...
 
bool C3D_FrameBegin (u8 flags)
 Begins drawing frame. More...
 
bool C3D_FrameDrawOn (C3D_RenderTarget *target)
 Specifies render target to draw frame to. More...
 
void C3D_FrameSplit (u8 flags)
 Splits and submits the GPU cmdlist in the middle of a renderqueue frame. More...
 
void C3D_FrameEnd (u8 flags)
 Ends drawing frame. More...
 
void C3D_FrameEndHook (void(*hook)(void *), void *param)
 Executes callback upon C3D_FrameEnd(). More...
 
float C3D_GetDrawingTime (void)
 Gets time spent by the GPU during last render. More...
 
float C3D_GetProcessingTime (void)
 Gets time elapsed between last C3D_FrameBegin() and C3D_FrameEnd(). More...
 
C3D_RenderTargetC3D_RenderTargetCreate (int width, int height, GPU_COLORBUF colorFmt, C3D_DEPTHTYPE depthFmt)
 Creates a new render target. More...
 
C3D_RenderTargetC3D_RenderTargetCreateFromTex (C3D_Tex *tex, GPU_TEXFACE face, int level, C3D_DEPTHTYPE depthFmt)
 Constructs render target for texture. More...
 
void C3D_RenderTargetDelete (C3D_RenderTarget *target)
 Deletes render target. More...
 
void C3D_RenderTargetSetOutput (C3D_RenderTarget *target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags)
 Sets render target output to screen. More...
 
static void C3D_RenderTargetDetachOutput (C3D_RenderTarget *target)
 Detaches render target from screen output. More...
 
static void C3D_RenderTargetClear (C3D_RenderTarget *target, C3D_ClearBits clearBits, u32 clearColor, u32 clearDepth)
 Clears framebuffer of target. More...
 
void C3D_SyncDisplayTransfer (u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 flags)
 Synchronizes and initiates a display transfer. Synchronizes and initiates a GX_DisplayTransfer(). More...
 
void C3D_SyncTextureCopy (u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 size, u32 flags)
 Synchronizes and initiates a texture copy. Synchronizes and initiates a GX_TextureCopy(). More...
 
void C3D_SyncMemoryFill (u32 *buf0a, u32 buf0v, u32 *buf0e, u16 control0, u32 *buf1a, u32 buf1v, u32 *buf1e, u16 control1)
 Synchronizes and fills the memory of two buffers with the given values. Synchronizes and initiates a GX_MemoryFill(). More...
 

Detailed Description

Set up rendertarget and render frame.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Flags for C3D_FrameBegin.

Enumerator
C3D_FRAME_SYNCDRAW 

Perform C3D_FrameSync() before checking the GPU status.

C3D_FRAME_NONBLOCK 

Return false instead of waiting if the GPU is busy.

Function Documentation

◆ C3D_FrameBegin()

bool C3D_FrameBegin ( u8  flags)

Begins drawing frame.

Parameters
[in]flagsSpecifies options for rendering; 0 or more flags may be provided. C3D_FRAME_SYNCDRAW specifies that C3D_FrameSync() should be performed before checking the GPU status, C3D_FRAME_NONBLOCK specifies that the function should return false instead of waiting for GPU to be ready.
Returns
True if frame began successfully, otherwise false.

◆ C3D_FrameCounter()

u32 C3D_FrameCounter ( int  id)

Returns total number of frames drawn.

Parameters
[in]idVblank frame counter id.
Returns
Total number of frames.

◆ C3D_FrameDrawOn()

bool C3D_FrameDrawOn ( C3D_RenderTarget target)

Specifies render target to draw frame to.

Parameters
[in]targetPointer to render target.
Returns
True if rendertarget was set successfully, otherwise false.

◆ C3D_FrameEnd()

void C3D_FrameEnd ( u8  flags)

Ends drawing frame.

Parameters
[in]flagsSpecifies 0 or more GX_CMDLIST flags.

◆ C3D_FrameEndHook()

void C3D_FrameEndHook ( void(*)(void *)  hook,
void *  param 
)

Executes callback upon C3D_FrameEnd().

Parameters
[in]hookFunction callback.
[in]paramUser data.

◆ C3D_FrameRate()

float C3D_FrameRate ( float  fps)

Specifies framerate cap. Specifies target framerate for C3D_FrameSync().

Parameters
[in]fpsSpecifies the target framerate. Must be between 0.0 and 60.0 fps.
Returns
Previous framerate.

◆ C3D_FrameSplit()

void C3D_FrameSplit ( u8  flags)

Splits and submits the GPU cmdlist in the middle of a renderqueue frame.

Parameters
[in]flagsSpecifies 0 or more GX_CMDLIST flags.

◆ C3D_FrameSync()

void C3D_FrameSync ( void  )

Performs framerate limiting. Waits for the required amount of vblanks specified by C3D_FrameRate().

Note
Used by C3D_FrameBegin() when using C3D_FRAME_SYNCDRAW.

◆ C3D_GetDrawingTime()

float C3D_GetDrawingTime ( void  )

Gets time spent by the GPU during last render.

Returns
Drawing time in milliseconds.

◆ C3D_GetProcessingTime()

float C3D_GetProcessingTime ( void  )

Gets time elapsed between last C3D_FrameBegin() and C3D_FrameEnd().

Returns
Time in milliseconds.

◆ C3D_RenderTargetClear()

static void C3D_RenderTargetClear ( C3D_RenderTarget target,
C3D_ClearBits  clearBits,
u32  clearColor,
u32  clearDepth 
)
inlinestatic

Clears framebuffer of target.

Parameters
[in]targetPointer to render target.
[in]clearBitsSpecifies which buffers to clear. (see C3D_ClearBits)
[in]clearColor32 bit RGBA value to clear color buffer with.
[in]clearDepthValue to clear depth buffer with.

◆ C3D_RenderTargetCreate()

C3D_RenderTarget* C3D_RenderTargetCreate ( int  width,
int  height,
GPU_COLORBUF  colorFmt,
C3D_DEPTHTYPE  depthFmt 
)

Creates a new render target.

Note
When creating a rendertarget intended for display, keep in mind the orientation of the screens. When you hold a 3DS normally, the screens are rotated 90 degrees counter-clockwise.
Parameters
[in]widthSpecifies width of the render target in pixels.
[in]heightSpecifies height of the render target in pixels.
[in]colorFmtSpecifies the color format of the render target.
[in]depthFmtSpecifies the depth format of the render target using GPU_DEPTHBUF. (-1 for no depth type)
Returns
Pointer to newly created render target.

◆ C3D_RenderTargetCreateFromTex()

C3D_RenderTarget* C3D_RenderTargetCreateFromTex ( C3D_Tex tex,
GPU_TEXFACE  face,
int  level,
C3D_DEPTHTYPE  depthFmt 
)

Constructs render target for texture.

Parameters
[in]texPointer to C3D_Tex.
[in]faceSpecifies face of cubemap to be used. (GPU_TEXFACE_2D if not cubemap)
[in]levelSpecifies mipmap level to use.
[in]depthFmtSpecifies the depth format of the render target using GPU_DEPTHBUF. (-1 for no depth type)
Returns
Pointer to newly created render target.

◆ C3D_RenderTargetDelete()

void C3D_RenderTargetDelete ( C3D_RenderTarget target)

Deletes render target.

Parameters
[in]targetPointer to render target.

◆ C3D_RenderTargetDetachOutput()

static void C3D_RenderTargetDetachOutput ( C3D_RenderTarget target)
inlinestatic

Detaches render target from screen output.

Parameters
[in]targetPointer to render target.

◆ C3D_RenderTargetSetOutput()

void C3D_RenderTargetSetOutput ( C3D_RenderTarget target,
gfxScreen_t  screen,
gfx3dSide_t  side,
u32  transferFlags 
)

Sets render target output to screen.

Parameters
[in]targetPointer to render target.
[in]screenScreen to transfer the framebuffer to.
[in]sideSide of the screen to transfer the framebuffer to. (unused for the bottom screen)
[in]transferFlagsSpecifies GX_TRANSFER bitflags.

◆ C3D_SyncDisplayTransfer()

void C3D_SyncDisplayTransfer ( u32 inadr,
u32  indim,
u32 outadr,
u32  outdim,
u32  flags 
)

Synchronizes and initiates a display transfer. Synchronizes and initiates a GX_DisplayTransfer().

Parameters
[in]inadrAddress of the input.
[in]indimGX_BUFFER_DIM() of the input.
[out]outadrAddress of the output.
[in]outdimGX_BUFFER_DIM() of the output.
[in]flagsFlags to transfer with.

◆ C3D_SyncMemoryFill()

void C3D_SyncMemoryFill ( u32 buf0a,
u32  buf0v,
u32 buf0e,
u16  control0,
u32 buf1a,
u32  buf1v,
u32 buf1e,
u16  control1 
)

Synchronizes and fills the memory of two buffers with the given values. Synchronizes and initiates a GX_MemoryFill().

Parameters
[in]buf0aStart address of the first buffer.
[in]buf0vValue to fill first buffer.
[in]buf0eEnd address of the first buffer.
[in]control0Value to fill the first buffer with.
[in]buf1aStart address of the second buffer.
[in]buf1vValue to fill second buffer.
[in]buf1eEnd address of the second buffer.
[in]control1Value to fill the second buffer with.

◆ C3D_SyncTextureCopy()

void C3D_SyncTextureCopy ( u32 inadr,
u32  indim,
u32 outadr,
u32  outdim,
u32  size,
u32  flags 
)

Synchronizes and initiates a texture copy. Synchronizes and initiates a GX_TextureCopy().

Parameters
[in]inadrAddress of the input.
[in]indimGX_BUFFER_DIM() of the input.
[out]outadrAddress of the output.
[in]outdimGX_BUFFER_DIM() of the output.
[in]sizeSize of the data to transfer.
[in]flagsFlags to transfer with.