#include <stdbool.h>
#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;
uint8_t driverUUID[VK_UUID_SIZE];
};
-struct vk_cmd_buffer
-{
- VkCommandBuffer buffer;
- VkSubmitInfo submit_info;
-};
-
struct vk_swapchain
{
VkSwapchainKHR swapchain;
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 */
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,
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);
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,
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
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);