Merge vk-gl-cts/vulkan-cts-1.0.2 into vk-gl-cts/vulkan-cts-1.1.0
authorAlexander Galazin <alexander.galazin@arm.com>
Thu, 1 Mar 2018 13:24:31 +0000 (14:24 +0100)
committerAlexander Galazin <alexander.galazin@arm.com>
Thu, 1 Mar 2018 13:30:10 +0000 (14:30 +0100)
Change-Id: I8c2317b97955bbee922af624b91287071fbc7661

1  2 
external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp

@@@ -511,6 -493,71 +511,71 @@@ void submitDummySignal (const vk::Devic
        VK_CHECK(vkd.queueSubmit(queue, 1, &submit, (vk::VkFence)0u));
  }
  
 -                                                                                              vk::VkExternalSemaphoreHandleTypeFlagBitsKHR    externalType,
+ void submitDummySignalAndGetSemaphoreNative ( const vk::DeviceInterface&                                              vk,
+                                                                                               vk::VkDevice                                                                    device,
+                                                                                               vk::VkQueue                                                                             queue,
+                                                                                               deUint32                                                                                queueFamilyIndex,
+                                                                                               vk::VkSemaphore                                                                 semaphore,
++                                                                                              vk::VkExternalSemaphoreHandleTypeFlagBits               externalType,
+                                                                                               NativeHandle&                                                                   nativeHandle)
+ {
+       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));
+       const vk::VkEventCreateInfo eventCreateInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
+               DE_NULL,
+               0u
+       };
+       const vk::Unique<vk::VkEvent> event(createEvent(vk, device, &eventCreateInfo, DE_NULL));
+       const vk::VkCommandBufferBeginInfo cmdBufferBeginInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+               DE_NULL,
+               vk::VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
+               DE_NULL,
+       };
+       VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
+       /*
+               The submitDummySignal function calls vkQueueSubmit with an empty VkSubmitInfo structure and a
+               VkSemaphore to be signalled when the work is finished. Because there is no work in the submission, vkQueueSubmit
+               may signal the semaphore immediately. When a semaphore's file descriptor is obtained using vkGetFenceFdKHR, if the
+               handle type is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR, vkGetFenceFdKHR is allowed to return -1 if the fence
+               is already signalled, instead of a file descriptor, . In order to make sure that a valid file descriptor is returned
+               we use vkCmdWaitEvents to make sure that vkQueueSubmit doesn't signal the fence.
+       */
+       vk.cmdWaitEvents(*cmdBuffer, 1, &event.get(), vk::VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, DE_NULL, 0, DE_NULL, 0, DE_NULL);
+       vk.endCommandBuffer(*cmdBuffer);
+       const vk::VkSubmitInfo submit =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,
+               DE_NULL,
+               0u,
+               DE_NULL,
+               DE_NULL,
+               1u,
+               &cmdBuffer.get(),
+               1u,
+               &semaphore
+       };
+       VK_CHECK(vk.queueSubmit(queue, 1, &submit, (vk::VkFence)0u));
+       getSemaphoreNative(vk, device, semaphore, externalType, nativeHandle);
+       VK_CHECK(vk.setEvent(device, *event));
+       VK_CHECK(vk.queueWaitIdle(queue));
+ }
  void submitDummyWait (const vk::DeviceInterface&      vkd,
                                          vk::VkQueue                                   queue,
                                          vk::VkSemaphore                               semaphore)
@@@ -558,7 -605,72 +623,72 @@@ void submitDummySignal (const vk::Devic
        VK_CHECK(vkd.queueSubmit(queue, 1, &submit, fence));
  }
  
 -                                                                                      vk::VkExternalFenceHandleTypeFlagBitsKHR        externalType,
