forked from AuroraMiddleware/gtk
Add semaphores to the command buffer submit api
Allow to pass in semaphores to wait for before executing and to signal after executing the command buffer. This just exposes the capabilities of the underlying Vulkan api. Update all callers to pass no semaphores, for now. We will use this in the future.
This commit is contained in:
parent
ff188f6bf0
commit
85e4e0672a
@ -75,33 +75,36 @@ gsk_vulkan_command_pool_get_buffer (GskVulkanCommandPool *self)
|
||||
void
|
||||
gsk_vulkan_command_pool_submit_buffer (GskVulkanCommandPool *self,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize wait_semaphore_count,
|
||||
VkSemaphore *wait_semaphores,
|
||||
gsize signal_semaphore_count,
|
||||
VkSemaphore *signal_semaphores,
|
||||
VkFence fence)
|
||||
{
|
||||
VkPipelineStageFlags *wait_semaphore_flags = NULL;
|
||||
|
||||
GSK_VK_CHECK (vkEndCommandBuffer, command_buffer);
|
||||
|
||||
if (wait_semaphore_count > 0)
|
||||
{
|
||||
wait_semaphore_flags = alloca (sizeof (VkPipelineStageFlags) * wait_semaphore_count);
|
||||
for (int i = 0; i < wait_semaphore_count; i++)
|
||||
wait_semaphore_flags[i] = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
}
|
||||
|
||||
GSK_VK_CHECK (vkQueueSubmit, gdk_vulkan_context_get_queue (self->vulkan),
|
||||
1,
|
||||
&(VkSubmitInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||
/*
|
||||
.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = (VkSemaphore[1]) {
|
||||
gdk_vulkan_context_get_draw_semaphore (self->vulkan)
|
||||
},
|
||||
*/
|
||||
.pWaitDstStageMask = (VkPipelineStageFlags []) {
|
||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
},
|
||||
.waitSemaphoreCount = wait_semaphore_count,
|
||||
.pWaitSemaphores = wait_semaphores,
|
||||
.pWaitDstStageMask = wait_semaphore_flags,
|
||||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = (VkCommandBuffer[1]) {
|
||||
command_buffer
|
||||
},
|
||||
/*
|
||||
.signalSemaphoreCount = 1,
|
||||
.pSignalSemaphores = (VkSemaphore[1]) {
|
||||
gdk_vulkan_context_get_draw_semaphore (self->vulkan)
|
||||
}
|
||||
*/
|
||||
.signalSemaphoreCount = signal_semaphore_count,
|
||||
.pSignalSemaphores = signal_semaphores,
|
||||
},
|
||||
fence);
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ void gsk_vulkan_command_pool_reset (GskVulk
|
||||
VkCommandBuffer gsk_vulkan_command_pool_get_buffer (GskVulkanCommandPool *self);
|
||||
void gsk_vulkan_command_pool_submit_buffer (GskVulkanCommandPool *self,
|
||||
VkCommandBuffer buffer,
|
||||
gsize wait_semaphore_count,
|
||||
VkSemaphore *wait_semaphores,
|
||||
gsize signal_semaphores_count,
|
||||
VkSemaphore *signal_semaphores,
|
||||
VkFence fence);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -154,7 +154,7 @@ gsk_vulkan_uploader_upload (GskVulkanUploader *self)
|
||||
0, NULL,
|
||||
self->before_buffer_barriers->len, (VkBufferMemoryBarrier *) self->before_buffer_barriers->data,
|
||||
self->before_image_barriers->len, (VkImageMemoryBarrier *) self->before_image_barriers->data);
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, command_buffer, VK_NULL_HANDLE);
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, command_buffer, 0, NULL, 0, NULL, VK_NULL_HANDLE);
|
||||
g_array_set_size (self->before_buffer_barriers, 0);
|
||||
g_array_set_size (self->before_image_barriers, 0);
|
||||
}
|
||||
@ -176,7 +176,7 @@ gsk_vulkan_uploader_upload (GskVulkanUploader *self)
|
||||
|
||||
if (self->copy_buffer != VK_NULL_HANDLE)
|
||||
{
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, self->copy_buffer, VK_NULL_HANDLE);
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, self->copy_buffer, 0, NULL, 0, NULL, VK_NULL_HANDLE);
|
||||
self->copy_buffer = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self,
|
||||
vkCmdEndRenderPass (command_buffer);
|
||||
}
|
||||
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, command_buffer, self->fence);
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool, command_buffer, 0, NULL, 0, NULL, self->fence);
|
||||
|
||||
if (GSK_RENDER_MODE_CHECK (SYNC))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user