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];
35 VkImageUsageFlagBits usage;
38 VkImageLayout in_layout;
39 VkImageLayout end_layout;
53 struct vk_mem_obj mobj;
57 struct vk_image_obj obj;
58 struct vk_image_props props;
66 VkPrimitiveTopology topology;
72 struct vk_mem_obj mobj;
79 VkPipelineLayout pipeline_layout;
80 VkRenderPass renderpass;
85 struct vk_vertex_info vertex_info;
96 VkSemaphore frame_ready;
97 VkSemaphore frame_done;
102 bool vk_init_ctx(struct vk_ctx *ctx);
103 bool vk_init_ctx_for_rendering(struct vk_ctx *ctx);
104 void vk_cleanup_ctx(struct vk_ctx *ctx);
109 vk_create_image(struct vk_ctx *ctx,
110 struct vk_image_props *props,
111 struct vk_image_obj *img_obj);
113 vk_destroy_image(struct vk_ctx *ctx,
114 struct vk_image_obj *img_obj);
118 vk_fill_ext_image_props(struct vk_ctx *ctx,
119 uint32_t w, uint32_t h,
121 uint32_t num_samples,
125 VkImageTiling tiling,
126 VkImageLayout in_layout,
127 VkImageLayout end_layout,
129 struct vk_image_props *props);
134 vk_create_buffer(struct vk_ctx *ctx,
137 VkBufferUsageFlagBits usage,
141 vk_destroy_buffer(struct vk_ctx *ctx,
144 vk_update_buffer_data(struct vk_ctx *ctx,
150 vk_create_ext_buffer(struct vk_ctx *ctx,
152 VkBufferUsageFlagBits usage,
159 vk_create_semaphores(struct vk_ctx *ctx,
160 struct vk_semaphores *semaphores);
162 vk_destroy_semaphores(struct vk_ctx *ctx,
163 struct vk_semaphores *semaphores);
168 vk_create_renderer(struct vk_ctx *ctx,
170 unsigned int vs_size,
172 unsigned int fs_size,
175 struct vk_image_att *color_att,
176 struct vk_image_att *depth_att,
177 struct vk_vertex_info *vert_info,
178 struct vk_renderer *renderer);
181 vk_destroy_renderer(struct vk_ctx *ctx,
182 struct vk_renderer *pipeline);
187 vk_draw(struct vk_ctx *ctx,
189 struct vk_renderer *renderer,
191 uint32_t vk_fb_color_count,
192 struct vk_semaphores *semaphores,
193 struct vk_image_att *attachments,
194 uint32_t n_attachments,
195 float x, float y, float w, float h);
198 vk_clear_color(struct vk_ctx *ctx,
200 struct vk_renderer *renderer,
202 uint32_t vk_fb_color_count,
203 struct vk_semaphores *semaphores,
204 bool has_wait, bool has_signal,
205 struct vk_image_att *attachments,
206 uint32_t n_attachments,
207 float x, float y, float w, float h);
212 vk_copy_image_to_buffer(struct vk_ctx *ctx,
213 struct vk_image_att *src_img,
214 struct vk_buf *dst_bo,
218 vk_transition_image_layout(struct vk_image_att *img_att,
219 VkCommandBuffer cmd_buf,
220 VkImageLayout old_layout,
221 VkImageLayout new_layout,
222 uint32_t src_queue_family_index,
223 uint32_t dst_queue_family_index);