Skip to content

Commit

Permalink
Move base compute functions to base graphics headers
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jan 19, 2024
1 parent 997f9c8 commit 06a3cab
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
13 changes: 13 additions & 0 deletions Backends/Graphics4/G4onG5/Sources/kinc/backend/graphics4/G4.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <kinc/backend/graphics4/pipeline.h>
#include <kinc/backend/graphics4/vertexbuffer.h>
#include <kinc/color.h>
#include <kinc/graphics4/compute.h>
#include <kinc/graphics4/constantbuffer.h>
#include <kinc/graphics4/indexbuffer.h>
#include <kinc/graphics4/pipeline.h>
Expand Down Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 0 additions & 18 deletions Sources/kinc/graphics4/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/// <summary>
/// Sets a shader for the next compute-run.
/// </summary>
/// <param name="shader">The shader to use</param>
KINC_FUNC void kinc_g4_set_compute_shader(kinc_g4_compute_shader *shader);

/// <summary>
/// Fire off a compute-run on x * y * z elements.
/// </summary>
/// <param name="x">The x-size for the compute-run</param>
/// <param name="y">The y-size for the compute-run</param>
/// <param name="z">The z-size for the compute-run</param>
KINC_FUNC void kinc_g4_compute(int x, int y, int z);

#ifdef __cplusplus
}
#endif
22 changes: 22 additions & 0 deletions Sources/kinc/graphics4/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -420,6 +421,27 @@ KINC_FUNC int kinc_g4_antialiasing_samples(void);
/// <param name="samples">The number of samples</param>
KINC_FUNC void kinc_g4_set_antialiasing_samples(int samples);

#ifdef KORE_OPENGL
/// <summary>
/// Old, hack thing, do not use.
/// </summary>
KINC_FUNC void kinc_g4_set_shader_storage_buffer(kinc_shader_storage_buffer_t *buffer, int index);
#endif

/// <summary>
/// Sets a shader for the next compute-run.
/// </summary>
/// <param name="shader">The shader to use</param>
KINC_FUNC void kinc_g4_set_compute_shader(struct kinc_g4_compute_shader *shader);

/// <summary>
/// Fire off a compute-run on x * y * z elements.
/// </summary>
/// <param name="x">The x-size for the compute-run</param>
/// <param name="y">The y-size for the compute-run</param>
/// <param name="z">The z-size for the compute-run</param>
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);
Expand Down

0 comments on commit 06a3cab

Please sign in to comment.