diff options
Diffstat (limited to 'src/renderer/renderpasses.c')
-rw-r--r-- | src/renderer/renderpasses.c | 96 |
1 files changed, 42 insertions, 54 deletions
diff --git a/src/renderer/renderpasses.c b/src/renderer/renderpasses.c index 3f2152f..e005c14 100644 --- a/src/renderer/renderpasses.c +++ b/src/renderer/renderpasses.c @@ -1,19 +1,19 @@ /** * @file renderpasses.c * @author your name (you@domain.com) - * @brief + * @brief * @version 0.1 * @date 2024-06-22 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "renderpasses.h" +#include "file.h" #include "maths_types.h" #include "ral.h" #include "ral_types.h" -#include "file.h" #define SHADOW_WIDTH 1000 #define SHADOW_HEIGHT 1000 @@ -26,19 +26,15 @@ void ren_shadowmaps_init(ren_shadowmaps* storage) { gpu_renderpass* shadowmaps_renderpass_create() { // Create depthmap texture u32x2 extents = u32x2(SHADOW_WIDTH, SHADOW_HEIGHT); - texture_desc depthmap_desc = { - .extents = extents, - .format = CEL_TEXTURE_FORMAT_DEPTH_DEFAULT, - .tex_type = CEL_TEXTURE_TYPE_2D - }; + texture_desc depthmap_desc = { .extents = extents, + .format = CEL_TEXTURE_FORMAT_DEPTH_DEFAULT, + .tex_type = CEL_TEXTURE_TYPE_2D }; texture_handle depthmap = gpu_texture_create(depthmap_desc, false, NULL); - gpu_renderpass_desc shadows_desc = { - .default_framebuffer = false, - .has_color_target = false, - .has_depth_stencil = true, - .depth_stencil = depthmap - }; + gpu_renderpass_desc shadows_desc = { .default_framebuffer = false, + .has_color_target = false, + .has_depth_stencil = true, + .depth_stencil = depthmap }; return gpu_renderpass_create(&shadows_desc); } @@ -54,30 +50,28 @@ typedef struct lightspace_tf_uniform { shader_data_layout model_uniform_layout(void* data) { bool has_data = data != NULL; - shader_binding b1 = { - .label = "Model", - .type = SHADER_BINDING_BYTES, - .stores_data = has_data, - .data = {.bytes.size = sizeof(model_uniform)} - }; + shader_binding b1 = { .label = "Model", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes.size = sizeof(model_uniform) } }; if (has_data) { b1.data.bytes.data = data; } - return (shader_data_layout){ .name = "model_uniform", .bindings = {b1}, .bindings_count = 1}; + return (shader_data_layout){ .name = "model_uniform", .bindings = { b1 }, .bindings_count = 1 }; } shader_data_layout lightspace_uniform_layout(void* data) { bool has_data = data != NULL; - shader_binding b1 = { - .label = "LightSpace", - .type = SHADER_BINDING_BYTES, - .stores_data = has_data, - .data = {.bytes.size = sizeof(lightspace_tf_uniform)} - }; + shader_binding b1 = { .label = "LightSpace", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes.size = sizeof(lightspace_tf_uniform) } }; if (has_data) { b1.data.bytes.data = data; } - return (shader_data_layout){ .name = "lightspace_tf_uniform", .bindings = {b1}, .bindings_count = 1}; + return (shader_data_layout){ .name = "lightspace_tf_uniform", + .bindings = { b1 }, + .bindings_count = 1 }; } // ================== @@ -94,33 +88,27 @@ gpu_pipeline* shadowmaps_pipeline_create(gpu_renderpass* rpass) { } // We'll have two data layouts. 1. for the light-space transform, and 2. for the model matrix - shader_data model_uniform = {.data = NULL, .shader_data_get_layout = &model_uniform_layout }; - shader_data lightspace_uniform = {.data = NULL, .shader_data_get_layout = &lightspace_uniform_layout }; - - struct graphics_pipeline_desc desc = { - .debug_name = "Shadowmap drawing pipeline", - .vertex_desc = static_3d_vertex_description(), - .data_layouts = { model_uniform, lightspace_uniform }, - .data_layouts_count = 2, - .vs = { - .debug_name = "Shadows Vert shader", - .filepath = vert_path, - .code = vertex_shader.contents, - .is_spirv = true - }, - .fs = { - .debug_name = "Shadows Frag shader", - .filepath = vert_path, - .code = vertex_shader.contents, - .is_spirv = true - }, - .renderpass = rpass - }; + shader_data model_uniform = { .data = NULL, .shader_data_get_layout = &model_uniform_layout }; + shader_data lightspace_uniform = { .data = NULL, + .shader_data_get_layout = &lightspace_uniform_layout }; + + struct graphics_pipeline_desc desc = { .debug_name = "Shadowmap drawing pipeline", + .vertex_desc = static_3d_vertex_description(), + .data_layouts = { model_uniform, lightspace_uniform }, + .data_layouts_count = 2, + .vs = { .debug_name = "Shadows Vert shader", + .filepath = vert_path, + .code = vertex_shader.contents, + .is_spirv = true }, + .fs = { .debug_name = "Shadows Frag shader", + .filepath = vert_path, + .code = vertex_shader.contents, + .is_spirv = true }, + .renderpass = rpass }; arena_free_storage(&scratch); return gpu_graphics_pipeline_create(desc); } -void renderpass_shadowmap_execute(gpu_renderpass* pass, render_entity* entities, size_t entity_count) { - -}
\ No newline at end of file +void renderpass_shadowmap_execute(gpu_renderpass* pass, render_entity* entities, + size_t entity_count) {}
\ No newline at end of file |