citro3d
Macros | Functions | Variables
uniforms.h File Reference

Write to shader uniforms. More...

#include "maths.h"

Go to the source code of this file.

Macros

#define C3D_FVUNIF_COUNT   96
 
#define C3D_IVUNIF_COUNT   4
 

Functions

static C3D_FVecC3D_FVUnifWritePtr (GPU_SHADER_TYPE type, int id, int size)
 Provides a writable pointer for a floating-point uniform. More...
 
static C3D_IVecC3D_IVUnifWritePtr (GPU_SHADER_TYPE type, int id)
 Provides a writable pointer for an integer uniform. More...
 
static void C3D_FVUnifMtxNx4 (GPU_SHADER_TYPE type, int id, const C3D_Mtx *mtx, int num)
 Writes an Nx4 matrix to the uniform registers. More...
 
static void C3D_FVUnifMtx4x4 (GPU_SHADER_TYPE type, int id, const C3D_Mtx *mtx)
 Writes a 4x4 matrix to the uniform registers. More...
 
static void C3D_FVUnifMtx3x4 (GPU_SHADER_TYPE type, int id, const C3D_Mtx *mtx)
 Writes a 3x4 matrix to the uniform registers. More...
 
static void C3D_FVUnifMtx2x4 (GPU_SHADER_TYPE type, int id, const C3D_Mtx *mtx)
 Writes a 2x4 matrix to the uniform registers. More...
 
static void C3D_FVUnifSet (GPU_SHADER_TYPE type, int id, float x, float y, float z, float w)
 Writes a 4-component floating-point vector to the uniform registers. More...
 
static void C3D_IVUnifSet (GPU_SHADER_TYPE type, int id, int x, int y, int z, int w)
 Writes a 4-component integer vector to the uniform registers. More...
 
static void C3D_BoolUnifSet (GPU_SHADER_TYPE type, int id, bool value)
 Writes a boolean value to the uniform registers. More...
 
void C3D_UpdateUniforms (GPU_SHADER_TYPE type)
 Flushes newly-updated uniforms to the uniform registers. More...
 

Variables

C3D_FVec C3D_FVUnif [2][96]
 
C3D_IVec C3D_IVUnif [2][4]
 
u16 C3D_BoolUnifs [2]
 
bool C3D_FVUnifDirty [2][96]
 
bool C3D_IVUnifDirty [2][4]
 
bool C3D_BoolUnifsDirty [2]
 

Detailed Description

Write to shader uniforms.

Function Documentation

◆ C3D_BoolUnifSet()

static void C3D_BoolUnifSet ( GPU_SHADER_TYPE  type,
int  id,
bool  value 
)
inlinestatic

Writes a boolean value to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]valueBoolean value to write.

◆ C3D_FVUnifMtx2x4()

static void C3D_FVUnifMtx2x4 ( GPU_SHADER_TYPE  type,
int  id,
const C3D_Mtx mtx 
)
inlinestatic

Writes a 2x4 matrix to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]mtxMatrix to be written.

◆ C3D_FVUnifMtx3x4()

static void C3D_FVUnifMtx3x4 ( GPU_SHADER_TYPE  type,
int  id,
const C3D_Mtx mtx 
)
inlinestatic

Writes a 3x4 matrix to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]mtxMatrix to be written.

◆ C3D_FVUnifMtx4x4()

static void C3D_FVUnifMtx4x4 ( GPU_SHADER_TYPE  type,
int  id,
const C3D_Mtx mtx 
)
inlinestatic

Writes a 4x4 matrix to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]mtxMatrix to be written.

◆ C3D_FVUnifMtxNx4()

static void C3D_FVUnifMtxNx4 ( GPU_SHADER_TYPE  type,
int  id,
const C3D_Mtx mtx,
int  num 
)
inlinestatic

Writes an Nx4 matrix to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]mtxMatrix to be written.
[in]numRow count of the matrix.
Remarks
Usually, one should use the helper functions for 4x4, 3x4, and 2x4 matrices listed below.

◆ C3D_FVUnifSet()

static void C3D_FVUnifSet ( GPU_SHADER_TYPE  type,
int  id,
float  x,
float  y,
float  z,
float  w 
)
inlinestatic

Writes a 4-component floating-point vector to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]xX component of the vector.
[in]yY component of the vector.
[in]zZ component of the vector.
[in]wW component of the vector.

◆ C3D_FVUnifWritePtr()

static C3D_FVec* C3D_FVUnifWritePtr ( GPU_SHADER_TYPE  type,
int  id,
int  size 
)
inlinestatic

Provides a writable pointer for a floating-point uniform.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]sizeNumber of registers allocated for this uniform.
Returns
Writable pointer. This should not be freed.

◆ C3D_IVUnifSet()

static void C3D_IVUnifSet ( GPU_SHADER_TYPE  type,
int  id,
int  x,
int  y,
int  z,
int  w 
)
inlinestatic

Writes a 4-component integer vector to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
[in]xX component of the vector.
[in]yY component of the vector.
[in]zZ component of the vector.
[in]wW component of the vector.

◆ C3D_IVUnifWritePtr()

static C3D_IVec* C3D_IVUnifWritePtr ( GPU_SHADER_TYPE  type,
int  id 
)
inlinestatic

Provides a writable pointer for an integer uniform.

Parameters
[in]typeGPU_SHADER_TYPE of the uniform to be set.
[in]idID of the uniform (retrievable using libctru's shaderInstanceGetUniformLocation())
Returns
Writable pointer. This should not be freed.

◆ C3D_UpdateUniforms()

void C3D_UpdateUniforms ( GPU_SHADER_TYPE  type)

Flushes newly-updated uniforms to the uniform registers.

Parameters
[in]typeGPU_SHADER_TYPE of the uniforms to be flushed.
Remarks
This is called internally, and generally does not need to be handled by the user.