4 #include <vulkan/vulkan.h>
7 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
11 VkPhysicalDevice pdev;
14 VkCommandPool cmd_pool;
15 VkCommandBuffer cmd_buf;
20 uint8_t deviceUUID[VK_UUID_SIZE];
21 uint8_t driverUUID[VK_UUID_SIZE];
26 VkSwapchainKHR swapchain;
28 VkSurfaceFormatKHR surf_fmt;
44 VkImageUsageFlagBits usage;
47 VkImageLayout in_layout;
48 VkImageLayout end_layout;
62 struct vk_mem_obj mobj;
66 struct vk_image_obj obj;
67 struct vk_image_props props;
75 VkPrimitiveTopology topology;
81 struct vk_mem_obj mobj;
87 VkPipelineLayout pipeline_layout;
88 VkRenderPass renderpass;
93 struct vk_vertex_info vertex_info;
104 VkSemaphore frame_ready;
105 VkSemaphore frame_done;
110 bool vk_init_ctx(struct vk_ctx *ctx);
111 bool vk_init_ctx_for_rendering(struct vk_ctx *ctx);
112 void vk_cleanup_ctx(struct vk_ctx *ctx);
117 vk_create_image(struct vk_ctx *ctx,
118 struct vk_image_props *props,
119 struct vk_image_obj *img_obj);
121 vk_destroy_image(struct vk_ctx *ctx,
122 struct vk_image_obj *img_obj);
126 vk_fill_ext_image_props(struct vk_ctx *ctx,
127 uint32_t w, uint32_t h,
129 uint32_t num_samples,
133 VkImageTiling tiling,
134 VkImageLayout in_layout,
135 VkImageLayout end_layout,
137 struct vk_image_props *props);
142 vk_create_buffer(struct vk_ctx *ctx,
145 VkBufferUsageFlagBits usage,
149 vk_destroy_buffer(struct vk_ctx *ctx,
152 vk_update_buffer_data(struct vk_ctx *ctx,
158 vk_create_ext_buffer(struct vk_ctx *ctx,
160 VkBufferUsageFlagBits usage,
167 vk_create_semaphores(struct vk_ctx *ctx,
168 struct vk_semaphores *semaphores);
170 vk_destroy_semaphores(struct vk_ctx *ctx,
171 struct vk_semaphores *semaphores);
176 vk_create_renderer(struct vk_ctx *ctx,
178 unsigned int vs_size,
180 unsigned int fs_size,
183 struct vk_image_att *color_att,
184 struct vk_image_att *depth_att,
185 struct vk_vertex_info *vert_info,
186 struct vk_renderer *renderer);
189 vk_destroy_renderer(struct vk_ctx *ctx,
190 struct vk_renderer *pipeline);
195 vk_draw(struct vk_ctx *ctx,
197 struct vk_renderer *renderer,
199 uint32_t vk_fb_color_count,
200 struct vk_semaphores *semaphores,
201 struct vk_image_att *attachments,
202 uint32_t n_attachments,
203 float x, float y, float w, float h);
206 vk_clear_color(struct vk_ctx *ctx,
208 struct vk_renderer *renderer,
210 uint32_t vk_fb_color_count,
211 struct vk_semaphores *semaphores,
212 bool has_wait, bool has_signal,
213 struct vk_image_att *attachments,
214 uint32_t n_attachments,
215 float x, float y, float w, float h);
220 vk_create_swapchain(struct vk_ctx *ctx,
221 int width, int height,
223 struct vk_swapchain *swapchain);
225 vk_destroy_swapchain(struct vk_ctx *ctx,
226 struct vk_swapchain *swapchain);
231 vk_copy_image_to_buffer(struct vk_ctx *ctx,
232 struct vk_image_att *src_img,
233 struct vk_buf *dst_bo,
237 vk_transition_image_layout(struct vk_image_att *img_att,
238 VkCommandBuffer cmd_buf,
239 VkImageLayout old_layout,
240 VkImageLayout new_layout,
241 uint32_t src_queue_family_index,
242 uint32_t dst_queue_family_index);