Vulkan: Fix Fuchsia external semaphore fix tryWait().
Fix an issue where tryWait() would abort when called on an
unsignaled semaphore. Due to the fact that zx_object_wait_one()
will return ZX_ERR_TIMED_OUT in this case (because the expiration
time was set with zx_clock_get_monotonic() instead of
ZX_TIME_INFINITE).
This fixes an issue that appears when vkWaitForIdle() is called
by certain Fuchsia Vulkan graphics tests.
+ Replace ABORT() calls with DABORT() and proper returns to
avoid crashing if DCHECK_ALWAYS_ON is not defined at
build time.
Bug: None
Change-Id: Idaf14ed580c0c3ab326705842bcfe5e23eaad2b8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44018
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: David Turner <digit@google.com>
diff --git a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
index 90f68d4..1e37e68 100644
--- a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
+++ b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
@@ -69,7 +69,7 @@
zx_status_t status = zx_handle_duplicate(handle, ZX_RIGHT_SAME_RIGHTS, &new_handle);
if(status != ZX_OK)
{
- TRACE("zx_handle_duplicate() returned %d", status);
+ DABORT("zx_handle_duplicate() returned %d", status);
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
*pHandle = new_handle;
@@ -83,17 +83,20 @@
handle, ZX_EVENT_SIGNALED, ZX_TIME_INFINITE, &observed);
if(status != ZX_OK)
{
- ABORT("zx_object_wait_one() returned %d", status);
+ DABORT("zx_object_wait_one() returned %d", status);
+ return;
}
if(observed != ZX_EVENT_SIGNALED)
{
- ABORT("zx_object_wait_one() returned observed %x (%x expected)", observed, ZX_EVENT_SIGNALED);
+ DABORT("zx_object_wait_one() returned observed %x (%x expected)", observed, ZX_EVENT_SIGNALED);
+ return;
}
// Need to unsignal the event now, as required by the Vulkan spec.
status = zx_object_signal(handle, ZX_EVENT_SIGNALED, 0);
if(status != ZX_OK)
{
- ABORT("zx_object_signal() returned %d", status);
+ DABORT("zx_object_signal() returned %d", status);
+ return;
}
}
@@ -102,9 +105,10 @@
zx_signals_t observed = 0;
zx_status_t status = zx_object_wait_one(
handle, ZX_EVENT_SIGNALED, zx_clock_get_monotonic(), &observed);
- if(status != ZX_OK)
+ if(status != ZX_OK && status != ZX_ERR_TIMED_OUT)
{
- ABORT("zx_object_wait_one() returned %d", status);
+ DABORT("zx_object_wait_one() returned %d", status);
+ return false;
}
if(observed != ZX_EVENT_SIGNALED)
{
@@ -114,7 +118,8 @@
status = zx_object_signal(handle, ZX_EVENT_SIGNALED, 0);
if(status != ZX_OK)
{
- ABORT("zx_object_signal() returned %d", status);
+ DABORT("zx_object_signal() returned %d", status);
+ return false;
}
return true;
}
@@ -124,7 +129,7 @@
zx_status_t status = zx_object_signal(handle, 0, ZX_EVENT_SIGNALED);
if(status != ZX_OK)
{
- ABORT("zx_object_signal() returned %d", status);
+ DABORT("zx_object_signal() returned %d", status);
}
}