Kohi Game Engine
kshader_system.h File Reference
#include <core_render_types.h>
#include <defines.h>
#include "renderer/renderer_types.h"

Go to the source code of this file.

Data Structures

struct  kshader_system_config
 Configuration for the shader system. More...
 

Typedefs

typedef struct kshader_system_config kshader_system_config
 Configuration for the shader system. More...
 

Functions

b8 kshader_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 kshader_system_shutdown (void *state)
 Shuts down the shader system. More...
 
KAPI kshader kshader_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 kshader kshader_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 kshader_system_destroy (kshader *shader)
 Attempts to destroy the shader with the given handle. Handle will be invalidated. More...
 
KAPI b8 kshader_system_set_wireframe (kshader 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 kshader_system_use (kshader shader, u8 vertex_layout_index)
 Uses the shader with the given handle and the shader's default topology. More...
 
KAPI b8 kshader_system_use_with_topology (kshader shader, primitive_topology_type topology, u8 vertex_layout_index)
 Uses the shader with the given handle and the provided topology. More...
 
KAPI void kshader_set_immediate_data (kshader shader, const void *data, u8 size)
 
KAPI void kshader_set_binding_data (kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u64 offset, void *data, u64 size)
 
KAPI void kshader_set_binding_texture (kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u8 array_index, ktexture texture)
 
KAPI void kshader_set_binding_sampler (kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u8 array_index, ksampler_backend sampler)
 
KAPI u32 kshader_acquire_binding_set_instance (kshader shader, u8 binding_set)
 
KAPI void kshader_release_binding_set_instance (kshader shader, u8 binding_set, u32 instance_id)
 
KAPI u32 kshader_binding_set_instance_count_get (kshader shader, u8 binding_set)
 
KAPI b8 kshader_apply_binding_set (kshader shader, u8 binding_set, u32 instance_id)
 

Typedef Documentation

◆ kshader_system_config

Configuration for the shader system.

Function Documentation

◆ kshader_acquire_binding_set_instance()

KAPI u32 kshader_acquire_binding_set_instance ( kshader  shader,
u8  binding_set 
)

◆ kshader_apply_binding_set()

KAPI b8 kshader_apply_binding_set ( kshader  shader,
u8  binding_set,
u32  instance_id 
)

◆ kshader_binding_set_instance_count_get()

KAPI u32 kshader_binding_set_instance_count_get ( kshader  shader,
u8  binding_set 
)

◆ kshader_release_binding_set_instance()

KAPI void kshader_release_binding_set_instance ( kshader  shader,
u8  binding_set,
u32  instance_id 
)

◆ kshader_set_binding_data()

KAPI void kshader_set_binding_data ( kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u64  offset,
void *  data,
u64  size 
)

◆ kshader_set_binding_sampler()

KAPI void kshader_set_binding_sampler ( kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u8  array_index,
ksampler_backend  sampler 
)

◆ kshader_set_binding_texture()

KAPI void kshader_set_binding_texture ( kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u8  array_index,
ktexture  texture 
)

◆ kshader_set_immediate_data()

KAPI void kshader_set_immediate_data ( kshader  shader,
const void *  data,
u8  size 
)

◆ kshader_system_destroy()

KAPI void kshader_system_destroy ( kshader shader)

Attempts to destroy the shader with the given handle. Handle will be invalidated.

Parameters
shader_nameA pointer to a handle to the shader to destroy. Handle will be invalidated.

◆ kshader_system_get()

KAPI kshader kshader_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.

Parameters
shader_nameThe kname to search for.
package_nameThe package to get the shader from if not already loaded. Pass INVALID_KNAME to search all packages.
Returns
A handle to a shader, if found/loaded; otherwise KSHADER_INVALID.

◆ kshader_system_get_from_source()

KAPI kshader kshader_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.

Parameters
shader_nameThe name of the new shader.
shader_config_sourceA string containing the shader's configuration source as if it were loaded from an asset.
Returns
A handle to a shader, if loaded; otherwise KSHADER_INVALID.

◆ kshader_system_initialize()

b8 kshader_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.

Parameters
memory_requirementA pointer to hold the memory requirement of this system in bytes.
memoryA memory block to be used to hold the state of this system. Pass 0 on the first call to get memory requirement.
configThe configuration (kshader_system_config) to be used when initializing the system.
Returns
b8 True on success; otherwise false.

◆ kshader_system_set_wireframe()

KAPI b8 kshader_system_set_wireframe ( kshader  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.

Parameters
shaderA handle to the shader to set wireframe mode for.
wireframe_enabledIndicates if wireframe mode should be enabled.
Returns
True on success; otherwise false.

◆ kshader_system_shutdown()

void kshader_system_shutdown ( void *  state)

Shuts down the shader system.

Parameters
stateA pointer to the system state.

◆ kshader_system_use()

KAPI b8 kshader_system_use ( kshader  shader,
u8  vertex_layout_index 
)

Uses the shader with the given handle and the shader's default topology.

Parameters
shaderA handle to the shader to be used.
Returns
True on success; otherwise false.

◆ kshader_system_use_with_topology()

KAPI b8 kshader_system_use_with_topology ( kshader  shader,
primitive_topology_type  topology,
u8  vertex_layout_index 
)

Uses the shader with the given handle and the provided topology.

Parameters
shaderA handle to the shader to be used.
topologyThe topology type to use.
Returns
True on success; otherwise false.