Kore
Loading...
Searching...
No Matches
commandlist.h File Reference

Contains functions for building command-lists to send commands to the GPU. More...

#include <kinc/global.h>
#include "rendertarget.h"
#include "sampler.h"
#include "texture.h"
#include "textureunit.h"
#include <kinc/backend/graphics5/commandlist.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  kinc_g5_command_list

Macros

#define KINC_G5_CLEAR_COLOR   1
#define KINC_G5_CLEAR_DEPTH   2
#define KINC_G5_CLEAR_STENCIL   4

Typedefs

typedef struct kinc_g5_command_list kinc_g5_command_list_t

Functions

KINC_FUNC void kinc_g5_command_list_init (kinc_g5_command_list_t *list)
 Initializes a command-list.
KINC_FUNC void kinc_g5_command_list_destroy (kinc_g5_command_list_t *list)
 Destroys a command-list.
KINC_FUNC void kinc_g5_command_list_begin (kinc_g5_command_list_t *list)
 Starts recording commands in a command-list.
KINC_FUNC void kinc_g5_command_list_end (kinc_g5_command_list_t *list)
 Ends recording commands for the list. Has to be called after kinc_g5_command_list_begin and before kinc_g5_command_list_execute.
KINC_FUNC void kinc_g5_command_list_clear (kinc_g5_command_list_t *list, struct kinc_g5_render_target *render_target, unsigned flags, unsigned color, float depth, int stencil)
 Records a command to clear the color, depth and/or stencil-components of a render-target.
KINC_FUNC void kinc_g5_command_list_render_target_to_framebuffer_barrier (kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget)
 Records a command that prepares a render-target to be used as the current framebuffer.
KINC_FUNC void kinc_g5_command_list_framebuffer_to_render_target_barrier (kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget)
 Records a command that prepares a render-target for regular render-target-usage after being used as the current framebuffer.
KINC_FUNC void kinc_g5_command_list_texture_to_render_target_barrier (kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget)
 Writes a command that prepares a render-target to be rendered to.
KINC_FUNC void kinc_g5_command_list_render_target_to_texture_barrier (kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget)
 Writes a command that prepares a render-target to be used for sampling/reading like a texture.
KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices (kinc_g5_command_list_t *list)
 Writes a command that draws the entire content of the currently set index-buffer and vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.
KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_from_to (kinc_g5_command_list_t *list, int start, int count)
 Writes a command that draws a part of the content of the currently set index-buffer and vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.
KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_from_to_from (kinc_g5_command_list_t *list, int start, int count, int vertex_offset)
 Writes a command that draws a part of the content of the currently set index-buffer and vertex-buffer and additionally applies a general offset into the vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.
KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_instanced (kinc_g5_command_list_t *list, int instanceCount)
KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to (kinc_g5_command_list_t *list, int instanceCount, int start, int count)
KINC_FUNC void kinc_g5_command_list_viewport (kinc_g5_command_list_t *list, int x, int y, int width, int height)
 Writes a command that sets the viewport which defines the portion of the framebuffer or render-target things are rendered into. By default the viewport is equivalent to the full size of the current render-target or framebuffer.
KINC_FUNC void kinc_g5_command_list_scissor (kinc_g5_command_list_t *list, int x, int y, int width, int height)
 Writes a command that enables and defines the scissor-rect. When the scissor-rect is enabled, anything that's rendered outside of the scissor-rect will be ignored.
KINC_FUNC void kinc_g5_command_list_disable_scissor (kinc_g5_command_list_t *list)
 Writes a command to disable the scissor-rect.
KINC_FUNC void kinc_g5_command_list_set_pipeline (kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline)
 Writes a command to set the pipeline for the next draw-call. The pipeline defines most rendering-state including the shaders to be used.
KINC_FUNC void kinc_g5_command_list_set_compute_shader (kinc_g5_command_list_t *list, struct kinc_g5_compute_shader *shader)
 Writes a command to set the compute shader for the next compute-call.
KINC_FUNC void kinc_g5_command_list_set_blend_constant (kinc_g5_command_list_t *list, float r, float g, float b, float a)
 Sets the blend constant used for KINC_G5_BLEND_CONSTANT or KINC_G5_INV_BLEND_CONSTANT.
