From e266d2f1ee82d20c06c3c48064f60ac4fecd8b1d Mon Sep 17 00:00:00 2001 From: Lingfeng Yang Date: Wed, 21 Aug 2019 08:45:10 -0700 Subject: [PATCH] external fence tests: account for sync fd -1 in multiple export case Spec allows for sync fd == -1 to be returned from vkGetFenceFdKHR as a signal that the fence is signaled. VK-GL-CTS issue: 1937 Components: Vulkan Affects: dEQP-VK.api.external.fence.sync_fd.export_multiple_times_temporary Change-Id: I7391d180bdc1a585c7b57930fc1750d13f7151e1 --- .../modules/vulkan/api/vktApiExternalMemoryTests.cpp | 9 +++++---- .../modules/vulkan/util/vktExternalMemoryUtil.cpp | 14 ++++++++++++-- .../modules/vulkan/util/vktExternalMemoryUtil.hpp | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp index 864a89d..415109b 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp @@ -686,7 +686,8 @@ void submitDummySignalAndGetFenceNative ( const vk::DeviceInterface& vk, deUint32 queueFamilyIndex, vk::VkFence fence, vk::VkExternalFenceHandleTypeFlagBits externalType, - NativeHandle& nativeHandle) + NativeHandle& nativeHandle, + bool expectFenceUnsignaled = true) { const vk::Unique cmdPool(createCommandPool(vk, device, vk::VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex, DE_NULL)); const vk::Unique cmdBuffer(allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY)); @@ -738,7 +739,7 @@ void submitDummySignalAndGetFenceNative ( const vk::DeviceInterface& vk, VK_CHECK(vk.queueSubmit(queue, 1, &submit, fence)); - getFenceNative(vk, device, fence, externalType, nativeHandle); + getFenceNative(vk, device, fence, externalType, nativeHandle, expectFenceUnsignaled); VK_CHECK(vk.setEvent(device, *event)); @@ -2190,9 +2191,9 @@ tcu::TestStatus testFenceMultipleExports (Context& context, NativeHandle handle; if (transference == TRANSFERENCE_COPY) - submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fence, config.externalType, handle); + submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fence, config.externalType, handle, exportNdx == 0 /* expect fence to be signaled after first pass */); else - getFenceNative(vkd, *device, *fence, config.externalType, handle); + getFenceNative(vkd, *device, *fence, config.externalType, handle, exportNdx == 0 /* expect fence to be signaled after first pass */); } submitDummySignal(vkd, queue, *fence); diff --git a/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp b/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp index b25d09a..980fd05 100644 --- a/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp +++ b/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp @@ -572,7 +572,8 @@ void getFenceNative (const vk::DeviceInterface& vkd, vk::VkDevice device, vk::VkFence fence, vk::VkExternalFenceHandleTypeFlagBits externalType, - NativeHandle& nativeHandle) + NativeHandle& nativeHandle, + bool expectFenceUnsignaled) { if (externalType == vk::VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT || externalType == vk::VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT) @@ -588,7 +589,16 @@ void getFenceNative (const vk::DeviceInterface& vkd, int fd = -1; VK_CHECK(vkd.getFenceFdKHR(device, &info, &fd)); - TCU_CHECK(fd >= 0); + + if (externalType == vk::VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT) + { + TCU_CHECK(!expectFenceUnsignaled || (fd >= 0)); + } + else + { + TCU_CHECK(fd >= 0); + } + nativeHandle = fd; } else if (externalType == vk::VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT diff --git a/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.hpp b/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.hpp index 6b494b1..fab19d3 100644 --- a/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.hpp +++ b/external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.hpp @@ -226,7 +226,8 @@ void getFenceNative (const vk::DeviceInterface& vkd, vk::VkDevice device, vk::VkFence fence, vk::VkExternalFenceHandleTypeFlagBits externalType, - NativeHandle& nativeHandle); + NativeHandle& nativeHandle, + bool expectFenceUnsignaled = true); void importFence (const vk::DeviceInterface& vkd, const vk::VkDevice device, -- 2.7.4