Kohi Game Engine
renderer_frontend.h File Reference

The renderer frontend, which is the only thing the rest of the engine sees. This is responsible for transferring any data to and from the renderer backend in an agnostic way. More...

#include <defines.h>
#include <identifiers/khandle.h>
#include <kresources/kresource_types.h>
#include <math/geometry.h>
#include <strings/kname.h>
#include "core/frame_data.h"
#include "core_render_types.h"
#include "renderer_types.h"

Go to the source code of this file.

Data Structures

struct  renderer_system_config
 

Typedefs

typedef struct renderer_system_config renderer_system_config
 

Functions

b8 renderer_system_deserialize_config (const char *config_str, renderer_system_config *out_config)
 
KAPI b8 renderer_system_initialize (u64 *memory_requirement, struct renderer_system_state *state, const renderer_system_config *config)
 Initializes the renderer frontend/system. Should be called twice - once to obtain the memory requirement (passing state=0), and a second time passing allocated memory to state. More...
 
KAPI void renderer_system_shutdown (struct renderer_system_state *state)
 Shuts the renderer system/frontend down. More...
 
KAPI u16 renderer_system_frame_number_get (struct renderer_system_state *state)
 
KAPI b8 renderer_on_window_created (struct renderer_system_state *state, struct kwindow *window)
 
KAPI void renderer_on_window_destroyed (struct renderer_system_state *state, struct kwindow *window)
 
KAPI void renderer_on_window_resized (struct renderer_system_state *state, const struct kwindow *window)
 Handles window resize events. More...
 
KAPI void renderer_begin_debug_label (const char *label_text, vec3 colour)
 Begins the marking of a section of commands, listed under a given name and colour. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this. More...
 
KAPI void renderer_end_debug_label (void)
 Ends the last debug section of commands. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this. More...
 
