diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-27 12:00:37 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-27 12:00:37 +1000 |
commit | d6837defc03e431517f6616ec8e49a8eb3643011 (patch) | |
tree | 14e6685c86d268dfc08f3f831e7ee9b19efc60e0 /src/renderer/cleanroom | |
parent | 8dae0a94059bd21a5a10e4434cadc843126d8b05 (diff) |
Start moving more files to using ral.h
Diffstat (limited to 'src/renderer/cleanroom')
-rw-r--r-- | src/renderer/cleanroom/backend_vulkan.c | 16 | ||||
-rw-r--r-- | src/renderer/cleanroom/ral.h | 23 | ||||
-rw-r--r-- | src/renderer/cleanroom/renderer.c | 6 | ||||
-rw-r--r-- | src/renderer/cleanroom/renderer.h | 6 | ||||
-rw-r--r-- | src/renderer/cleanroom/types.h | 24 |
5 files changed, 41 insertions, 34 deletions
diff --git a/src/renderer/cleanroom/backend_vulkan.c b/src/renderer/cleanroom/backend_vulkan.c index 2838f20..71a09f3 100644 --- a/src/renderer/cleanroom/backend_vulkan.c +++ b/src/renderer/cleanroom/backend_vulkan.c @@ -1,16 +1,17 @@ #include <stdlib.h> #include "ral.h" #include "types.h" -#include "render_types.h" +// #include "render_types.h" #define VULKAN_QUEUES_COUNT 2 -const char* queue_names[VULKAN_QUEUES_COUNT] = { - "GRAPHICS", "TRANSFER" -}; +const char* queue_names[VULKAN_QUEUES_COUNT] = { "GRAPHICS", "TRANSFER" }; + +typedef struct gpu_device { +} gpu_device; typedef struct vulkan_context { gpu_device device; - + VkInstance instance; } vulkan_context; @@ -41,7 +42,6 @@ bool gpu_device_create(gpu_device* out_device) { // Queues // Create the command pool - } gpu_renderpass* gpu_renderpass_create() { @@ -51,8 +51,8 @@ gpu_renderpass* gpu_renderpass_create() { } void encode_set_pipeline(gpu_cmd_encoder* encoder, pipeline_type kind, gpu_pipeline* pipeline) { -// VK_PIPELINE_BIND_POINT_GRAPHICS, &shader->pipeline); - if (kind== PIPELINE_GRAPHICS) { + // VK_PIPELINE_BIND_POINT_GRAPHICS, &shader->pipeline); + if (kind == PIPELINE_GRAPHICS) { // ... } else { // ... diff --git a/src/renderer/cleanroom/ral.h b/src/renderer/cleanroom/ral.h index 8f7c8a4..a1e9929 100644 --- a/src/renderer/cleanroom/ral.h +++ b/src/renderer/cleanroom/ral.h @@ -14,12 +14,6 @@ #include "cleanroom/types.h" #include "defines.h" -// TODO: Replace with handle defines -typedef int buffer_handle; -typedef int texture_handle; -typedef int sampler_handle; -typedef int model_handle; - // Forward declare structs typedef struct gpu_swapchain gpu_swapchain; typedef struct gpu_device gpu_device; @@ -28,6 +22,21 @@ typedef struct gpu_renderpass gpu_renderpass; typedef struct gpu_cmd_encoder gpu_cmd_encoder; // Recording typedef struct gpu_cmd_buffer gpu_cmd_buffer; // Ready for submission +enum pipeline_kind { + GRAPHICS, + COMPUTE, +} pipeline_kind; + +typedef struct shader_desc { + const char* debug_name; + str8 filepath; // where it came from + str8 glsl; // contents +} shader_desc; + +struct pipeline_desc { + shader_desc vs; /** @brief Vertex shader stage */ + shader_desc fs; /** @brief Fragment shader stage */ +}; // lifecycle functions gpu_device* gpu_device_create(); @@ -36,7 +45,7 @@ void gpu_device_destroy(); gpu_renderpass* gpu_renderpass_create(); void gpu_renderpass_destroy(gpu_renderpass* pass); -gpu_pipeline* gpu_pipeline_create(pipeline_kind kind); +gpu_pipeline* gpu_pipeline_create(enum pipeline_kind kind, struct pipeline_desc description); void gpu_pipeline_destroy(gpu_pipeline* pipeline); void gpu_cmd_encoder_begin(); diff --git a/src/renderer/cleanroom/renderer.c b/src/renderer/cleanroom/renderer.c index 65c09de..a874664 100644 --- a/src/renderer/cleanroom/renderer.c +++ b/src/renderer/cleanroom/renderer.c @@ -1,6 +1,4 @@ -#include "render_types.h" #include "defines.h" +#include "render_types.h" -bool renderer_init() { - -}
\ No newline at end of file +bool renderer_init() {}
\ No newline at end of file diff --git a/src/renderer/cleanroom/renderer.h b/src/renderer/cleanroom/renderer.h index 7d56fe2..8012b49 100644 --- a/src/renderer/cleanroom/renderer.h +++ b/src/renderer/cleanroom/renderer.h @@ -7,4 +7,8 @@ typedef struct renderer2 { void* backend_state; gpu_device* device; gpu_pipeline* static_opaque_pipeline; -} renderer2;
\ No newline at end of file +} renderer2; + +// mesh +// model +// material
\ No newline at end of file diff --git a/src/renderer/cleanroom/types.h b/src/renderer/cleanroom/types.h index a37e0e6..98c2e21 100644 --- a/src/renderer/cleanroom/types.h +++ b/src/renderer/cleanroom/types.h @@ -4,11 +4,11 @@ #include "maths_types.h" #include "str.h" -// TODO: Replace with handle defines -typedef int buffer_handle; -typedef int texture_handle; -typedef int sampler_handle; -typedef int model_handle; +CORE_DEFINE_HANDLE(buffer_handle); +CORE_DEFINE_HANDLE(texture_handle); +CORE_DEFINE_HANDLE(sampler_handle); +CORE_DEFINE_HANDLE(shader_handle); +CORE_DEFINE_HANDLE(model_handle); typedef struct transform_hierarchy {} transform_hierarchy; @@ -56,7 +56,7 @@ typedef struct model bp_material; // blinn-phong #include "maths_types.h" -typedef enum vertex_format { VERTEX_STATIC_3D, VERTEX_SPRITE, VERTEX_COUNT } vertex_format; +typedef enum vertex_format { VERTEX_STATIC_3D, VERTEX_SPRITE, VERTEX_SKINNED, VERTEX_COUNT } vertex_format; typedef union vertex { struct { @@ -70,7 +70,7 @@ typedef union vertex { vec2 position; vec4 colour; vec2 tex_coords; - } sprite; + } sprite; /** @brief vertex format for 2D sprites or quads */ struct { vec3 position; @@ -79,7 +79,7 @@ typedef union vertex { vec3 normal; vec4i bone_ids; // Integer vector for bone IDs vec4 bone_weights; // Weight of each bone's influence - } skinned_3d; /** @brief vertex format for skeletal (animated) geometry in 3D */ + } skinned_3d; /** @brief vertex format for skeletal (animated) geometry in 3D */ } vertex; KITC_DECL_TYPED_ARRAY(vertex) @@ -88,6 +88,7 @@ KITC_DECL_TYPED_ARRAY(u32) typedef struct geometry_data { vertex_format format; vertex_darray vertices; + bool has_indices; u32_darray indices; } geometry_data; @@ -107,6 +108,7 @@ C side - reload_model(): */ +// TODO: move to some sort of render layer (not inside the abstraction layer) typedef struct model { str8 debug_name; mesh* meshes; @@ -126,12 +128,6 @@ typedef struct model { /* ral.h */ -// enum pipeline_type { -// GRAPHICS, -// COMPUTE, -// } pipeline_type; - - // command buffer gubbins |