+ void submitDummySignalAndGetFenceNative (     const vk::DeviceInterface&                                      vk,
+                                                                                       vk::VkDevice                                                            device,
+                                                                                       vk::VkQueue                                                                     queue,
+                                                                                       deUint32                                                                        queueFamilyIndex,
+                                                                                       vk::VkFence                                                                     fence,
 -tcu::TestStatus testSemaphoreQueries (Context& context, vk::VkExternalSemaphoreHandleTypeFlagBitsKHR externalType)
++                                                                                      vk::VkExternalFenceHandleTypeFlagBits           externalType,
+                                                                                       NativeHandle&                                                           nativeHandle)
+ {
+       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));
+       const vk::VkEventCreateInfo eventCreateInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
+               DE_NULL,
+               0u
+       };
+       const vk::Unique<vk::VkEvent> event(createEvent(vk, device, &eventCreateInfo, DE_NULL));
+       const vk::VkCommandBufferBeginInfo cmdBufferBeginInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+               DE_NULL,
+               vk::VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
+               DE_NULL,
+       };
+       VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
+       /*
+               The submitDummySignal function calls vkQueueSubmit with an empty VkSubmitInfo structure and a
+               VkFence to be signalled when the work is finished. Because there is no work in the submission, vkQueueSubmit
+               could signal the fence immediately. When a fence's file descriptor is obtained using vkGetFenceFdKHR, if the
+               handle type is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR, vkGetFenceFdKHR is allowed to return -1 instead of a
+               file descriptor, if the fence is already signalled. In order to make sure that a valid file descriptor is returned
+               we use vkCmdWaitEvents to make sure that vkQueueSubmit doesn't signal the fence.
+       */
+       vk.cmdWaitEvents(*cmdBuffer, 1, &event.get(), vk::VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, DE_NULL, 0, DE_NULL, 0, DE_NULL);
+       vk.endCommandBuffer(*cmdBuffer);
+       const vk::VkSubmitInfo submit =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,
+               DE_NULL,
+               0u,
+               DE_NULL,
+               DE_NULL,
+               1u,
+               &cmdBuffer.get(),
+               0u,
+               DE_NULL
+       };
+       VK_CHECK(vk.queueSubmit(queue, 1, &submit, fence));
+       getFenceNative(vk, device, fence, externalType, nativeHandle);
+       VK_CHECK(vk.setEvent(device, *event));
+       VK_CHECK(vk.queueWaitIdle(queue));
+ }
 +tcu::TestStatus testSemaphoreQueries (Context& context, vk::VkExternalSemaphoreHandleTypeFlagBits externalType)
  {
        const vk::PlatformInterface&            vkp                             (context.getPlatformInterface());
        const vk::Unique<vk::VkInstance>        instance                (createInstance(vkp, externalType, 0u, 0u));
@@@ -741,15 -853,15 +871,15 @@@ tcu::TestStatus testSemaphoreImportReim
                const vk::VkQueue                                       queue                   (getQueue(vkd, *device, queueFamilyIndex));
  
                const vk::Unique<vk::VkSemaphore>       semaphoreA              (createExportableSemaphore(vkd, *device, config.externalType));
+               NativeHandle                                            handleA;
  
                if (transference == TRANSFERENCE_COPY)
-                       submitDummySignal(vkd, queue, *semaphoreA);
-               NativeHandle                                            handleA;
-               getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
+                       submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handleA);
+               else
+                       getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
  
                NativeHandle                                            handleB         (handleA);
 -              const vk::VkSemaphoreImportFlagsKHR     flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkSemaphoreImportFlagBitsKHR)0u;
 +              const vk::VkSemaphoreImportFlags        flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
                const vk::Unique<vk::VkSemaphore>       semaphoreB      (createAndImportSemaphore(vkd, *device, config.externalType, handleA, flags));
  
                importSemaphore(vkd, *device, *semaphoreB, config.externalType, handleB, flags);
@@@ -789,13 -901,10 +919,10 @@@ tcu::TestStatus testSemaphoreSignalExpo
                {
                        NativeHandle    handle;
  
-                       getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+                       submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
  
                        {
 -                              const vk::VkSemaphoreImportFlagsKHR     flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkSemaphoreImportFlagBitsKHR)0u;
 +                              const vk::VkSemaphoreImportFlags        flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
                                const vk::Unique<vk::VkSemaphore>       semaphoreB      (createAndImportSemaphore(vkd, *device, config.externalType, handle, flags));
                                submitDummyWait(vkd, queue, *semaphoreB);
  
@@@ -1306,16 -1421,21 +1439,21 @@@ tcu::TestStatus testSemaphoreFdDup3 (Co
                const vk::Unique<vk::VkSemaphore>       semaphoreA      (createExportableSemaphore(vkd, *device, config.externalType));
                const vk::Unique<vk::VkSemaphore>       semaphoreB      (createExportableSemaphore(vkd, *device, config.externalType));
  
-               if (transference == TRANSFERENCE_COPY)
                {
-                       submitDummySignal(vkd, queue, *semaphoreA);
-                       submitDummySignal(vkd, queue, *semaphoreB);
-               }
+                       NativeHandle                                            fd, secondFd;
+                       if (transference == TRANSFERENCE_COPY)
+                       {
+                               submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, fd);
+                               submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreB, config.externalType, secondFd);
+                       }
+                       else
+                       {
+                               getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, fd);
+                               getSemaphoreNative(vkd, *device, *semaphoreB, config.externalType, secondFd);
+                       }
  
