4 #include <vulkan/vulkan.h>
7 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
11 VkPhysicalDevice pdev;
13 VkPipelineCache cache;
15 VkCommandPool cmd_pool;
16 VkCommandBuffer cmd_buf;
21 uint8_t deviceUUID[VK_UUID_SIZE];
22 uint8_t driverUUID[VK_UUID_SIZE];
36 VkImageUsageFlagBits usage;
39 VkImageLayout in_layout;
40 VkImageLayout end_layout;
51 struct vk_mem_obj mobj;
57 struct vk_mem_obj mobj;
61 struct vk_image_obj obj;
62 struct vk_image_props props;
70 VkPrimitiveTopology topology;
76 VkPipelineLayout pipeline_layout;
77 VkRenderPass renderpass;
82 struct vk_vertex_info vertex_info;
93 VkSemaphore frame_ready;
94 VkSemaphore frame_done;
99 bool vk_init_ctx(struct vk_ctx *ctx);
100 bool vk_init_ctx_for_rendering(struct vk_ctx *ctx);
101 void vk_cleanup_ctx(struct vk_ctx *ctx);
106 vk_create_image(struct vk_ctx *ctx,
107 struct vk_image_props *props,
108 struct vk_image_obj *img_obj);
110 vk_destroy_image(struct vk_ctx *ctx,
111 struct vk_image_obj *img_obj);
115 vk_fill_ext_image_props(struct vk_ctx *ctx,
116 uint32_t w, uint32_t h,
118 uint32_t num_samples,
122 VkImageTiling tiling,
123 VkImageUsageFlagBits usage,
124 VkImageLayout in_layout,
125 VkImageLayout end_layout,
126 struct vk_image_props *props);
131 vk_create_buffer(struct vk_ctx *ctx,
133 VkBufferUsageFlagBits usage,
137 vk_destroy_buffer(struct vk_ctx *ctx,
140 vk_update_buffer_data(struct vk_ctx *ctx,
148 vk_create_semaphores(struct vk_ctx *ctx,
149 struct vk_semaphores *semaphores);
151 vk_destroy_semaphores(struct vk_ctx *ctx,
152 struct vk_semaphores *semaphores);
157 vk_create_renderer(struct vk_ctx *ctx,
159 unsigned int vs_size,
161 unsigned int fs_size,
164 struct vk_image_att *color_att,
165 struct vk_image_att *depth_att,
166 struct vk_vertex_info *vert_info,
167 struct vk_renderer *renderer);
170 vk_destroy_renderer(struct vk_ctx *ctx,
171 struct vk_renderer *pipeline);
176 vk_draw(struct vk_ctx *ctx,
178 struct vk_renderer *renderer,
180 uint32_t vk_fb_color_count,
181 struct vk_semaphores *semaphores,
182 struct vk_image_att *attachments,
183 uint32_t n_attachments,
184 float x, float y, float w, float h);
189 vk_copy_image_to_buffer(struct vk_ctx *ctx,
190 struct vk_image_att *src_img,
191 struct vk_buf *dst_bo,
195 vk_transition_image_layout(struct vk_image_att *img_att,
196 VkCommandBuffer cmd_buf,
197 VkImageLayout old_layout,
198 VkImageLayout new_layout,
199 uint32_t src_queue_family_index,
200 uint32_t dst_queue_family_index);