summaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-12 15:07:57 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-12 15:07:57 +1000
commit634f22e2b6d538fc5a45da2b1b23af631f6f8703 (patch)
treeeee6cb6dab16408bd6b44f93996204cd7fbd5c2e /src/renderer
parentd52d39d7843ed2203b001a822efe6d4b692c2642 (diff)
more restructuring
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/backends/backend_vulkan.c7
-rw-r--r--src/renderer/backends/metal/README.md1
-rw-r--r--src/renderer/backends/opengl/README.md1
-rw-r--r--src/renderer/backends/vulkan/README.md1
-rw-r--r--src/renderer/ral.h4
-rw-r--r--src/renderer/ral_types.h32
-rw-r--r--src/renderer/render.h2
-rw-r--r--src/renderer/standard_vertex_types.c11
8 files changed, 54 insertions, 5 deletions
diff --git a/src/renderer/backends/backend_vulkan.c b/src/renderer/backends/backend_vulkan.c
index a845ebf..f83ef84 100644
--- a/src/renderer/backends/backend_vulkan.c
+++ b/src/renderer/backends/backend_vulkan.c
@@ -393,6 +393,7 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip
attribute_descs[1].offset = offsetof(custom_vertex, color);
// Vertex input
+ // TODO: Generate this from descroiption now
VkVertexInputBindingDescription binding_desc;
binding_desc.binding = 0;
binding_desc.stride = sizeof(custom_vertex);
@@ -819,9 +820,9 @@ void encode_bind_shader_data(gpu_cmd_encoder* encoder, u32 group, shader_data* d
alloc_info.pSetLayouts = &encoder->pipeline->desc_set_layouts[group];
VkDescriptorSet sets[1];
- /* VK_CHECK( */
- vkAllocateDescriptorSets(context.device->logical_device, &alloc_info, sets);
- /* ); */
+ VK_CHECK(
+ vkAllocateDescriptorSets(context.device->logical_device, &alloc_info, sets)
+ );
VkDescriptorSet_darray_push(context.free_set_queue, sets[0]);
shader_data_layout sdl = data->shader_data_get_layout(NULL);
diff --git a/src/renderer/backends/metal/README.md b/src/renderer/backends/metal/README.md
new file mode 100644
index 0000000..f87f5c1
--- /dev/null
+++ b/src/renderer/backends/metal/README.md
@@ -0,0 +1 @@
+# TODO \ No newline at end of file
diff --git a/src/renderer/backends/opengl/README.md b/src/renderer/backends/opengl/README.md
new file mode 100644
index 0000000..f87f5c1
--- /dev/null
+++ b/src/renderer/backends/opengl/README.md
@@ -0,0 +1 @@
+# TODO \ No newline at end of file
diff --git a/src/renderer/backends/vulkan/README.md b/src/renderer/backends/vulkan/README.md
new file mode 100644
index 0000000..220ed64
--- /dev/null
+++ b/src/renderer/backends/vulkan/README.md
@@ -0,0 +1 @@
+# Vulkan Backend Overview \ No newline at end of file
diff --git a/src/renderer/ral.h b/src/renderer/ral.h
index 0df23ea..30d5413 100644
--- a/src/renderer/ral.h
+++ b/src/renderer/ral.h
@@ -54,6 +54,7 @@ typedef struct shader_desc {
struct graphics_pipeline_desc {
const char* debug_name;
+ vertex_description vertex_desc;
shader_desc vs; /** @brief Vertex shader stage */
shader_desc fs; /** @brief Fragment shader stage */
@@ -150,8 +151,11 @@ void gpu_sampler_create();
// --- Vertex formats
bytebuffer vertices_as_bytebuffer(arena* a, vertex_format format, vertex_darray* vertices);
+void vertex_desc_add(vertex_description* builder, const char* name, vertex_attrib_type type);
+
// TODO: Bindgroup texture samplers / shader resources
// TEMP
void gpu_temp_draw(size_t n_verts);
+
diff --git a/src/renderer/ral_types.h b/src/renderer/ral_types.h
index e7863a9..48695ea 100644
--- a/src/renderer/ral_types.h
+++ b/src/renderer/ral_types.h
@@ -1,7 +1,7 @@
/**
* @file ral_types.h
* @author your name (you@domain.com)
- * @brief
+ * @brief Struct and enum definitions for RAL
* @version 0.1
* @date 2024-04-27
*
@@ -14,6 +14,8 @@
#include "defines.h"
#include "maths_types.h"
+#define MAX_VERTEX_ATTRIBUTES 16
+
#ifndef RENDERER_TYPED_HANDLES
CORE_DEFINE_HANDLE(buffer_handle);
CORE_DEFINE_HANDLE(texture_handle);
@@ -143,19 +145,45 @@ typedef enum vertex_attrib_type {
ATTR_I32x4,
} vertex_attrib_type;
+typedef struct vertex_description {
+ char* debug_label;
+ const char* attr_names[MAX_VERTEX_ATTRIBUTES];
+ vertex_attrib_type attributes[MAX_VERTEX_ATTRIBUTES];
+ size_t stride;
+} vertex_description;
+
+// --- Shaders & Bindings
+
typedef enum shader_visibility {
VISIBILITY_VERTEX = 1 << 0,
VISIBILITY_FRAGMENT = 1 << 1 ,
VISIBILITY_COMPUTE = 1 << 2,
} shader_visibility;
+/** @brief Describes the kind of binding a `shader_binding` is for. This changes how we create backing data for it. */
typedef enum shader_binding_type {
+ /**
+ * @brief Binds a buffer to a shader
+ * @note Vulkan: Becomes a Storage Buffer
+ */
SHADER_BINDING_BUFFER,
+ SHADER_BINDING_BUFFER_ARRAY,
SHADER_BINDING_TEXTURE,
+ SHADER_BINDING_TEXTURE_ARRAY,
+ SHADER_BINDING_SAMPLER,
+ /**
+ * @brief Binds raw data to a shader
+ * @note Vulkan: Becomes a Uniform Buffer
+ */
SHADER_BINDING_BYTES,
+ // TODO: Acceleration Structure
SHADER_BINDING_COUNT
} shader_binding_type;
+// pub trait ShaderBindable: Clone + Copy {
+// fn bind_to(&self, context: &mut PipelineContext, index: u32);
+// }
+
typedef struct shader_binding {
const char* label;
shader_binding_type type;
@@ -171,7 +199,7 @@ typedef struct shader_binding {
void* data;
size_t size;
} bytes;
- } data;
+ } data; /** @brief */
} shader_binding;
#define MAX_LAYOUT_BINDINGS 8
diff --git a/src/renderer/render.h b/src/renderer/render.h
index c690e80..4477121 100644
--- a/src/renderer/render.h
+++ b/src/renderer/render.h
@@ -44,3 +44,5 @@ mesh mesh_create(geometry_data* geometry);
model_handle model_load(const char* debug_name, const char* filepath);
void geo_set_vertex_colours(geometry_data* geo, vec4 colour);
+
+vertex_description static_3d_vertex_description(); \ No newline at end of file
diff --git a/src/renderer/standard_vertex_types.c b/src/renderer/standard_vertex_types.c
new file mode 100644
index 0000000..4973bf0
--- /dev/null
+++ b/src/renderer/standard_vertex_types.c
@@ -0,0 +1,11 @@
+#include "ral.h"
+#include "ral_types.h"
+#include "render.h"
+
+vertex_description static_3d_vertex_description() {
+ vertex_description builder = { .debug_label = "vertex" };
+ vertex_desc_add(&builder, "position", ATTR_F32x3);
+ vertex_desc_add(&builder, "normal", ATTR_F32x3);
+ vertex_desc_add(&builder, "texCoords", ATTR_F32x2);
+ return builder;
+} \ No newline at end of file