#pragma once #include #include #include #include /*! \file constantbuffer.h \brief Provides support for managing buffers of constant-data for shaders. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_g5_constant_buffer { uint8_t *data; ConstantBuffer5Impl impl; } kinc_g5_constant_buffer_t; /// /// Initializes a constant-buffer. /// /// The buffer to initialize /// The size of the constant-data in the buffer in bytes KINC_FUNC void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size); /// /// Destroys a buffer. /// /// The buffer to destroy KINC_FUNC void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer); /// /// Locks all of a constant-buffer to modify its contents. /// /// The buffer to lock /// The contents of the buffer KINC_FUNC void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer); /// /// Locks part of a constant-buffer to modify its contents. /// /// The buffer to lock /// The offset of where to start the lock in bytes /// The number of bytes to lock /// The contents of the buffer, starting at start KINC_FUNC void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count); /// /// Unlocks a constant-buffer so the changed contents can be used. /// /// The buffer to unlock KINC_FUNC void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer); /// /// Figures out the size of the constant-data in the buffer. /// /// The buffer to figure out the size for /// Returns the size of the constant-data in the buffer in bytes KINC_FUNC int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer); /// /// Assigns a bool at an offset in a constant-buffer. /// /// The offset at which to write the data /// The value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int offset, bool value); /// /// Assigns an integer at an offset in a constant-buffer. /// /// The offset at which to write the data /// The value to assign to the constant/uniform KINC_FUNC void kinc_g5_constant_buffer_set_int(kinc_g5_constant_buffer_t *buffer, int offset, int value); /// /// Assigns two integers at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_int2(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2); /// /// Assigns three integers at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer /// The third value to write into the buffer/param> KINC_FUNC void kinc_g5_constant_buffer_set_int3(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3); /// /// Assigns four integers at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer /// The third value to write into the buffer/param> /// The fourth value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_int4(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4); /// /// Assigns a bunch of integers at an offset in a constant-buffer. /// /// The location of the constant/uniform to assign the values to /// The values to write into the buffer /// The number of values to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_ints(kinc_g5_constant_buffer_t *buffer, int offset, int *values, int count); /// /// Assigns a float at an offset in a constant-buffer. /// /// The offset at which to write the data /// The value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_float(kinc_g5_constant_buffer_t *buffer, int offset, float value); /// /// Assigns two floats at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_float2(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2); /// /// Assigns three floats at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer /// The third value to write into the buffer/param> KINC_FUNC void kinc_g5_constant_buffer_set_float3(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3); /// /// Assigns four floats at an offset in a constant-buffer. /// /// The offset at which to write the data /// The first value to write into the buffer /// The second value to write into the buffer /// The third value to write into the buffer/param> /// The fourth value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4); /// /// Assigns a bunch of floats at an offset in a constant-buffer. /// /// The location of the constant/uniform to assign the values to /// The values to write into the buffer /// The number of values to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int offset, float *values, int count); /// /// Assigns a 3x3-matrix at an offset in a constant-buffer. /// /// The offset at which to write the data /// The value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value); /// /// Assigns a 4x4-matrix at an offset in a constant-buffer. /// /// The offset at which to write the data /// The value to write into the buffer KINC_FUNC void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value); KINC_FUNC extern bool kinc_g5_transposeMat3; KINC_FUNC extern bool kinc_g5_transposeMat4; #ifdef __cplusplus } #endif