Kohi Game Engine
renderer_plugin Struct Reference

A generic "interface" for the renderer plugin. The renderer backend is what is responsible for making calls to the graphics API such as Vulkan, OpenGL or DirectX. Each of these should implement this interface. The frontend only interacts via this structure and has no knowledge of the way things actually work on the backend. More...

#include <renderer_types.h>

Data Fields

u64 frame_number
 The current frame number. More...
 
u8 draw_index
 The draw index for the current frame. Typically aligns with the number of queue submissions per frame. More...
 
u64 internal_context_size
 The size of the plugin-specific renderer context. More...
 
void * internal_context
 The plugin-specific renderer context. More...
 
b8(* initialize )(struct renderer_plugin *plugin, const renderer_backend_config *config, u8 *out_window_render_target_count)
 Initializes the backend. More...
 
void(* shutdown )(struct renderer_plugin *plugin)
 Shuts the renderer backend down. More...
 
void(* resized )(struct renderer_plugin *plugin, u16 width, u16 height)
 Handles window resizes. More...
 
b8(* frame_prepare )(struct renderer_plugin *plugin, struct frame_data *p_frame_data)
 Performs setup routines required at the start of a frame. More...
 
b8(* begin )(struct renderer_plugin *plugin, struct frame_data *p_frame_data)
 Begins a render. There must be at least one of these and a matching end per frame. More...
 
b8(* end )(struct renderer_plugin *plugin, struct frame_data *p_frame_data)
 Ends a render. More...
 
