Functions
mk_shader_destroyfunction
void mk_shader_destroy(mk_shader_t shader)
Get underlying GPU program handle (escape hatch).
Requires modkit.h. Destroy shader and release resources.
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
mk_shader_is_validfunction
bool mk_shader_is_valid(mk_shader_t shader)
Check if a shader is publicly valid and not pending destruction.
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
Returns True when the condition holds.
mk_shader_loadfunction
mk_shader_t mk_shader_load(const char *vs_path, const char *fs_path)
Load shader program from binary files.
| Parameter | Type | Description |
|---|
vs_path | const char * | Path to vertex shader .bin file |
fs_path | const char * | Path to fragment shader .bin file |
Returns Shader handle or MK_SHADER_INVALID on failure
mk_shader_load_computefunction
mk_shader_t mk_shader_load_compute(const char *cs_path)
Load a COMPUTE program from a binary file.
A compute program is a single shader (no vertex/fragment). The returned mk_shader_t is used with mk_dispatch()/mk_encoder_dispatch().
| Parameter | Type | Description |
|---|
cs_path | const char * | Path to compute shader .bin file |
Returns Shader handle or MK_SHADER_INVALID on failure
mk_shader_load_compute_descfunction
mk_shader_t mk_shader_load_compute_desc(const mk_compute_shader_desc *desc)
Load a compute program with uniforms created before the program links.
Uniform ownership and lookup are identical to mk_shader_load_desc().
| Parameter | Type | Description |
|---|
desc | const mk_compute_shader_desc * | Configuration descriptor. |
Returns The resulting handle or value.
mk_shader_load_compute_memfunction
mk_shader_t mk_shader_load_compute_mem(const void *cs_data, uint32_t cs_size)
Load a COMPUTE program from memory (embedded data).
| Parameter | Type | Description |
|---|
cs_data | const void * | Compute shader data |
cs_size | uint32_t | Compute shader size |
Returns Shader handle or MK_SHADER_INVALID on failure
mk_shader_load_descfunction
mk_shader_t mk_shader_load_desc(const mk_shader_desc *desc)
Load a shader program, creating the declared uniforms BEFORE the program links (see block comment above).
The uniforms are owned by the shader: look them up with mk_shader_uniform() and do NOT destroy them yourself mk_shader_destroy() releases them.
| Parameter | Type | Description |
|---|
desc | const mk_shader_desc * | Shader descriptor. |
Returns Shader handle or MK_SHADER_INVALID on failure.
mk_shader_load_memfunction
mk_shader_t mk_shader_load_mem(const void *vs_data, uint32_t vs_size, const void *fs_data, uint32_t fs_size)
Load shader program from memory (embedded data).
| Parameter | Type | Description |
|---|
vs_data | const void * | Vertex shader data |
vs_size | uint32_t | Vertex shader size |
fs_data | const void * | Fragment shader data |
fs_size | uint32_t | Fragment shader size |
Returns Shader handle or MK_SHADER_INVALID on failure
mk_shader_pinfunction
bool mk_shader_pin(mk_shader_t shader)
Perform the shader pin operation.
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
Returns True when the operation succeeds.
mk_shader_replace_compute_memfunction
mk_result mk_shader_replace_compute_mem(mk_shader_t shader, const void *cs_data, uint32_t cs_size)
Compute equivalent of mk_shader_replace_mem().
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
cs_data | const void * | Value for cs data. |
cs_size | uint32_t | Cs size in bytes. |
Returns MK_SUCCESS or an error result.
mk_shader_replace_memfunction
mk_result mk_shader_replace_mem(mk_shader_t shader, const void *vs_data, uint32_t vs_size, const void *fs_data, uint32_t fs_size)
Replace a graphics program without changing its public mk_shader_t handle.
Existing pipelines/materials resolve the new program automatically. The previous program remains active if the replacement cannot be created.
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
vs_data | const void * | Value for vs data. |
vs_size | uint32_t | Vs size in bytes. |
fs_data | const void * | Value for fs data. |
fs_size | uint32_t | Fs size in bytes. |
Returns MK_SUCCESS or an error result.
mk_shader_system_initfunction
void mk_shader_system_init(void)
Initialize the shader system.
mk_shader_system_shutdownfunction
void mk_shader_system_shutdown(void)
Perform the shader system shutdown operation.
mk_uniform_t mk_shader_uniform(mk_shader_t shader, const char *name)
Look up a uniform declared in the mk_shader_desc this shader was loaded with.
Returns MK_UNIFORM_INVALID for unknown names or shaders not loaded via mk_shader_load_desc().
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
name | const char * | Stable name. |
Returns The resulting handle or value.
mk_shader_unpinfunction
void mk_shader_unpin(mk_shader_t shader)
Perform the shader unpin operation.
| Parameter | Type | Description |
|---|
shader | mk_shader_t | Value for shader. |
mk_uniform_t mk_uniform_create(const char *name, mk_uniform_type_t type, uint16_t count)
Create uniform.
| Parameter | Type | Description |
|---|
name | const char * | Uniform name (must match shader) |
type | mk_uniform_type_t | Uniform type |
count | uint16_t | Array count (1 for non-arrays) |
Returns Uniform handle or MK_UNIFORM_INVALID on failure
void mk_uniform_destroy(mk_uniform_t uniform)
Get underlying GPU uniform handle (escape hatch).
Requires modkit.h. Destroy uniform and release resources.
| Parameter | Type | Description |
|---|
uniform | mk_uniform_t | Value for uniform. |
bool mk_uniform_info(mk_uniform_t uniform, mk_uniform_info_t *out_info)
Query a uniform's name/type/array-count.
Returns false for an invalid handle.
| Parameter | Type | Description |
|---|
uniform | mk_uniform_t | Value for uniform. |
out_info | mk_uniform_info_t * | Receives the info. |
Returns True when the operation succeeds.
bool mk_uniform_is_valid(mk_uniform_t uniform)
Check if uniform handle is valid.
| Parameter | Type | Description |
|---|
uniform | mk_uniform_t | Value for uniform. |
Returns True when the condition holds.
bool mk_uniform_pin(mk_uniform_t uniform)
Retain/release an internal reference.
New retains reject pending handles.
| Parameter | Type | Description |
|---|
uniform | mk_uniform_t | Value for uniform. |
Returns True when the operation succeeds.
void mk_uniform_unpin(mk_uniform_t uniform)
Perform the uniform unpin operation.
| Parameter | Type | Description |
|---|
uniform | mk_uniform_t | Value for uniform. |
Macros
MK_SHADER_INVALIDdefine
Invalid sentinel for shader.
mk_shader_load_compute_multidefine
mk_shader_load_compute_multi(cs)
Helper macro for loading a multi-profile compute shader (runtime renderer selection).
Works with a cs_*.sc compiled via modkit_add_shaders_multi(). Usage: mk_shader_load_compute_multi(cs_plasma)
mk_shader_load_embeddeddefine
mk_shader_load_embedded(vs, fs)
Helper macro for loading shader from embedded data (single profile).
Usage: mk_shader_load_embedded(vs_array, fs_array)
mk_shader_load_multidefine
mk_shader_load_multi(vs, fs)
Helper macro for loading multi-profile shaders (runtime renderer selection).
Works with shaders compiled using modkit_add_shaders_multi(). The _data() and _size() functions are auto-generated in the shader header. Usage: mk_shader_load_multi(vs_name, fs_name) Example: mk_shader_load_multi(vs_cube, fs_cube)
Maximum supported shader uniforms.
MK_SHADER_MULTIdefine
Initialize a desc's vs/fs fields from multi-profile embedded shaders (modkit_add_shaders_multi).
Use inside a mk_shader_desc initializer.
Invalid sentinel for uniform.