Module: Mesa
Branch: main
Commit: 63baeffc2dbaece36202649ca1abd5aa4b0797be
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=63baeffc2dbaece36202649ca1abd5aa4b0797be

Author: Jason Ekstrand <[email protected]>
Date:   Wed Nov 17 09:24:40 2021 -0600

vulkan/sync: Rework asserts a bit

ANV currently smashes off the TIMELINE bit depending on whether or not
the i915 interface supports them, triggering assert(!type->get_value).
Instead of requiring ANV to smash off function pointers, let the extra
function pointers through and then assert on the feature bits before the
function pointers get used.  This should give us roughly the same amount
of assert protection while side-stepping the feature disabling problem.

Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13839>

---

 src/vulkan/runtime/vk_sync.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/vulkan/runtime/vk_sync.c b/src/vulkan/runtime/vk_sync.c
index e0f9b5cd6d6..21604186cd4 100644
--- a/src/vulkan/runtime/vk_sync.c
+++ b/src/vulkan/runtime/vk_sync.c
@@ -51,8 +51,6 @@ vk_sync_type_validate(const struct vk_sync_type *type)
                                VK_SYNC_FEATURE_WAIT_PENDING));
       assert(type->signal);
       assert(type->get_value);
-   } else {
-      assert(!type->get_value);
    }
 
    if (!(type->features & VK_SYNC_FEATURE_BINARY)) {
@@ -74,13 +72,9 @@ vk_sync_type_validate(const struct vk_sync_type *type)
 
    if (type->features & VK_SYNC_FEATURE_CPU_RESET)
       assert(type->reset);
-   else
-      assert(!type->reset);
 
    if (type->features & VK_SYNC_FEATURE_CPU_SIGNAL)
       assert(type->signal);
-   else
-      assert(!type->signal);
 }
 
 VkResult
@@ -150,6 +144,8 @@ vk_sync_signal(struct vk_device *device,
                struct vk_sync *sync,
                uint64_t value)
 {
+   assert(sync->type->features & VK_SYNC_FEATURE_CPU_SIGNAL);
+
    if (sync->flags & VK_SYNC_IS_TIMELINE)
       assert(value > 0);
    else
@@ -171,6 +167,7 @@ VkResult
 vk_sync_reset(struct vk_device *device,
               struct vk_sync *sync)
 {
+   assert(sync->type->features & VK_SYNC_FEATURE_CPU_RESET);
    assert(!(sync->flags & VK_SYNC_IS_TIMELINE));
    return sync->type->reset(device, sync);
 }

Reply via email to