KINC_FUNC void kinc_g5_command_list_set_vertex_buffers (kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **buffers, int *offsets, int count)
 Writes a command which sets vertex-buffers for the next draw-call.
KINC_FUNC void kinc_g5_command_list_set_index_buffer (kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer)
 Writes a command to set an index-buffer to be used for the next draw-command.
KINC_FUNC void kinc_g5_command_list_set_render_targets (kinc_g5_command_list_t *list, struct kinc_g5_render_target **targets, int count)
 Writes a command that sets the render-targets to draw into in following draw-calls.
KINC_FUNC void kinc_g5_command_list_upload_index_buffer (kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer)
 Writes a command to upload an index-buffer that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.
KINC_FUNC void kinc_g5_command_list_upload_vertex_buffer (kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer)
 Writes a command to upload a vertex-buffer that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.
KINC_FUNC void kinc_g5_command_list_upload_texture (kinc_g5_command_list_t *list, struct kinc_g5_texture *texture)
 Writes a command to upload a texture that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.
KINC_FUNC void kinc_g5_command_list_set_vertex_constant_buffer (kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size)
 Writes a command that sets a constant-buffer for the vertex-shader-stage.
KINC_FUNC void kinc_g5_command_list_set_fragment_constant_buffer (kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size)
 Writes a command that sets a constant-buffer for the fragment-shader-stage.
KINC_FUNC void kinc_g5_command_list_set_compute_constant_buffer (kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size)
 Writes a command that sets a constant-buffer for the compute-shader-stage.
KINC_FUNC void kinc_g5_command_list_execute (kinc_g5_command_list_t *list)
 Kicks off execution of the commands which have been recorded in the command-list. kinc_g5_command_list_end has to be called beforehand.
KINC_FUNC void kinc_g5_command_list_wait_for_execution_to_finish (kinc_g5_command_list_t *list)
 Waits for execution of the command_list to finish. Make sure the command-list is executing before you wait for it. Also take note that waiting for a command-list to finish executing completely is a very expensive operation.
KINC_FUNC void kinc_g5_command_list_get_render_target_pixels (kinc_g5_command_list_t *list, struct kinc_g5_render_target *render_target, uint8_t *data)
 Writes a command that copies the contents of a render-target into a cpu-side buffer. Beware: This is enormously slow.
KINC_FUNC void kinc_g5_command_list_compute (kinc_g5_command_list_t *list, int x, int y, int z)
 Records a command that fires off a compute-run on x * y * z elements.
KINC_FUNC void kinc_g5_command_list_set_texture (kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture)
 Assigns a texture to a texture-unit for sampled access via GLSL's texture.
KINC_FUNC void kinc_g5_command_list_set_image_texture (kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture)
 Assigns a texture to a texture-unit for direct access via GLSL's texelFetch (as opposed to GLSL's texture). The name of this functions is unfortunately based on OpenGL's confusing terminology.
KINC_FUNC void kinc_g5_command_list_set_texture_from_render_target (kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_render_target_t *target)
 Uses the color-component of a render-target as a texture.
KINC_FUNC void kinc_g5_command_list_set_texture_from_render_target_depth (kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_render_target_t *target)
 Uses the depth-component of a render-target as a texture.
KINC_FUNC void kinc_g5_command_list_set_render_target_face (kinc_g5_command_list_t *list, kinc_g5_render_target_t *texture, int face)
KINC_FUNC void kinc_g5_command_list_set_sampler (kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler)
KINC_FUNC bool kinc_g5_command_list_init_occlusion_query (kinc_g5_command_list_t *list, unsigned *occlusionQuery)
KINC_FUNC void kinc_g5_command_list_delete_occlusion_query (kinc_g5_command_list_t *list, unsigned occlusionQuery)
KINC_FUNC void kinc_g5_command_list_render_occlusion_query (kinc_g5_command_list_t *list, unsigned occlusionQuery, int triangles)
KINC_FUNC bool kinc_g5_command_list_are_query_results_available (kinc_g5_command_list_t *list, unsigned occlusionQuery)
KINC_FUNC void kinc_g5_command_list_get_query_result (kinc_g5_command_list_t *list, unsigned occlusionQuery, unsigned *pixelCount)

Detailed Description

Contains functions for building command-lists to send commands to the GPU.

Function Documentation

◆ kinc_g5_command_list_begin()

