diff options
author | Jason Ekstrand <[email protected]> | 2017-08-03 11:46:09 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-08-28 18:35:22 -0700 |
commit | f992bb205c174e0a8e6574258598f5268dd0e0cb (patch) | |
tree | b4d0121867d4d6da752ba5455d31d9e233d503f5 /src/intel/vulkan/anv_batch_chain.c | |
parent | 2eacfdeec9c1bd3be291e8f9526580da331a8ec4 (diff) |
anv: Rework fences to work more like BO semaphores
This commit changes fences to work a bit more like BO semaphores.
Instead of the fence being a batch, it's simply a BO that gets added
to the validation list for the last execbuf call in the QueueSubmit
operation. It's a bit annoying finding the last submit in the execbuf
but this allows us to avoid the dummy execbuf.
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_batch_chain.c')
-rw-r--r-- | src/intel/vulkan/anv_batch_chain.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 1e7455f71e1..ef6ada49ff3 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1451,8 +1451,11 @@ anv_cmd_buffer_execbuf(struct anv_device *device, const VkSemaphore *in_semaphores, uint32_t num_in_semaphores, const VkSemaphore *out_semaphores, - uint32_t num_out_semaphores) + uint32_t num_out_semaphores, + VkFence _fence) { + ANV_FROM_HANDLE(anv_fence, fence, _fence); + struct anv_execbuf execbuf; anv_execbuf_init(&execbuf); @@ -1545,6 +1548,13 @@ anv_cmd_buffer_execbuf(struct anv_device *device, } } + if (fence) { + result = anv_execbuf_add_bo(&execbuf, &fence->bo, NULL, + EXEC_OBJECT_WRITE, &device->alloc); + if (result != VK_SUCCESS) + return result; + } + if (cmd_buffer) result = setup_execbuf_for_cmd_buffer(&execbuf, cmd_buffer); else @@ -1588,6 +1598,20 @@ anv_cmd_buffer_execbuf(struct anv_device *device, anv_semaphore_reset_temporary(device, semaphore); } + if (fence) { + /* Once the execbuf has returned, we need to set the fence state to + * SUBMITTED. We can't do this before calling execbuf because + * anv_GetFenceStatus does take the global device lock before checking + * fence->state. + * + * We set the fence state to SUBMITTED regardless of whether or not the + * execbuf succeeds because we need to ensure that vkWaitForFences() and + * vkGetFenceStatus() return a valid result (VK_ERROR_DEVICE_LOST or + * VK_SUCCESS) in a finite amount of time even if execbuf fails. + */ + fence->state = ANV_FENCE_STATE_SUBMITTED; + } + if (result == VK_SUCCESS && need_out_fence) { int out_fence = execbuf.execbuf.rsvd2 >> 32; for (uint32_t i = 0; i < num_out_semaphores; i++) { |