-               {
 -                      const vk::VkSemaphoreImportFlagsKHR     flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkSemaphoreImportFlagBitsKHR)0u;
 +                      const vk::VkSemaphoreImportFlags        flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
-                       const NativeHandle                                      fd                      (getSemaphoreFd(vkd, *device, *semaphoreA, config.externalType));
-                       NativeHandle                                            secondFd        (getSemaphoreFd(vkd, *device, *semaphoreB, config.externalType));
                        const int                                                       newFd           (dup3(fd.getFd(), secondFd.getFd(), 0));
  
                        if (newFd < 0)
@@@ -1672,15 -1793,15 +1811,15 @@@ tcu::TestStatus testFenceImportReimpor
                const vk::VkQueue                               queue   (getQueue(vkd, *device, queueFamilyIndex));
  
                const vk::Unique<vk::VkFence>   fenceA  (createExportableFence(vkd, *device, config.externalType));
+               NativeHandle                                    handleA;
  
                if (transference == TRANSFERENCE_COPY)
-                       submitDummySignal(vkd, queue, *fenceA);
-               NativeHandle                                    handleA;
-               getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
+                       submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handleA);
+               else
+                       getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
  
                NativeHandle                                    handleB (handleA);
 -              const vk::VkFenceImportFlagsKHR flags   = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkFenceImportFlagBitsKHR)0u;
 +              const vk::VkFenceImportFlags    flags   = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
                const vk::Unique<vk::VkFence>   fenceB  (createAndImportFence(vkd, *device, config.externalType, handleA, flags));
  
                importFence(vkd, *device, *fenceB, config.externalType, handleB, flags);
@@@ -1721,12 -1842,10 +1860,10 @@@ tcu::TestStatus testFenceSignalExportIm
                {
                        NativeHandle    handle;
  
-                       getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+                       submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
  
                        {
 -                              const vk::VkFenceImportFlagsKHR flags   = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkFenceImportFlagBitsKHR)0u;
 +                              const vk::VkFenceImportFlags    flags   = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
                                const vk::Unique<vk::VkFence>   fenceB  (createAndImportFence(vkd, *device, config.externalType, handle, flags));
                                VK_CHECK(vkd.waitForFences(*device, 1u, &*fenceB, VK_TRUE, ~0ull));
  
@@@ -2312,16 -2435,21 +2453,21 @@@ tcu::TestStatus testFenceFdDup3 (Contex
                const vk::Unique<vk::VkFence>   fenceA  (createExportableFence(vkd, *device, config.externalType));
                const vk::Unique<vk::VkFence>   fenceB  (createExportableFence(vkd, *device, config.externalType));
  
-               if (transference == TRANSFERENCE_COPY)
                {
-                       submitDummySignal(vkd, queue, *fenceA);
-                       submitDummySignal(vkd, queue, *fenceB);
-               }
+                       NativeHandle                                    fd, secondFd;
+                       if (transference == TRANSFERENCE_COPY)
+                       {
+                               submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, fd);
+                               submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceB, config.externalType, secondFd);
+                       }
+                       else
+                       {
+                               getFenceNative(vkd, *device, *fenceA, config.externalType, fd);
+                               getFenceNative(vkd, *device, *fenceB, config.externalType, secondFd);
+                       }
  
-               {
 -                      const vk::VkFenceImportFlagsKHR flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT_KHR : (vk::VkFenceImportFlagBitsKHR)0u;
 +                      const vk::VkFenceImportFlags    flags           = config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
-                       const NativeHandle                              fd                      (getFenceFd(vkd, *device, *fenceA, config.externalType));
-                       NativeHandle                                    secondFd        (getFenceFd(vkd, *device, *fenceB, config.externalType));
                        const int                                               newFd           (dup3(fd.getFd(), secondFd.getFd(), 0));
  
                        if (newFd < 0)
@@@ -677,7 -677,7 +677,7 @@@ public
        const vector<Attachment>&                                                       getAttachments  (void) const { return m_attachments;    }
        const vector<Subpass>&                                                          getSubpasses    (void) const { return m_subpasses;              }
        const vector<SubpassDependency>&                                        getDependencies (void) const { return m_dependencies;   }
-       const vector<VkInputAttachmentAspectReference>          getInputAspects (void) const { return m_inputAspects;   }
 -      const vector<VkInputAttachmentAspectReferenceKHR>&      getInputAspects (void) const { return m_inputAspects;   }
++      const vector<VkInputAttachmentAspectReference>&         getInputAspects (void) const { return m_inputAspects;   }
  
  private:
        const vector<Attachment>                                                        m_attachments;