KINC_FUNC void kinc_g5_command_list_begin ( kinc_g5_command_list_t * list)

Starts recording commands in a command-list.

Parameters
listThe list to use

◆ kinc_g5_command_list_clear()

KINC_FUNC void kinc_g5_command_list_clear ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * render_target,
unsigned flags,
unsigned color,
float depth,
int stencil )

Records a command to clear the color, depth and/or stencil-components of a render-target.

Parameters
listThe list to write the command to
render_targetThe render-target to clear
flagsDefines what components to clear
colorThe color-value to clear to in 0xAARRGGBB
depthThe depth-value to clear to
stencilThe stencil-value to clear to

◆ kinc_g5_command_list_compute()

KINC_FUNC void kinc_g5_command_list_compute ( kinc_g5_command_list_t * list,
int x,
int y,
int z )

Records a command that fires off a compute-run on x * y * z elements.

Parameters
listThe list to write the command to
xThe x-size for the compute-run
yThe y-size for the compute-run
zThe z-size for the compute-run

◆ kinc_g5_command_list_destroy()

KINC_FUNC void kinc_g5_command_list_destroy ( kinc_g5_command_list_t * list)

Destroys a command-list.

Parameters
listThe command-list to destroy

◆ kinc_g5_command_list_disable_scissor()

KINC_FUNC void kinc_g5_command_list_disable_scissor ( kinc_g5_command_list_t * list)

Writes a command to disable the scissor-rect.

Parameters
listThe list to write the command to

◆ kinc_g5_command_list_draw_indexed_vertices()

KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices ( kinc_g5_command_list_t * list)

Writes a command that draws the entire content of the currently set index-buffer and vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.

Parameters
listThe list to write the command to

◆ kinc_g5_command_list_draw_indexed_vertices_from_to()

KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_from_to ( kinc_g5_command_list_t * list,
int start,
int count )

Writes a command that draws a part of the content of the currently set index-buffer and vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.

Parameters
listThe list to write the command to
startThe offset into the index-buffer
countThe number of indices to use

◆ kinc_g5_command_list_draw_indexed_vertices_from_to_from()

KINC_FUNC void kinc_g5_command_list_draw_indexed_vertices_from_to_from ( kinc_g5_command_list_t * list,
int start,
int count,
int vertex_offset )

Writes a command that draws a part of the content of the currently set index-buffer and vertex-buffer and additionally applies a general offset into the vertex-buffer. G4 can only draw triangle-lists using vertex-indices as this is what GPUs tend to be optimized for.

Parameters
listThe list to write the command to
startThe offset into the index-buffer
countThe number of indices to use
vertex_offsetThe offset into the vertex-buffer which is added to each index read from the index-buffer

◆ kinc_g5_command_list_end()

KINC_FUNC void kinc_g5_command_list_end ( kinc_g5_command_list_t * list)

Ends recording commands for the list. Has to be called after kinc_g5_command_list_begin and before kinc_g5_command_list_execute.

Parameters
list
Returns

◆ kinc_g5_command_list_execute()

KINC_FUNC void kinc_g5_command_list_execute ( kinc_g5_command_list_t * list)

Kicks off execution of the commands which have been recorded in the command-list. kinc_g5_command_list_end has to be called beforehand.

Parameters
listThe command-list to execute

◆ kinc_g5_command_list_framebuffer_to_render_target_barrier()

KINC_FUNC void kinc_g5_command_list_framebuffer_to_render_target_barrier ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * renderTarget )

Records a command that prepares a render-target for regular render-target-usage after being used as the current framebuffer.

Parameters
listThe list to write the command to
renderTargetThe render-target to use in regular render-target-mode

◆ kinc_g5_command_list_get_render_target_pixels()

KINC_FUNC void kinc_g5_command_list_get_render_target_pixels ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * render_target,
uint8_t * data )

Writes a command that copies the contents of a render-target into a cpu-side buffer. Beware: This is enormously slow.

Parameters
listThe list to write the command to
render_targetThe render-target to copy the data from
dataThe buffer to copy the data into

◆ kinc_g5_command_list_init()

KINC_FUNC void kinc_g5_command_list_init ( kinc_g5_command_list_t * list)

Initializes a command-list.

Parameters
listThe command-list to initialize

◆ kinc_g5_command_list_render_target_to_framebuffer_barrier()

