diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2024-06-04 15:50:06 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2024-06-04 15:50:06 +0300 |
commit | e3c514f1c279c9955cac6b1fa9d0ede6ecbc310d (patch) | |
tree | 18397e00e96efb08853d676f8015ba95b1182db2 /src/state.h | |
parent | 64617ea2c46d13cd2f72df72fcd426d2fc561bff (diff) | |
download | cgame-e3c514f1c279c9955cac6b1fa9d0ede6ecbc310d.tar.gz cgame-e3c514f1c279c9955cac6b1fa9d0ede6ecbc310d.tar.bz2 cgame-e3c514f1c279c9955cac6b1fa9d0ede6ecbc310d.zip |
vks work and clang-format
Diffstat (limited to 'src/state.h')
-rw-r--r-- | src/state.h | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/src/state.h b/src/state.h index 95f636b..28f49e6 100644 --- a/src/state.h +++ b/src/state.h @@ -3,8 +3,10 @@ #include <shaderc/shaderc.h> #include <vulkan/vulkan_core.h> -#define CGLM_FORCE_DEPTH_ZERO_TO_ONE +#define VKSETUP_IMPLEMENTATION +#include "vksetup.h" +#define CGLM_FORCE_DEPTH_ZERO_TO_ONE #include "../lib/cglm/include/cglm/cglm.h" #pragma once @@ -38,11 +40,13 @@ typedef struct { VkSemaphore render_finished_semaphore; VkFence in_flight_fence; - VkBuffer vk_uniform_buffer; - VkDeviceMemory vk_uniform_buffer_memory; - void * vk_uniform_buffer_mapped; + vks_buffer uniform_buffer; + void * uniform_buffer_mapped; VkDescriptorSet vk_descriptor_set; + + VkDescriptorSet vk_compute_descriptor_set; + vks_buffer shader_storage_buffer; } frame_data; typedef struct { @@ -62,6 +66,13 @@ typedef struct { V2 texCoord; } Vertex; +typedef struct { + vec2 position; + vec2 velocity; + vec4 color; +} Particle; + + typedef struct state { camera3d camera; @@ -75,62 +86,44 @@ typedef struct state { int mouse_pressed; int middle_click; - UniformBufferObject ubo; - float x; int zoom; - SDL_Window *sdl_window; + UniformBufferObject ubo; + int sdl_window_resized; - VkInstance vk_instance; VkDebugUtilsMessengerEXT vk_debug_messenger; PFN_vkCreateDebugUtilsMessengerEXT pfnCreateDebugUtilsMessengerEXT; PFN_vkDestroyDebugUtilsMessengerEXT pfnDestroyDebugUtilsMessengerEXT; - VkPhysicalDevice vk_physical_device; - VkDevice vk_device; + vks_context vk; + VkQueue vk_graphics_queue; - VkSurfaceKHR vk_surface; VkQueue vk_present_queue; - VkSwapchainKHR vk_swap_chain; - - uint32_t vk_swap_chain_image_count; - VkImage vk_swap_chain_images[5]; - VkImageView vk_swap_chain_image_views[5]; // 5 for some reason - - VkFormat vk_swap_chain_image_format; - VkExtent2D vk_swap_chain_extent; - VkDescriptorSetLayout vk_descriptor_set_layout; - VkPipelineLayout vk_pipeline_layout; - VkPipeline vk_graphics_pipeline; + + vks_pipeline graphics_pipeline; VkCommandPool vk_command_pool; frame_data frames[MAX_FRAMES_IN_FLIGHT]; - VkBuffer vk_vertex_buffer; - VkDeviceMemory vk_vertex_buffer_memory; - - VkBuffer vk_index_buffer; - VkDeviceMemory vk_index_buffer_memory; + vks_buffer vertex_buffer; + vks_buffer index_buffer; VkDescriptorPool vk_descriptor_pool; shaderc_compilation_result_t prev_vert_result; shaderc_compilation_result_t prev_frag_result; + shaderc_compilation_result_t prev_comp_result; uint32_t vk_mip_levels; - VkImage vk_texture_image; - VkDeviceMemory vk_texture_image_memory; - VkImageView vk_texture_image_view; + vks_image texture_image; VkSampler vk_texture_sampler; - VkImage vk_depth_image; - VkDeviceMemory vk_depth_image_memory; - VkImageView vk_depth_image_view; + vks_image depth_image; VkPolygonMode polygon_mode; @@ -138,22 +131,21 @@ typedef struct state { size_t vertices_count; uint32_t * indices; size_t indices_count; - VkBuffer vertexBuffer; - VkDeviceMemory vertexBufferMemory; char model_path[1000]; VkSampleCountFlagBits msaa_samples; - VkImage vk_color_image; - VkDeviceMemory vk_color_image_memory; - VkImageView vk_color_image_view; + vks_image color_image; + + VkDescriptorSetLayout vk_compute_descriptor_set_layout; + VkPipelineLayout vk_compute_pipeline_layout; + VkPipeline vk_compute_pipeline; } state_t; static void init_state(state_t *s) { - strcpy(s->model_path, "assets/monkey.obj"); s->camera.pos[0] = 2.0f; s->camera.pos[1] = 2.0f; @@ -195,10 +187,10 @@ init_state(state_t *s) glm_mat4_identity(s->ubo.model); - s->sdl_window = NULL; + s->vk.window = NULL; - s->vk_swap_chain_image_count = 0; - s->vk_physical_device = VK_NULL_HANDLE; + s->vk.swapchain.image_count = 0; + s->vk.physical_device = VK_NULL_HANDLE; s->prev_vert_result = NULL; s->prev_frag_result = NULL; |