diff --git a/src/virtio/vulkan/vn_queue.c b/src/virtio/vulkan/vn_queue.c index dfa5dbfc828..57ba3cbca5c 100644 --- a/src/virtio/vulkan/vn_queue.c +++ b/src/virtio/vulkan/vn_queue.c @@ -55,6 +55,7 @@ struct vn_queue_submission { const void *batches; const VkSubmitInfo *submit_batches; const VkSubmitInfo2 *submit_batches2; + const VkBindSparseInfo *sparse_batches; }; VkFence fence_handle; @@ -94,24 +95,32 @@ static inline uint32_t vn_get_wait_semaphore_count(struct vn_queue_submission *submit, uint32_t batch_index) { - assert((submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO) || - (submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO_2)); - - return submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO - ? submit->submit_batches[batch_index].waitSemaphoreCount - : submit->submit_batches2[batch_index].waitSemaphoreInfoCount; + switch (submit->batch_type) { + case VK_STRUCTURE_TYPE_SUBMIT_INFO: + return submit->submit_batches[batch_index].waitSemaphoreCount; + case VK_STRUCTURE_TYPE_SUBMIT_INFO_2: + return submit->submit_batches2[batch_index].waitSemaphoreInfoCount; + case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO: + return submit->sparse_batches[batch_index].waitSemaphoreCount; + default: + unreachable("unexpected batch type"); + } } static inline uint32_t vn_get_signal_semaphore_count(struct vn_queue_submission *submit, uint32_t batch_index) { - assert((submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO) || - (submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO_2)); - - return submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO - ? submit->submit_batches[batch_index].signalSemaphoreCount - : submit->submit_batches2[batch_index].signalSemaphoreInfoCount; + switch (submit->batch_type) { + case VK_STRUCTURE_TYPE_SUBMIT_INFO: + return submit->submit_batches[batch_index].signalSemaphoreCount; + case VK_STRUCTURE_TYPE_SUBMIT_INFO_2: + return submit->submit_batches2[batch_index].signalSemaphoreInfoCount; + case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO: + return submit->sparse_batches[batch_index].signalSemaphoreCount; + default: + unreachable("unexpected batch type"); + } } static inline VkSemaphore @@ -119,15 +128,20 @@ vn_get_wait_semaphore(struct vn_queue_submission *submit, uint32_t batch_index, uint32_t semaphore_index) { - assert((submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO) || - (submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO_2)); - - return submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO - ? submit->submit_batches[batch_index] - .pWaitSemaphores[semaphore_index] - : submit->submit_batches2[batch_index] - .pWaitSemaphoreInfos[semaphore_index] - .semaphore; + switch (submit->batch_type) { + case VK_STRUCTURE_TYPE_SUBMIT_INFO: + return submit->submit_batches[batch_index] + .pWaitSemaphores[semaphore_index]; + case VK_STRUCTURE_TYPE_SUBMIT_INFO_2: + return submit->submit_batches2[batch_index] + .pWaitSemaphoreInfos[semaphore_index] + .semaphore; + case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO: + return submit->sparse_batches[batch_index] + .pWaitSemaphores[semaphore_index]; + default: + unreachable("unexpected batch type"); + } } static inline VkSemaphore @@ -135,27 +149,36 @@ vn_get_signal_semaphore(struct vn_queue_submission *submit, uint32_t batch_index, uint32_t semaphore_index) { - assert((submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO) || - (submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO_2)); - - return submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO - ? submit->submit_batches[batch_index] - .pSignalSemaphores[semaphore_index] - : submit->submit_batches2[batch_index] - .pSignalSemaphoreInfos[semaphore_index] - .semaphore; + switch (submit->batch_type) { + case VK_STRUCTURE_TYPE_SUBMIT_INFO: + return submit->submit_batches[batch_index] + .pSignalSemaphores[semaphore_index]; + case VK_STRUCTURE_TYPE_SUBMIT_INFO_2: + return submit->submit_batches2[batch_index] + .pSignalSemaphoreInfos[semaphore_index] + .semaphore; + case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO: + return submit->sparse_batches[batch_index] + .pSignalSemaphores[semaphore_index]; + default: + unreachable("unexpected batch type"); + } } static inline uint32_t vn_get_cmd_buffer_count(struct vn_queue_submission *submit, uint32_t batch_index) { - assert((submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO) || - (submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO_2)); - - return submit->batch_type == VK_STRUCTURE_TYPE_SUBMIT_INFO - ? submit->submit_batches[batch_index].commandBufferCount - : submit->submit_batches2[batch_index].commandBufferInfoCount; + switch (submit->batch_type) { + case VK_STRUCTURE_TYPE_SUBMIT_INFO: + return submit->submit_batches[batch_index].commandBufferCount; + case VK_STRUCTURE_TYPE_SUBMIT_INFO_2: + return submit->submit_batches2[batch_index].commandBufferInfoCount; + case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO: + return submit->sparse_batches[batch_index].bufferBindCount; + default: + unreachable("unexpected batch type"); + } } static inline const void *