Kohi Game Engine
|
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... | |
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.
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.
plugin | A pointer to the renderer plugin interface. |
p_frame_data | A pointer to the current frame's data. |
texture*(* depth_attachment_get) (struct renderer_plugin *plugin, u8 index) |
Returns a pointer to the main depth texture target.
plugin | A pointer to the renderer plugin interface. |
index | The index of the attachment to get. Must be within the range of window render target count. |
u8 draw_index |
The draw index for the current frame. Typically aligns with the number of queue submissions per frame.
b8(* end) (struct renderer_plugin *plugin, struct frame_data *p_frame_data) |
Ends a render.
plugin | A pointer to the renderer plugin interface. |
p_frame_data | A pointer to the current frame's data. |
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.
plugin | A pointer to the renderer plugin interface. |
flag | The flag to be checked. |
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.
plugin | A pointer to the renderer plugin interface. |
flag | The flag to be checked. |
enabled | Indicates whether or not to enable the flag(s). |
u64 frame_number |
The current frame number.
b8(* frame_prepare) (struct renderer_plugin *plugin, struct frame_data *p_frame_data) |
Performs setup routines required at the start of a frame.
plugin | A pointer to the renderer plugin interface. |
p_frame_data | A pointer to the current frame's data. |
b8(* geometry_create) (struct renderer_plugin *plugin, geometry *g) |
Creates renderer-backend-API-specific internal resources for the given geometry using the data provided.
plugin | A pointer to the renderer plugin interface. |
g | A pointer to the geometry to be created. |
void(* geometry_destroy) (struct renderer_plugin *plugin, geometry *g) |
Destroys the given geometry, releasing internal resources.
plugin | A pointer to the renderer plugin interface. |
g | A pointer to the geometry to be destroyed. |
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.
plugin | A pointer to the renderer plugin interface. |
data | A pointer to the render data of the geometry to be drawn. |
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.
plugin | A pointer to the renderer plugin interface. |
g | A pointer to the geometry to be initialized. |
vertex_offset | The offset in bytes from the beginning of the geometry's vertex data. |
vertex_size | The amount in bytes of vertex data to be uploaded. |
index_offset | The offset in bytes from the beginning of the geometry's index data. |
index_size | The amount in bytes of index data to be uploaded. |
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.
plugin | A pointer to the renderer plugin interface. |
g | A pointer to the geometry to be created. |
offset | The offset in bytes to update. 0 if updating from the beginning. |
vertex_count | The number of vertices which will be updated. |
vertices | The vertex data. |
b8(* initialize) (struct renderer_plugin *plugin, const renderer_backend_config *config, u8 *out_window_render_target_count) |
Initializes the backend.
plugin | A pointer to the renderer plugin interface. |
config | A pointer to configuration to be used when initializing the backend. |
out_window_render_target_count | A pointer to hold how many render targets are needed for renderpasses targeting the window. |
void* internal_context |
The plugin-specific renderer context.
u64 internal_context_size |
The size of the plugin-specific renderer context.
b8(* is_multithreaded) (struct renderer_plugin *plugin) |
Indicates if the renderer is capable of multi-threading.
plugin | A pointer to the renderer plugin interface. |
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.
plugin | A pointer to the renderer plugin interface. |
p_frame_data | A constant pointer to the current frame's data. |
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.
plugin | A pointer to the renderer plugin interface. |
attachment_count | The number of attachments. |
attachments | An array of attachments. |
renderpass | A pointer to the renderpass the render target is associated with. |
width | The width of the render target in pixels. |
height | The height of the render target in pixels. |
out_target | A pointer to hold the newly created render target. |
void(* render_target_destroy) (struct renderer_plugin *plugin, render_target *target, b8 free_internal_memory) |
Destroys the provided render target.
plugin | A pointer to the renderer plugin interface. |
target | A pointer to the render target to be destroyed. |
free_internal_memory | Indicates if internal memory should be freed. |
b8(* renderbuffer_bind) (struct renderer_plugin *plugin, renderbuffer *buffer, u64 offset) |
Binds the given buffer at the provided offset.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to bind. |
offset | The offset in bytes from the beginning of the buffer. |
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.
plugin | A pointer to the renderer plugin interface. |
source | A pointer to the source buffer to copy data from. |
source_offset | The offset in bytes from the beginning of the source buffer. |
dest | A pointer to the destination buffer to copy data to. |
dest_offset | The offset in bytes from the beginning of the destination buffer. |
size | The size of the data in bytes to be copied. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to be drawn. |
offset | The offset in bytes from the beginning of the buffer. |
element_count | The number of elements to be drawn. |
bind_only | Only binds the buffer, but does not call draw. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to unmap. |
offset | The number of bytes from the beginning of the buffer to flush. |
size | The amount of memory in the buffer to flush. |
b8(* renderbuffer_internal_create) (struct renderer_plugin *plugin, renderbuffer *buffer) |
Creates and assigns the renderer-backend-specific buffer.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to create the internal buffer for. |
void(* renderbuffer_internal_destroy) (struct renderer_plugin *plugin, renderbuffer *buffer) |
Destroys the given buffer.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to be destroyed. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to load data into. |
offset | The offset in bytes from the beginning of the buffer. |
size | The size of the data in bytes to be loaded. |
data | The data to be loaded. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to map. |
offset | The number of bytes from the beginning of the buffer to map. |
size | The amount of memory in the buffer to map. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to read from. |
offset | The number of bytes from the beginning of the buffer to read. |
size | The amount of memory in the buffer to read. |
out_memory | A pointer to a block of memory to read to. Must be of appropriate size. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to be resized. |
new_total_size | The new size in bytes. Must be larger than the current size. |
b8(* renderbuffer_unbind) (struct renderer_plugin *plugin, renderbuffer *buffer) |
Unbinds the given buffer.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to be unbound. |
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.
plugin | A pointer to the renderer plugin interface. |
buffer | A pointer to the buffer to unmap. |
offset | The number of bytes from the beginning of the buffer to unmap. |
size | The amount of memory in the buffer to unmap. |
b8(* renderpass_begin) (struct renderer_plugin *plugin, renderpass *pass, render_target *target) |
Begins a renderpass with the given id.
plugin | A pointer to the renderer plugin interface. |
pass | A pointer to the renderpass to begin. |
target | A pointer to the render target to be used. |
b8(* renderpass_create) (struct renderer_plugin *plugin, const renderpass_config *config, renderpass *out_renderpass) |
Creates a new renderpass.
plugin | A pointer to the renderer plugin interface. |
config | A constant pointer to the configuration to be used when creating the renderpass. |
out_renderpass | A pointer to the generic renderpass. |
void(* renderpass_destroy) (struct renderer_plugin *plugin, renderpass *pass) |
Destroys the given renderpass.
plugin | A pointer to the renderer plugin interface. |
pass | A pointer to the renderpass to be destroyed. |
b8(* renderpass_end) (struct renderer_plugin *plugin, renderpass *pass) |
Ends a renderpass with the given id.
plugin | A pointer to the renderer plugin interface. |
pass | A pointer to the renderpass to end. |
void(* resized) (struct renderer_plugin *plugin, u16 width, u16 height) |
Handles window resizes.
plugin | A pointer to the renderer plugin interface. |
width | The new window width. |
height | The new window height. |
void(* scissor_reset) (struct renderer_plugin *plugin) |
Resets the scissor to the default, which matches the application window. Must be done within a renderpass.
plugin | A pointer to the renderer plugin interface. |
void(* scissor_set) (struct renderer_plugin *plugin, vec4 rect) |
Sets the renderer scissor to the given rectangle. Must be done within a renderpass.
plugin | A pointer to the renderer plugin interface. |
rect | The scissor rectangle to be set. |
b8(* shader_apply_globals) (struct renderer_plugin *plugin, struct shader *s, b8 needs_update) |
Applies global data to the uniform buffer.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to apply the global data for. |
needs_update | Indicates if the shader uniforms need to be updated or just bound. |
b8(* shader_apply_instance) (struct renderer_plugin *plugin, struct shader *s, b8 needs_update) |
Applies data for the currently bound instance.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to apply the instance data for. |
needs_update | Indicates if the shader uniforms need to be updated or just bound. |
b8(* shader_bind_globals) (struct renderer_plugin *plugin, struct shader *s) |
Binds global resources for use and updating.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader whose globals are to be bound. |
b8(* shader_bind_instance) (struct renderer_plugin *plugin, struct shader *s, u32 instance_id) |
Binds instance resources for use and updating.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader whose instance resources are to be bound. |
instance_id | The identifier of the instance to be bound. |
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.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader. |
config | A constant pointer to the shader config. |
pass | A pointer to the renderpass to be associated with the shader. |
stage_count | The total number of stages. |
stage_filenames | An array of shader stage filenames to be loaded. Should align with stages array. |
stages | A array of shader_stages indicating what render stages (vertex, fragment, etc.) used in this shader. |
void(* shader_destroy) (struct renderer_plugin *plugin, struct shader *shader) |
Destroys the given shader and releases any resources held by it.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to be destroyed. |
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().
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to be initialized. |
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.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to acquire resources from. |
texture_map_count | The number of texture maps used. |
maps | An array of pointers to texture maps. Must be one map per instance texture. |
out_instance_id | A pointer to hold the new instance identifier. |
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.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to release resources from. |
instance_id | The instance identifier whose resources are to be released. |
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.
plugin | A pointer to the renderer plugin interface. |
s | A ponter to the shader. |
uniform | A constant pointer to the uniform. |
value | A pointer to the value to be set. |
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.
plugin | A pointer to the renderer plugin interface. |
s | A pointer to the shader to be used. |
void(* shutdown) (struct renderer_plugin *plugin) |
Shuts the renderer backend down.
plugin | A pointer to the renderer plugin interface. |
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.
plugin | A pointer to the renderer plugin interface. |
pixels | The raw image data used for the texture. |
texture | A pointer to the texture to hold the resources. |
void(* texture_create_writeable) (struct renderer_plugin *plugin, texture *t) |
Creates a new writeable texture with no data written to it.
plugin | A pointer to the renderer plugin interface. |
t | A pointer to the texture to hold the resources. |
void(* texture_destroy) (struct renderer_plugin *plugin, struct texture *texture) |
Destroys the given texture, releasing internal resources.
plugin | A pointer to the renderer plugin interface. |
texture | A pointer to the texture to be destroyed. |
b8(* texture_map_resources_acquire) (struct renderer_plugin *plugin, struct texture_map *map) |
Acquires internal resources for the given texture map.
plugin | A pointer to the renderer plugin interface. |
map | A pointer to the texture map to obtain resources for. |
void(* texture_map_resources_release) (struct renderer_plugin *plugin, struct texture_map *map) |
Releases internal resources for the given texture map.
plugin | A pointer to the renderer plugin interface. |
map | A pointer to the texture map to release resources from. |
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.
plugin | A pointer to the renderer plugin interface. |
t | A pointer to the texture to be read from. |
offset | The offset in bytes from the beginning of the data to be read. |
size | The number of bytes to be read. |
out_memory | A pointer to a block of memory to write the read data to. |
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.
plugin | A pointer to the renderer plugin interface. |
t | A pointer to the texture to be read from. |
x | The pixel x-coordinate. |
y | The pixel y-coordinate. |
out_rgba | A pointer to an array of u8s to hold the pixel data (should be sizeof(u8) * 4) |
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.
plugin | A pointer to the renderer plugin interface. |
t | A pointer to the texture to be resized. |
new_width | The new width in pixels. |
new_height | The new height in pixels. |
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.
plugin | A pointer to the renderer plugin interface. |
t | A pointer to the texture to be written to. |
offset | The offset in bytes from the beginning of the data to be written. |
size | The number of bytes to be written. |
pixels | The raw image data to be written. |
void(* viewport_reset) (struct renderer_plugin *plugin) |
Resets the viewport to the default, which matches the application window. Must be done within a renderpass.
plugin | A pointer to the renderer plugin interface. |
void(* viewport_set) (struct renderer_plugin *plugin, vec4 rect) |
Sets the renderer viewport to the given rectangle. Must be done within a renderpass.
plugin | A pointer to the renderer plugin interface. |
rect | The viewport rectangle to be set. |
void(* winding_set) (struct renderer_plugin *plugin, renderer_winding winding) |
Set the renderer to use the given winding direction.
A | pointer to the renderer plugin interface. |
winding | The winding direction. |
u8(* window_attachment_count_get) (struct renderer_plugin *plugin) |
Returns the number of attachments required for window-based render targets.
plugin | A pointer to the renderer plugin interface. |
texture*(* window_attachment_get) (struct renderer_plugin *plugin, u8 index) |
Attempts to get the window render target at the given index.
plugin | A pointer to the renderer plugin interface. |
index | The index of the attachment to get. Must be within the range of window render target count. |
u8(* window_attachment_index_get) (struct renderer_plugin *plugin) |
Returns the current window attachment index.
plugin | A pointer to the renderer plugin interface. |