Kohi Game Engine
shader_system.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <defines.h>
17 #include <identifiers/khandle.h>
19 
21 typedef struct shader_system_config {
27 
38 b8 shader_system_initialize(u64* memory_requirement, void* memory, void* config);
39 
45 void shader_system_shutdown(void* state);
46 
56 
65 KAPI khandle shader_system_get_from_source(kname name, const char* shader_config_source);
66 
73 
82 KAPI b8 shader_system_set_wireframe(khandle shader, b8 wireframe_enabled);
83 
91 
100 
109 KAPI b8 shader_system_uniform_set(khandle shader, kname uniform_name, const void* value);
110 
120 KAPI b8 shader_system_uniform_set_arrayed(khandle shader, kname uniform_name, u32 array_index, const void* value);
121 
131 
141 KAPI b8 shader_system_texture_set_arrayed(khandle shader, kname uniform_name, u32 array_index, ktexture t);
142 
151 KAPI b8 shader_system_uniform_set_by_location(khandle shader, u16 location, const void* value);
152 
162 KAPI b8 shader_system_uniform_set_by_location_arrayed(khandle shader, u16 location, u32 array_index, const void* value);
163 
173 
184 
195 
214 
224 
232 
240 
248 
258 
267 
277 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:22
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:19
A global handle system for Kohi. Handles are used to obtain various resources using a unique handle i...
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
u16 ktexture
Represents a texture to be used for rendering purposes, stored on the GPU (VRAM)
Definition: kresource_types.h:45
KAPI b8 shader_system_shader_group_release(khandle shader, u32 instance_id)
Releases group resources and texture map resources from the provided shader.
KAPI b8 shader_system_texture_set_by_location_arrayed(khandle shader, u16 location, u32 array_index, ktexture value)
Sets a texture value by location.
KAPI b8 shader_system_apply_per_group(khandle shader)
Applies per-group uniforms.
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.
void shader_system_shutdown(void *state)
Shuts down the shader system.
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.
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.
struct shader_system_config shader_system_config
Configuration for the shader system.
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.
KAPI u16 shader_system_uniform_location(khandle shader, kname uniform_name)
Returns the uniform location for a uniform with the given name, if found.
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.
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.
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....
KAPI b8 shader_system_sampler_set_by_location_arrayed(khandle shader, u16 location, u32 array_index, ktexture t)
Sets a sampler value by location.
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.
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.
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.
b8 shader_system_initialize(u64 *memory_requirement, void *memory, void *config)
Initializes the shader system using the supplied configuration. NOTE: Call this twice,...
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.
KAPI b8 shader_system_texture_set_by_location(khandle shader, u16 location, ktexture t)
Sets a texture value by location.
KAPI b8 shader_system_use(khandle shader)
Uses the shader with the given handle.
KAPI void shader_system_destroy(khandle *shader)
Attempts to destroy the shader with the given handle. Handle will be invalidated.
KAPI b8 shader_system_apply_per_draw(khandle shader)
Applies per-draw uniforms. Updates the generation pointed to.
KAPI b8 shader_system_uniform_set_by_location(khandle shader, u16 location, const void *value)
Sets a uniform value by location.
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.
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.
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 s...
KAPI b8 shader_system_apply_per_frame(khandle shader)
Applies per-frame uniforms.
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
Configuration for the shader system.
Definition: shader_system.h:21
u8 max_uniform_count
The maximum number of uniforms allowed in a single shader.
Definition: shader_system.h:25
u16 max_shader_count
The maximum number of shaders held in the system. NOTE: Should be at least 512.
Definition: shader_system.h:23