kiba-engine
internal.h
1 #pragma once
2 
3 #include <kiba/containers/array.h>
4 #include <kiba/core/types.h>
5 #include <kiba/gpu/enums.h>
6 #include <kiba/gpu/limits.h>
7 #include <vulkan/vulkan.h>
8 
9 // TODO this should be injected from the backend folder e.g. vulkan
10 
12  VkSurfaceKHR raw;
13  VkExtent2D extent;
14  VkSwapchainKHR swap_chain;
15  u32 presentation_image_index;
16  u32 image_count;
17  VkImage images[3]; // TODO reconsider this
18  VkFence fc_image_aquire;
19 };
20 
22  VkImage raw;
23  VkDeviceMemory memory;
24 };
25 
27  VkImageView raw;
28 };
29 
31  VkCommandBuffer buffer;
32  VkFence exec_done;
33 };
34 
35 struct vk_queue {
36  u32 index;
37  VkQueue queue;
38  VkSemaphore sp_relays[2];
39  i32 sp_index; // TODO should ideally be atomic
40  b8 available;
41  VkCommandPool command_pool; // TODO one pool per thread for MT command recording
42  array_of(struct gpu_backend_command_encoder) encoders;
43 };
44 
46  VkImageView view;
47  // TODO image view image flags
48  enum gpu_texture_use usage;
49  enum gpu_texture_format format;
50  // TODO raw view formats?
51 };
52 
54  u32 attachment_count;
55  struct vk_framebuffer_attachment attachments[KB_GPU_MAX_ATTACHMENTS];
56  VkExtent3D extent;
57  // TODO sample count
58 };
59 
61  VkFormat format;
62  VkImageLayout layout;
63  enum gpu_attachment_ops ops;
64 };
65 
67  struct vk_attachment_key base;
68  b8 resolve_set;
69  struct vk_attachment_key resolve;
70 };
71 
73  struct vk_attachment_key base;
74  enum gpu_attachment_ops stencil_ops;
75 };
76 
78  u32 color_count;
79  struct vk_color_attachment_key colors[KB_GPU_MAX_COLOR_ATTACHMENTS];
80  b8 depth_stencil_set;
81  struct vk_depth_stencil_attachment_key depth_stencil;
82  // TODO sample_count and multiview??
83 };
84 
86  struct vk_framebuffer_key key;
87  VkFramebuffer fb;
88 };
89 
90 struct vk_renderpass {
91  struct vk_renderpass_key key;
92  VkRenderPass rp;
93 };
94 
96  VkPhysicalDevice physical;
97  VkDevice logical;
98  struct vk_queue graphics_queue;
99  struct vk_queue transfer_queue;
100  struct vk_queue present_queue;
101  struct vk_queue compute_queue;
102  array_of(struct vk_renderpass) renderpasses;
103  array_of(struct vk_framebuffer) framebuffers;
104 };
105 
107  VkShaderModule raw;
108 };
109 
110 typedef VkDescriptorSetLayout gpu_bind_group_layout;
111 
113  VkPipelineLayout raw;
114 };
115 
117  VkPipeline raw;
118 };
119 
121  VkBuffer raw;
122  VkDeviceMemory memory;
123  void *mapped;
124 };