Remove g4

This commit is contained in:
luboslenco
2025-02-15 15:46:05 +01:00
parent c4b56aa1af
commit 8c61bf25e7
20 changed files with 65 additions and 158 deletions
@@ -752,7 +752,7 @@ static void cmd(struct android_app *app, int32_t cmd) {
}
else {
initDisplay();
kinc_g4_swap_buffers();
kinc_g5_swap_buffers();
}
updateAppForegroundStatus(true, appIsForeground);
@@ -1,7 +1,7 @@
#include <kinc/backend/system_microsoft.h>
bool kinc_g5_transposeMat = false;
bool kinc_g5_transpose_mat = false;
void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) {
buffer->impl.mySize = size;
@@ -8,5 +8,3 @@ typedef struct {
int lastCount;
int mySize;
} ConstantBuffer5Impl;
extern bool kinc_g5_transposeMat;
@@ -3,7 +3,7 @@
id getMetalDevice(void);
bool kinc_g5_transposeMat = true;
bool kinc_g5_transpose_mat = true;
void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) {
buffer->impl.mySize = size;
@@ -3,7 +3,7 @@
bool memory_type_from_properties(uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex);
bool kinc_g5_transposeMat = true;
bool kinc_g5_transpose_mat = true;
static void createUniformBuffer(VkBuffer *buf, VkMemoryAllocateInfo *mem_alloc, VkDeviceMemory *mem, VkDescriptorBufferInfo *buffer_info, int size) {
VkBufferCreateInfo buf_info;
@@ -1,7 +1,7 @@
#include <kinc/graphics5/constantbuffer.h>
#include <stdlib.h>
bool kinc_g5_transposeMat = false;
bool kinc_g5_transpose_mat = false;
void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) {
+2 -2
View File
@@ -468,7 +468,7 @@ void _update(void *data) {
kinc_g4_begin(0);
iron_update();
kinc_g4_end(0);
kinc_g4_swap_buffers();
kinc_g5_swap_buffers();
}
char *_copy(void *data) {
@@ -2029,7 +2029,7 @@ void iron_g4_end() {
void iron_g4_swap_buffers() {
kinc_g4_end(0);
kinc_g4_swap_buffers();
kinc_g5_swap_buffers();
kinc_g4_begin(0);
}
@@ -1 +0,0 @@
#include "commandlist.h"
@@ -1,27 +1,23 @@
#pragma once
#include <stddef.h>
#include <kinc/global.h>
#include <kinc/backend/graphics5/commandlist.h>
#include "rendertarget.h"
#include "texture.h"
#include "pipeline.h"
#include <kinc/backend/graphics5/commandlist.h>
#include <stddef.h>
/*! \file commandlist.h
\brief Contains functions for building command-lists to send commands to the GPU.
*/
#define KINC_G5_CLEAR_COLOR 1
#define KINC_G5_CLEAR_DEPTH 2
struct kinc_g5_compute_shader;
struct kinc_g5_constant_buffer;
struct kinc_g5_index_buffer;
struct kinc_g5_vertex_buffer;
struct kinc_g5_pipeline;
struct kinc_g5_render_target;
struct kinc_g5_texture;
struct kinc_g5_vertex_buffer;
struct kinc_g5_render_target;
typedef struct kinc_g5_command_list {
CommandList5Impl impl;
@@ -1,34 +0,0 @@
#include <kinc/graphics5/compute.h>
#include <kinc/graphics5/graphics.h>
#include <kinc/graphics5/rendertarget.h>
#include <kinc/graphics5/texture.h>
#include <kinc/image.h>
#include <kinc/log.h>
#include <kinc/math/core.h>
#include <stdio.h>
#include <string.h>
extern kinc_g5_command_list_t commandList;
void kinc_g4_compute_shader_init(kinc_g4_compute_shader *shader, void *source, int length) {
kinc_g5_compute_shader_init(&shader->impl.shader, source, length);
}
void kinc_g4_compute_shader_destroy(kinc_g4_compute_shader *shader) {
kinc_g5_compute_shader_destroy(&shader->impl.shader);
}
kinc_g4_constant_location_t kinc_g4_compute_shader_get_constant_location(kinc_g4_compute_shader *shader, const char *name) {
kinc_g4_constant_location_t location;
location.impl._location = kinc_g5_compute_shader_get_constant_location(&shader->impl.shader, name);
return location;
}
kinc_g4_texture_unit_t kinc_g4_compute_shader_get_texture_unit(kinc_g4_compute_shader *shader, const char *name) {
kinc_g5_texture_unit_t g5_unit = kinc_g5_compute_shader_get_texture_unit(&shader->impl.shader, name);
kinc_g4_texture_unit_t g4_unit;
for (int i = 0; i < KINC_G4_SHADER_TYPE_COUNT; ++i) {
g4_unit.stages[i] = g5_unit.stages[i];
}
return g4_unit;
}
@@ -12,23 +12,7 @@ typedef struct kinc_g5_compute_shader {
kinc_g5_compute_shader_impl impl;
} kinc_g5_compute_shader;
typedef struct kinc_g4_compute_shader_impl {
kinc_g5_compute_shader shader;
} kinc_g4_compute_shader_impl;
struct kinc_g4_texture;
struct kinc_g4_render_target;
typedef struct kinc_g4_compute_shader {
kinc_g4_compute_shader_impl impl;
} kinc_g4_compute_shader;
void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length);
void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader);
kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name);
kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name);
void kinc_g4_compute_shader_init(kinc_g4_compute_shader *shader, void *source, int length);
void kinc_g4_compute_shader_destroy(kinc_g4_compute_shader *shader);
kinc_g4_constant_location_t kinc_g4_compute_shader_get_constant_location(kinc_g4_compute_shader *shader, const char *name);
kinc_g4_texture_unit_t kinc_g4_compute_shader_get_texture_unit(kinc_g4_compute_shader *shader, const char *name);
@@ -71,7 +71,7 @@ void kinc_g5_constant_buffer_set_bool(kinc_g5_constant_buffer_t *buffer, int off
ints[0] = value ? 1 : 0;
}
static void set_matrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value) {
static void kinc_internal_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) {
@@ -81,17 +81,17 @@ static void set_matrix3(uint8_t *constants, int offset, kinc_matrix3x3_t *value)
}
void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value) {
if (kinc_g5_transposeMat) {
if (kinc_g5_transpose_mat) {
kinc_matrix3x3_t m = *value;
kinc_matrix3x3_transpose(&m);
set_matrix3(buffer->data, offset, &m);
kinc_internal_set_matrix3(buffer->data, offset, &m);
}
else {
set_matrix3(buffer->data, offset, value);
kinc_internal_set_matrix3(buffer->data, offset, value);
}
}
static void set_matrix4(uint8_t *constants, int offset, kinc_matrix4x4_t *value) {
static void kinc_internal_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) {
@@ -101,12 +101,12 @@ static void set_matrix4(uint8_t *constants, int offset, kinc_matrix4x4_t *value)
}
void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value) {
if (kinc_g5_transposeMat) {
if (kinc_g5_transpose_mat) {
kinc_matrix4x4_t m = *value;
kinc_matrix4x4_transpose(&m);
set_matrix4(buffer->data, offset, &m);
kinc_internal_set_matrix4(buffer->data, offset, &m);
}
else {
set_matrix4(buffer->data, offset, value);
kinc_internal_set_matrix4(buffer->data, offset, value);
}
}
@@ -34,4 +34,4 @@ void kinc_g5_constant_buffer_set_floats(kinc_g5_constant_buffer_t *buffer, int o
void kinc_g5_constant_buffer_set_matrix3(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix3x3_t *value);
void kinc_g5_constant_buffer_set_matrix4(kinc_g5_constant_buffer_t *buffer, int offset, kinc_matrix4x4_t *value);
extern bool kinc_g5_transposeMat;
extern bool kinc_g5_transpose_mat;
+1 -3
View File
@@ -1,9 +1,7 @@
#include "pipeline.c.h"
#include "commandlist.c.h"
#include "constantbuffer.c.h"
#include "graphics.c.h"
#include "compute.c.h"
#include "indexbuffer.c.h"
#include "vertexbuffer.c.h"
#include "rendertarget.c.h"
#include "texture.c.h"
#include "vertexbuffer.c.h"
+36 -56
View File
@@ -1,34 +1,24 @@
#include <kinc/graphics5/graphics.h>
#include "graphics.h"
#include <assert.h>
#include <string.h>
#include <kinc/system.h>
#include <kinc/window.h>
#include <kinc/color.h>
#include <kinc/graphics5/indexbuffer.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/graphics5/rendertarget.h>
#include <kinc/graphics5/texture.h>
#include <kinc/graphics5/vertexbuffer.h>
#include <kinc/graphics5/commandlist.h>
#include <kinc/graphics5/compute.h>
#include <kinc/graphics5/constantbuffer.h>
#include <kinc/io/filereader.h>
#include <kinc/math/core.h>
#include <kinc/math/matrix.h>
#include <kinc/system.h>
#include <assert.h>
#include <string.h>
#include <kinc/graphics5/indexbuffer.h>
#include <kinc/graphics5/vertexbuffer.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/graphics5/rendertarget.h>
#include <kinc/graphics5/texture.h>
#include <kinc/graphics5/commandlist.h>
#include <kinc/graphics5/compute.h>
#include <kinc/graphics5/constantbuffer.h>
void samplers_reset(void);
bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_unit_t *unit2) {
for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) {
if (unit1->stages[i] != unit2->stages[i]) {
return false;
}
}
return true;
}
kinc_g5_command_list_t commandList;
bool waitAfterNextDraw = false;
static kinc_g5_constant_buffer_t vertexConstantBuffer;
@@ -38,18 +28,6 @@ static kinc_g5_constant_buffer_t computeConstantBuffer;
#define constantBufferMultiply 100
static int constantBufferIndex = 0;
void kinc_g4_internal_init(void) {
kinc_g5_internal_init();
}
void kinc_g4_internal_destroy(void) {
kinc_g5_internal_destroy();
}
void kinc_g4_internal_destroy_window(int window) {
kinc_g5_internal_destroy_window(window);
}
#define bufferCount 2
#define renderTargetCount 8
@@ -105,6 +83,27 @@ typedef struct render_state {
static render_state current_state;
bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_unit_t *unit2) {
for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) {
if (unit1->stages[i] != unit2->stages[i]) {
return false;
}
}
return true;
}
void kinc_g4_internal_init(void) {
kinc_g5_internal_init();
}
void kinc_g4_internal_destroy(void) {
kinc_g5_internal_destroy();
}
void kinc_g4_internal_destroy_window(int window) {
kinc_g5_internal_destroy_window(window);
}
void kinc_g4_on_g5_internal_resize(int window, int width, int height) {
windows[window].resized = true;
}
@@ -315,13 +314,9 @@ void kinc_g4_begin(int window) {
samplers_reset();
// commandList = new Graphics5::CommandList;
kinc_g5_command_list_begin(&commandList);
// Currently we do not necessarily wait at the end of a frame so for now it's endDraw
// constantBufferIndex = 0;
// kinc_g5_constant_buffer_lock(&vertexConstantBuffer, 0, constantBufferSize);
// kinc_g5_constant_buffer_lock(&fragmentConstantBuffer, 0, constantBufferSize);
endDraw(false);
kinc_g5_command_list_framebuffer_to_render_target_barrier(&commandList, &windows[current_window].framebuffers[windows[current_window].currentBuffer]);
@@ -360,22 +355,12 @@ void kinc_g4_end(int window) {
kinc_g5_command_list_end(&commandList);
kinc_g5_command_list_execute(&commandList);
// delete commandList;
// commandList = nullptr;
kinc_g5_end(window);
// to support doing work after kinc_g4_end and before kinc_g4_begin
kinc_g5_command_list_begin(&commandList);
}
bool kinc_g4_swap_buffers(void) {
return kinc_g5_swap_buffers();
}
void kinc_g4_flush(void) {
kinc_g5_flush();
}
void kinc_g4_set_int(kinc_g4_constant_location_t location, int value) {
if (location.impl._location.impl.vertexOffset >= 0)
kinc_g5_constant_buffer_set_int(&vertexConstantBuffer, location.impl._location.impl.vertexOffset, value);
@@ -596,10 +581,6 @@ void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, kinc_g4_texture_t *texture
kinc_g5_command_list_set_texture(&commandList, g5_unit, &texture->impl._texture);
}
int kinc_g4_max_bound_textures(void) {
return kinc_g5_max_bound_textures();
}
void kinc_g4_set_pipeline(kinc_g4_pipeline_t *pipeline) {
kinc_g5_pipeline_t *g5_pipeline = &pipeline->impl._pipeline;
current_state.pipeline = g5_pipeline;
@@ -664,10 +645,9 @@ void kinc_g4_render_target_use_depth_as_texture(kinc_g4_render_target_t *render_
kinc_g5_command_list_set_texture_from_render_target_depth(&commandList, g5_unit, &render_target->impl._renderTarget);
}
void kinc_g4_set_compute_shader(kinc_g4_compute_shader *shader) {
kinc_g5_compute_shader *g5_shader = &shader->impl.shader;
current_state.compute_shader = g5_shader;
kinc_g5_command_list_set_compute_shader(&commandList, g5_shader);
void kinc_g5_set_compute_shader(kinc_g5_compute_shader *shader) {
current_state.compute_shader = shader;
kinc_g5_command_list_set_compute_shader(&commandList, shader);
}
void kinc_g4_compute(int x, int y, int z) {
+3 -5
View File
@@ -16,6 +16,9 @@
\brief Contains the base G5-functionality.
*/
#define KINC_G5_CLEAR_COLOR 1
#define KINC_G5_CLEAR_DEPTH 2
bool kinc_g5_supports_raytracing(void);
int kinc_g5_max_bound_textures(void);
void kinc_g5_flush(void);
@@ -28,7 +31,6 @@ void kinc_g5_internal_init_window(int window, int depth_buffer_bits, bool vsync)
void kinc_g5_internal_destroy_window(int window);
void kinc_g5_internal_destroy(void);
struct kinc_g4_compute_shader;
struct kinc_g4_pipeline;
struct kinc_g4_render_target;
struct kinc_g4_texture;
@@ -65,11 +67,8 @@ typedef enum kinc_g4_usage {
KINC_G4_USAGE_READABLE
} kinc_g4_usage_t;
int kinc_g4_max_bound_textures(void);
void kinc_g4_flush(void);
void kinc_g4_begin(int window);
void kinc_g4_end(int window);
bool kinc_g4_swap_buffers(void);
#define KINC_G4_CLEAR_COLOR 1
#define KINC_G4_CLEAR_DEPTH 2
@@ -101,7 +100,6 @@ void kinc_g4_set_texture_mipmap_filter(struct kinc_g4_texture_unit unit, kinc_g4
void kinc_g4_restore_render_target(void);
void kinc_g4_set_render_targets(struct kinc_g4_render_target **targets, int count);
void kinc_g4_set_texture(struct kinc_g4_texture_unit unit, struct kinc_g4_texture *texture);
void kinc_g4_set_compute_shader(struct kinc_g4_compute_shader *shader);
void kinc_g4_compute(int x, int y, int z);
void kinc_g4_internal_init(void);
@@ -4,7 +4,6 @@
#include <kinc/image.h>
#include <kinc/backend/graphics5/texture.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/graphics5/texture.h>
/*! \file texture.h
\brief Provides functions for handling textures.
@@ -26,8 +25,6 @@ typedef struct {
bool _uploaded;
} kinc_g4_texture_impl_t;
typedef kinc_image_t kinc_g4_image_t;
typedef struct kinc_g4_texture {
int tex_width;
int tex_height;
@@ -31,7 +31,7 @@ void kinc_g4_vertex_buffer_destroy(kinc_g4_vertex_buffer_t *buffer) {
}
}
static void prepareLock(kinc_g4_vertex_buffer_t *buffer) {
static void kinc_internal_prepare_lock(kinc_g4_vertex_buffer_t *buffer) {
++buffer->impl._currentIndex;
if (buffer->impl._currentIndex >= buffer->impl._multiple - 1) {
waitAfterNextDraw = true;
@@ -42,12 +42,12 @@ static void prepareLock(kinc_g4_vertex_buffer_t *buffer) {
}
float *kinc_g4_vertex_buffer_lock_all(kinc_g4_vertex_buffer_t *buffer) {
prepareLock(buffer);
kinc_internal_prepare_lock(buffer);
return kinc_g5_vertex_buffer_lock_all(&buffer->impl._buffer[buffer->impl._currentIndex]);
}
float *kinc_g4_vertex_buffer_lock(kinc_g4_vertex_buffer_t *buffer, int start, int count) {
prepareLock(buffer);
kinc_internal_prepare_lock(buffer);
return kinc_g5_vertex_buffer_lock(&buffer->impl._buffer[buffer->impl._currentIndex], start, count);
}
@@ -1,11 +1,11 @@
#pragma once
#include <stdbool.h>
#include <kinc/global.h>
#include "vertexstructure.h"
#include <kinc/backend/graphics5/vertexbuffer.h>
#include <kinc/graphics5/vertexbuffer.h>
#include "graphics.h"
#include <stdbool.h>
#include <kinc/graphics5/graphics.h>
#include <kinc/graphics5/vertexstructure.h>
/*! \file vertexbuffer.h
\brief Provides functions for setting up and using vertex-buffers.
@@ -1,7 +1,6 @@
#pragma once
#include <kinc/global.h>
#include <kinc/graphics5/vertexstructure.h>
#include <stdbool.h>
/*! \file vertexstructure.h
@@ -127,11 +126,3 @@ static inline int kinc_g4_vertex_data_size(kinc_g4_vertex_data_t data) {
void kinc_g4_vertex_structure_init(kinc_g4_vertex_structure_t *structure);
void kinc_g4_vertex_structure_add(kinc_g4_vertex_structure_t *structure, const char *name, kinc_g4_vertex_data_t data);
static inline void kinc_g5_vertex_structure_init(kinc_g5_vertex_structure_t *structure) {
kinc_g4_vertex_structure_init(structure);
}
static inline void kinc_g5_vertex_structure_add(kinc_g5_vertex_structure_t *structure, const char *name, kinc_g5_vertex_data_t data) {
kinc_g4_vertex_structure_add(structure, name, data);
}