diff --git a/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h b/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h
index 05dadbe2e..e35e174e8 100644
--- a/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h
+++ b/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h
@@ -432,13 +432,41 @@ void kinc_g4_set_int(kinc_g4_constant_location_t location, int value) {
kinc_g5_constant_buffer_set_int(&computeConstantBuffer, location.impl._location.impl.computeOffset, value);
}
-void kinc_g4_set_int2(kinc_g4_constant_location_t location, int value1, int value2) {}
+void kinc_g4_set_int2(kinc_g4_constant_location_t location, int value1, int value2) {
+ if (location.impl._location.impl.vertexOffset >= 0)
+ kinc_g5_constant_buffer_set_int2(&vertexConstantBuffer, location.impl._location.impl.vertexOffset, value1, value2);
+ if (location.impl._location.impl.fragmentOffset >= 0)
+ kinc_g5_constant_buffer_set_int2(&fragmentConstantBuffer, location.impl._location.impl.fragmentOffset, value1, value2);
+ if (location.impl._location.impl.computeOffset >= 0)
+ kinc_g5_constant_buffer_set_int2(&computeConstantBuffer, location.impl._location.impl.computeOffset, value1, value2);
+}
-void kinc_g4_set_int3(kinc_g4_constant_location_t location, int value1, int value2, int value3) {}
+void kinc_g4_set_int3(kinc_g4_constant_location_t location, int value1, int value2, int value3) {
+ if (location.impl._location.impl.vertexOffset >= 0)
+ kinc_g5_constant_buffer_set_int3(&vertexConstantBuffer, location.impl._location.impl.vertexOffset, value1, value2, value3);
+ if (location.impl._location.impl.fragmentOffset >= 0)
+ kinc_g5_constant_buffer_set_int3(&fragmentConstantBuffer, location.impl._location.impl.fragmentOffset, value1, value2, value3);
+ if (location.impl._location.impl.computeOffset >= 0)
+ kinc_g5_constant_buffer_set_int3(&computeConstantBuffer, location.impl._location.impl.computeOffset, value1, value2, value3);
+}
-void kinc_g4_set_int4(kinc_g4_constant_location_t location, int value1, int value2, int value3, int value4) {}
+void kinc_g4_set_int4(kinc_g4_constant_location_t location, int value1, int value2, int value3, int value4) {
+ if (location.impl._location.impl.vertexOffset >= 0)
+ kinc_g5_constant_buffer_set_int4(&vertexConstantBuffer, location.impl._location.impl.vertexOffset, value1, value2, value3, value4);
+ if (location.impl._location.impl.fragmentOffset >= 0)
+ kinc_g5_constant_buffer_set_int4(&fragmentConstantBuffer, location.impl._location.impl.fragmentOffset, value1, value2, value3, value4);
+ if (location.impl._location.impl.computeOffset >= 0)
+ kinc_g5_constant_buffer_set_int4(&computeConstantBuffer, location.impl._location.impl.computeOffset, value1, value2, value3, value4);
+}
-void kinc_g4_set_ints(kinc_g4_constant_location_t location, int *values, int count) {}
+void kinc_g4_set_ints(kinc_g4_constant_location_t location, int *values, int count) {
+ if (location.impl._location.impl.vertexOffset >= 0)
+ kinc_g5_constant_buffer_set_ints(&vertexConstantBuffer, location.impl._location.impl.vertexOffset, values, count);
+ if (location.impl._location.impl.fragmentOffset >= 0)
+ kinc_g5_constant_buffer_set_ints(&fragmentConstantBuffer, location.impl._location.impl.fragmentOffset, values, count);
+ if (location.impl._location.impl.computeOffset >= 0)
+ kinc_g5_constant_buffer_set_ints(&computeConstantBuffer, location.impl._location.impl.computeOffset, values, count);
+}
void kinc_g4_set_float(kinc_g4_constant_location_t location, float value) {
if (location.impl._location.impl.vertexOffset >= 0)
diff --git a/Sources/kinc/graphics5/constantbuffer.c.h b/Sources/kinc/graphics5/constantbuffer.c.h
index 8a82fa391..1427782b4 100644
--- a/Sources/kinc/graphics5/constantbuffer.c.h
+++ b/Sources/kinc/graphics5/constantbuffer.c.h
@@ -1,58 +1,77 @@
#include "constantbuffer.h"
-static void setInt(uint8_t *constants, int offset, int value) {
- int *ints = (int *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_int(kinc_g5_constant_buffer_t *buffer, int offset, int value) {
+ int *ints = (int *)(&buffer->data[offset]);
ints[0] = value;
}
-static void setFloat(uint8_t *constants, int offset, float value) {
- float *floats = (float *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_int2(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2) {
+ int *ints = (int *)(&buffer->data[offset]);
+ ints[0] = value1;
+ ints[1] = value2;
+}
+
+void kinc_g5_constant_buffer_set_int3(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3) {
+ int *ints = (int *)(&buffer->data[offset]);
+ ints[0] = value1;
+ ints[1] = value2;
+ ints[2] = value3;
+}
+
+void kinc_g5_constant_buffer_set_int4(kinc_g5_constant_buffer_t *buffer, int offset, int value1, int value2, int value3, int value4) {
+ int *ints = (int *)(&buffer->data[offset]);
+ ints[0] = value1;
+ ints[1] = value2;
+ ints[2] = value3;
+ ints[3] = value4;
+}
+
+void kinc_g5_constant_buffer_set_ints(kinc_g5_constant_buffer_t *buffer, int offset, int *values, int count) {
+ int *ints = (int *)(&buffer->data[offset]);
+ for (int i = 0; i < count; ++i) {
+ ints[i] = values[i];
+ }
+}
+
+void kinc_g5_constant_buffer_set_float(kinc_g5_constant_buffer_t *buffer, int offset, float value) {
+ float *floats = (float *)(&buffer->data[offset]);
floats[0] = value;
}
-static void setFloat2(uint8_t *constants, int offset, float value1, float value2) {
- float *floats = (float *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_float2(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2) {
+ float *floats = (float *)(&buffer->data[offset]);
floats[0] = value1;
floats[1] = value2;
}
-static void setFloat3(uint8_t *constants, int offset, float value1, float value2, float value3) {
- float *floats = (float *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_float3(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) {
+ float *floats = (float *)(&buffer->data[offset]);
floats[0] = value1;
floats[1] = value2;
floats[2] = value3;
}
-static void setFloat4(uint8_t *constants, int offset, float value1, float value2, float value3, float value4) {
- float *floats = (float *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) {
+ float *floats = (float *)(&buffer->data[offset]);
floats[0] = value1;
floats[1] = value2;
floats[2] = value3;
floats[3] = value4;
}
-static void setFloats(uint8_t *constants, int offset, float *values, int count) {
- float *floats = (float *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int offset, float *values, int count) {
+ float *floats = (float *)(&buffer->data[offset]);
for (int i = 0; i < count; ++i) {
floats[i] = values[i];
}
}
-static void setBool(uint8_t *constants, int offset, bool value) {
- int *ints = (int *)(&constants[offset]);
+void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int offset, bool value) {
+ int *ints = (int *)(&buffer->data[offset]);
ints[0] = value ? 1 : 0;
}
-static void setMatrix4(uint8_t *constants, int offset, kinc_matrix4x4_t *value) {
- float *floats = (float *)(&constants[offset]);
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- floats[x + y * 4] = kinc_matrix4x4_get(value, x, y);
- }
- }
-}
-
-static void setMatrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value) {
+static void set_matrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value) {
float *floats = (float *)(&constants[offset]);
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
@@ -61,52 +80,33 @@ static void setMatrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value)
}
}
-void kinc_g5_constant_buffer_set_int(kinc_g5_constant_buffer_t *buffer, int offset, int value) {
- setInt(buffer->data, offset, value);
-}
-
-void kinc_g5_constant_buffer_set_float(kinc_g5_constant_buffer_t *buffer, int offset, float value) {
- setFloat(buffer->data, offset, value);
-}
-
-void kinc_g5_constant_buffer_set_float2(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2) {
- setFloat2(buffer->data, offset, value1, value2);
-}
-
-void kinc_g5_constant_buffer_set_float3(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3) {
- setFloat3(buffer->data, offset, value1, value2, value3);
-}
-
-void kinc_g5_constant_buffer_set_float4(kinc_g5_constant_buffer_t *buffer, int offset, float value1, float value2, float value3, float value4) {
- setFloat4(buffer->data, offset, value1, value2, value3, value4);
-}
-
-void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int offset, float *values, int count) {
- setFloats(buffer->data, offset, values, count);
+void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value) {
+ if (kinc_g5_transposeMat3) {
+ kinc_matrix3x3_t m = *value;
+ kinc_matrix3x3_transpose(&m);
+ set_matrix3(buffer->data, offset, &m);
+ }
+ else {
+ set_matrix3(buffer->data, offset, value);
+ }
}
-void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int offset, bool value) {
- setBool(buffer->data, offset, value);
+static void set_matrix4(uint8_t *constants, int offset, kinc_matrix4x4_t *value) {
+ float *floats = (float *)(&constants[offset]);
+ for (int y = 0; y < 4; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ floats[x + y * 4] = kinc_matrix4x4_get(value, x, y);
+ }
+ }
}
void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value) {
if (kinc_g5_transposeMat4) {
kinc_matrix4x4_t m = *value;
kinc_matrix4x4_transpose(&m);
- setMatrix4(buffer->data, offset, &m);
- }
- else {
- setMatrix4(buffer->data, offset, value);
- }
-}
-
-void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value) {
- if (kinc_g5_transposeMat3) {
- kinc_matrix3x3_t m = *value;
- kinc_matrix3x3_transpose(&m);
- setMatrix3(buffer->data, offset, &m);
+ set_matrix4(buffer->data, offset, &m);
}
else {
- setMatrix3(buffer->data, offset, value);
+ set_matrix4(buffer->data, offset, value);
}
}
diff --git a/Sources/kinc/graphics5/constantbuffer.h b/Sources/kinc/graphics5/constantbuffer.h
index ce689671a..9909752e5 100644
--- a/Sources/kinc/graphics5/constantbuffer.h
+++ b/Sources/kinc/graphics5/constantbuffer.h
@@ -76,6 +76,41 @@ KINC_FUNC void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffe
/// 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.
///