KAPI b8 renderer_frame_prepare (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Performs setup routines required at the start of a frame. More...
 
KAPI b8 renderer_frame_prepare_window_surface (struct renderer_system_state *state, struct kwindow *window, struct frame_data *p_frame_data)
 Prepares a window's surface for drawing. More...
 
KAPI b8 renderer_frame_command_list_begin (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Begins a render. There must be at least one of these and a matching end per frame. More...
 
KAPI b8 renderer_frame_command_list_end (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Ends a render. More...
 
KAPI b8 renderer_frame_submit (struct renderer_system_state *state, struct frame_data *p_frame_data)
 
KAPI b8 renderer_frame_present (struct renderer_system_state *state, struct kwindow *window, struct frame_data *p_frame_data)
 Performs routines required to draw a frame, such as presentation. Should only be called after a successful return of begin_frame. More...
 
KAPI void renderer_viewport_set (vec4 rect)
 Sets the renderer viewport to the given rectangle. More...
 
KAPI void renderer_viewport_reset (void)
 Resets the viewport to the default, which matches the application window. More...
 
KAPI void renderer_scissor_set (vec4 rect)
 Sets the renderer scissor to the given rectangle. More...
 
KAPI void renderer_scissor_reset (void)
 Resets the scissor to the default, which matches the application window. More...
 
KAPI void renderer_winding_set (renderer_winding winding)
 Set the renderer to use the given winding direction. More...
 
KAPI void renderer_cull_mode_set (renderer_cull_mode cull_mode)
 Set the renderer to use the given cull mode. More...
 
KAPI void renderer_set_stencil_test_enabled (b8 enabled)
 Set stencil testing enabled/disabled. More...
 
KAPI void renderer_set_stencil_reference (u32 reference)
 Set the stencil reference for testing. More...
 
KAPI void renderer_set_depth_test_enabled (b8 enabled)
 Set depth testing enabled/disabled. More...
 
KAPI void renderer_set_depth_write_enabled (b8 enabled)
 Set depth write enabled/disabled. More...
 
KAPI void renderer_set_stencil_op (renderer_stencil_op fail_op, renderer_stencil_op pass_op, renderer_stencil_op depth_fail_op, renderer_compare_op compare_op)
 Set stencil operation. More...
 
KAPI void renderer_begin_rendering (struct renderer_system_state *state, struct frame_data *p_frame_data, rect_2d render_area, u32 colour_target_count, khandle *colour_targets, khandle depth_stencil_target, u32 depth_stencil_layer)
 Begins rendering against the given targets. More...
 
KAPI void renderer_end_rendering (struct renderer_system_state *state, struct frame_data *p_frame_data)
 
KAPI void renderer_set_stencil_compare_mask (u32 compare_mask)
 Set stencil compare mask. More...
 
KAPI void renderer_set_stencil_write_mask (u32 write_mask)
 Set stencil write mask. More...
 
KAPI b8 renderer_texture_resources_acquire (struct renderer_system_state *state, kname name, ktexture_type type, u32 width, u32 height, u8 channel_count, u8 mip_levels, u16 array_size, ktexture_flag_bits flags, khandle *out_renderer_texture_handle)
 
KAPI void renderer_texture_resources_release (struct renderer_system_state *state, khandle *handle)
 
KAPI b8 renderer_texture_resize (struct renderer_system_state *state, khandle renderer_texture_handle, u32 new_width, u32 new_height)
 Resizes a texture. There is no check at this level to see if the texture is writeable. Internal resources are destroyed and re-created at the new resolution. Data is lost and would need to be reloaded. More...
 
KAPI b8 renderer_texture_write_data (struct renderer_system_state *state, khandle renderer_texture_handle, u32 offset, u32 size, const u8 *pixels)
 Writes the given data to the provided texture. More...
 
KAPI b8 renderer_texture_read_data (struct renderer_system_state *state, khandle renderer_texture_handle, u32 offset, u32 size, u8 **out_memory)
 Reads the given data from the provided texture. More...
 
KAPI b8 renderer_texture_read_pixel (struct renderer_system_state *state, khandle renderer_texture_handle, u32 x, u32 y, u8 **out_rgba)
 Reads a pixel from the provided texture at the given x/y coordinate. More...
 
KAPI void renderer_default_texture_register (struct renderer_system_state *state, renderer_default_texture default_texture, khandle renderer_texture_handle)
 Registers a texture with the given handle to the default texture slot specified. More...
 
KAPI khandle renderer_default_texture_get (struct renderer_system_state *state, renderer_default_texture default_texture)
 Gets a texture handle with the default texture slot specified. More...
 
KAPI renderbufferrenderer_renderbuffer_get (renderbuffer_type type)
 Attempts retrieve the renderer's internal buffer of the given type. More...
 
KAPI b8 renderer_geometry_upload (kgeometry *geometry)
 Acquires GPU resources and uploads geometry data. More...
 
KAPI void renderer_geometry_vertex_update (kgeometry *g, u32 offset, u32 vertex_count, void *vertices, b8 include_in_frame_workload)
 Updates vertex data in the given geometry with the provided data in the given range. More...
 
KAPI void renderer_geometry_destroy (kgeometry *geometry)
 Destroys the given geometry, releasing GPU resources. More...
 
KAPI void renderer_geometry_draw (geometry_render_data *data)
 Draws the given geometry. More...
 
KAPI void renderer_clear_colour_set (struct renderer_system_state *state, vec4 colour)
 Sets the value to be used on the colour buffer clear. More...
 
KAPI void renderer_clear_depth_set (struct renderer_system_state *state, f32 depth)
 Sets the value to be used on the depth buffer clear. More...
 
KAPI void renderer_clear_stencil_set (struct renderer_system_state *state, u32 stencil)
 Sets the value to be used on the stencil buffer clear. More...
 
KAPI b8 renderer_clear_colour (struct renderer_system_state *state, khandle texture_handle)
 Clears the colour buffer using the previously set clear colour. More...
 
KAPI b8 renderer_clear_depth_stencil (struct renderer_system_state *state, khandle texture_handle)
 Clears the depth/stencil buffer using the previously set clear values. More...
 
KAPI void renderer_colour_texture_prepare_for_present (struct renderer_system_state *state, khandle texture_handle)
 Performs operations required on the supplied colour texture before presentation. More...
 
KAPI void renderer_texture_prepare_for_sampling (struct renderer_system_state *state, khandle texture_handle, ktexture_flag_bits flags)
 Performs operations required on the supplied texture before being used for sampling. More...
 
KAPI b8 renderer_shader_create (struct renderer_system_state *state, khandle shader, kname name, shader_flags flags, u32 topology_types, face_cull_mode cull_mode, u32 stage_count, shader_stage *stages, kname *stage_names, const char **stage_sources, u32 max_groups, u32 max_draw_ids, u32 attribute_count, const shader_attribute *attributes, u32 uniform_count, const shader_uniform *d_uniforms)
 Creates internal shader resources using the provided parameters. More...
 
KAPI void renderer_shader_destroy (struct renderer_system_state *state, khandle shader)
 Destroys the given shader and releases any resources held by it. More...
 
KAPI b8 renderer_shader_reload (struct renderer_system_state *state, khandle shader, u32 stage_count, shader_stage *stages, kname *names, const char **sources)
 Reloads the internals of the given shader. More...
 
KAPI b8 renderer_shader_use (struct renderer_system_state *state, khandle shader)
 Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls. More...
 
KAPI b8 renderer_shader_supports_wireframe (struct renderer_system_state *state, khandle shader)
 Determines if the given shader supports wireframe mode. More...
 
KAPI b8 renderer_shader_flag_get (struct renderer_system_state *state, khandle shader, shader_flags flag)
 Indicates if the given shader flag is set. More...
 
KAPI void renderer_shader_flag_set (struct renderer_system_state *state, khandle shader, shader_flags flag, b8 enabled)
 Sets the given shader flag. More...
 
KAPI b8 renderer_shader_bind_per_frame (struct renderer_system_state *state, khandle shader)
 Binds the per-frame frequency. More...
 
KAPI b8 renderer_shader_bind_per_group (struct renderer_system_state *state, khandle shader, u32 group_id)
 Binds the given per-group frequency id. More...
 
KAPI b8 renderer_shader_bind_per_draw (struct renderer_system_state *state, khandle shader, u32 draw_id)
 Binds the given per-draw frequency id. More...
 
KAPI b8 renderer_shader_apply_per_frame (struct renderer_system_state *state, khandle shader)
 Applies per-frame data to the uniform buffer. More...
 
KAPI b8 renderer_shader_apply_per_group (struct renderer_system_state *state, khandle shader)
 Applies data for the currently bound group. More...
 
KAPI b8 renderer_shader_apply_per_draw (struct renderer_system_state *state, khandle shader)
 Triggers the upload of per-draw uniform data to the GPU. More...
 
KAPI b8 renderer_shader_per_group_resources_acquire (struct renderer_system_state *state, khandle shader, u32 *out_group_id)
 Acquires internal per-group resources and provides a group id. More...
 
KAPI b8 renderer_shader_per_group_resources_release (struct renderer_system_state *state, khandle shader, u32 group_id)
 Releases internal per-group resources for the given group id. More...
 
KAPI b8 renderer_shader_per_draw_resources_acquire (struct renderer_system_state *state, khandle shader, u32 *out_draw_id)
 Acquires internal per-draw resources and provides a per-draw id. More...
 
KAPI b8 renderer_shader_per_draw_resources_release (struct renderer_system_state *state, khandle shader, u32 draw_id)
 Releases internal per-draw resources for the given per-draw id. More...
 
KAPI b8 renderer_shader_uniform_set (struct renderer_system_state *state, khandle shader, struct shader_uniform *uniform, u32 array_index, const void *value)
 Sets the uniform of the given shader to the provided value. More...
 
KAPI khandle renderer_generic_sampler_get (struct renderer_system_state *state, shader_generic_sampler sampler)
 Gets a handle to a generic sampler of the given type. More...
 
KAPI khandle renderer_sampler_acquire (struct renderer_system_state *state, kname name, texture_filter filter, texture_repeat repeat, f32 anisotropy)
 Acquires a internal sampler and returns a handle to it. More...
 
KAPI void renderer_sampler_release (struct renderer_system_state *state, khandle *sampler)
 Releases the internal sampler for the given handle. More...
 
KAPI b8 renderer_sampler_refresh (struct renderer_system_state *state, khandle *sampler, texture_filter filter, texture_repeat repeat, f32 anisotropy, u32 mip_levels)
 Recreates the internal sampler pointed to by the given handle. Modifies the handle. More...
 
KAPI kname renderer_sampler_name_get (struct renderer_system_state *state, khandle sampler)
 Attempts to obtain the name of a sampler with the given handle. Returns INVALID_KNAME if not found. More...
 
KAPI b8 renderer_is_multithreaded (void)
 Indicates if the renderer is capable of multi-threading. More...
 
KAPI b8 renderer_flag_enabled_get (renderer_config_flags flag)
 Indicates if the provided renderer flag is enabled. If multiple flags are passed, all must be set for this to return true. More...
 
KAPI void renderer_flag_enabled_set (renderer_config_flags flag, b8 enabled)
 Sets whether the included flag(s) are enabled or not. If multiple flags are passed, multiple are set at once. More...
 
KAPI f32 renderer_max_anisotropy_get (void)
 Obtains the max anisotropy level available from the renderer. 0 means not available. More...
 
KAPI b8 renderer_renderbuffer_create (const char *name, renderbuffer_type type, u64 total_size, renderbuffer_track_type track_type, renderbuffer *out_buffer)
 Creates a new renderbuffer to hold data for a given purpose/use. Backed by a renderer-backend-specific buffer resource. More...
 
KAPI void renderer_renderbuffer_destroy (renderbuffer *buffer)
 Destroys the given renderbuffer. More...
 
KAPI b8 renderer_renderbuffer_bind (renderbuffer *buffer, u64 offset)
 Binds the given buffer at the provided offset. More...
 
KAPI b8 renderer_renderbuffer_unbind (renderbuffer *buffer)
 Unbinds the given buffer. More...
 
KAPI void * renderer_renderbuffer_map_memory (renderbuffer *buffer, u64 offset, u64 size)
 Maps memory from the given buffer in the provided range to a block of memory and returns it. This memory should be considered invalid once unmapped. More...
 
KAPI void renderer_renderbuffer_unmap_memory (renderbuffer *buffer, u64 offset, u64 size)
 Unmaps memory from the given buffer in the provided range to a block of memory. This memory should be considered invalid once unmapped. More...
 
KAPI b8 renderer_renderbuffer_flush (renderbuffer *buffer, u64 offset, u64 size)
 Flushes buffer memory at the given range. Should be done after a write. More...
 
KAPI b8 renderer_renderbuffer_read (renderbuffer *buffer, u64 offset, u64 size, void **out_memory)
 Reads memory from the provided buffer at the given range to the output variable. More...
 
KAPI b8 renderer_renderbuffer_resize (renderbuffer *buffer, u64 new_total_size)
 Resizes the given buffer to new_total_size. new_total_size must be greater than the current buffer size. Data from the old internal buffer is copied over. More...
 
KAPI b8 renderer_renderbuffer_allocate (renderbuffer *buffer, u64 size, u64 *out_offset)
 Attempts to allocate memory from the given buffer. Should only be used on buffers that were created with use_freelist = true. More...
 
KAPI b8 renderer_renderbuffer_free (renderbuffer *buffer, u64 size, u64 offset)
 Frees memory from the given buffer. More...
 
KAPI b8 renderer_renderbuffer_clear (renderbuffer *buffer, b8 zero_memory)
 Clears the given buffer. Internally, resets the free list if one is used. More...
 
KAPI b8 renderer_renderbuffer_load_range (renderbuffer *buffer, u64 offset, u64 size, const void *data, b8 include_in_frame_workload)
 Loads provided data into the specified rage of the given buffer. More...
 
KAPI b8 renderer_renderbuffer_copy_range (renderbuffer *source, u64 source_offset, renderbuffer *dest, u64 dest_offset, u64 size, b8 include_in_frame_workload)
 Copies data in the specified rage fron the source to the destination buffer. More...
 
KAPI b8 renderer_renderbuffer_draw (renderbuffer *buffer, u64 offset, u32 element_count, b8 bind_only)
 Attempts to draw the contents of the provided buffer at the given offset and element count. Only meant to be used with vertex and index buffers. More...
 
KAPI struct viewportrenderer_active_viewport_get (void)
 Returns a pointer to the currently active viewport. More...
 
KAPI void renderer_active_viewport_set (struct viewport *v)
 Sets the currently active viewport. More...
 
KAPI void renderer_wait_for_idle (void)
 
KAPI b8 renderer_pcf_enabled (struct renderer_system_state *state)
 
KAPI u16 renderer_max_bound_texture_count_get (struct renderer_system_state *state)
 Returns the max number of textures that can be bound at once for a single draw call. More...
 
KAPI u16 renderer_max_bound_sampler_count_get (struct renderer_system_state *state)
 Returns the max number of samplers that can be bound at once for a single draw call. More...
 

Detailed Description

The renderer frontend, which is the only thing the rest of the engine sees. This is responsible for transferring any data to and from the renderer backend in an agnostic way.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-01-11

The lifecycle of a single frame (including mult. monitors) should look something like this:

frame_prepare - Increments renderer frame number

frame_prepare_window_surface - verifies swapchain, gets image index, etc. frame_commands_begin - begins command list/buffer <insert renderpasses, draws, etc. here> frame_commands_end - ends command list/buffer frame_submit - submits command list/buffer for execution. frame_present - once frame execution is complete, presents swapchain image.

Typedef Documentation

◆ renderer_system_config

Function Documentation

◆ renderer_active_viewport_get()

KAPI struct viewport* renderer_active_viewport_get ( void  )

Returns a pointer to the currently active viewport.

◆ renderer_active_viewport_set()

KAPI void renderer_active_viewport_set ( struct viewport v)

Sets the currently active viewport.

Parameters
viewportA pointer to the viewport to be set.

◆ renderer_begin_debug_label()

KAPI void renderer_begin_debug_label ( const char *  label_text,
vec3  colour 
)

Begins the marking of a section of commands, listed under a given name and colour. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this.

Parameters
label_textThe text to be used for the label.
colourThe colour to be used for the label.

◆ renderer_begin_rendering()

KAPI void renderer_begin_rendering ( struct renderer_system_state *  state,
struct frame_data p_frame_data,
rect_2d  render_area,
u32  colour_target_count,
khandle colour_targets,
khandle  depth_stencil_target,
u32  depth_stencil_layer 
)

Begins rendering against the given targets.

Parameters
stateA pointer to the renderer system state.
p_frame_dataA pointer to the current frame data.
render_areaA rectangle representing the area of the attachments to render to.
colour_target_countThe number of colour targets to be drawn to.
colour_targetsAn array of handles to colour targets. Required unless colour_target_count is 0.
depth_stencil_targetA handle to a depth stencil target to render to.
depth_stencil_layerFor layered depth targets, the layer index to render to. Ignored otherwise.

◆ renderer_clear_colour()

KAPI b8 renderer_clear_colour ( struct renderer_system_state *  state,
khandle  texture_handle 
)

Clears the colour buffer using the previously set clear colour.

Parameters
stateA pointer to the renderer system state.
texture_handleA handle to the texture to clear.
Returns
True if successful; otherwise false.

◆ renderer_clear_colour_set()

KAPI void renderer_clear_colour_set ( struct renderer_system_state *  state,
vec4  colour 
)

Sets the value to be used on the colour buffer clear.

Parameters
stateA pointer to the renderer system state.
colourthe RGBA colour to be used for the next clear operation. Each element is clamped to [0-1]

◆ renderer_clear_depth_set()

KAPI void renderer_clear_depth_set ( struct renderer_system_state *  state,
f32  depth 
)

Sets the value to be used on the depth buffer clear.

Parameters
stateA pointer to the renderer system state.
depthThe depth value to be used for the next clear operation. Clamped to [0-1].

◆ renderer_clear_depth_stencil()

KAPI b8 renderer_clear_depth_stencil ( struct renderer_system_state *  state,
khandle  texture_handle 
)

Clears the depth/stencil buffer using the previously set clear values.

Parameters
stateA pointer to the renderer system state.
texture_handleA handle to the texture to clear.
Returns
True if successful; otherwise false.

◆ renderer_clear_stencil_set()

KAPI void renderer_clear_stencil_set ( struct renderer_system_state *  state,
u32  stencil 
)

Sets the value to be used on the stencil buffer clear.

Parameters
stateA pointer to the renderer system state.
stencilThe depth value to be used for the next clear operation.

◆ renderer_colour_texture_prepare_for_present()

KAPI void renderer_colour_texture_prepare_for_present ( struct renderer_system_state *  state,
khandle  texture_handle 
)

Performs operations required on the supplied colour texture before presentation.

Parameters
stateA pointer to the renderer system state.
texture_handleA handle to the texture to prepare for presentation.

◆ renderer_cull_mode_set()

KAPI void renderer_cull_mode_set ( renderer_cull_mode  cull_mode)

Set the renderer to use the given cull mode.

Parameters
cull_modeThe cull mode.

◆ renderer_default_texture_get()

KAPI khandle renderer_default_texture_get ( struct renderer_system_state *  state,
renderer_default_texture  default_texture 
)

Gets a texture handle with the default texture slot specified.

Parameters
stateA pointer to the renderer system state.
default_textureThe texture slot to register to.
Returns
A handle to the default texture.

◆ renderer_default_texture_register()

KAPI void renderer_default_texture_register ( struct renderer_system_state *  state,
renderer_default_texture  default_texture,
khandle  renderer_texture_handle 
)

Registers a texture with the given handle to the default texture slot specified.

Parameters
stateA pointer to the renderer system state.
default_textureThe texture slot to register to.
renderer_texture_handleA handle to the texture to be registered.

◆ renderer_end_debug_label()

KAPI void renderer_end_debug_label ( void  )

Ends the last debug section of commands. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this.

◆ renderer_end_rendering()

KAPI void renderer_end_rendering ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)
Parameters
stateA pointer to the renderer system state.
p_frame_dataA pointer to the current frame data.

◆ renderer_flag_enabled_get()

KAPI b8 renderer_flag_enabled_get ( renderer_config_flags  flag)

Indicates if the provided renderer flag is enabled. If multiple flags are passed, all must be set for this to return true.

Parameters
flagThe flag to be checked.
Returns
True if the flag(s) set; otherwise false.

◆ renderer_flag_enabled_set()

KAPI void renderer_flag_enabled_set ( renderer_config_flags  flag,
b8  enabled 
)

Sets whether the included flag(s) are enabled or not. If multiple flags are passed, multiple are set at once.

Parameters
flagThe flag to be checked.
enabledIndicates whether or not to enable the flag(s).

◆ renderer_frame_command_list_begin()

KAPI b8 renderer_frame_command_list_begin ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Begins a render. There must be at least one of these and a matching end per frame.

Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_command_list_end()

KAPI b8 renderer_frame_command_list_end ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Ends a render.

Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_prepare()

KAPI b8 renderer_frame_prepare ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Performs setup routines required at the start of a frame.

Note
A false result does not necessarily indicate failure. It can also specify that the backend is simply not in a state capable of drawing a frame at the moment, and that it should be attempted again on the next loop. End frame does not need to (and should not) be called if this is the case.
Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_prepare_window_surface()

KAPI b8 renderer_frame_prepare_window_surface ( struct renderer_system_state *  state,
struct kwindow window,
struct frame_data p_frame_data 
)

Prepares a window's surface for drawing.

Parameters
p_frame_dataA pointer to the current frame's data. d
Returns
True if successful; otherwise false.

◆ renderer_frame_present()

KAPI b8 renderer_frame_present ( struct renderer_system_state *  state,
struct kwindow window,
struct frame_data p_frame_data 
)

Performs routines required to draw a frame, such as presentation. Should only be called after a successful return of begin_frame.

Parameters
p_frame_dataA constant pointer to the current frame's data.
Returns
True on success; otherwise false.

◆ renderer_frame_submit()

KAPI b8 renderer_frame_submit ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

◆ renderer_generic_sampler_get()

KAPI khandle renderer_generic_sampler_get ( struct renderer_system_state *  state,
shader_generic_sampler  sampler 
)

Gets a handle to a generic sampler of the given type.

Parameters
stateA pointer to the renderer state.
samplerThe shader sampler to get a handle to.
Returns
A handle to a generic sampler of the given type.

◆ renderer_geometry_destroy()

KAPI void renderer_geometry_destroy ( kgeometry geometry)

Destroys the given geometry, releasing GPU resources.

Parameters
geometryA pointer to the geometry to be destroyed.

◆ renderer_geometry_draw()

KAPI void renderer_geometry_draw ( geometry_render_data data)

Draws the given geometry.

Parameters
dataThe render data of the geometry to be drawn.

◆ renderer_geometry_upload()

KAPI b8 renderer_geometry_upload ( kgeometry geometry)

Acquires GPU resources and uploads geometry data.

Parameters
geometryA pointer to the geometry to upload.
Returns
True on success; otherwise false.

◆ renderer_geometry_vertex_update()

KAPI void renderer_geometry_vertex_update ( kgeometry g,
u32  offset,
u32  vertex_count,
void *  vertices,
b8  include_in_frame_workload 
)

Updates vertex data in the given geometry with the provided data in the given range.

Parameters
gA pointer to the geometry to be created.
offsetThe offset in bytes to update. 0 if updating from the beginning.
vertex_countThe number of vertices which will be updated.
verticesThe vertex data.

◆ renderer_is_multithreaded()

KAPI b8 renderer_is_multithreaded ( void  )

Indicates if the renderer is capable of multi-threading.

◆ renderer_max_anisotropy_get()

KAPI f32 renderer_max_anisotropy_get ( void  )

Obtains the max anisotropy level available from the renderer. 0 means not available.

◆ renderer_max_bound_sampler_count_get()

KAPI u16 renderer_max_bound_sampler_count_get ( struct renderer_system_state *  state)

Returns the max number of samplers that can be bound at once for a single draw call.

◆ renderer_max_bound_texture_count_get()

KAPI u16 renderer_max_bound_texture_count_get ( struct renderer_system_state *  state)

Returns the max number of textures that can be bound at once for a single draw call.

◆ renderer_on_window_created()

KAPI b8 renderer_on_window_created ( struct renderer_system_state *  state,
struct kwindow window 
)

◆ renderer_on_window_destroyed()

KAPI void renderer_on_window_destroyed ( struct renderer_system_state *  state,
struct kwindow window 
)

◆ renderer_on_window_resized()

KAPI void renderer_on_window_resized ( struct renderer_system_state *  state,
const struct kwindow window 
)

Handles window resize events.

Parameters
stateA pointer to the state block of memory.
windowA const pointer to the window that was resized.

◆ renderer_pcf_enabled()

KAPI b8 renderer_pcf_enabled ( struct renderer_system_state *  state)

Indicates if PCF filtering is enabled for shadow maps.

◆ renderer_renderbuffer_allocate()

KAPI b8 renderer_renderbuffer_allocate ( renderbuffer buffer,
u64  size,
u64 out_offset 
)

Attempts to allocate memory from the given buffer. Should only be used on buffers that were created with use_freelist = true.

Parameters
bufferA pointer to the buffer to be allocated from.
sizeThe size in bytes to allocate.
out_offsetA pointer to hold the offset in bytes of the allocation from the beginning of the buffer.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_bind()

KAPI b8 renderer_renderbuffer_bind ( renderbuffer buffer,
u64  offset 
)

Binds the given buffer at the provided offset.

Parameters
bufferA pointer to the buffer to bind.
offsetThe offset in bytes from the beginning of the buffer.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_clear()

KAPI b8 renderer_renderbuffer_clear ( renderbuffer buffer,
b8  zero_memory 
)

Clears the given buffer. Internally, resets the free list if one is used.

Parameters
bufferA pointer to the buffer to be freed from.
zero_memoryTrue if memory should be zeroed; otherwise false. NOTE: this can be an expensive operation on large sums of memory.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_copy_range()

KAPI b8 renderer_renderbuffer_copy_range ( renderbuffer source,
u64  source_offset,
renderbuffer dest,
u64  dest_offset,
u64  size,
b8  include_in_frame_workload 
)

Copies data in the specified rage fron the source to the destination buffer.

Parameters
sourceA pointer to the source buffer to copy data from.
source_offsetThe offset in bytes from the beginning of the source buffer.
destA pointer to the destination buffer to copy data to.
dest_offsetThe offset in bytes from the beginning of the destination buffer.
sizeThe size of the data in bytes to be copied.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_create()

KAPI b8 renderer_renderbuffer_create ( const char *  name,
renderbuffer_type  type,
u64  total_size,
renderbuffer_track_type  track_type,
renderbuffer out_buffer 
)

Creates a new renderbuffer to hold data for a given purpose/use. Backed by a renderer-backend-specific buffer resource.

Parameters
nameThe name of the renderbuffer, used for debugging purposes.
typeThe type of buffer, indicating it's use (i.e. vertex/index data, uniforms, etc.)
total_sizeThe total size in bytes of the buffer.
track_typeIndicates what type of allocation tracking should be used.
out_bufferA pointer to hold the newly created buffer.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_destroy()

KAPI void renderer_renderbuffer_destroy ( renderbuffer buffer)

Destroys the given renderbuffer.

Parameters
bufferA pointer to the buffer to be destroyed.

◆ renderer_renderbuffer_draw()

KAPI b8 renderer_renderbuffer_draw ( renderbuffer buffer,
u64  offset,
u32  element_count,
b8  bind_only 
)

Attempts to draw the contents of the provided buffer at the given offset and element count. Only meant to be used with vertex and index buffers.

Parameters
bufferA pointer to the buffer to be drawn.
offsetThe offset in bytes from the beginning of the buffer.
element_countThe number of elements to be drawn.
bind_onlyOnly bind the buffer, but don't draw.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_flush()

KAPI b8 renderer_renderbuffer_flush ( renderbuffer buffer,
u64  offset,
u64  size 
)

Flushes buffer memory at the given range. Should be done after a write.

Parameters
bufferA pointer to the buffer to unmap.
offsetThe number of bytes from the beginning of the buffer to flush.
sizeThe amount of memory in the buffer to flush.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_free()

KAPI b8 renderer_renderbuffer_free ( renderbuffer buffer,
u64  size,
u64  offset 
)

Frees memory from the given buffer.

Parameters
bufferA pointer to the buffer to be freed from.
sizeThe size in bytes to free.
offsetThe offset in bytes from the beginning of the buffer to free.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_get()

KAPI renderbuffer* renderer_renderbuffer_get ( renderbuffer_type  type)

Attempts retrieve the renderer's internal buffer of the given type.

Parameters
typeThe type of buffer to retrieve. @returnshader A handle to the buffer on success; otherwise 0/null.

◆ renderer_renderbuffer_load_range()

KAPI b8 renderer_renderbuffer_load_range ( renderbuffer buffer,
u64  offset,
u64  size,
const void *  data,
b8  include_in_frame_workload 
)

Loads provided data into the specified rage of the given buffer.

Parameters
bufferA pointer to the buffer to load data into.
offsetThe offset in bytes from the beginning of the buffer.
sizeThe size of the data in bytes to be loaded.
dataThe data to be loaded.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_map_memory()

KAPI void* renderer_renderbuffer_map_memory ( renderbuffer buffer,
u64  offset,
u64  size 
)

Maps memory from the given buffer in the provided range to a block of memory and returns it. This memory should be considered invalid once unmapped.

Parameters
bufferA pointer to the buffer to map.
offsetThe number of bytes from the beginning of the buffer to map.
sizeThe amount of memory in the buffer to map.
Returns
A mapped block of memory. Freed and invalid once unmapped.

◆ renderer_renderbuffer_read()

KAPI b8 renderer_renderbuffer_read ( renderbuffer buffer,
u64  offset,
u64  size,
void **  out_memory 
)

Reads memory from the provided buffer at the given range to the output variable.

Parameters
bufferA pointer to the buffer to read from.
offsetThe number of bytes from the beginning of the buffer to read.
sizeThe amount of memory in the buffer to read.
out_memoryA pointer to a block of memory to read to. Must be of appropriate size.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_resize()

KAPI b8 renderer_renderbuffer_resize ( renderbuffer buffer,
u64  new_total_size 
)

Resizes the given buffer to new_total_size. new_total_size must be greater than the current buffer size. Data from the old internal buffer is copied over.

Parameters
bufferA pointer to the buffer to be resized.
new_total_sizeThe new size in bytes. Must be larger than the current size.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_unbind()

KAPI b8 renderer_renderbuffer_unbind ( renderbuffer buffer)

Unbinds the given buffer.

Parameters
bufferA pointer to the buffer to be unbound.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_unmap_memory()

KAPI void renderer_renderbuffer_unmap_memory ( renderbuffer buffer,
u64  offset,
u64  size 
)

Unmaps memory from the given buffer in the provided range to a block of memory. This memory should be considered invalid once unmapped.

Parameters
bufferA pointer to the buffer to unmap.
offsetThe number of bytes from the beginning of the buffer to unmap.
sizeThe amount of memory in the buffer to unmap.

◆ renderer_sampler_acquire()

KAPI khandle renderer_sampler_acquire ( struct renderer_system_state *  state,
kname  name,
texture_filter  filter,
texture_repeat  repeat,
f32  anisotropy 
)

Acquires a internal sampler and returns a handle to it.

Parameters
stateA pointer to the renderer state.
nameThe name of the sampler.
filterThe min/mag filter.
repeatThe repeat mode.
anisotropyThe anisotropy level, if needed; otherwise 0.
Returns
A handle to the sampler on success; otherwise an invalid handle.

◆ renderer_sampler_name_get()

KAPI kname renderer_sampler_name_get ( struct renderer_system_state *  state,
khandle  sampler 
)

Attempts to obtain the name of a sampler with the given handle. Returns INVALID_KNAME if not found.

Parameters
stateA pointer to the renderer state.
samplerA handle to the sampler whose name to get.
Returns
The name of the sampler on success; otherwise INVALID_KNAME.

◆ renderer_sampler_refresh()

KAPI b8 renderer_sampler_refresh ( struct renderer_system_state *  state,
khandle sampler,
texture_filter  filter,
texture_repeat  repeat,
f32  anisotropy,
u32  mip_levels 
)

Recreates the internal sampler pointed to by the given handle. Modifies the handle.

Parameters
stateA pointer to the renderer state.
samplerA pointer to the handle of the sampler to be refreshed.
filterThe min/mag filter.
repeatThe repeat mode.
anisotropyThe anisotropy level, if needed; otherwise 0.
mip_levelsThe mip levels, if used; otherwise 0.
Returns
True on success; otherwise false.

◆ renderer_sampler_release()

KAPI void renderer_sampler_release ( struct renderer_system_state *  state,
khandle sampler 
)

Releases the internal sampler for the given handle.

Parameters
stateA pointer to the renderer state.
mapA pointer to the handle whose sampler is to be released. Handle is invalidated upon release.

◆ renderer_scissor_reset()

KAPI void renderer_scissor_reset ( void  )

Resets the scissor to the default, which matches the application window.

◆ renderer_scissor_set()

KAPI void renderer_scissor_set ( vec4  rect)

Sets the renderer scissor to the given rectangle.

Parameters
rectThe scissor rectangle to be set.

◆ renderer_set_depth_test_enabled()

KAPI void renderer_set_depth_test_enabled ( b8  enabled)

Set depth testing enabled/disabled.

Parameters
enabledIndicates if depth testing should be enabled/disabled for subsequent draws.

◆ renderer_set_depth_write_enabled()

KAPI void renderer_set_depth_write_enabled ( b8  enabled)

Set depth write enabled/disabled.

Parameters
enabledIndicates if depth write should be enabled/disabled for subsequent draws.

◆ renderer_set_stencil_compare_mask()

KAPI void renderer_set_stencil_compare_mask ( u32  compare_mask)

Set stencil compare mask.

Parameters
compare_maskThe new value to use as the stencil compare mask.

◆ renderer_set_stencil_op()

KAPI void renderer_set_stencil_op ( renderer_stencil_op  fail_op,
renderer_stencil_op  pass_op,
renderer_stencil_op  depth_fail_op,
renderer_compare_op  compare_op 
)

Set stencil operation.

Parameters
fail_opSpecifys the action performed on samples that fail the stencil test.
pass_opSpecifys the action performed on samples that pass both the depth and stencil tests.
depth_fail_opSpecifys the action performed on samples that pass the stencil test and fail the depth test.
compare_opSpecifys the comparison operator used in the stencil test.

◆ renderer_set_stencil_reference()

KAPI void renderer_set_stencil_reference ( u32  reference)

Set the stencil reference for testing.

Parameters
referenceThe reference to use when stencil testing/writing.

◆ renderer_set_stencil_test_enabled()

KAPI void renderer_set_stencil_test_enabled ( b8  enabled)

Set stencil testing enabled/disabled.

Parameters
enabledIndicates if stencil testing should be enabled/disabled for subsequent draws.

◆ renderer_set_stencil_write_mask()

KAPI void renderer_set_stencil_write_mask ( u32  write_mask)

Set stencil write mask.

Parameters
write_maskThe new value to use as the stencil write mask.

◆ renderer_shader_apply_per_draw()

KAPI b8 renderer_shader_apply_per_draw ( struct renderer_system_state *  state,
khandle  shader 
)

Triggers the upload of per-draw uniform data to the GPU.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader.
Returns
True on success; otherwise false.

◆ renderer_shader_apply_per_frame()

KAPI b8 renderer_shader_apply_per_frame ( struct renderer_system_state *  state,
khandle  shader 
)

Applies per-frame data to the uniform buffer.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to apply the global data for.
Returns
True on success; otherwise false.

◆ renderer_shader_apply_per_group()

KAPI b8 renderer_shader_apply_per_group ( struct renderer_system_state *  state,
khandle  shader 
)

Applies data for the currently bound group.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to apply the instance data for.
Returns
True on success; otherwise false.

◆ renderer_shader_bind_per_draw()

KAPI b8 renderer_shader_bind_per_draw ( struct renderer_system_state *  state,
khandle  shader,
u32  draw_id 
)

Binds the given per-draw frequency id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
draw_idThe per-draw frequency id.
Returns
True on success; otherwise false.

◆ renderer_shader_bind_per_frame()

KAPI b8 renderer_shader_bind_per_frame ( struct renderer_system_state *  state,
khandle  shader 
)

Binds the per-frame frequency.

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

◆ renderer_shader_bind_per_group()

KAPI b8 renderer_shader_bind_per_group ( struct renderer_system_state *  state,
khandle  shader,
u32  group_id 
)

Binds the given per-group frequency id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
group_idThe per-group frequency id.
Returns
True on success; otherwise false.

◆ renderer_shader_create()

KAPI b8 renderer_shader_create ( struct renderer_system_state *  state,
khandle  shader,
kname  name,
shader_flags  flags,
u32  topology_types,
face_cull_mode  cull_mode,
u32  stage_count,
shader_stage stages,
kname stage_names,
const char **  stage_sources,
u32  max_groups,
u32  max_draw_ids,
u32  attribute_count,
const shader_attribute attributes,
u32  uniform_count,
const shader_uniform d_uniforms 
)

Creates internal shader resources using the provided parameters.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader.
shader_assetA constant pointer to the shader asset.
Returns
b8 True on success; otherwise false.

◆ renderer_shader_destroy()

KAPI void renderer_shader_destroy ( struct renderer_system_state *  state,
khandle  shader 
)

Destroys the given shader and releases any resources held by it.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be destroyed.

◆ renderer_shader_flag_get()

KAPI b8 renderer_shader_flag_get ( struct renderer_system_state *  state,
khandle  shader,
shader_flags  flag 
)

Indicates if the given shader flag is set.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
flagThe flag to check.
Returns
True if set; otherwise false.

◆ renderer_shader_flag_set()

KAPI void renderer_shader_flag_set ( struct renderer_system_state *  state,
khandle  shader,
shader_flags  flag,
b8  enabled 
)

Sets the given shader flag.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
flagThe flag to set.
enabledIndicates whether the flag should be set or unset.

◆ renderer_shader_per_draw_resources_acquire()

KAPI b8 renderer_shader_per_draw_resources_acquire ( struct renderer_system_state *  state,
khandle  shader,
u32 out_draw_id 
)

Acquires internal per-draw resources and provides a per-draw id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to acquire resources from.
texture_map_countThe number of texture maps used.
mapsAn array of pointers to texture maps. Must be one map for each per-group texture.
out_draw_idA pointer to hold the new per-draw identifier.
Returns
True on success; otherwise false.

◆ renderer_shader_per_draw_resources_release()

KAPI b8 renderer_shader_per_draw_resources_release ( struct renderer_system_state *  state,
khandle  shader,
u32  draw_id 
)

Releases internal per-draw resources for the given per-draw id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to release resources from.
draw_idThe per-draw identifier whose resources are to be released.
Returns
True on success; otherwise false.

◆ renderer_shader_per_group_resources_acquire()

KAPI b8 renderer_shader_per_group_resources_acquire ( struct renderer_system_state *  state,
khandle  shader,
u32 out_group_id 
)

Acquires internal per-group resources and provides a group id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to acquire resources from.
configA constant pointer to the configuration of the group to be used while acquiring resources.
out_group_idA pointer to hold the new per-group identifier.
Returns
True on success; otherwise false.

◆ renderer_shader_per_group_resources_release()

KAPI b8 renderer_shader_per_group_resources_release ( struct renderer_system_state *  state,
khandle  shader,
u32  group_id 
)

Releases internal per-group resources for the given group id.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to release resources from.
group_idThe per-group identifier whose resources are to be released.
Returns
True on success; otherwise false.

◆ renderer_shader_reload()

KAPI b8 renderer_shader_reload ( struct renderer_system_state *  state,
khandle  shader,
u32  stage_count,
shader_stage stages,
kname names,
const char **  sources 
)

Reloads the internals of the given shader.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be reloaded.
shader_stage_countThe number of shader stages.
shader_stagesAn array of shader stages configs.
Returns
True on success; otherwise false.

◆ renderer_shader_supports_wireframe()

KAPI b8 renderer_shader_supports_wireframe ( struct renderer_system_state *  state,
khandle  shader 
)

Determines if the given shader supports wireframe mode.

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

◆ renderer_shader_uniform_set()

KAPI b8 renderer_shader_uniform_set ( struct renderer_system_state *  state,
khandle  shader,
struct shader_uniform uniform,
u32  array_index,
const void *  value 
)

Sets the uniform of the given shader to the provided value.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader.
uniformA constant pointer to the uniform.
array_indexThe index of the uniform array to be set, if it is an array. For non-array types, this value is ignored.
valueA pointer to the value to be set.
Returns
True on success; otherwise false.

◆ renderer_shader_use()

KAPI b8 renderer_shader_use ( struct renderer_system_state *  state,
khandle  shader 
)

Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls.

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

◆ renderer_system_deserialize_config()

b8 renderer_system_deserialize_config ( const char *  config_str,
renderer_system_config out_config 
)

◆ renderer_system_frame_number_get()

KAPI u16 renderer_system_frame_number_get ( struct renderer_system_state *  state)

◆ renderer_system_initialize()

KAPI b8 renderer_system_initialize ( u64 memory_requirement,
struct renderer_system_state *  state,
const renderer_system_config config 
)

Initializes the renderer frontend/system. Should be called twice - once to obtain the memory requirement (passing state=0), and a second time passing allocated memory to state.

Parameters
memory_requirementA pointer to hold the memory requirement for this system.
stateA block of memory to hold state data, or 0 if obtaining memory requirement.
configA constant pointer to the configuration for the renderer.
Returns
True on success; otherwise false.

◆ renderer_system_shutdown()

KAPI void renderer_system_shutdown ( struct renderer_system_state *  state)

Shuts the renderer system/frontend down.

Parameters
stateA pointer to the state block of memory.

◆ renderer_texture_prepare_for_sampling()

KAPI void renderer_texture_prepare_for_sampling ( struct renderer_system_state *  state,
khandle  texture_handle,
ktexture_flag_bits  flags 
)

Performs operations required on the supplied texture before being used for sampling.

Parameters
stateA pointer to the renderer system state.
texture_handleA handle to the texture to prepare for sampling.
flagsTexture flags from the texture itself, used to determine format/layout, etc.

◆ renderer_texture_read_data()

KAPI b8 renderer_texture_read_data ( struct renderer_system_state *  state,
khandle  renderer_texture_handle,
u32  offset,
u32  size,
u8 **  out_memory 
)

Reads the given data from the provided texture.

Parameters
stateA pointer to the renderer system state.
renderer_texture_handleA handle to the texture to be read from.
offsetThe offset in bytes from the beginning of the data to be read.
sizeThe number of bytes to be read.
out_pixelshaderA handle to a block of memory to write the read data to.
Returns
True on success; otherwise false.

◆ renderer_texture_read_pixel()

KAPI b8 renderer_texture_read_pixel ( struct renderer_system_state *  state,
khandle  renderer_texture_handle,
u32  x,
u32  y,
u8 **  out_rgba 
)

Reads a pixel from the provided texture at the given x/y coordinate.

Parameters
stateA pointer to the renderer system state.
renderer_texture_handleA handle to the texture to be read from.
xThe pixel x-coordinate.
yThe pixel y-coordinate.
out_rgbaA pointer to an array of u8s to hold the pixel data (should be sizeof(u8) * 4)
Returns
True on success; otherwise false.

◆ renderer_texture_resize()

KAPI b8 renderer_texture_resize ( struct renderer_system_state *  state,
khandle  renderer_texture_handle,
u32  new_width,
u32  new_height 
)

Resizes a texture. There is no check at this level to see if the texture is writeable. Internal resources are destroyed and re-created at the new resolution. Data is lost and would need to be reloaded.

Parameters
stateA pointer to the renderer system state.
renderer_texture_handleA handle to the texture to be resized.
new_widthThe new width in pixels.
new_heightThe new height in pixels.
Returns
True on success; otherwise false.

◆ renderer_texture_resources_acquire()

KAPI b8 renderer_texture_resources_acquire ( struct renderer_system_state *  state,
kname  name,
ktexture_type  type,
u32  width,
u32  height,
u8  channel_count,
u8  mip_levels,
u16  array_size,
ktexture_flag_bits  flags,
khandle out_renderer_texture_handle 
)

Attempts to acquire renderer-specific resources to back a texture.

Parameters
stateA pointer to the renderer system state.
nameThe name of the texture.
typeThe type of texture.
widthThe texture width in pixels.
heightThe texture height in pixels.
channel_countThe number of channels in the texture (i.e. RGBA = 4)
mip_levelsThe number of mip maps the internal texture has. Must always be at least 1.
array_sizeFor arrayed textures, how many "layers" there are. Otherwise this is 1.
flagsVarious property flags to be used in creating this texture.
out_renderer_texture_handleA pointer to hold the renderer texture handle, which points to the backing resource(s) of the texture.
Returns
True on success, otherwise false;

◆ renderer_texture_resources_release()

KAPI void renderer_texture_resources_release ( struct renderer_system_state *  state,
khandle handle 
)

Releases backing renderer-specific resources for the given renderer_texture_id.

Parameters
stateA pointer to the renderer system state.
handleA pointer to the handle of the renderer texture whose resources are to be released. Handle is automatically invalidated.

◆ renderer_texture_write_data()

KAPI b8 renderer_texture_write_data ( struct renderer_system_state *  state,
khandle  renderer_texture_handle,
u32  offset,
u32  size,
const u8 pixels 
)

Writes the given data to the provided texture.

Parameters
stateA pointer to the renderer system state.
renderer_texture_handleA handle to the texture to be written to. NOTE: Must be a writeable texture.
offsetThe offset in bytes from the beginning of the data to be written.
sizeThe number of bytes to be written.
pixelsThe raw image data to be written.
Returns
True on success; otherwise false.

◆ renderer_viewport_reset()

KAPI void renderer_viewport_reset ( void  )

Resets the viewport to the default, which matches the application window.

◆ renderer_viewport_set()

KAPI void renderer_viewport_set ( vec4  rect)

Sets the renderer viewport to the given rectangle.

Parameters
rectThe viewport rectangle to be set.

◆ renderer_wait_for_idle()

KAPI void renderer_wait_for_idle ( void  )

Waits for the renderer backend to be completely idle of work before returning. NOTE: This incurs a lot of overhead/waits, and should be used sparingly.

◆ renderer_winding_set()

KAPI void renderer_winding_set ( renderer_winding  winding)

Set the renderer to use the given winding direction.

Parameters
windingThe winding direction.