anv: make semaphore helper work on a single object

Should have done that last time.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9045>
This commit is contained in:
Lionel Landwerlin
2021-03-12 19:34:31 +02:00
committed by Marge Bot
parent ad9d95eee4
commit 8d9102bde2

View File

@@ -886,17 +886,14 @@ maybe_transfer_temporary_semaphore(struct anv_queue_submit *submit,
}
static VkResult
anv_queue_submit_add_in_semaphores(struct anv_queue_submit *submit,
anv_queue_submit_add_in_semaphore(struct anv_queue_submit *submit,
struct anv_device *device,
const VkSemaphore *in_semaphores,
const uint64_t *in_values,
uint32_t num_in_semaphores)
const VkSemaphore _semaphore,
const uint64_t value)
{
VkResult result;
for (uint32_t i = 0; i < num_in_semaphores; i++) {
ANV_FROM_HANDLE(anv_semaphore, semaphore, in_semaphores[i]);
ANV_FROM_HANDLE(anv_semaphore, semaphore, _semaphore);
struct anv_semaphore_impl *impl;
VkResult result;
result = maybe_transfer_temporary_semaphore(submit, semaphore, &impl);
if (result != VK_SUCCESS)
@@ -915,7 +912,7 @@ anv_queue_submit_add_in_semaphores(struct anv_queue_submit *submit,
return result;
break;
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ: {
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ:
result = anv_queue_submit_add_syncobj(submit, device,
impl->syncobj,
I915_EXEC_FENCE_WAIT,
@@ -923,27 +920,24 @@ anv_queue_submit_add_in_semaphores(struct anv_queue_submit *submit,
if (result != VK_SUCCESS)
return result;
break;
}
case ANV_SEMAPHORE_TYPE_TIMELINE:
assert(in_values);
if (in_values[i] == 0)
if (value == 0)
break;
result = anv_queue_submit_add_timeline_wait(submit, device,
&impl->timeline,
in_values[i]);
value);
if (result != VK_SUCCESS)
return result;
break;
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ_TIMELINE:
assert(in_values);
if (in_values[i] == 0)
if (value == 0)
break;
result = anv_queue_submit_add_syncobj(submit, device,
impl->syncobj,
I915_EXEC_FENCE_WAIT,
in_values[i]);
value);
if (result != VK_SUCCESS)
return result;
break;
@@ -951,33 +945,29 @@ anv_queue_submit_add_in_semaphores(struct anv_queue_submit *submit,
default:
break;
}
}
return VK_SUCCESS;
}
static VkResult
anv_queue_submit_add_out_semaphores(struct anv_queue_submit *submit,
anv_queue_submit_add_out_semaphore(struct anv_queue_submit *submit,
struct anv_device *device,
const VkSemaphore *out_semaphores,
const uint64_t *out_values,
uint32_t num_out_semaphores)
const VkSemaphore _semaphore,
const uint64_t value)
{
ANV_FROM_HANDLE(anv_semaphore, semaphore, _semaphore);
VkResult result;
for (uint32_t i = 0; i < num_out_semaphores; i++) {
ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
/* Under most circumstances, out fences won't be temporary. However,
* the spec does allow it for opaque_fd. From the Vulkan 1.0.53 spec:
/* Under most circumstances, out fences won't be temporary. However, the
* spec does allow it for opaque_fd. From the Vulkan 1.0.53 spec:
*
* "If the import is temporary, the implementation must restore the
* semaphore to its prior permanent state after submitting the next
* semaphore wait operation."
*
* The spec says nothing whatsoever about signal operations on
* temporarily imported semaphores so it appears they are allowed.
* There are also CTS tests that require this to work.
* The spec says nothing whatsoever about signal operations on temporarily
* imported semaphores so it appears they are allowed. There are also CTS
* tests that require this to work.
*/
struct anv_semaphore_impl *impl =
semaphore->temporary.type != ANV_SEMAPHORE_TYPE_NONE ?
@@ -986,9 +976,9 @@ anv_queue_submit_add_out_semaphores(struct anv_queue_submit *submit,
switch (impl->type) {
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ: {
/*
* Reset the content of the syncobj so it doesn't contain a
* previously signaled dma-fence, until one is added by EXECBUFFER by
* the submission thread.
* Reset the content of the syncobj so it doesn't contain a previously
* signaled dma-fence, until one is added by EXECBUFFER by the
* submission thread.
*/
anv_gem_syncobj_reset(device, impl->syncobj);
@@ -1001,23 +991,21 @@ anv_queue_submit_add_out_semaphores(struct anv_queue_submit *submit,
}
case ANV_SEMAPHORE_TYPE_TIMELINE:
assert(out_values);
if (out_values[i] == 0)
if (value == 0)
break;
result = anv_queue_submit_add_timeline_signal(submit, device,
&impl->timeline,
out_values[i]);
value);
if (result != VK_SUCCESS)
return result;
break;
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ_TIMELINE:
assert(out_values);
if (out_values[i] == 0)
if (value == 0)
break;
result = anv_queue_submit_add_syncobj(submit, device, impl->syncobj,
I915_EXEC_FENCE_SIGNAL,
out_values[i]);
value);
if (result != VK_SUCCESS)
return result;
break;
@@ -1025,7 +1013,6 @@ anv_queue_submit_add_out_semaphores(struct anv_queue_submit *submit,
default:
break;
}
}
return VK_SUCCESS;
}
@@ -1279,13 +1266,14 @@ VkResult anv_QueueSubmit(
}
/* Wait semaphores */
result = anv_queue_submit_add_in_semaphores(submit,
for (uint32_t j = 0; j < pSubmits[i].waitSemaphoreCount; j++) {
result = anv_queue_submit_add_in_semaphore(submit,
device,
pSubmits[i].pWaitSemaphores,
wait_values,
pSubmits[i].waitSemaphoreCount);
pSubmits[i].pWaitSemaphores[j],
wait_values ? wait_values[j] : 0);
if (result != VK_SUCCESS)
goto out;
}
/* Command buffers */
for (uint32_t j = 0; j < pSubmits[i].commandBufferCount; j++) {
@@ -1310,13 +1298,14 @@ VkResult anv_QueueSubmit(
}
/* Signal semaphores */
result = anv_queue_submit_add_out_semaphores(submit,
for (uint32_t j = 0; j < pSubmits[i].signalSemaphoreCount; j++) {
result = anv_queue_submit_add_out_semaphore(submit,
device,
pSubmits[i].pSignalSemaphores,
signal_values,
pSubmits[i].signalSemaphoreCount);
pSubmits[i].pSignalSemaphores[j],
signal_values ? signal_values[j] : 0);
if (result != VK_SUCCESS)
goto out;
}
/* WSI BO */
if (wsi_signal_bo) {