KINC_FUNC void kinc_g5_command_list_render_target_to_framebuffer_barrier ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * renderTarget )

Records a command that prepares a render-target to be used as the current framebuffer.

Parameters
listThe list to write the command to
renderTargetThe render-target to use as the current framebuffer

◆ kinc_g5_command_list_render_target_to_texture_barrier()

KINC_FUNC void kinc_g5_command_list_render_target_to_texture_barrier ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * renderTarget )

Writes a command that prepares a render-target to be used for sampling/reading like a texture.

Parameters
listThe list to write the command to
renderTargetThe render-target to be used like a texture

◆ kinc_g5_command_list_scissor()

KINC_FUNC void kinc_g5_command_list_scissor ( kinc_g5_command_list_t * list,
int x,
int y,
int width,
int height )

Writes a command that enables and defines the scissor-rect. When the scissor-rect is enabled, anything that's rendered outside of the scissor-rect will be ignored.

Parameters
listThe list to write the command to
xThe x-offset of the scissor-rect from the left of the screen in pixels
yThe y-offset of the scissor-rect from the top of the screen in pixels
widthThe width of the scissor-rect in pixels
heightThe height of the scissor-rect in pixels

◆ kinc_g5_command_list_set_compute_constant_buffer()

KINC_FUNC void kinc_g5_command_list_set_compute_constant_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_constant_buffer * buffer,
int offset,
size_t size )

Writes a command that sets a constant-buffer for the compute-shader-stage.

Parameters
listThe list to write the command to
bufferThe buffer to set
offsetThe offset into the buffer in bytes to use as the start
sizeThe size of the buffer to use in bytes starting at the offset

◆ kinc_g5_command_list_set_compute_shader()

KINC_FUNC void kinc_g5_command_list_set_compute_shader ( kinc_g5_command_list_t * list,
struct kinc_g5_compute_shader * shader )

Writes a command to set the compute shader for the next compute-call.

Parameters
listThe list to write the command to
pipelineThe compute shader to set

◆ kinc_g5_command_list_set_fragment_constant_buffer()

KINC_FUNC void kinc_g5_command_list_set_fragment_constant_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_constant_buffer * buffer,
int offset,
size_t size )

Writes a command that sets a constant-buffer for the fragment-shader-stage.

Parameters
listThe list to write the command to
bufferThe buffer to set
offsetThe offset into the buffer in bytes to use as the start
sizeThe size of the buffer to use in bytes starting at the offset

◆ kinc_g5_command_list_set_image_texture()

KINC_FUNC void kinc_g5_command_list_set_image_texture ( kinc_g5_command_list_t * list,
kinc_g5_texture_unit_t unit,
kinc_g5_texture_t * texture )

Assigns a texture to a texture-unit for direct access via GLSL's texelFetch (as opposed to GLSL's texture). The name of this functions is unfortunately based on OpenGL's confusing terminology.

Parameters
listThe list to write the command to
unitThe unit to assign this texture to
textureThe texture to assign to the unit

◆ kinc_g5_command_list_set_index_buffer()

KINC_FUNC void kinc_g5_command_list_set_index_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_index_buffer * buffer )

Writes a command to set an index-buffer to be used for the next draw-command.

Parameters
listThe list to write the command to
bufferThe buffer to use

◆ kinc_g5_command_list_set_pipeline()

KINC_FUNC void kinc_g5_command_list_set_pipeline ( kinc_g5_command_list_t * list,
struct kinc_g5_pipeline * pipeline )

Writes a command to set the pipeline for the next draw-call. The pipeline defines most rendering-state including the shaders to be used.

Parameters
listThe list to write the command to
pipelineThe pipeline to set

◆ kinc_g5_command_list_set_render_targets()

KINC_FUNC void kinc_g5_command_list_set_render_targets ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target ** targets,
int count )

Writes a command that sets the render-targets to draw into in following draw-calls.

Parameters
listThe list to write the command to
targetsThe render-targets to use for following-draw calls
countThe number of render-targets to use

◆ kinc_g5_command_list_set_texture()

KINC_FUNC void kinc_g5_command_list_set_texture ( kinc_g5_command_list_t * list,
kinc_g5_texture_unit_t unit,
kinc_g5_texture_t * texture )

Assigns a texture to a texture-unit for sampled access via GLSL's texture.

