diff options
author | Juston Li <justonli@google.com> | 2023-04-19 12:03:26 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-05-09 04:35:16 +0000 |
commit | c3e1140c20bdfa630381797b321dbc5d7a315d52 (patch) | |
tree | bc816c22972ca5dcc4fdcc39bae059bacf14b618 /src/virtio | |
parent | 6ec54465d489b7b5fe5da27188e73154617332c2 (diff) | |
download | mesa-c3e1140c20bdfa630381797b321dbc5d7a315d52.tar.gz |
venus: add helper function support for VkBindSparseInfo
add getter/setters for VkBindSparseInfo so we can at least share
vn_queue_submission_prepare() to handle external semaphores and
check for fence/semaphore feedback
Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22616>
Diffstat (limited to 'src/virtio')
-rw-r--r-- | src/virtio/vulkan/vn_queue.c | 95 |
1 files changed, 59 insertions, 36 deletions
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 * |