summaryrefslogtreecommitdiff
path: root/src/ral
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-14 23:55:18 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-14 23:55:18 +1000
commitb9315f9cb625db09c3c41d8adf5230a67510bef7 (patch)
tree8e02010d4e29c82ec9310b02b7924f4c8456ef6f /src/ral
parent529a603128d5e9dc4701322f44961f165e2183e1 (diff)
wip shadows
Diffstat (limited to 'src/ral')
-rw-r--r--src/ral/ral_common.c24
-rw-r--r--src/ral/ral_impl.h7
-rw-r--r--src/ral/ral_types.h5
3 files changed, 19 insertions, 17 deletions
diff --git a/src/ral/ral_common.c b/src/ral/ral_common.c
index 8ff282e..35bf15f 100644
--- a/src/ral/ral_common.c
+++ b/src/ral/ral_common.c
@@ -19,23 +19,23 @@ void ResourcePools_Init(arena* a, struct ResourcePools* res_pools) {
}
VertexDescription static_3d_vertex_description() {
- VertexDescription builder = { .debug_label = "Standard static 3d vertex format" };
- VertexDesc_AddAttr(&builder, "inPosition", ATTR_F32x3);
- VertexDesc_AddAttr(&builder, "inNormal", ATTR_F32x3);
- VertexDesc_AddAttr(&builder, "inTexCoords", ATTR_F32x2);
- builder.use_full_vertex_size = true;
- return builder;
+ VertexDescription builder = { .debug_label = "Standard static 3d vertex format" };
+ VertexDesc_AddAttr(&builder, "inPosition", ATTR_F32x3);
+ VertexDesc_AddAttr(&builder, "inNormal", ATTR_F32x3);
+ VertexDesc_AddAttr(&builder, "inTexCoords", ATTR_F32x2);
+ builder.use_full_vertex_size = true;
+ return builder;
}
void VertexDesc_AddAttr(VertexDescription* builder, const char* name, VertexAttribType type) {
- u32 i = builder->attributes_count;
+ u32 i = builder->attributes_count;
- size_t size = VertexAttribSize(type);
- builder->attributes[i] = type;
- builder->stride += size;
- builder->attr_names[i] = name;
+ size_t size = VertexAttribSize(type);
+ builder->attributes[i] = type;
+ builder->stride += size;
+ builder->attr_names[i] = name;
- builder->attributes_count++;
+ builder->attributes_count++;
}
size_t VertexAttribSize(VertexAttribType attr) {
diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h
index a896eff..3c3eaa5 100644
--- a/src/ral/ral_impl.h
+++ b/src/ral/ral_impl.h
@@ -8,6 +8,7 @@
#include "ral_types.h"
struct GLFWwindow;
+struct ResourcePools;
// Forward declare structs - these must be defined in the backend implementation
typedef struct GPU_Swapchain GPU_Swapchain;
@@ -20,8 +21,6 @@ typedef struct GPU_CmdBuffer GPU_CmdBuffer; // Ready for submission
typedef struct GPU_Buffer GPU_Buffer;
typedef struct GPU_Texture GPU_Texture;
-struct ResourcePools;
-
bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window, struct ResourcePools* res_pools);
void GPU_Backend_Shutdown();
@@ -40,6 +39,8 @@ PUB void GraphicsPipeline_Destroy(GPU_Pipeline* pipeline);
// --- Command buffer
PUB GPU_CmdEncoder GPU_CmdEncoder_Create();
PUB void GPU_CmdEncoder_Destroy(GPU_CmdEncoder* encoder);
+PUB void GPU_CmdEncoder_Begin(GPU_CmdEncoder* encoder);
+PUB void GPU_CmdEncoder_Finish(GPU_CmdEncoder* encoder);
PUB void GPU_CmdEncoder_BeginRender(GPU_CmdEncoder* encoder, GPU_Renderpass* renderpass);
PUB void GPU_CmdEncoder_EndRender(GPU_CmdEncoder* encoder);
PUB GPU_CmdEncoder* GPU_GetDefaultEncoder();
@@ -67,7 +68,7 @@ void copy_buffer_to_image_oneshot(BufferHandle src, TextureHandle dst);
// --- Render commands
PUB void GPU_EncodeBindPipeline(GPU_CmdEncoder* encoder, GPU_Pipeline* pipeline);
-PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderData* data);
+PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderData data);
void GPU_EncodeSetDefaults(GPU_CmdEncoder* encoder);
PUB void GPU_EncodeSetVertexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf);
PUB void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf);
diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h
index 188951a..4470700 100644
--- a/src/ral/ral_types.h
+++ b/src/ral/ral_types.h
@@ -152,6 +152,7 @@ typedef enum ShaderVisibility {
typedef struct ShaderDesc {} ShaderDesc;
typedef enum ShaderBindingKind {
+ BINDING_BYTES,
BINDING_BUFFER,
BINDING_BUFFER_ARRAY,
BINDING_TEXTURE,
@@ -165,14 +166,14 @@ typedef struct ShaderBinding {
ShaderBindingKind kind;
ShaderVisibility vis;
union {
- struct { u32 size; } bytes;
+ struct { u32 size; void* data; } bytes;
struct { BufferHandle handle; } buffer;
struct { TextureHandle handle; } texture;
} data;
} ShaderBinding;
typedef struct ShaderDataLayout {
- ShaderBinding* bindings;
+ ShaderBinding bindings[MAX_SHADER_BINDINGS];
size_t binding_count;
} ShaderDataLayout;