libctru  v2.4.1
Data Structures | Functions
shaderProgram.h File Reference

Functions for working with shaders. More...

#include <3ds/types.h>
#include <3ds/gpu/shbin.h>

Go to the source code of this file.

Data Structures

struct  float24Uniform_s
 24-bit float uniforms. More...
 
struct  shaderInstance_s
 Describes an instance of either a vertex or geometry shader. More...
 
struct  shaderProgram_s
 Describes an instance of a full shader program. More...
 

Functions

Result shaderInstanceInit (shaderInstance_s *si, DVLE_s *dvle)
 Initializes a shader instance. More...
 
Result shaderInstanceFree (shaderInstance_s *si)
 Frees a shader instance. More...
 
Result shaderInstanceSetBool (shaderInstance_s *si, int id, bool value)
 Sets a bool uniform of a shader. More...
 
Result shaderInstanceGetBool (shaderInstance_s *si, int id, bool *value)
 Gets a bool uniform of a shader. More...
 
s8 shaderInstanceGetUniformLocation (shaderInstance_s *si, const char *name)
 Gets the location of a shader's uniform. More...
 
Result shaderProgramInit (shaderProgram_s *sp)
 Initializes a shader program. More...
 
Result shaderProgramFree (shaderProgram_s *sp)
 Frees a shader program. More...
 
Result shaderProgramSetVsh (shaderProgram_s *sp, DVLE_s *dvle)
 Sets the vertex shader of a shader program. More...
 
Result shaderProgramSetGsh (shaderProgram_s *sp, DVLE_s *dvle, u8 stride)
 Sets the geometry shader of a shader program. More...
 
Result shaderProgramSetGshInputPermutation (shaderProgram_s *sp, u64 permutation)
 Configures the permutation of the input attributes of the geometry shader of a shader program. More...
 
Result shaderProgramConfigure (shaderProgram_s *sp, bool sendVshCode, bool sendGshCode)
 Configures the shader units to use the specified shader program. More...
 
Result shaderProgramUse (shaderProgram_s *sp)
 Same as shaderProgramConfigure, but always loading code/operand descriptors and uploading DVLE constants afterwards. More...
 

Detailed Description

Functions for working with shaders.

Function Documentation

◆ shaderInstanceFree()

Result shaderInstanceFree ( shaderInstance_s si)

Frees a shader instance.

Parameters
siShader instance to free.

◆ shaderInstanceGetBool()

Result shaderInstanceGetBool ( shaderInstance_s si,
int  id,
bool *  value 
)

Gets a bool uniform of a shader.

Parameters
siShader instance to use.
idID of the bool uniform.
valuePointer to output the value to.

◆ shaderInstanceGetUniformLocation()

s8 shaderInstanceGetUniformLocation ( shaderInstance_s si,
const char *  name 
)

◆ shaderInstanceInit()

Result shaderInstanceInit ( shaderInstance_s si,
DVLE_s dvle 
)

Initializes a shader instance.

Parameters
siShader instance to initialize.
dvleDVLE to initialize the shader instance with.

◆ shaderInstanceSetBool()

Result shaderInstanceSetBool ( shaderInstance_s si,
int  id,
bool  value 
)

Sets a bool uniform of a shader.

Parameters
siShader instance to use.
idID of the bool uniform.
valueValue to set.

◆ shaderProgramConfigure()

Result shaderProgramConfigure ( shaderProgram_s sp,
bool  sendVshCode,
bool  sendGshCode 
)

Configures the shader units to use the specified shader program.

Parameters
spShader program to use.
sendVshCodeWhen true, the vertex shader's code and operand descriptors are uploaded.
sendGshCodeWhen true, the geometry shader's code and operand descriptors are uploaded.

◆ shaderProgramFree()

Result shaderProgramFree ( shaderProgram_s sp)

◆ shaderProgramInit()

Result shaderProgramInit ( shaderProgram_s sp)

◆ shaderProgramSetGsh()

Result shaderProgramSetGsh ( shaderProgram_s sp,
DVLE_s dvle,
u8  stride 
)

Sets the geometry shader of a shader program.

Parameters
spShader program to use.
dvleGeometry shader to set.
strideInput stride of the shader (pass 0 to match the number of outputs of the vertex shader).
Examples
graphics/gpu/geoshader/source/main.c, graphics/gpu/loop_subdivision/source/main.c, and graphics/gpu/particles/source/main.c.

◆ shaderProgramSetGshInputPermutation()

Result shaderProgramSetGshInputPermutation ( shaderProgram_s sp,
u64  permutation 
)

Configures the permutation of the input attributes of the geometry shader of a shader program.

Parameters
spShader program to use.
permutationAttribute permutation to use.

◆ shaderProgramSetVsh()

Result shaderProgramSetVsh ( shaderProgram_s sp,
DVLE_s dvle 
)

◆ shaderProgramUse()

Result shaderProgramUse ( shaderProgram_s sp)

Same as shaderProgramConfigure, but always loading code/operand descriptors and uploading DVLE constants afterwards.

Parameters
spShader program to use.