From 35a70d71f62e41d78d68247075ce174f2b6d997a Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Wed, 7 Feb 2024 22:49:00 +0100 Subject: inital commit -- THE CUBES SPIN Signed-off-by: Anna (navi) Figueiredo Gomes --- include/render/renderer.h | 107 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 include/render/renderer.h (limited to 'include/render/renderer.h') diff --git a/include/render/renderer.h b/include/render/renderer.h new file mode 100644 index 0000000..bae799d --- /dev/null +++ b/include/render/renderer.h @@ -0,0 +1,107 @@ +#ifndef _RENDER_H_ +#define _RENDER_H_ + +#include +#include +#include "render/window.h" +#include "render/buffer.h" +#include "render/shader.h" +#include "render/mesh.h" + +#define MAX_FRAMES 2 + +struct image { + VkImage image; + VkDeviceMemory memory; + VkImageView view; +}; + +struct renderer { + struct window *win; + VkInstance instance; + VkSurfaceKHR surface; + + struct { + uint32_t cap, len; + struct phy_gpu { + VkPhysicalDevice gpu; + size_t graphics_queue; + size_t present_queue; + struct surface_caps { + VkSurfaceCapabilitiesKHR caps; + struct { + uint32_t len; + VkSurfaceFormatKHR *data; + } formats; + struct { + uint32_t len; + VkPresentModeKHR *data; + } present_modes; + } surface_caps; + } *gpus; + struct phy_gpu *chosen; + } phy_gpus; + + struct { + VkDevice device; + VkQueue gfx_queue; + VkQueue present_queue; + } gpu; + + struct { + VkSwapchainKHR swapchain; + VkFormat format; + VkExtent2D extent; + struct { + uint32_t len; + struct { + VkImage image; + VkImageView view; + VkFramebuffer framebuffer; + } *data; + } images; + } swapchain; + + VkRenderPass render_pass; + + struct { + VkCommandPool pool; + VkCommandBuffer buffers[MAX_FRAMES]; + } command; + + struct { + VkPipelineLayout layout; + VkPipeline gfx; + } pipeline; + + struct { + VkSemaphore image_available[MAX_FRAMES]; + VkSemaphore render_finished[MAX_FRAMES]; + VkFence in_flight[MAX_FRAMES]; + } locks; + + struct { + VkDescriptorSetLayout layout; + VkDescriptorPool pool; + VkDescriptorSet sets[MAX_FRAMES]; + } descriptor; + + struct image depth; + struct { + struct buffer buffer; + void *data; + } uniform[MAX_FRAMES]; + + VkSampler sampler; + VkSampleCountFlagBits msaa_samples; + + uint32_t mip_levels; + uint32_t current_frame; +}; + +struct renderer *renderer_init(struct window *win); +void renderer_destroy(struct renderer *ren); +void renderer_draw(struct renderer *ren, size_t mesh_count, struct mesh meshes[mesh_count]); +void renderer_resize(struct renderer *ren); + +#endif -- cgit v1.2.3