X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fvk.h;h=5adfbd71b96624646a60b32e3eba645ff06e1769;hb=35f7d10bf03cc666b551490bcae87ac389d63cb7;hp=dfe6aa685ec307030df1984581bafeac8f717ea3;hpb=e123e37a567080a67a1d59837f52cada1b02c951;p=vkrt diff --git a/src/vk.h b/src/vk.h index dfe6aa6..5adfbd7 100644 --- a/src/vk.h +++ b/src/vk.h @@ -5,15 +5,15 @@ #include #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + struct vk_ctx { VkInstance inst; + VkPhysicalDevice pdev; VkDevice dev; VkCommandPool cmd_pool; - VkCommandBuffer *cmd_buffers; - uint32_t num_cmd_buffers; VkQueue queue; int qfam_idx; @@ -22,16 +22,9 @@ struct vk_ctx uint8_t driverUUID[VK_UUID_SIZE]; }; -struct vk_cmd_buffer -{ - VkCommandBuffer buffer; - VkSubmitInfo submit_info; -}; - struct vk_swapchain { VkSwapchainKHR swapchain; - VkSurfaceKHR surface; VkSurfaceFormatKHR surf_fmt; /* image properties */ @@ -121,6 +114,10 @@ struct vk_semaphores VkSemaphore frame_done; }; +#ifdef __cplusplus +extern "C" { +#endif + /* context */ bool vk_init_ctx(struct vk_ctx *ctx, @@ -130,8 +127,7 @@ bool vk_init_ctx_for_rendering(struct vk_ctx *ctx, bool enable_cache, bool enable_layers); -void vk_cleanup_ctx(struct vk_ctx *ctx, - bool enable_layers); +void vk_cleanup_ctx(struct vk_ctx *ctx); /* images */ @@ -194,12 +190,6 @@ void vk_destroy_semaphores(struct vk_ctx *ctx, struct vk_semaphores *semaphores); -bool -vk_create_fences(struct vk_ctx *ctx, - int num_cmd_buf, - VkFenceCreateFlagBits flags, - VkFence *fences); - void vk_destroy_fences(struct vk_ctx *ctc, int num_fences, @@ -227,7 +217,11 @@ void vk_destroy_renderer(struct vk_ctx *ctx, struct vk_renderer *pipeline); -/* draw */ +/* fences and command buffers */ +bool +vk_create_fence(struct vk_ctx *ctx, + VkFence *fence); + VkCommandBuffer vk_create_cmd_buffer(struct vk_ctx *ctx); @@ -244,13 +238,11 @@ vk_record_cmd_buffer(struct vk_ctx *ctx, float w, float h); void -vk_reset_cmd_buf(struct vk_cmd_buffer *cmd_buf); - -void -vk_destroy_cmd_bufs(struct vk_ctx *ctx, - uint32_t num_buffers, - VkCommandBuffer *buffers); +vk_destroy_cmd_buffers(struct vk_ctx *ctx, + uint32_t num_buffers, + VkCommandBuffer *buffers); +/* draw */ void vk_draw(struct vk_ctx *ctx, struct vk_semaphores *semaphores, @@ -270,6 +262,13 @@ vk_clear_color(struct vk_ctx *ctx, uint32_t n_attachments, float x, float y, float w, float h); +void +vk_set_viewport(struct vk_ctx *ctx, + VkCommandBuffer cmd_buf, + float x, float y, + float w, float h, + float near, float far); + /* swapchain */ bool @@ -284,7 +283,7 @@ vk_destroy_swapchain(struct vk_ctx *ctx, struct vk_swapchain *swapchain); bool -vk_present_queue(struct vk_swapchain *swapchain, +vk_queue_present(struct vk_swapchain *swapchain, VkQueue queue, uint32_t image_idx, VkSemaphore wait_sema); @@ -306,4 +305,9 @@ vk_transition_image_layout(struct vk_attachment *img_att, uint32_t src_queue_family_index, uint32_t dst_queue_family_index); + +#ifdef __cplusplus +} +#endif + #endif /* VK_H */