Kohi Game Engine
|
A system to manage shaders. Respondible for working with the renderer to create, destroy, bind/unbind and set shader properties such as uniforms. More...
Go to the source code of this file.
Data Structures | |
struct | shader_system_config |
Configuration for the shader system. More... | |
Typedefs | |
typedef struct shader_system_config | shader_system_config |
Configuration for the shader system. More... | |
Functions | |
b8 | shader_system_initialize (u64 *memory_requirement, void *memory, void *config) |
Initializes the shader system using the supplied configuration. NOTE: Call this twice, once to obtain memory requirement (memory = 0) and a second time including allocated memory. More... | |
void | shader_system_shutdown (void *state) |
Shuts down the shader system. More... | |
KAPI khandle | shader_system_get (kname name, kname package_name) |
Returns a handle to a shader with the given name. Attempts to load the shader if not already loaded. More... | |
KAPI khandle | shader_system_get_from_source (kname name, const char *shader_config_source) |
Returns a handle to a shader with the given name based on the provided config source. Attempts to load the shader if not already loaded. More... | |
KAPI void | shader_system_destroy (khandle *shader) |
Attempts to destroy the shader with the given handle. Handle will be invalidated. More... | |
KAPI b8 | shader_system_set_wireframe (khandle shader, b8 wireframe_enabled) |
Attempts to set wireframe mode on the given shader. If the renderer backend, or the shader does not support this , it will fail when attempting to enable. Disabling will always succeed. More... | |
KAPI b8 | shader_system_use (khandle shader) |
Uses the shader with the given handle. More... | |
KAPI u16 | shader_system_uniform_location (khandle shader, kname uniform_name) |
Returns the uniform location for a uniform with the given name, if found. More... | |
KAPI b8 | shader_system_uniform_set (khandle shader, kname uniform_name, const void *value) |
Sets the value of a uniform with the given name to the supplied value. More... | |
KAPI b8 | shader_system_uniform_set_arrayed (khandle shader, kname uniform_name, u32 array_index, const void *value) |
Sets the value of an arrayed uniform with the given name to the supplied value. More... | |
KAPI b8 | shader_system_texture_set (khandle shader, kname sampler_name, ktexture t) |
Sets the texture uniform with the given name to the supplied texture. More... | |
KAPI b8 | shader_system_texture_set_arrayed (khandle shader, kname uniform_name, u32 array_index, ktexture t) |
Sets the arrayed texture uniform with the given name to the supplied texture at the given index. More... | |
KAPI b8 | shader_system_uniform_set_by_location (khandle shader, u16 location, const void *value) |
Sets a uniform value by location. More... | |
KAPI b8 | shader_system_uniform_set_by_location_arrayed (khandle shader, u16 location, u32 array_index, const void *value) |
Sets a uniform value by location. More... | |
KAPI b8 | shader_system_texture_set_by_location (khandle shader, u16 location, ktexture t) |
Sets a texture value by location. More... | |
KAPI b8 | shader_system_texture_set_by_location_arrayed (khandle shader, u16 location, u32 array_index, ktexture value) |
Sets a texture value by location. More... | |
KAPI b8 | shader_system_sampler_set_by_location_arrayed (khandle shader, u16 location, u32 array_index, ktexture t) |
Sets a sampler value by location. More... | |
KAPI b8 | shader_system_bind_frame (khandle shader) |
Binds the shader at per-frame frequency for use. Must be done before setting frame-scoped uniforms. More... | |
KAPI b8 | shader_system_bind_group (khandle shader, u32 group_id) |
Binds the instance with the given id for use. Must be done before setting instance-scoped uniforms. More... | |
KAPI b8 | shader_system_bind_draw_id (khandle shader, u32 draw_id) |
Binds the local with the given id for use. Must be done before setting local-scoped uniforms. More... | |
KAPI b8 | shader_system_apply_per_frame (khandle shader) |
Applies per-frame uniforms. More... | |
KAPI b8 | shader_system_apply_per_group (khandle shader) |
Applies per-group uniforms. More... | |
KAPI b8 | shader_system_apply_per_draw (khandle shader) |
Applies per-draw uniforms. Updates the generation pointed to. More... | |
KAPI b8 | shader_system_shader_group_acquire (khandle shader, u32 *out_group_id) |
Attempts to acquire new group resources from the given shader using the collection of maps passed. More... | |
KAPI b8 | shader_system_shader_group_release (khandle shader, u32 instance_id) |
Releases group resources and texture map resources from the provided shader. More... | |
KAPI b8 | shader_system_shader_per_draw_acquire (khandle shader, u32 *out_per_draw_id) |
Attempts to acquire new per-draw resources from the given shader using the collection of maps passed. More... | |
KAPI b8 | shader_system_shader_per_draw_release (khandle shader, u32 per_draw_id) |
Releases per-draw resources and texture map resources from the provided shader. More... | |
A system to manage shaders. Respondible for working with the renderer to create, destroy, bind/unbind and set shader properties such as uniforms.
typedef struct shader_system_config shader_system_config |
Configuration for the shader system.
Applies per-draw uniforms. Updates the generation pointed to.
shader | A handle to the shader to update. |
Applies per-frame uniforms.
shader | A handle to the shader to update. |
Applies per-group uniforms.
shader | A handle to the shader to update. |
Binds the local with the given id for use. Must be done before setting local-scoped uniforms.
shader | A handle to the shader to update. |
draw_id | The identifier of the per-draw resources to bind. |
Binds the shader at per-frame frequency for use. Must be done before setting frame-scoped uniforms.
shader | A handle to the shader to update. |
instance_id | The identifier of the instance to bind. |
Binds the instance with the given id for use. Must be done before setting instance-scoped uniforms.
shader | A handle to the shader to update. |
group_id | The identifier of the group to bind. |
Attempts to destroy the shader with the given handle. Handle will be invalidated.
shader_name | A pointer to a handle to the shader to destroy. Handle will be invalidated. |
Returns a handle to a shader with the given name. Attempts to load the shader if not already loaded.
shader_name | The kname to search for. |
package_name | The package to get the shader from if not already loaded. Pass INVALID_KNAME to search all packages. |
Returns a handle to a shader with the given name based on the provided config source. Attempts to load the shader if not already loaded.
shader_name | The name of the new shader. |
shader_config_source | A string containing the shader's configuration source as if it were loaded from an asset. |
Initializes the shader system using the supplied configuration. NOTE: Call this twice, once to obtain memory requirement (memory = 0) and a second time including allocated memory.
memory_requirement | A pointer to hold the memory requirement of this system in bytes. |
memory | A memory block to be used to hold the state of this system. Pass 0 on the first call to get memory requirement. |
config | The configuration (shader_system_config) to be used when initializing the system. |
KAPI b8 shader_system_sampler_set_by_location_arrayed | ( | khandle | shader, |
u16 | location, | ||
u32 | array_index, | ||
ktexture | t | ||
) |
Sets a sampler value by location.
shader | A handle to the shader to update. |
index | The location of the uniform. |
array_index | The index into the uniform array, if the uniform is in fact an array. Otherwise ignored. |
value | A pointer to the texture to be set. |
Attempts to set wireframe mode on the given shader. If the renderer backend, or the shader does not support this , it will fail when attempting to enable. Disabling will always succeed.
shader | A handle to the shader to set wireframe mode for. |
wireframe_enabled | Indicates if wireframe mode should be enabled. |
Attempts to acquire new group resources from the given shader using the collection of maps passed.
shader | A handle to the shader to acquire group resources for. |
out_group_id | A pointer to hold the group id once resources are acquired. |
Releases group resources and texture map resources from the provided shader.
shader | A handle to the shader to release group resources for. |
instance_id | The identifier of the group to release. |
Attempts to acquire new per-draw resources from the given shader using the collection of maps passed.
shader | A handle to the shader to acquire per-draw resources for. |
out_per_draw_id | A pointer to hold the per-draw id once resources are acquired. |
Releases per-draw resources and texture map resources from the provided shader.
shader | A handle to the shader to release per-draw resources for. |
per_draw_id | The identifier of the per-draw to release. |
void shader_system_shutdown | ( | void * | state | ) |
Shuts down the shader system.
state | A pointer to the system state. |
Sets the texture uniform with the given name to the supplied texture.
shader | A handle to the shader to update. |
uniform_name | The name of the uniform to be set. |
t | A pointer to the texture to be set. |
KAPI b8 shader_system_texture_set_arrayed | ( | khandle | shader, |
kname | uniform_name, | ||
u32 | array_index, | ||
ktexture | t | ||
) |
Sets the arrayed texture uniform with the given name to the supplied texture at the given index.
shader | A handle to the shader to update. |
uniform_name | The name of the uniform to be set. |
array_index | The index into the uniform array, if the uniform is in fact an array. Otherwise ignored. |
t | A pointer to the texture to be set. |
Sets a texture value by location.
shader | A handle to the shader to update. |
location | The location of the uniform. |
value | A pointer to the texture to be set. |
KAPI b8 shader_system_texture_set_by_location_arrayed | ( | khandle | shader, |
u16 | location, | ||
u32 | array_index, | ||
ktexture | value | ||
) |
Sets a texture value by location.
shader | A handle to the shader to update. |
location | The location of the uniform. |
array_index | The index into the uniform array, if the uniform is in fact an array. Otherwise ignored. |
value | A pointer to the texture to be set. |
Returns the uniform location for a uniform with the given name, if found.
shader | A handle to the shader to obtain the location from. |
uniform_name | The name of the uniform to search for. |
Sets the value of a uniform with the given name to the supplied value.
shader | A handle to the shader to update. |
uniform_name | The name of the uniform to be set. |
value | The value to be set. |
KAPI b8 shader_system_uniform_set_arrayed | ( | khandle | shader, |
kname | uniform_name, | ||
u32 | array_index, | ||
const void * | value | ||
) |
Sets the value of an arrayed uniform with the given name to the supplied value.
shader | A handle to the shader to update. |
uniform_name | The name of the uniform to be set. |
array_index | The index into the uniform array, if the uniform is in fact an array. Otherwise ignored. |
value | The value to be set. |
Sets a uniform value by location.
shader | A handle to the shader to update. |
index | The location of the uniform. |
value | The value of the uniform. |
KAPI b8 shader_system_uniform_set_by_location_arrayed | ( | khandle | shader, |
u16 | location, | ||
u32 | array_index, | ||
const void * | value | ||
) |
Sets a uniform value by location.
shader | A handle to the shader to update. |
location | The location of the uniform. |
array_index | The index into the uniform array, if the uniform is in fact an array. Otherwise ignored. |
value | The value of the uniform. |