+int vk_submit(VkQueue q, VkCommandBuffer cmdbuf, VkSemaphore semwait, VkSemaphore semsig)
+{
+ /* TODO: investigate if we need to expose the wait stage */
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo sinf = {0};
+ sinf.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ sinf.waitSemaphoreCount = semwait ? 1 : 0;
+ sinf.pWaitSemaphores = &semwait;
+ sinf.pWaitDstStageMask = &wait_stage;
+ sinf.commandBufferCount = 1;
+ sinf.pCommandBuffers = &cmdbuf;
+ sinf.signalSemaphoreCount = semsig ? 1 : 0;
+ sinf.pSignalSemaphores = &semsig;
+
+ if(vkQueueSubmit(q, 1, &sinf, 0) != 0) {
+ fprintf(stderr, "failed to submit command buffer\n");
+ return -1;
+ }
+ return 0;
+}
+
+int vk_present(VkQueue q, int imgid, VkSemaphore semwait)
+{
+ VkPresentInfoKHR pinf = {0};
+
+ pinf.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ pinf.waitSemaphoreCount = semwait ? 1 : 0;
+ pinf.pWaitSemaphores = &semwait;
+ pinf.swapchainCount = 1;
+ pinf.pSwapchains = &vksc;
+ pinf.pImageIndices = (unsigned int*)&imgid;
+
+ if(vkQueuePresentKHR(q, &pinf) != 0) {
+ fprintf(stderr, "present failed\n");
+ return -1;
+ }
+ return 0;
+}
+