b8(* present )(struct renderer_plugin *plugin, 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...
 
void(* viewport_set )(struct renderer_plugin *plugin, vec4 rect)
 Sets the renderer viewport to the given rectangle. Must be done within a renderpass. More...
 
void(* viewport_reset )(struct renderer_plugin *plugin)
 Resets the viewport to the default, which matches the application window. Must be done within a renderpass. More...
 
void(* scissor_set )(struct renderer_plugin *plugin, vec4 rect)
 Sets the renderer scissor to the given rectangle. Must be done within a renderpass. More...
 
void(* scissor_reset )(struct renderer_plugin *plugin)
 Resets the scissor to the default, which matches the application window. Must be done within a renderpass. More...
 
void(* winding_set )(struct renderer_plugin *plugin, renderer_winding winding)
 Set the renderer to use the given winding direction. More...
 
b8(* renderpass_begin )(struct renderer_plugin *plugin, renderpass *pass, render_target *target)
 Begins a renderpass with the given id. More...
 
b8(* renderpass_end )(struct renderer_plugin *plugin, renderpass *pass)
 Ends a renderpass with the given id. More...
 
void(* texture_create )(struct renderer_plugin *plugin, const u8 *pixels, struct texture *texture)
 Creates a renderer-backend-API-specific texture, acquiring internal resources as needed. More...
 
void(* texture_destroy )(struct renderer_plugin *plugin, struct texture *texture)
 Destroys the given texture, releasing internal resources. More...
 
void(* texture_create_writeable )(struct renderer_plugin *plugin, texture *t)
 Creates a new writeable texture with no data written to it. More...
 
void(* texture_resize )(struct renderer_plugin *plugin, texture *t, 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...
 
void(* texture_write_data )(struct renderer_plugin *plugin, texture *t, u32 offset, u32 size, const u8 *pixels)
 Writes the given data to the provided texture. NOTE: At this level, this can either be a writeable or non-writeable texture because this also handles the initial texture load. The texture system itself should be responsible for blocking write requests to non-writeable textures. More...
 
void(* texture_read_data )(struct renderer_plugin *plugin, texture *t, u32 offset, u32 size, void **out_memory)
 Reads the given data from the provided texture. More...
 
void(* texture_read_pixel )(struct renderer_plugin *plugin, texture *t, u32 x, u32 y, u8 **out_rgba)
 Reads a pixel from the provided texture at the given x/y coordinate. More...
 
b8(* geometry_create )(struct renderer_plugin *plugin, geometry *g)
 Creates renderer-backend-API-specific internal resources for the given geometry using the data provided. More...
 
b8(* geometry_upload )(struct renderer_plugin *plugin, geometry *g, u32 vertex_offset, u32 vertex_size, u32 index_offset, u32 index_size)
 Acquires renderer-backend-API-specific internal resources for the given geometry and uploads data to the GPU. More...
 
void(* geometry_vertex_update )(struct renderer_plugin *plugin, geometry *g, u32 offset, u32 vertex_count, void *vertices)
 Updates vertex data in the given geometry with the provided data in the given range. More...
 
void(* geometry_destroy )(struct renderer_plugin *plugin, geometry *g)
 Destroys the given geometry, releasing internal resources. More...
 
void(* geometry_draw )(struct renderer_plugin *plugin, geometry_render_data *data)
 Draws the given geometry. Should only be called inside a renderpass, within a frame. More...
 
b8(* shader_create )(struct renderer_plugin *plugin, struct shader *shader, const shader_config *config, renderpass *pass, u8 stage_count, const char **stage_filenames, shader_stage *stages)
 Creates internal shader resources using the provided parameters. More...
 
void(* shader_destroy )(struct renderer_plugin *plugin, struct shader *shader)
 Destroys the given shader and releases any resources held by it. More...
 
b8(* shader_initialize )(struct renderer_plugin *plugin, struct shader *shader)
 Initializes a configured shader. Will be automatically destroyed if this step fails. Must be done after vulkan_shader_create(). More...
 
b8(* shader_use )(struct renderer_plugin *plugin, struct shader *shader)
 Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls. More...
 
b8(* shader_bind_globals )(struct renderer_plugin *plugin, struct shader *s)
 Binds global resources for use and updating. More...
 
b8(* shader_bind_instance )(struct renderer_plugin *plugin, struct shader *s, u32 instance_id)
 Binds instance resources for use and updating. More...
 
b8(* shader_apply_globals )(struct renderer_plugin *plugin, struct shader *s, b8 needs_update)
 Applies global data to the uniform buffer. More...
 
b8(* shader_apply_instance )(struct renderer_plugin *plugin, struct shader *s, b8 needs_update)
 Applies data for the currently bound instance. More...
 
b8(* shader_instance_resources_acquire )(struct renderer_plugin *plugin, struct shader *s, u32 texture_map_count, texture_map **maps, u32 *out_instance_id)
 Acquires internal instance-level resources and provides an instance id. More...
 
b8(* shader_instance_resources_release )(struct renderer_plugin *plugin, struct shader *s, u32 instance_id)
 Releases internal instance-level resources for the given instance id. More...
 
b8(* shader_uniform_set )(struct renderer_plugin *plugin, struct shader *frontend_shader, struct shader_uniform *uniform, const void *value)
 Sets the uniform of the given shader to the provided value. More...
 
b8(* texture_map_resources_acquire )(struct renderer_plugin *plugin, struct texture_map *map)
 Acquires internal resources for the given texture map. More...
 
void(* texture_map_resources_release )(struct renderer_plugin *plugin, struct texture_map *map)
 Releases internal resources for the given texture map. More...
 
b8(* render_target_create )(struct renderer_plugin *plugin, u8 attachment_count, render_target_attachment *attachments, renderpass *pass, u32 width, u32 height, render_target *out_target)
 Creates a new render target using the provided data. More...
 
void(* render_target_destroy )(struct renderer_plugin *plugin, render_target *target, b8 free_internal_memory)
 Destroys the provided render target. More...
 
b8(* renderpass_create )(struct renderer_plugin *plugin, const renderpass_config *config, renderpass *out_renderpass)
 Creates a new renderpass. More...
 
void(* renderpass_destroy )(struct renderer_plugin *plugin, renderpass *pass)
 Destroys the given renderpass. More...
 
texture *(* window_attachment_get )(struct renderer_plugin *plugin, u8 index)
 Attempts to get the window render target at the given index. More...
 
texture *(* depth_attachment_get )(struct renderer_plugin *plugin, u8 index)
 Returns a pointer to the main depth texture target. More...
 
u8(* window_attachment_index_get )(struct renderer_plugin *plugin)
 Returns the current window attachment index. More...
 
u8(* window_attachment_count_get )(struct renderer_plugin *plugin)
 Returns the number of attachments required for window-based render targets. More...
 
b8(* is_multithreaded )(struct renderer_plugin *plugin)
 Indicates if the renderer is capable of multi-threading. More...
 
b8(* flag_enabled_get )(struct renderer_plugin *plugin, 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...
 
void(* flag_enabled_set )(struct renderer_plugin *plugin, 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...
 
b8(* renderbuffer_internal_create )(struct renderer_plugin *plugin, renderbuffer *buffer)
 Creates and assigns the renderer-backend-specific buffer. More...
 
void(* renderbuffer_internal_destroy )(struct renderer_plugin *plugin, renderbuffer *buffer)
 Destroys the given buffer. More...
 
b8(* renderbuffer_bind )(struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset)
 Binds the given buffer at the provided offset. More...
 
b8(* renderbuffer_unbind )(struct renderer_plugin *plugin, renderbuffer *buffer)
 Unbinds the given buffer. More...
 
void *(* renderbuffer_map_memory )(struct renderer_plugin *plugin, 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...
 
void(* renderbuffer_unmap_memory )(struct renderer_plugin *plugin, 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...
 
b8(* renderbuffer_flush )(struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size)
 Flushes buffer memory at the given range. Should be done after a write. More...
 
b8(* renderbuffer_read )(struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size, void **out_memory)
 Reads memory from the provided buffer at the given range to the output variable. More...
 
b8(* renderbuffer_resize )(struct renderer_plugin *plugin, 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...
 
b8(* renderbuffer_load_range )(struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size, const void *data)
 Loads provided data into the specified rage of the given buffer. More...
 
b8(* renderbuffer_copy_range )(struct renderer_plugin *plugin, renderbuffer *source, u64 source_offset, renderbuffer *dest, u64 dest_offset, u64 size)
 Copies data in the specified rage fron the source to the destination buffer. More...
 
b8(* renderbuffer_draw )(struct renderer_plugin *plugin, 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 for use with vertex and index buffers. More...
 

Detailed Description

A generic "interface" for the renderer plugin. The renderer backend is what is responsible for making calls to the graphics API such as Vulkan, OpenGL or DirectX. Each of these should implement this interface. The frontend only interacts via this structure and has no knowledge of the way things actually work on the backend.

Field Documentation

◆ begin

b8(* begin) (struct renderer_plugin *plugin, struct frame_data *p_frame_data)

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

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

◆ depth_attachment_get

texture*(* depth_attachment_get) (struct renderer_plugin *plugin, u8 index)

Returns a pointer to the main depth texture target.

Parameters
pluginA pointer to the renderer plugin interface.
indexThe index of the attachment to get. Must be within the range of window render target count.
Returns
A pointer to a texture attachment if successful; otherwise 0.

◆ draw_index

u8 draw_index

The draw index for the current frame. Typically aligns with the number of queue submissions per frame.

◆ end

b8(* end) (struct renderer_plugin *plugin, struct frame_data *p_frame_data)

Ends a render.

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

◆ flag_enabled_get

b8(* flag_enabled_get) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
flagThe flag to be checked.
Returns
True if the flag(s) set; otherwise false.

◆ flag_enabled_set

void(* flag_enabled_set) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
flagThe flag to be checked.
enabledIndicates whether or not to enable the flag(s).

◆ frame_number

u64 frame_number

The current frame number.

◆ frame_prepare

b8(* frame_prepare) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ geometry_create

b8(* geometry_create) (struct renderer_plugin *plugin, geometry *g)

Creates renderer-backend-API-specific internal resources for the given geometry using the data provided.

Parameters
pluginA pointer to the renderer plugin interface.
gA pointer to the geometry to be created.
Returns
True on success; otherwise false.

◆ geometry_destroy

void(* geometry_destroy) (struct renderer_plugin *plugin, geometry *g)

Destroys the given geometry, releasing internal resources.

Parameters
pluginA pointer to the renderer plugin interface.
gA pointer to the geometry to be destroyed.

◆ geometry_draw

void(* geometry_draw) (struct renderer_plugin *plugin, geometry_render_data *data)

Draws the given geometry. Should only be called inside a renderpass, within a frame.

Parameters
pluginA pointer to the renderer plugin interface.
dataA pointer to the render data of the geometry to be drawn.

◆ geometry_upload

b8(* geometry_upload) (struct renderer_plugin *plugin, geometry *g, u32 vertex_offset, u32 vertex_size, u32 index_offset, u32 index_size)

Acquires renderer-backend-API-specific internal resources for the given geometry and uploads data to the GPU.

Parameters
pluginA pointer to the renderer plugin interface.
gA pointer to the geometry to be initialized.
vertex_offsetThe offset in bytes from the beginning of the geometry's vertex data.
vertex_sizeThe amount in bytes of vertex data to be uploaded.
index_offsetThe offset in bytes from the beginning of the geometry's index data.
index_sizeThe amount in bytes of index data to be uploaded.
Returns
True on success; otherwise false.

◆ geometry_vertex_update

void(* geometry_vertex_update) (struct renderer_plugin *plugin, geometry *g, u32 offset, u32 vertex_count, void *vertices)

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

Parameters
pluginA pointer to the renderer plugin interface.
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.

◆ initialize

b8(* initialize) (struct renderer_plugin *plugin, const renderer_backend_config *config, u8 *out_window_render_target_count)

Initializes the backend.

Parameters
pluginA pointer to the renderer plugin interface.
configA pointer to configuration to be used when initializing the backend.
out_window_render_target_countA pointer to hold how many render targets are needed for renderpasses targeting the window.
Returns
True if initialized successfully; otherwise false.

◆ internal_context

void* internal_context

The plugin-specific renderer context.

◆ internal_context_size

u64 internal_context_size

The size of the plugin-specific renderer context.

◆ is_multithreaded

b8(* is_multithreaded) (struct renderer_plugin *plugin)

Indicates if the renderer is capable of multi-threading.

Parameters
pluginA pointer to the renderer plugin interface.

◆ present

b8(* present) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
p_frame_dataA constant pointer to the current frame's data.
Returns
True on success; otherwise false.

◆ render_target_create

b8(* render_target_create) (struct renderer_plugin *plugin, u8 attachment_count, render_target_attachment *attachments, renderpass *pass, u32 width, u32 height, render_target *out_target)

Creates a new render target using the provided data.

Parameters
pluginA pointer to the renderer plugin interface.
attachment_countThe number of attachments.
attachmentsAn array of attachments.
renderpassA pointer to the renderpass the render target is associated with.
widthThe width of the render target in pixels.
heightThe height of the render target in pixels.
out_targetA pointer to hold the newly created render target.

◆ render_target_destroy

void(* render_target_destroy) (struct renderer_plugin *plugin, render_target *target, b8 free_internal_memory)

Destroys the provided render target.

Parameters
pluginA pointer to the renderer plugin interface.
targetA pointer to the render target to be destroyed.
free_internal_memoryIndicates if internal memory should be freed.

◆ renderbuffer_bind

b8(* renderbuffer_bind) (struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset)

Binds the given buffer at the provided offset.

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

◆ renderbuffer_copy_range

b8(* renderbuffer_copy_range) (struct renderer_plugin *plugin, renderbuffer *source, u64 source_offset, renderbuffer *dest, u64 dest_offset, u64 size)

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

Parameters
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_draw

b8(* renderbuffer_draw) (struct renderer_plugin *plugin, 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 for use with vertex and index buffers.

Parameters
pluginA pointer to the renderer plugin interface.
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 binds the buffer, but does not call draw.
Returns
True on success; otherwise false.

◆ renderbuffer_flush

b8(* renderbuffer_flush) (struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size)

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

Parameters
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_internal_create

b8(* renderbuffer_internal_create) (struct renderer_plugin *plugin, renderbuffer *buffer)

Creates and assigns the renderer-backend-specific buffer.

Parameters
pluginA pointer to the renderer plugin interface.
bufferA pointer to create the internal buffer for.
Returns
True on success; otherwise false.

◆ renderbuffer_internal_destroy

void(* renderbuffer_internal_destroy) (struct renderer_plugin *plugin, renderbuffer *buffer)

Destroys the given buffer.

Parameters
pluginA pointer to the renderer plugin interface.
bufferA pointer to the buffer to be destroyed.

◆ renderbuffer_load_range

b8(* renderbuffer_load_range) (struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size, const void *data)

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

Parameters
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_map_memory

void*(* renderbuffer_map_memory) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_read

b8(* renderbuffer_read) (struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset, u64 size, void **out_memory)

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

Parameters
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_resize

b8(* renderbuffer_resize) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
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.

◆ renderbuffer_unbind

b8(* renderbuffer_unbind) (struct renderer_plugin *plugin, renderbuffer *buffer)

Unbinds the given buffer.

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

◆ renderbuffer_unmap_memory

void(* renderbuffer_unmap_memory) (struct renderer_plugin *plugin, 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
pluginA pointer to the renderer plugin interface.
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.

◆ renderpass_begin

b8(* renderpass_begin) (struct renderer_plugin *plugin, renderpass *pass, render_target *target)

Begins a renderpass with the given id.

Parameters
pluginA pointer to the renderer plugin interface.
passA pointer to the renderpass to begin.
targetA pointer to the render target to be used.
Returns
True on success; otherwise false.

◆ renderpass_create

b8(* renderpass_create) (struct renderer_plugin *plugin, const renderpass_config *config, renderpass *out_renderpass)

Creates a new renderpass.

Parameters
pluginA pointer to the renderer plugin interface.
configA constant pointer to the configuration to be used when creating the renderpass.
out_renderpassA pointer to the generic renderpass.

◆ renderpass_destroy

void(* renderpass_destroy) (struct renderer_plugin *plugin, renderpass *pass)

Destroys the given renderpass.

Parameters
pluginA pointer to the renderer plugin interface.
passA pointer to the renderpass to be destroyed.

◆ renderpass_end

b8(* renderpass_end) (struct renderer_plugin *plugin, renderpass *pass)

Ends a renderpass with the given id.

Parameters
pluginA pointer to the renderer plugin interface.
passA pointer to the renderpass to end.
Returns
True on success; otherwise false.

◆ resized

void(* resized) (struct renderer_plugin *plugin, u16 width, u16 height)

Handles window resizes.

Parameters
pluginA pointer to the renderer plugin interface.
widthThe new window width.
heightThe new window height.

◆ scissor_reset

void(* scissor_reset) (struct renderer_plugin *plugin)

Resets the scissor to the default, which matches the application window. Must be done within a renderpass.

Parameters
pluginA pointer to the renderer plugin interface.

◆ scissor_set

void(* scissor_set) (struct renderer_plugin *plugin, vec4 rect)

Sets the renderer scissor to the given rectangle. Must be done within a renderpass.

Parameters
pluginA pointer to the renderer plugin interface.
rectThe scissor rectangle to be set.

◆ shader_apply_globals

b8(* shader_apply_globals) (struct renderer_plugin *plugin, struct shader *s, b8 needs_update)

Applies global data to the uniform buffer.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to apply the global data for.
needs_updateIndicates if the shader uniforms need to be updated or just bound.
Returns
True on success; otherwise false.

◆ shader_apply_instance

b8(* shader_apply_instance) (struct renderer_plugin *plugin, struct shader *s, b8 needs_update)

Applies data for the currently bound instance.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to apply the instance data for.
needs_updateIndicates if the shader uniforms need to be updated or just bound.
Returns
True on success; otherwise false.

◆ shader_bind_globals

b8(* shader_bind_globals) (struct renderer_plugin *plugin, struct shader *s)

Binds global resources for use and updating.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader whose globals are to be bound.
Returns
True on success; otherwise false.

◆ shader_bind_instance

b8(* shader_bind_instance) (struct renderer_plugin *plugin, struct shader *s, u32 instance_id)

Binds instance resources for use and updating.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader whose instance resources are to be bound.
instance_idThe identifier of the instance to be bound.
Returns
True on success; otherwise false.

◆ shader_create

b8(* shader_create) (struct renderer_plugin *plugin, struct shader *shader, const shader_config *config, renderpass *pass, u8 stage_count, const char **stage_filenames, shader_stage *stages)

Creates internal shader resources using the provided parameters.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader.
configA constant pointer to the shader config.
passA pointer to the renderpass to be associated with the shader.
stage_countThe total number of stages.
stage_filenamesAn array of shader stage filenames to be loaded. Should align with stages array.
stagesA array of shader_stages indicating what render stages (vertex, fragment, etc.) used in this shader.
Returns
b8 True on success; otherwise false.

◆ shader_destroy

void(* shader_destroy) (struct renderer_plugin *plugin, struct shader *shader)

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

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to be destroyed.

◆ shader_initialize

b8(* shader_initialize) (struct renderer_plugin *plugin, struct shader *shader)

Initializes a configured shader. Will be automatically destroyed if this step fails. Must be done after vulkan_shader_create().

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to be initialized.
Returns
True on success; otherwise false.

◆ shader_instance_resources_acquire

b8(* shader_instance_resources_acquire) (struct renderer_plugin *plugin, struct shader *s, u32 texture_map_count, texture_map **maps, u32 *out_instance_id)

Acquires internal instance-level resources and provides an instance id.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer 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 per instance texture.
out_instance_idA pointer to hold the new instance identifier.
Returns
True on success; otherwise false.

◆ shader_instance_resources_release

b8(* shader_instance_resources_release) (struct renderer_plugin *plugin, struct shader *s, u32 instance_id)

Releases internal instance-level resources for the given instance id.

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to release resources from.
instance_idThe instance identifier whose resources are to be released.
Returns
True on success; otherwise false.

◆ shader_uniform_set

b8(* shader_uniform_set) (struct renderer_plugin *plugin, struct shader *frontend_shader, struct shader_uniform *uniform, const void *value)

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

Parameters
pluginA pointer to the renderer plugin interface.
sA ponter to the shader.
uniformA constant pointer to the uniform.
valueA pointer to the value to be set.
Returns
b8 True on success; otherwise false.

◆ shader_use

b8(* shader_use) (struct renderer_plugin *plugin, struct shader *shader)

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

Parameters
pluginA pointer to the renderer plugin interface.
sA pointer to the shader to be used.
Returns
True on success; otherwise false.

◆ shutdown

void(* shutdown) (struct renderer_plugin *plugin)

Shuts the renderer backend down.

Parameters
pluginA pointer to the renderer plugin interface.

◆ texture_create

void(* texture_create) (struct renderer_plugin *plugin, const u8 *pixels, struct texture *texture)

Creates a renderer-backend-API-specific texture, acquiring internal resources as needed.

Parameters
pluginA pointer to the renderer plugin interface.
pixelsThe raw image data used for the texture.
textureA pointer to the texture to hold the resources.

◆ texture_create_writeable

void(* texture_create_writeable) (struct renderer_plugin *plugin, texture *t)

Creates a new writeable texture with no data written to it.

Parameters
pluginA pointer to the renderer plugin interface.
tA pointer to the texture to hold the resources.

◆ texture_destroy

void(* texture_destroy) (struct renderer_plugin *plugin, struct texture *texture)

Destroys the given texture, releasing internal resources.

Parameters
pluginA pointer to the renderer plugin interface.
textureA pointer to the texture to be destroyed.

◆ texture_map_resources_acquire

b8(* texture_map_resources_acquire) (struct renderer_plugin *plugin, struct texture_map *map)

Acquires internal resources for the given texture map.

Parameters
pluginA pointer to the renderer plugin interface.
mapA pointer to the texture map to obtain resources for.
Returns
True on success; otherwise false.

◆ texture_map_resources_release

void(* texture_map_resources_release) (struct renderer_plugin *plugin, struct texture_map *map)

Releases internal resources for the given texture map.

Parameters
pluginA pointer to the renderer plugin interface.
mapA pointer to the texture map to release resources from.

◆ texture_read_data

void(* texture_read_data) (struct renderer_plugin *plugin, texture *t, u32 offset, u32 size, void **out_memory)

Reads the given data from the provided texture.

Parameters
pluginA pointer to the renderer plugin interface.
tA pointer 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_memoryA pointer to a block of memory to write the read data to.

◆ texture_read_pixel

void(* texture_read_pixel) (struct renderer_plugin *plugin, texture *t, u32 x, u32 y, u8 **out_rgba)

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

Parameters
pluginA pointer to the renderer plugin interface.
tA pointer 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)

◆ texture_resize

void(* texture_resize) (struct renderer_plugin *plugin, texture *t, 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
pluginA pointer to the renderer plugin interface.
tA pointer to the texture to be resized.
new_widthThe new width in pixels.
new_heightThe new height in pixels.

◆ texture_write_data

void(* texture_write_data) (struct renderer_plugin *plugin, texture *t, u32 offset, u32 size, const u8 *pixels)

Writes the given data to the provided texture. NOTE: At this level, this can either be a writeable or non-writeable texture because this also handles the initial texture load. The texture system itself should be responsible for blocking write requests to non-writeable textures.

Parameters
pluginA pointer to the renderer plugin interface.
tA pointer to the texture to be written to.
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.

◆ viewport_reset

void(* viewport_reset) (struct renderer_plugin *plugin)

Resets the viewport to the default, which matches the application window. Must be done within a renderpass.

Parameters
pluginA pointer to the renderer plugin interface.

◆ viewport_set

void(* viewport_set) (struct renderer_plugin *plugin, vec4 rect)

Sets the renderer viewport to the given rectangle. Must be done within a renderpass.

Parameters
pluginA pointer to the renderer plugin interface.
rectThe viewport rectangle to be set.

◆ winding_set

void(* winding_set) (struct renderer_plugin *plugin, renderer_winding winding)

Set the renderer to use the given winding direction.

Parameters
Apointer to the renderer plugin interface.
windingThe winding direction.

◆ window_attachment_count_get

u8(* window_attachment_count_get) (struct renderer_plugin *plugin)

Returns the number of attachments required for window-based render targets.

Parameters
pluginA pointer to the renderer plugin interface.

◆ window_attachment_get

texture*(* window_attachment_get) (struct renderer_plugin *plugin, u8 index)

Attempts to get the window render target at the given index.

Parameters
pluginA pointer to the renderer plugin interface.
indexThe index of the attachment to get. Must be within the range of window render target count.
Returns
A pointer to a texture attachment if successful; otherwise 0.

◆ window_attachment_index_get

u8(* window_attachment_index_get) (struct renderer_plugin *plugin)

Returns the current window attachment index.

Parameters
pluginA pointer to the renderer plugin interface.

The documentation for this struct was generated from the following file: