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;
78 VkPipelineLayout pipeline_layout;
79 VkRenderPass renderpass;
84 struct vk_vertex_info vertex_info;
95 VkSemaphore frame_ready;
96 VkSemaphore frame_done;
101 bool vk_init_ctx(struct vk_ctx *ctx);
102 bool vk_init_ctx_for_rendering(struct vk_ctx *ctx);
103 void vk_cleanup_ctx(struct vk_ctx *ctx);
108 vk_create_image(struct vk_ctx *ctx,
109 struct vk_image_props *props,
110 struct vk_image_obj *img_obj);
112 vk_destroy_image(struct vk_ctx *ctx,
113 struct vk_image_obj *img_obj);
117 vk_fill_ext_image_props(struct vk_ctx *ctx,
118 uint32_t w, uint32_t h,
120 uint32_t num_samples,
124 VkImageTiling tiling,
125 VkImageLayout in_layout,
126 VkImageLayout end_layout,
128 struct vk_image_props *props);
133 vk_create_buffer(struct vk_ctx *ctx,
136 VkBufferUsageFlagBits usage,
140 vk_destroy_buffer(struct vk_ctx *ctx,
143 vk_update_buffer_data(struct vk_ctx *ctx,
149 vk_create_ext_buffer(struct vk_ctx *ctx,
151 VkBufferUsageFlagBits usage,
158 vk_create_semaphores(struct vk_ctx *ctx,
159 struct vk_semaphores *semaphores);
161 vk_destroy_semaphores(struct vk_ctx *ctx,
162 struct vk_semaphores *semaphores);
167 vk_create_renderer(struct vk_ctx *ctx,
169 unsigned int vs_size,
171 unsigned int fs_size,
174 struct vk_image_att *color_att,
175 struct vk_image_att *depth_att,
176 struct vk_vertex_info *vert_info,
177 struct vk_renderer *renderer);
180 vk_destroy_renderer(struct vk_ctx *ctx,
181 struct vk_renderer *pipeline);
186 vk_draw(struct vk_ctx *ctx,
188 struct vk_renderer *renderer,
190 uint32_t vk_fb_color_count,
191 struct vk_semaphores *semaphores,
192 struct vk_image_att *attachments,
193 uint32_t n_attachments,
194 float x, float y, float w, float h);
197 vk_clear_color(struct vk_ctx *ctx,
199 struct vk_renderer *renderer,
201 uint32_t vk_fb_color_count,
202 struct vk_semaphores *semaphores,
203 bool has_wait, bool has_signal,
204 struct vk_image_att *attachments,
205 uint32_t n_attachments,
206 float x, float y, float w, float h);
211 vk_copy_image_to_buffer(struct vk_ctx *ctx,
212 struct vk_image_att *src_img,
213 struct vk_buf *dst_bo,
217 vk_transition_image_layout(struct vk_image_att *img_att,
218 VkCommandBuffer cmd_buf,
219 VkImageLayout old_layout,
220 VkImageLayout new_layout,
221 uint32_t src_queue_family_index,
222 uint32_t dst_queue_family_index);