diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-10-22 21:18:13 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-10-22 21:18:13 +0300 |
commit | e9bd321c8bd6bdb6aa7305c6da8b33e8cac462f7 (patch) | |
tree | 14d1e8993b68520dcfedfd6939b84c1af1330376 /src/graphics.h | |
parent | 7e555eeadd1f295db7700b8bde884fcb92bb2b8d (diff) |
renamed device.c/.h to graphics
Diffstat (limited to 'src/graphics.h')
-rw-r--r-- | src/graphics.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/graphics.h b/src/graphics.h new file mode 100644 index 0000000..52e511e --- /dev/null +++ b/src/graphics.h @@ -0,0 +1,73 @@ +#ifndef GRAPHICS_H +#define GRAPHICS_H + +#include <stdint.h> +#include <stdbool.h> +#include <vulkan/vulkan.h> + +#include "common.h" + +// from vulkan source +#define MAKE_VERSION(major, minor, patch) \ + ((((u32)(major)) << 22U) | (((u32)(minor)) << 12U) | ((u32)(patch))) + +typedef uint32_t u32; + +typedef struct graphics { + VkInstance instance; + VkDebugUtilsMessengerEXT debug_messenger; + + VkPhysicalDevice physical_device; + VkDevice logical_device; + + VkQueue graphics_queue; + VkQueue present_queue; + + VkSurfaceKHR surface; + + struct pipeline { + VkRenderPass render_pass; + VkPipelineLayout layout; + VkPipeline pipeline; + } pipeline; + + struct swap_chain { + VkSwapchainKHR swap_chain; + + VkImage *images; + VkImageView *image_views; + VkFramebuffer *framebuffers; + u32 nimages; + + VkFormat image_format; + VkExtent2D extent; + } swap_chain; + + struct command { + VkCommandPool pool; + VkCommandBuffer buffer; + } command; + + struct sync { + VkSemaphore semph_image_available; + VkSemaphore semph_render_finished; + VkFence fence_inflight; + } sync; + +} * graphics_t; + +struct graphics_info { + char *name; + u32 version; + + const char* const* extensions; + u32 ext_count; + + int (*surface_func)(VkInstance instance, VkSurfaceKHR *surface); +}; + +graphics_t graphics_create(struct graphics_info *info); +void graphics_destroy(graphics_t device); +int graphics_draw_frame(graphics_t device); + +#endif |