external fence tests: account for sync fd -1 in multiple export case
authorLingfeng Yang <lfy@google.com>
Wed, 21 Aug 2019 15:45:10 +0000 (08:45 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 29 Aug 2019 10:32:46 +0000 (06:32 -0400)
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
(cherry picked from commit e266d2f1ee82d20c06c3c48064f60ac4fecd8b1d)

external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp
external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.hpp

index 65f1dda..8d28fb7 100644 (file)
@@ -646,7 +646,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<vk::VkCommandPool>             cmdPool(createCommandPool(vk, device, vk::VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex, DE_NULL));
        const vk::Unique<vk::VkCommandBuffer>   cmdBuffer(allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
@@ -698,7 +699,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));
 
@@ -2150,9 +2151,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);
index 3eaf29b..cc653ac 100644 (file)
@@ -568,7 +568,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)
@@ -584,7 +585,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
index 6b494b1..fab19d3 100644 (file)
@@ -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,