Parameters
listThe list to write the command to
unitThe unit to assign this texture to
textureThe texture to assign to the unit

◆ kinc_g5_command_list_set_texture_from_render_target()

KINC_FUNC void kinc_g5_command_list_set_texture_from_render_target ( kinc_g5_command_list_t * list,
kinc_g5_texture_unit_t unit,
kinc_g5_render_target_t * target )

Uses the color-component of a render-target as a texture.

Parameters
listThe list to write the command to
unitThe texture-unit to assign the render-target to
targetThe render-target to use

◆ kinc_g5_command_list_set_texture_from_render_target_depth()

KINC_FUNC void kinc_g5_command_list_set_texture_from_render_target_depth ( kinc_g5_command_list_t * list,
kinc_g5_texture_unit_t unit,
kinc_g5_render_target_t * target )

Uses the depth-component of a render-target as a texture.

Parameters
listThe list to write the command to
unitThe texture-unit to assign the render-target to
targetThe render-target to use

◆ kinc_g5_command_list_set_vertex_buffers()

KINC_FUNC void kinc_g5_command_list_set_vertex_buffers ( kinc_g5_command_list_t * list,
struct kinc_g5_vertex_buffer ** buffers,
int * offsets,
int count )

Writes a command which sets vertex-buffers for the next draw-call.

Parameters
listThe list to write the command to
buffersThe buffers to set
offsetsThe offset to use for every buffer in number of vertices
countThe number of buffers to set

◆ kinc_g5_command_list_set_vertex_constant_buffer()

KINC_FUNC void kinc_g5_command_list_set_vertex_constant_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_constant_buffer * buffer,
int offset,
size_t size )

Writes a command that sets a constant-buffer for the vertex-shader-stage.

Parameters
listThe list to write the command to
bufferThe buffer to set
offsetThe offset into the buffer in bytes to use as the start
sizeThe size of the buffer to use in bytes starting at the offset

◆ kinc_g5_command_list_texture_to_render_target_barrier()

KINC_FUNC void kinc_g5_command_list_texture_to_render_target_barrier ( kinc_g5_command_list_t * list,
struct kinc_g5_render_target * renderTarget )

Writes a command that prepares a render-target to be rendered to.

Parameters
listThe list to write the command to
renderTargetThe render-target to render to

◆ kinc_g5_command_list_upload_index_buffer()

KINC_FUNC void kinc_g5_command_list_upload_index_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_index_buffer * buffer )

Writes a command to upload an index-buffer that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.

Parameters
listThe list to write the command to
bufferThe buffer to upload

◆ kinc_g5_command_list_upload_texture()

KINC_FUNC void kinc_g5_command_list_upload_texture ( kinc_g5_command_list_t * list,
struct kinc_g5_texture * texture )

Writes a command to upload a texture that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.

Parameters
listThe list to write the command to
bufferThe texture to upload

◆ kinc_g5_command_list_upload_vertex_buffer()

KINC_FUNC void kinc_g5_command_list_upload_vertex_buffer ( kinc_g5_command_list_t * list,
struct kinc_g5_vertex_buffer * buffer )

Writes a command to upload a vertex-buffer that's in main-memory to gpu-memory. Does nothing on unified-memory-systems.

Parameters
listThe list to write the command to
bufferThe buffer to upload

◆ kinc_g5_command_list_viewport()

KINC_FUNC void kinc_g5_command_list_viewport ( kinc_g5_command_list_t * list,
int x,
int y,
int width,
int height )

Writes a command that sets the viewport which defines the portion of the framebuffer or render-target things are rendered into. By default the viewport is equivalent to the full size of the current render-target or framebuffer.

Parameters
listThe list to write the command to
xThe x-offset of the viewport from the left of the screen in pixels
yThe y-offset of the viewport from the top of the screen in pixels
widthThe width of the viewport in pixels
heightThe height of the viewport in pixels

◆ kinc_g5_command_list_wait_for_execution_to_finish()

KINC_FUNC void kinc_g5_command_list_wait_for_execution_to_finish ( kinc_g5_command_list_t * list)

Waits for execution of the command_list to finish. Make sure the command-list is executing before you wait for it. Also take note that waiting for a command-list to finish executing completely is a very expensive operation.

Parameters
listThe command-list to execute