From 06a3cab4a3a7b75038bea99176f45ba71b8ea79f Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Fri, 19 Jan 2024 16:05:07 +0100 Subject: [PATCH] Move base compute functions to base graphics headers --- .../Sources/kinc/backend/graphics4/G4.c.h | 13 +++++++++++ .../kinc/backend/graphics4/compute.c.h | 12 ---------- .../kinc/backend/graphics4/compute.c.h | 2 +- Sources/kinc/graphics4/compute.h | 18 --------------- Sources/kinc/graphics4/graphics.h | 22 +++++++++++++++++++ 5 files changed, 36 insertions(+), 31 deletions(-) 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 f265f3980..05dadbe2e 100644 --- a/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h +++ b/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -901,3 +902,15 @@ void kinc_g4_set_constant_buffer(uint32_t id, struct kinc_g4_constant_buffer *bu kinc_g5_command_list_set_vertex_constant_buffer(&commandList, &buffer->impl.buffer, 0, kinc_g5_constant_buffer_size(&buffer->impl.buffer)); } #endif + +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_g4_compute(int x, int y, int z) { + startDraw(true); + kinc_g5_command_list_compute(&commandList, x, y, z); + endDraw(true); +} diff --git a/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/compute.c.h b/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/compute.c.h index 43bdb5140..bbab09bd3 100644 --- a/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/compute.c.h +++ b/Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/compute.c.h @@ -33,15 +33,3 @@ kinc_g4_texture_unit_t kinc_g4_compute_shader_get_texture_unit(kinc_g4_compute_s } return g4_unit; } - -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_g4_compute(int x, int y, int z) { - startDraw(true); - kinc_g5_command_list_compute(&commandList, x, y, z); - endDraw(true); -} diff --git a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/compute.c.h b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/compute.c.h index faf6174e5..0ce647c57 100644 --- a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/compute.c.h +++ b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/compute.c.h @@ -171,7 +171,7 @@ kinc_g4_texture_unit_t kinc_g4_compute_shader_get_texture_unit(kinc_g4_compute_s return unit; } -void kinc_g4_compute_set_buffer(kinc_shader_storage_buffer_t *buffer, int index) { +void kinc_g4_set_shader_storage_buffer(kinc_shader_storage_buffer_t *buffer, int index) { #ifdef HAS_COMPUTE glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, buffer->impl.bufferId); glCheckErrors(); diff --git a/Sources/kinc/graphics4/compute.h b/Sources/kinc/graphics4/compute.h index a0c06b869..8951054ac 100644 --- a/Sources/kinc/graphics4/compute.h +++ b/Sources/kinc/graphics4/compute.h @@ -69,24 +69,6 @@ KINC_FUNC int kinc_shader_storage_buffer_count(kinc_shader_storage_buffer_t *buf KINC_FUNC void kinc_shader_storage_buffer_internal_set(kinc_shader_storage_buffer_t *buffer); #endif -#ifdef KORE_OPENGL -KINC_FUNC void kinc_g4_compute_set_buffer(kinc_shader_storage_buffer_t *buffer, int index); -#endif - -/// -/// Sets a shader for the next compute-run. -/// -/// The shader to use -KINC_FUNC void kinc_g4_set_compute_shader(kinc_g4_compute_shader *shader); - -/// -/// Fire off a compute-run on x * y * z elements. -/// -/// The x-size for the compute-run -/// The y-size for the compute-run -/// The z-size for the compute-run -KINC_FUNC void kinc_g4_compute(int x, int y, int z); - #ifdef __cplusplus } #endif diff --git a/Sources/kinc/graphics4/graphics.h b/Sources/kinc/graphics4/graphics.h index 1731b4cb7..1f32a4286 100644 --- a/Sources/kinc/graphics4/graphics.h +++ b/Sources/kinc/graphics4/graphics.h @@ -16,6 +16,7 @@ extern "C" { #endif +struct kinc_g4_compute_shader; struct kinc_g4_pipeline; struct kinc_g4_render_target; struct kinc_g4_texture; @@ -420,6 +421,27 @@ KINC_FUNC int kinc_g4_antialiasing_samples(void); /// The number of samples KINC_FUNC void kinc_g4_set_antialiasing_samples(int samples); +#ifdef KORE_OPENGL +/// +/// Old, hack thing, do not use. +/// +KINC_FUNC void kinc_g4_set_shader_storage_buffer(kinc_shader_storage_buffer_t *buffer, int index); +#endif + +/// +/// Sets a shader for the next compute-run. +/// +/// The shader to use +KINC_FUNC void kinc_g4_set_compute_shader(struct kinc_g4_compute_shader *shader); + +/// +/// Fire off a compute-run on x * y * z elements. +/// +/// The x-size for the compute-run +/// The y-size for the compute-run +/// The z-size for the compute-run +KINC_FUNC void kinc_g4_compute(int x, int y, int z); + #ifndef KINC_DOCS void kinc_g4_internal_init(void); void kinc_g4_internal_init_window(int window, int depth_buffer_bits, int stencil_buffer_bits, bool vsync);