From ebee348781e68e61f97c31411512dc0aabab7acb Mon Sep 17 00:00:00 2001 From: Omniscient Date: Sun, 19 May 2024 00:04:31 +1000 Subject: chore: fmt --- examples/cube/ex_cube.c | 2 +- examples/triangle/ex_triangle.c | 6 +++--- src/renderer/backends/backend_vulkan.c | 15 ++++++++------- src/renderer/ral.h | 4 ++-- src/renderer/render.h | 10 +++++----- src/renderer/render_types.h | 4 ++-- src/scene.h | 8 ++++---- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/examples/cube/ex_cube.c b/examples/cube/ex_cube.c index 346dd10..80a4e26 100644 --- a/examples/cube/ex_cube.c +++ b/examples/cube/ex_cube.c @@ -48,7 +48,7 @@ int main() { vec3 camera_front = vec3_normalise(vec3_negate(camera_pos)); camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0)); - vertex_description vertex_input = {.use_full_vertex_size = true}; + vertex_description vertex_input = { .use_full_vertex_size = true }; vertex_input.debug_label = "Standard Static 3D Vertex Format"; vertex_desc_add(&vertex_input, "inPosition", ATTR_F32x3); vertex_desc_add(&vertex_input, "inNormal", ATTR_F32x3); diff --git a/examples/triangle/ex_triangle.c b/examples/triangle/ex_triangle.c index 69c29ac..d57e224 100644 --- a/examples/triangle/ex_triangle.c +++ b/examples/triangle/ex_triangle.c @@ -21,13 +21,13 @@ const custom_vertex vertices[] = { (custom_vertex){ .pos = vec2(-0.5, 0.5), .color = vec3(0.0, 0.0, 1.0) }, (custom_vertex){ .pos = vec2(0.5, 0.5), .color = vec3(0.0, 1.0, 0.0) }, }; -const u32 indices[] = { 2, 1, 0, 1, 2, 3}; +const u32 indices[] = { 2, 1, 0, 1, 2, 3 }; int main() { core_bringup(); arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024); - vertex_description vertex_input = {.use_full_vertex_size=false}; + vertex_description vertex_input = { .use_full_vertex_size = false }; vertex_input.debug_label = "Hello"; vertex_desc_add(&vertex_input, "inPos", ATTR_F32x2); vertex_desc_add(&vertex_input, "inColor", ATTR_F32x3); @@ -64,7 +64,7 @@ int main() { // Load triangle vertex and index data buffer_handle triangle_vert_buf = - gpu_buffer_create(4 * sizeof(vertex) , CEL_BUFFER_VERTEX, CEL_BUFFER_FLAG_GPU, vertices); + gpu_buffer_create(4 * sizeof(vertex), CEL_BUFFER_VERTEX, CEL_BUFFER_FLAG_GPU, vertices); buffer_handle triangle_index_buf = gpu_buffer_create(sizeof(indices), CEL_BUFFER_INDEX, CEL_BUFFER_FLAG_GPU, indices); diff --git a/src/renderer/backends/backend_vulkan.c b/src/renderer/backends/backend_vulkan.c index ae49cc3..33e0860 100644 --- a/src/renderer/backends/backend_vulkan.c +++ b/src/renderer/backends/backend_vulkan.c @@ -425,7 +425,7 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip attribute_descs[i].location = i; attribute_descs[i].format = format_from_vertex_attr(description.vertex_desc.attributes[i]); attribute_descs[i].offset = offset; - size_t this_offset = vertex_attrib_size(description.vertex_desc.attributes[i]); + size_t this_offset = vertex_attrib_size(description.vertex_desc.attributes[i]); printf("offset total %d this attr %ld\n", offset, this_offset); printf("sizeof vertex %ld\n", sizeof(vertex)); /* printf("%d \n", offsetof(vertex, static_3d)); */ @@ -446,7 +446,9 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip // TODO: Generate this from descroiption now VkVertexInputBindingDescription binding_desc; binding_desc.binding = 0; - binding_desc.stride = description.vertex_desc.use_full_vertex_size ? sizeof(vertex) : description.vertex_desc.stride; + binding_desc.stride = description.vertex_desc.use_full_vertex_size + ? sizeof(vertex) + : description.vertex_desc.stride; binding_desc.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; VkPipelineVertexInputStateCreateInfo vertex_input_info = { @@ -561,8 +563,8 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip pipeline->desc_set_layouts = desc_set_layouts; pipeline->desc_set_layouts_count = description.data_layouts_count; if (description.data_layouts_count > 0) { - pipeline->uniform_pointers = - malloc(description.data_layouts_count * sizeof(desc_set_uniform_buffer)); + pipeline->uniform_pointers = + malloc(description.data_layouts_count * sizeof(desc_set_uniform_buffer)); } else { pipeline->uniform_pointers = NULL; } @@ -1349,8 +1351,7 @@ buffer_handle gpu_buffer_create(u64 size, gpu_buffer_type buf_type, gpu_buffer_f } void gpu_buffer_destroy(buffer_handle buffer) { - gpu_buffer* b = - buffer_pool_get(&context.resource_pools->buffers, buffer); + gpu_buffer* b = buffer_pool_get(&context.resource_pools->buffers, buffer); vkDestroyBuffer(context.device->logical_device, b->handle, context.allocator); vkFreeMemory(context.device->logical_device, b->memory, context.allocator); buffer_pool_dealloc(&context.resource_pools->buffers, buffer); @@ -1493,7 +1494,7 @@ texture_handle gpu_texture_create(texture_desc desc, const void* data) { vkBindImageMemory(context.device->logical_device, image, image_memory, 0); -gpu_buffer_destroy(staging); + gpu_buffer_destroy(staging); texture_handle handle; gpu_texture* texture = texture_pool_alloc(&context.resource_pools->textures, &handle); diff --git a/src/renderer/ral.h b/src/renderer/ral.h index 48be83a..a82a2ba 100644 --- a/src/renderer/ral.h +++ b/src/renderer/ral.h @@ -176,8 +176,8 @@ struct resource_pools { // Must be implemented by backends void resource_pools_init(arena* a, struct resource_pools* res_pools); -void copy_buffer_to_buffer_oneshot(buffer_handle src, u64 src_offset, buffer_handle dst, u64 dst_offset, - u64 copy_size); +void copy_buffer_to_buffer_oneshot(buffer_handle src, u64 src_offset, buffer_handle dst, + u64 dst_offset, u64 copy_size); void copy_buffer_to_image_oneshot(buffer_handle src, texture_handle dst); // --- Helpers diff --git a/src/renderer/render.h b/src/renderer/render.h index 9a7ff2f..c193ff9 100644 --- a/src/renderer/render.h +++ b/src/renderer/render.h @@ -37,11 +37,11 @@ texture_handle texture_create(const char* debug_name, texture_desc description, texture_data texture_data_load(const char* path, bool invert_y); /** - * @brief - * - * @param data - * @param free_on_upload frees the CPU-side pixel data stored in `data` - * @return texture_handle + * @brief + * + * @param data + * @param free_on_upload frees the CPU-side pixel data stored in `data` + * @return texture_handle */ texture_handle texture_data_upload(texture_data data, bool free_on_upload); diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h index c6aec8e..cc5fd93 100644 --- a/src/renderer/render_types.h +++ b/src/renderer/render_types.h @@ -69,14 +69,14 @@ typedef struct model { u32 mesh_count; } model; -typedef struct texture {} texture; +typedef struct texture { +} texture; typedef struct texture_data { texture_desc description; void* image_data; } texture_data; - typedef struct blinn_phong_material { char name[256]; texture diffuse_texture; diff --git a/src/scene.h b/src/scene.h index 5a85e2e..5ac7542 100644 --- a/src/scene.h +++ b/src/scene.h @@ -32,10 +32,10 @@ void scene_free(scene* s); // Simplified API - no scene pointer; gets and sets global scene // Add/Remove objects from the scene - /* vec3 direction; */ - /* vec3 ambient; */ - /* vec3 diffuse; */ - /* vec3 specular; */ +/* vec3 direction; */ +/* vec3 ambient; */ +/* vec3 diffuse; */ +/* vec3 specular; */ void scene_set_dir_light(directional_light light); void _scene_set_dir_light(vec3 ambient, vec3 diffuse, vec3 specular, vec3 direction); -- cgit v1.2.3-70-g09d2