Shader Programs
-
struct ShaderSource
- #include <dag_shader.h>
Holds a direct pointer to a (compressed) shader data in bindump Supports both compressed (if dictionary not nullptr) and uncompressed data.
Public Functions
-
const uint32_t *uncompress(Tab<uint8_t> &tmpbuf) const
Uncompresses the shader data, in case of no compression just copies it.
- Parameters:
tmpbuf – Temporary memory that will hold resulting shader data
- Returns:
Pointer to uncompressed shader data.
-
const uint32_t *uncompress(Tab<uint8_t> &tmpbuf) const
-
namespace d3d
Functions
-
PROGRAM create_program(VPROG vprog, FSHADER fsh, VDECL vdecl, unsigned *strides = nullptr, unsigned streams = 0)
Creates a program with a vertex shader, fragment shader, and vertex declaration.
If strides and streams are not set, they will be obtained from the vertex declaration. The program should be deleted externally using delete_program().
- Parameters:
vprog – The vertex shader program.
fsh – The fragment shader program.
vdecl – The vertex declaration.
strides – The stride values for each vertex stream (optional, default is 0).
streams – The number of vertex streams (optional, default is 0).
- Returns:
The created program.
-
PROGRAM create_program_cs(const ShaderSource &cs_native, CSPreloaded preloaded)
Creates a compute shader program with native code.
- Parameters:
cs_native – The native code for the compute shader.
preloaded – The preloaded data for the compute shader.
- Returns:
The created program.
-
bool set_program(PROGRAM program)
Sets the program as the current program, including the pixel shader, vertex shader, and vertex declaration.
- Parameters:
program – The program to set.
- Returns:
True if the program was set successfully, false otherwise.
-
void delete_program(PROGRAM program)
Deletes a program, including the vertex shader and fragment shader.
Warning
The vertex declaration should be deleted independently.
- Parameters:
program – The program to delete.
-
VPROG create_vertex_shader(const ShaderSource &native_code)
Creates a vertex shader with native code.
- Parameters:
native_code – The native code for the vertex shader.
- Returns:
The created vertex shader.
-
void delete_vertex_shader(VPROG vs)
Deletes a vertex shader.
- Parameters:
vs – The vertex shader to delete.
-
FSHADER create_pixel_shader(const ShaderSource &native_code)
Creates a pixel shader with native code.
- Parameters:
native_code – The native code for the pixel shader.
- Returns:
The created pixel shader.
-
PROGRAM create_program(VPROG vprog, FSHADER fsh, VDECL vdecl, unsigned *strides = nullptr, unsigned streams = 0)