moved ui.[hc] to vk.[hc]
[vkrt] / src / vk.h
index 97496b8..140f525 100644 (file)
--- a/src/vk.h
+++ b/src/vk.h
@@ -10,7 +10,6 @@ struct vk_ctx
        VkInstance inst;
        VkPhysicalDevice pdev;
        VkDevice dev;
-       VkPipelineCache cache;
 
        VkCommandPool cmd_pool;
        VkCommandBuffer cmd_buf;
@@ -22,6 +21,15 @@ struct vk_ctx
        uint8_t driverUUID[VK_UUID_SIZE];
 };
 
+struct vk_swapchain
+{
+    VkSwapchainKHR swapchain;
+    VkSurfaceKHR surface;
+    VkSurfaceFormatKHR surf_fmt;
+    uint32_t num_images;
+    VkExtent2D extent2d;
+};
+
 struct vk_image_props
 {
        uint32_t w;
@@ -38,6 +46,8 @@ struct vk_image_props
 
        VkImageLayout in_layout;
        VkImageLayout end_layout;
+
+    bool need_export;
 };
 
 struct vk_mem_obj {
@@ -48,12 +58,7 @@ struct vk_mem_obj {
 
 struct vk_image_obj {
        VkImage img;
-       struct vk_mem_obj mobj;
-};
-
-struct vk_buf
-{
-       VkBuffer buf;
+    VkImageView img_view;
        struct vk_mem_obj mobj;
 };
 
@@ -70,6 +75,12 @@ struct vk_vertex_info
        VkPrimitiveTopology topology;
 };
 
+struct vk_buf
+{
+       VkBuffer buf;
+       struct vk_mem_obj mobj;
+};
+
 struct vk_renderer
 {
        VkPipeline pipeline;
@@ -120,15 +131,16 @@ vk_fill_ext_image_props(struct vk_ctx *ctx,
                                                uint32_t num_layers,
                                                VkFormat format,
                                                VkImageTiling tiling,
-                                               VkImageUsageFlagBits usage,
                                                VkImageLayout in_layout,
                                                VkImageLayout end_layout,
+                        bool need_export,
                                                struct vk_image_props *props);
 
 /* buffers */
 
 bool
 vk_create_buffer(struct vk_ctx *ctx,
+                 bool is_external,
                                 uint32_t sz,
                                 VkBufferUsageFlagBits usage,
                                 void *pnext,
@@ -142,6 +154,13 @@ vk_update_buffer_data(struct vk_ctx *ctx,
                                          uint32_t data_sz,
                                          struct vk_buf *bo);
 
+bool
+vk_create_ext_buffer(struct vk_ctx *ctx,
+                    uint32_t sz,
+                    VkBufferUsageFlagBits usage,
+                    struct vk_buf *bo);
+
+
 /* semaphores */
 
 bool
@@ -183,6 +202,29 @@ vk_draw(struct vk_ctx *ctx,
                uint32_t n_attachments,
                float x, float y, float w, float h);
 
+void
+vk_clear_color(struct vk_ctx *ctx,
+               struct vk_buf *vbo,
+               struct vk_renderer *renderer,
+               float *vk_fb_color,
+               uint32_t vk_fb_color_count,
+               struct vk_semaphores *semaphores,
+               bool has_wait, bool has_signal,
+               struct vk_image_att *attachments,
+               uint32_t n_attachments,
+               float x, float y, float w, float h);
+
+/* swapchain */
+
+bool
+vk_create_swapchain(struct vk_ctx *ctx,
+                    int width, int height,
+                    int num_qfam,
+                    struct vk_swapchain *swapchain);
+void
+vk_destroy_swapchain(struct vk_ctx *ctx,
+                     struct vk_swapchain *swapchain);
+
 /* transitions */
 
 void