summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-11 17:30:58 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-11 17:30:58 +1000
commit08d7e23fd5ed95953822a72ba11d4b6cd96b2846 (patch)
tree6d251658bacb6a892a01e88ba3b98da338b9206e /src
parentfa6b939d49398a11d76080029204e7462b22914e (diff)
prototyping shader data
Diffstat (limited to 'src')
-rw-r--r--src/renderer/ral.h1
-rw-r--r--src/renderer/ral_types.h61
-rw-r--r--src/systems/input.c1
3 files changed, 63 insertions, 0 deletions
diff --git a/src/renderer/ral.h b/src/renderer/ral.h
index 2fb0166..38a653d 100644
--- a/src/renderer/ral.h
+++ b/src/renderer/ral.h
@@ -104,6 +104,7 @@ void buffer_upload_bytes(buffer_handle gpu_buf, bytebuffer cpu_buf, u64 offset,
// render pass
void encode_bind_pipeline(gpu_cmd_encoder* encoder, pipeline_kind kind, gpu_pipeline* pipeline);
+void encode_bind_shader_data(gpu_cmd_encoder* encoder, u32 group, shader_data* data);
void encode_set_default_settings(gpu_cmd_encoder* encoder);
void encode_set_vertex_buffer(gpu_cmd_encoder* encoder, buffer_handle buf);
void encode_set_index_buffer(gpu_cmd_encoder* encoder, buffer_handle buf);
diff --git a/src/renderer/ral_types.h b/src/renderer/ral_types.h
index 2fa8258..230afc3 100644
--- a/src/renderer/ral_types.h
+++ b/src/renderer/ral_types.h
@@ -120,6 +120,67 @@ typedef struct custom_vertex {
vec3 color;
} custom_vertex;
+// Vertex attributes
+typedef enum vertex_attrib_type {
+ ATTR_F32,
+ ATTR_F32x2,
+ ATTR_F32x3,
+ ATTR_F32x4,
+ ATTR_U32,
+ ATTR_U32x2,
+ ATTR_U32x3,
+ ATTR_U32x4,
+ ATTR_I32,
+ ATTR_I32x2,
+ ATTR_I32x3,
+ ATTR_I32x4,
+} vertex_attrib_type;
+
+typedef enum shader_binding_type {
+ SHADER_BINDING_BUFFER,
+ SHADER_BINDING_TEXTURE,
+ SHADER_BINDING_BYTES,
+ SHADER_BINDING_COUNT
+} shader_binding_type;
+
+typedef struct shader_binding {
+ const char* label;
+ shader_binding_type type;
+ bool stores_data; /** @brief if this is true then the shader binding has references to live data,
+ if false then its just being used to describe a layout and .data
+ should be zeroed */
+ union {
+ struct {
+ buffer_handle handle;
+ } buffer;
+ struct {
+ void* data;
+ size_t size;
+ } bytes;
+ } data;
+} shader_binding;
+
+#define MAX_LAYOUT_BINDINGS 8
+
+/** @brief A list of bindings that describe what data a shader / pipeline expects
+ @note This roughly correlates to a descriptor set layout in Vulkan
+*/
+typedef struct shader_data_layout {
+ char* name;
+ shader_binding bindings[MAX_LAYOUT_BINDINGS];
+} shader_data_layout;
+
+typedef struct shader_data {
+ shader_data_layout (*shader_data_get_layout)(void* data);
+ void* data;
+} shader_data;
+
+/*
+ Usage:
+ 1. When we create the pipeline, we must call a function that return a layout without .data fields
+ 2. When binding
+*/
+
typedef enum gpu_cull_mode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } gpu_cull_mode;
// ? How to tie together materials and shaders
diff --git a/src/systems/input.c b/src/systems/input.c
index 5df1159..0c8f768 100644
--- a/src/systems/input.c
+++ b/src/systems/input.c
@@ -32,6 +32,7 @@ bool input_system_init(input_state *input, GLFWwindow *window) {
void input_system_shutdown(input_state *input) {}
void input_update(input_state *input) {
+ glfwPollEvents();
// --- update keyboard input
// if we go from un-pressed -> pressed, set as "just pressed"