Merge vk-gl-cts/vulkan-cts-1.1.1 into vk-gl-cts/vulkan-cts-next-dev
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / pipeline / vktPipelineImageUtil.cpp
index e655d41..ba0d82d 100644 (file)
@@ -555,6 +555,16 @@ void uploadTestTextureInternal (const DeviceInterface&                     vk,
        VK_CHECK(vk.waitForFences(device, 1, &fence.get(), true, ~(0ull) /* infinity */));
 }
 
+bool checkSparseImageFormatSupport (const VkPhysicalDevice             physicalDevice,
+                                                                       const InstanceInterface&        instance,
+                                                                       const VkImageCreateInfo&        imageCreateInfo)
+{
+       const std::vector<VkSparseImageFormatProperties> sparseImageFormatPropVec =
+               getPhysicalDeviceSparseImageFormatProperties(instance, physicalDevice, imageCreateInfo.format, imageCreateInfo.imageType, imageCreateInfo.samples, imageCreateInfo.usage, imageCreateInfo.tiling);
+
+       return (sparseImageFormatPropVec.size() != 0);
+}
+
 void allocateAndBindSparseImage (const DeviceInterface&                                                vk,
                                                                 VkDevice                                                                       device,
                                                                 const VkPhysicalDevice                                         physicalDevice,
@@ -573,10 +583,7 @@ void allocateAndBindSparseImage (const DeviceInterface&                                            vk,
        deUint32                                                                sparseMemoryReqCount    = 0;
 
        // Check if the image format supports sparse operations
-       const std::vector<VkSparseImageFormatProperties> sparseImageFormatPropVec =
-               getPhysicalDeviceSparseImageFormatProperties(instance, physicalDevice, imageCreateInfo.format, imageCreateInfo.imageType, imageCreateInfo.samples, imageCreateInfo.usage, imageCreateInfo.tiling);
-
-       if (sparseImageFormatPropVec.size() == 0)
+       if (!checkSparseImageFormatSupport(physicalDevice, instance, imageCreateInfo))
                TCU_THROW(NotSupportedError, "The image format does not support sparse operations.");
 
        vk.getImageSparseMemoryRequirements(device, destImage, &sparseMemoryReqCount, DE_NULL);
@@ -804,8 +811,9 @@ void uploadTestTextureInternalSparse (const DeviceInterface&                                        vk,
                                                                          const VkPhysicalDevice                                        physicalDevice,
                                                                          const InstanceInterface&                                      instance,
                                                                          const VkImageCreateInfo&                                      imageCreateInfo,
-                                                                         VkQueue                                                                       queue,
-                                                                         deUint32                                                                      queueFamilyIndex,
+                                                                         VkQueue                                                                       universalQueue,
+                                                                         deUint32                                                                      universalQueueFamilyIndex,
+                                                                         VkQueue                                                                       sparseQueue,
                                                                          Allocator&                                                            allocator,
                                                                          std::vector<de::SharedPtr<Allocation> >&      allocations,
                                                                          const TestTexture&                                            srcTexture,
@@ -827,7 +835,7 @@ void uploadTestTextureInternalSparse (const DeviceInterface&                                        vk,
                bufferSize              = stencilOffset + srcStencilTexture->getSize();
        }
 
-       allocateAndBindSparseImage (vk, device, physicalDevice, instance, imageCreateInfo, imageMemoryBindSemaphore.get(), queue, allocator, allocations, format, destImage);
+       allocateAndBindSparseImage (vk, device, physicalDevice, instance, imageCreateInfo, imageMemoryBindSemaphore.get(), sparseQueue, allocator, allocations, format, destImage);
 
        {
                // Create source buffer
@@ -845,7 +853,7 @@ void uploadTestTextureInternalSparse (const DeviceInterface&                                        vk,
 
                Move<VkBuffer>                  buffer          = createBuffer(vk, device, &bufferParams);
                de::MovePtr<Allocation> bufferAlloc = allocator.allocate(getBufferMemoryRequirements(vk, device, *buffer), MemoryRequirement::HostVisible);
-               Move<VkCommandPool>             cmdPool         = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+               Move<VkCommandPool>             cmdPool         = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, universalQueueFamilyIndex);
                Move<VkCommandBuffer>   cmdBuffer       = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
                Move<VkFence>                   fence           = createFence(vk, device);
 
@@ -960,7 +968,7 @@ void uploadTestTextureInternalSparse (const DeviceInterface&                                        vk,
 
                try
                {
-                       VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *fence));
+                       VK_CHECK(vk.queueSubmit(universalQueue, 1, &submitInfo, *fence));
                        VK_CHECK(vk.waitForFences(device, 1, &fence.get(), true, ~(0ull) /* infinity */));
                }
                catch (...)
@@ -1019,8 +1027,9 @@ void uploadTestTextureSparse (const DeviceInterface&                                      vk,
                                                          const VkPhysicalDevice                                        physicalDevice,
                                                          const InstanceInterface&                                      instance,
                                                          const VkImageCreateInfo&                                      imageCreateInfo,
-                                                         VkQueue                                                                       queue,
-                                                         deUint32                                                                      queueFamilyIndex,
+                                                         VkQueue                                                                       universalQueue,
+                                                         deUint32                                                                      universalQueueFamilyIndex,
+                                                         VkQueue                                                                       sparseQueue,
                                                          Allocator&                                                            allocator,
                                                          std::vector<de::SharedPtr<Allocation> >&      allocations,
                                                          const TestTexture&                                            srcTexture,
@@ -1060,8 +1069,9 @@ void uploadTestTextureSparse (const DeviceInterface&                                      vk,
                                                                                 physicalDevice,
                                                                                 instance,
                                                                                 imageCreateInfo,
-                                                                                queue,
-                                                                                queueFamilyIndex,
+                                                                                universalQueue,
+                                                                                universalQueueFamilyIndex,
+                                                                                sparseQueue,
                                                                                 allocator,
                                                                                 allocations,
                                                                                 *srcDepthTexture,
@@ -1076,8 +1086,9 @@ void uploadTestTextureSparse (const DeviceInterface&                                      vk,
                                                                                 physicalDevice,
                                                                                 instance,
                                                                                 imageCreateInfo,
-                                                                                queue,
-                                                                                queueFamilyIndex,
+                                                                                universalQueue,
+                                                                                universalQueueFamilyIndex,
+                                                                                sparseQueue,
                                                                                 allocator,
                                                                                 allocations,
                                                                                 srcTexture,