Use default device for sparse binding tests.
authorAri Suonpaa <ari.suonpaa@siru.fi>
Wed, 13 Dec 2017 09:49:35 +0000 (11:49 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 22 Jan 2018 01:15:11 +0000 (20:15 -0500)
The default device supports sparse binding when the underlying
physical device has support. There's no need to create a separate
device object. Test context creates a sparse queue whenever
sparse binding is supported by the physical device. This
change also adds support for having a separate sparse binding
queue.

Affects:

dEQP-VK.texture.shadow.*
dEQP-VK.renderpass.sparserendertarget.*

Components: Vulkan

VK-GL-CTS issue: 898

Change-Id: I2ca36d8e641fe3ef5694784e7bb3d8ebe6ed51bf

external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.hpp
external/vulkancts/modules/vulkan/renderpass/vktRenderPassSparseRenderTargetTests.cpp
external/vulkancts/modules/vulkan/texture/vktTextureTestUtil.cpp
external/vulkancts/modules/vulkan/texture/vktTextureTestUtil.hpp
external/vulkancts/modules/vulkan/vktTestCase.cpp
external/vulkancts/modules/vulkan/vktTestCase.hpp

index 24181a9d35164d9ba0ab3b55500d3a7d8e9a8102..53f7cca68a35b9a01994d730d0933366c3a89125 100644 (file)
@@ -802,8 +802,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,
@@ -825,7 +826,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
@@ -843,7 +844,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);
 
@@ -958,7 +959,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 (...)
@@ -1017,8 +1018,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,
@@ -1058,8 +1060,9 @@ void uploadTestTextureSparse (const DeviceInterface&                                      vk,
                                                                                 physicalDevice,
                                                                                 instance,
                                                                                 imageCreateInfo,
-                                                                                queue,
-                                                                                queueFamilyIndex,
+                                                                                universalQueue,
+                                                                                universalQueueFamilyIndex,
+                                                                                sparseQueue,
                                                                                 allocator,
                                                                                 allocations,
                                                                                 *srcDepthTexture,
@@ -1074,8 +1077,9 @@ void uploadTestTextureSparse (const DeviceInterface&                                      vk,
                                                                                 physicalDevice,
                                                                                 instance,
                                                                                 imageCreateInfo,
-                                                                                queue,
-                                                                                queueFamilyIndex,
+                                                                                universalQueue,
+                                                                                universalQueueFamilyIndex,
+                                                                                sparseQueue,
                                                                                 allocator,
                                                                                 allocations,
                                                                                 srcTexture,
index 076719aa0975242584aff768fdd4e62a6d544166..eec9b5d9035f5152a0eb56f59a1c45768a451b8c 100644 (file)
@@ -111,15 +111,14 @@ void                                                      uploadTestTextureSparse         (const vk::DeviceInterface&                                             vk,
                                                                                                                         const vk::VkPhysicalDevice                                             physicalDevice,
                                                                                                                         const vk::InstanceInterface&                                   instance,
                                                                                                                         const vk::VkImageCreateInfo&                                   imageCreateInfo,
-                                                                                                                        vk::VkQueue                                                                    queue,
-                                                                                                                        deUint32                                                                               queueFamilyIndex,
+                                                                                                                        vk::VkQueue                                                                    universalQueue,
+                                                                                                                        deUint32                                                                               universalQueueFamilyIndex,
+                                                                                                                        vk::VkQueue                                                                    sparseQueue,
                                                                                                                         vk::Allocator&                                                                 allocator,
                                                                                                                         std::vector<de::SharedPtr<vk::Allocation> >&   allocations,
                                                                                                                         const TestTexture&                                                             srcTexture,
                                                                                                                         vk::VkImage                                                                    destImage);
 
-
-
 /*--------------------------------------------------------------------*//*!
  * Allocates memory for a sparse image and handles the memory binding.
  *//*--------------------------------------------------------------------*/
index 8c1721be6c09f4a2e866b62b96c20511b82419c1..1e0018afa55bda932b05f5e9e359845b298efd65 100644 (file)
@@ -61,53 +61,6 @@ namespace vkt
 namespace
 {
 
-deUint32 findQueueFamilyIndexWithCaps (const InstanceInterface& vkInstance, VkPhysicalDevice physicalDevice, VkQueueFlags requiredCaps)
-{
-       const std::vector<VkQueueFamilyProperties>      queueProps      = getPhysicalDeviceQueueFamilyProperties(vkInstance, physicalDevice);
-
-       for (size_t queueNdx = 0; queueNdx < queueProps.size(); queueNdx++)
-       {
-               if ((queueProps[queueNdx].queueFlags & requiredCaps) == requiredCaps)
-                       return (deUint32)queueNdx;
-       }
-
-       TCU_THROW(NotSupportedError, "No matching queue found");
-}
-
-Move<VkDevice> createDevice(const InstanceInterface& vkInstance, VkPhysicalDevice physicalDevice, deUint32 queueFamilyIndex)
-{
-       const VkPhysicalDeviceFeatures          deviceFeatures      = getPhysicalDeviceFeatures(vkInstance, physicalDevice);
-
-       VkDeviceQueueCreateInfo                 queueInfo;
-       VkDeviceCreateInfo                      deviceInfo;
-       const float                             queuePriority       = 1.0f;
-
-       deMemset(&queueInfo,    0, sizeof(queueInfo));
-       deMemset(&deviceInfo,   0, sizeof(deviceInfo));
-
-       queueInfo.sType                         = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
-       queueInfo.pNext                         = DE_NULL;
-       queueInfo.flags                         = (VkDeviceQueueCreateFlags)0u;
-       queueInfo.queueFamilyIndex              = queueFamilyIndex;
-       queueInfo.queueCount                    = 1u;
-       queueInfo.pQueuePriorities              = &queuePriority;
-
-       deviceInfo.sType                        = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
-       deviceInfo.pNext                        = DE_NULL;
-       deviceInfo.queueCreateInfoCount         = 1u;
-       deviceInfo.pQueueCreateInfos            = &queueInfo;
-       deviceInfo.enabledExtensionCount        = 0u;
-       deviceInfo.ppEnabledExtensionNames      = DE_NULL;
-       deviceInfo.enabledLayerCount            = 0u;
-       deviceInfo.ppEnabledLayerNames          = DE_NULL;
-       deviceInfo.pEnabledFeatures             = &deviceFeatures;
-
-       if (!deviceFeatures.sparseBinding)
-               TCU_THROW(NotSupportedError, "Sparse binding not supported");
-
-       return createDevice(vkInstance, physicalDevice, &deviceInfo);
-}
-
 de::MovePtr<Allocation> createBufferMemory (const DeviceInterface&     vk,
                                                                                        VkDevice                                device,
                                                                                        Allocator&                              allocator,
@@ -124,21 +77,25 @@ Move<VkImage> createSparseImageAndMemory (const DeviceInterface&                           vk,
                                                                                  const InstanceInterface&                              instance,
                                                                                  Allocator&                                                    allocator,
                                                                                  vector<de::SharedPtr<Allocation> >&   allocations,
-                                                                                 deUint32                                                              queueFamilyIndex,
-                                                                                 VkQueue&                                                              queue,
+                                                                                 deUint32                                                              universalQueueFamilyIndex,
+                                                                                 VkQueue                                                               sparseQueue,
+                                                                                 deUint32                                                              sparseQueueFamilyIndex,
                                                                                  const VkSemaphore&                                    bindSemaphore,
                                                                                  VkFormat                                                              format,
                                                                                  deUint32                                                              width,
                                                                                  deUint32                                                              height)
 {
-       const VkExtent3D                imageExtent                     =
+       deUint32                                queueFamilyIndices[]    = {universalQueueFamilyIndex, sparseQueueFamilyIndex};
+       const VkSharingMode             sharingMode             = universalQueueFamilyIndex != sparseQueueFamilyIndex ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
+
+       const VkExtent3D                imageExtent                             =
        {
                width,
                height,
                1u
        };
 
-       const VkImageCreateInfo imageCreateInfo         =
+       const VkImageCreateInfo imageCreateInfo                 =
        {
                VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
                DE_NULL,
@@ -151,15 +108,15 @@ Move<VkImage> createSparseImageAndMemory (const DeviceInterface&                          vk,
                VK_SAMPLE_COUNT_1_BIT,
                VK_IMAGE_TILING_OPTIMAL,
                VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
-               VK_SHARING_MODE_EXCLUSIVE,
-               1u,
-               &queueFamilyIndex,
+               sharingMode,
+               sharingMode == VK_SHARING_MODE_CONCURRENT ? 2u : 1u,
+               queueFamilyIndices,
                VK_IMAGE_LAYOUT_UNDEFINED
        };
 
        Move<VkImage>                   destImage                       = createImage(vk, device, &imageCreateInfo);
 
-       vkt::pipeline::allocateAndBindSparseImage(vk, device, physicalDevice, instance, imageCreateInfo, bindSemaphore, queue, allocator, allocations, mapVkFormat(format), *destImage);
+       vkt::pipeline::allocateAndBindSparseImage(vk, device, physicalDevice, instance, imageCreateInfo, bindSemaphore, sparseQueue, allocator, allocations, mapVkFormat(format), *destImage);
 
        return destImage;
 }
@@ -516,11 +473,6 @@ private:
        const deUint32                                                  m_height;
        const VkFormat                                                  m_format;
 
-       deUint32                                                                m_queueFamilyIndex;
-       const Unique<VkDevice>                                  m_device;
-       VkQueue                                                                 m_queue;
-
-       SimpleAllocator                                                 m_allocator;
        vector<de::SharedPtr<Allocation> >              m_allocations;
 
        const Unique<VkSemaphore>                               m_bindSemaphore;
@@ -546,20 +498,16 @@ SparseRenderTargetTestInstance::SparseRenderTargetTestInstance (Context& context
        , m_width                                       (32u)
        , m_height                                      (32u)
        , m_format                                      (format)
-       , m_queueFamilyIndex            (findQueueFamilyIndexWithCaps(context.getInstanceInterface(), context.getPhysicalDevice(), VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_SPARSE_BINDING_BIT))
-       , m_device                                      (createDevice(context.getInstanceInterface(), context.getPhysicalDevice(), m_queueFamilyIndex))
-       , m_queue                                       (getDeviceQueue(context.getDeviceInterface(), *m_device, m_queueFamilyIndex, 0))
-       , m_allocator                           (context.getDeviceInterface(), *m_device, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()))
-       , m_bindSemaphore                       (createSemaphore(context.getDeviceInterface(), *m_device))
-       , m_dstImage                            (createSparseImageAndMemory(context.getDeviceInterface(), *m_device, context.getPhysicalDevice(), context.getInstanceInterface(), m_allocator, m_allocations, m_queueFamilyIndex, m_queue, *m_bindSemaphore, m_format, m_width, m_height))
-       , m_dstImageView                        (createImageView(context.getDeviceInterface(), *m_device, *m_dstImage, m_format, VK_IMAGE_ASPECT_COLOR_BIT))
-       , m_dstBuffer                           (createBuffer(context.getDeviceInterface(), *m_device, m_format, m_width, m_height))
-       , m_dstBufferMemory                     (createBufferMemory(context.getDeviceInterface(), *m_device, m_allocator, *m_dstBuffer))
-       , m_renderPass                          (createRenderPass(context.getDeviceInterface(), *m_device, m_format))
-       , m_framebuffer                         (createFramebuffer(context.getDeviceInterface(), *m_device, *m_renderPass, *m_dstImageView, m_width, m_height))
-       , m_renderPipelineLayout        (createRenderPipelineLayout(context.getDeviceInterface(), *m_device))
-       , m_renderPipeline                      (createRenderPipeline(context.getDeviceInterface(), *m_device, *m_renderPass, *m_renderPipelineLayout, context.getBinaryCollection(), m_width, m_height))
-       , m_commandPool                         (createCommandPool(context.getDeviceInterface(), *m_device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, m_queueFamilyIndex))
+       , m_bindSemaphore                       (createSemaphore(context.getDeviceInterface(), context.getDevice()))
+       , m_dstImage                            (createSparseImageAndMemory(context.getDeviceInterface(), context.getDevice(), context.getPhysicalDevice(), context.getInstanceInterface(), context.getDefaultAllocator(), m_allocations, context.getUniversalQueueFamilyIndex(), context.getSparseQueue(), context.getSparseQueueFamilyIndex(), *m_bindSemaphore, m_format, m_width, m_height))
+       , m_dstImageView                        (createImageView(context.getDeviceInterface(), context.getDevice(), *m_dstImage, m_format, VK_IMAGE_ASPECT_COLOR_BIT))
+       , m_dstBuffer                           (createBuffer(context.getDeviceInterface(), context.getDevice(), m_format, m_width, m_height))
+       , m_dstBufferMemory                     (createBufferMemory(context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), *m_dstBuffer))
+       , m_renderPass                          (createRenderPass(context.getDeviceInterface(), context.getDevice(), m_format))
+       , m_framebuffer                         (createFramebuffer(context.getDeviceInterface(), context.getDevice(), *m_renderPass, *m_dstImageView, m_width, m_height))
+       , m_renderPipelineLayout        (createRenderPipelineLayout(context.getDeviceInterface(), context.getDevice()))
+       , m_renderPipeline                      (createRenderPipeline(context.getDeviceInterface(), context.getDevice(), *m_renderPass, *m_renderPipelineLayout, context.getBinaryCollection(), m_width, m_height))
+       , m_commandPool                         (createCommandPool(context.getDeviceInterface(), context.getDevice(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, context.getUniversalQueueFamilyIndex()))
 {
 }
 
@@ -570,7 +518,7 @@ SparseRenderTargetTestInstance::~SparseRenderTargetTestInstance (void)
 tcu::TestStatus SparseRenderTargetTestInstance::iterate (void)
 {
        const DeviceInterface&                  vkd                             (m_context.getDeviceInterface());
-       const Unique<VkCommandBuffer>   commandBuffer   (allocateCommandBuffer(vkd, *m_device, *m_commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+       const Unique<VkCommandBuffer>   commandBuffer   (allocateCommandBuffer(vkd, m_context.getDevice(), *m_commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
 
        {
                const VkCommandBufferBeginInfo beginInfo =
@@ -698,8 +646,8 @@ tcu::TestStatus SparseRenderTargetTestInstance::iterate (void)
                        DE_NULL
                };
 
-               VK_CHECK(vkd.queueSubmit(m_queue, 1u, &submitInfo, (VkFence)0u));
-               VK_CHECK(vkd.queueWaitIdle(m_queue));
+               VK_CHECK(vkd.queueSubmit(m_context.getUniversalQueue(), 1u, &submitInfo, (VkFence)0u));
+               VK_CHECK(vkd.queueWaitIdle(m_context.getUniversalQueue()));
        }
 
        {
index f508026162b0db79f07b004e6da77ec15007e64a..46a48d5b8f1381492d3d7aa9f07519d5874fd064 100644 (file)
@@ -299,22 +299,14 @@ void initializePrograms(vk::SourceCollections& programCollection, glu::Precision
 
 TextureBinding::TextureBinding (Context& context)
        : m_context                             (context)
-       , m_queueFamilyIndex    (findQueueFamilyIndexWithCaps(context.getInstanceInterface(), context.getPhysicalDevice(), VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_SPARSE_BINDING_BIT))
-       , m_device                              (createDevice())
-       , m_deviceInterface             (context.getInstanceInterface(), *m_device)
-       , m_allocator                   (createAllocator())
 {
 }
 
 TextureBinding::TextureBinding (Context& context, const TestTextureSp& textureData, const TextureBinding::Type type, const TextureBinding::ImageBackingMode backingMode)
        : m_context                             (context)
-       , m_queueFamilyIndex    (findQueueFamilyIndexWithCaps(context.getInstanceInterface(), context.getPhysicalDevice(), VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_SPARSE_BINDING_BIT))
        , m_type                                (type)
        , m_backingMode                 (backingMode)
        , m_textureData                 (textureData)
-       , m_device                              (createDevice())
-       , m_deviceInterface             (context.getInstanceInterface(), *m_device)
-       , m_allocator                   (createAllocator())
 {
        updateTextureData(m_textureData, m_type);
 }
@@ -324,8 +316,7 @@ void TextureBinding::updateTextureData (const TestTextureSp& textureData, const
        const DeviceInterface&                                          vkd                                             = m_context.getDeviceInterface();
        const VkDevice                                                          vkDevice                                = m_context.getDevice();
        const bool                                                                      sparse                                  = m_backingMode == IMAGE_BACKING_MODE_SPARSE;
-       const deUint32                                                          queueFamilyIndex                = sparse ? m_queueFamilyIndex : m_context.getUniversalQueueFamilyIndex();
-       const VkQueue                                                           queue                                   = sparse ? getDeviceQueue(vkd, vkDevice, queueFamilyIndex, 0) : m_context.getUniversalQueue();
+       const deUint32                                                          queueFamilyIndices[]    = {m_context.getUniversalQueueFamilyIndex(), m_context.getSparseQueueFamilyIndex()};
        Allocator&                                                                      allocator                               = m_context.getDefaultAllocator();
        m_type                  = textureType;
        m_textureData   = textureData;
@@ -342,6 +333,7 @@ void TextureBinding::updateTextureData (const TestTextureSp& textureData, const
        const deUint32                                                          arraySize                               = textureData->getArraySize();
        vk::VkImageFormatProperties                                     imageFormatProperties;
        const VkResult                                                          imageFormatQueryResult  = m_context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(m_context.getPhysicalDevice(), format, imageType, imageTiling, imageUsageFlags, imageCreateFlags, &imageFormatProperties);
+       const VkSharingMode                                                     sharingMode                             = (sparse && m_context.getUniversalQueueFamilyIndex() != m_context.getSparseQueueFamilyIndex()) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
 
        if (imageFormatQueryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
        {
@@ -381,9 +373,9 @@ void TextureBinding::updateTextureData (const TestTextureSp& textureData, const
                VK_SAMPLE_COUNT_1_BIT,                                                                                  // VkSampleCountFlagBits        samples;
                imageTiling,                                                                                                    // VkImageTiling                        tiling;
                imageUsageFlags,                                                                                                // VkImageUsageFlags            usage;
-               VK_SHARING_MODE_EXCLUSIVE,                                                                              // VkSharingMode                        sharingMode;
-               1u,                                                                                                                             // deUint32                                     queueFamilyIndexCount;
-               &queueFamilyIndex,                                                                                              // const deUint32*                      pQueueFamilyIndices;
+               sharingMode,                                                                                                    // VkSharingMode                        sharingMode;
+               sharingMode == VK_SHARING_MODE_CONCURRENT ? 2u : 1u,                    // deUint32                                     queueFamilyIndexCount;
+               queueFamilyIndices,                                                                                             // const deUint32*                      pQueueFamilyIndices;
                VK_IMAGE_LAYOUT_UNDEFINED                                                                               // VkImageLayout                        initialLayout;
        };
 
@@ -396,9 +388,10 @@ void TextureBinding::updateTextureData (const TestTextureSp& textureData, const
                                                                                         m_context.getPhysicalDevice(),
                                                                                         m_context.getInstanceInterface(),
                                                                                         imageParams,
-                                                                                        queue,
-                                                                                        queueFamilyIndex,
-                                                                                        *m_allocator,
+                                                                                        m_context.getUniversalQueue(),
+                                                                                        m_context.getUniversalQueueFamilyIndex(),
+                                                                                        m_context.getSparseQueue(),
+                                                                                        allocator,
                                                                                         m_allocations,
                                                                                         *m_textureData,
                                                                                         *m_textureImage);
@@ -410,8 +403,8 @@ void TextureBinding::updateTextureData (const TestTextureSp& textureData, const
 
                pipeline::uploadTestTexture     (vkd,
                                                                         vkDevice,
-                                                                        queue,
-                                                                        queueFamilyIndex,
+                                                                        m_context.getUniversalQueue(),
+                                                                        m_context.getUniversalQueueFamilyIndex(),
                                                                         allocator,
                                                                         *m_textureData,
                                                                         *m_textureImage);
@@ -450,45 +443,6 @@ void TextureBinding::updateTextureViewMipLevels (deUint32 baseLevel, deUint32 ma
        m_textureImageView              = createImageView(vkd, vkDevice, &viewParams);
 }
 
-vk::Allocator* TextureBinding::createAllocator() const
-{
-       VkPhysicalDeviceMemoryProperties memoryProperties = getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice());
-       return new SimpleAllocator(m_deviceInterface, *m_device, memoryProperties);
-}
-
-Move<VkDevice> TextureBinding::createDevice() const
-{
-       const InstanceInterface&                                vk                                      = m_context.getInstanceInterface();
-       const VkPhysicalDevice                                  physicalDevice          = m_context.getPhysicalDevice();
-       const VkPhysicalDeviceFeatures                  deviceFeatures          = getPhysicalDeviceFeatures(vk, physicalDevice);
-
-       VkDeviceQueueCreateInfo                                 queueInfo;
-       VkDeviceCreateInfo                                              deviceInfo;
-       const float                                                             queuePriority           = 1.0f;
-
-       deMemset(&queueInfo,    0, sizeof(queueInfo));
-       deMemset(&deviceInfo,   0, sizeof(deviceInfo));
-
-       queueInfo.sType                                                 = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
-       queueInfo.pNext                                                 = DE_NULL;
-       queueInfo.flags                                                 = (VkDeviceQueueCreateFlags)0u;
-       queueInfo.queueFamilyIndex                              = m_queueFamilyIndex;
-       queueInfo.queueCount                                    = 1u;
-       queueInfo.pQueuePriorities                              = &queuePriority;
-
-       deviceInfo.sType                                                = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
-       deviceInfo.pNext                                                = DE_NULL;
-       deviceInfo.queueCreateInfoCount                 = 1u;
-       deviceInfo.pQueueCreateInfos                    = &queueInfo;
-       deviceInfo.enabledExtensionCount                = 0u;
-       deviceInfo.ppEnabledExtensionNames              = DE_NULL;
-       deviceInfo.enabledLayerCount                    = 0u;
-       deviceInfo.ppEnabledLayerNames                  = DE_NULL;
-       deviceInfo.pEnabledFeatures                             = &deviceFeatures;
-
-       return vk::createDevice(vk, physicalDevice, &deviceInfo);
-}
-
 const deUint16         TextureRenderer::s_vertexIndices[6] = { 0, 1, 2, 2, 1, 3 };
 const VkDeviceSize     TextureRenderer::s_vertexIndexBufferSize = sizeof(TextureRenderer::s_vertexIndices);
 
index 7b1fc927a281450b39f58c2ca18e4720a8574dee..1cb3127e741bff52de136021c103244a03a5a7a5 100644 (file)
@@ -155,20 +155,14 @@ private:
        TextureBinding&                                                                 operator=                                       (const TextureBinding&);        // not allowed!
 
        void                                                                                    updateTextureData                       (const TestTextureSp& textureData, const Type type);
-       vk::Allocator*                                                                  createAllocator                         (void) const;
-       vk::Move<vk::VkDevice>                                                  createDevice                            (void) const;
 
        Context&                                                                                m_context;
-       const deUint32                                                                  m_queueFamilyIndex;
        Type                                                                                    m_type;
        ImageBackingMode                                                                m_backingMode;
        TestTextureSp                                                                   m_textureData;
        vk::Move<vk::VkImage>                                                   m_textureImage;
        de::MovePtr<vk::Allocation>                                             m_textureImageMemory;
        vk::Move<vk::VkImageView>                                               m_textureImageView;
-       vk::Unique<vk::VkDevice>                                                m_device;
-       vk::DeviceDriver                                                                m_deviceInterface;
-       const de::UniquePtr<vk::Allocator>                              m_allocator;
        std::vector<de::SharedPtr<vk::Allocation> >             m_allocations;
 };
 
index 4e6bf9149af3f3d2f0d31890f78f58a1de11e5f9..5215cd9978838de8c2b6a33abe6b25769613f9bb 100644 (file)
@@ -145,16 +145,18 @@ static deUint32 findQueueFamilyIndexWithCaps (const InstanceInterface& vkInstanc
 Move<VkDevice> createDefaultDevice (const InstanceInterface&                   vki,
                                                                        VkPhysicalDevice                                        physicalDevice,
                                                                        deUint32                                                        queueIndex,
+                                                                       deUint32                                                        sparseQueueIndex,
                                                                        const VkPhysicalDeviceFeatures2KHR&     enabledFeatures,
                                                                        const vector<string>&                           enabledExtensions,
                                                                        const tcu::CommandLine&                         cmdLine)
 {
-       VkDeviceQueueCreateInfo         queueInfo;
+       VkDeviceQueueCreateInfo         queueInfo[2];
        VkDeviceCreateInfo                      deviceInfo;
        vector<string>                          enabledLayers;
        vector<const char*>                     layerPtrs;
        vector<const char*>                     extensionPtrs;
        const float                                     queuePriority   = 1.0f;
+       const deUint32                          numQueues = enabledFeatures.features.sparseBinding ? 2 : 1;
 
        deMemset(&queueInfo,    0, sizeof(queueInfo));
        deMemset(&deviceInfo,   0, sizeof(deviceInfo));
@@ -176,19 +178,25 @@ Move<VkDevice> createDefaultDevice (const InstanceInterface&                      vki,
        for (size_t ndx = 0; ndx < enabledExtensions.size(); ++ndx)
                extensionPtrs[ndx] = enabledExtensions[ndx].c_str();
 
-       // VK_KHR_get_physical_device_propeties2 is used if enabledFeatures.pNext != 0
-
-       queueInfo.sType                                                 = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
-       queueInfo.pNext                                                 = DE_NULL;
-       queueInfo.flags                                                 = (VkDeviceQueueCreateFlags)0u;
-       queueInfo.queueFamilyIndex                              = queueIndex;
-       queueInfo.queueCount                                    = 1u;
-       queueInfo.pQueuePriorities                              = &queuePriority;
-
+       queueInfo[0].sType                                              = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+       queueInfo[0].pNext                                              = DE_NULL;
+       queueInfo[0].flags                                              = (VkDeviceQueueCreateFlags)0u;
+       queueInfo[0].queueFamilyIndex                   = queueIndex;
+       queueInfo[0].queueCount                                 = 1u;
+       queueInfo[0].pQueuePriorities                   = &queuePriority;
+
+       queueInfo[1].sType                                              = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+       queueInfo[1].pNext                                              = DE_NULL;
+       queueInfo[1].flags                                              = (VkDeviceQueueCreateFlags)0u;
+       queueInfo[1].queueFamilyIndex                   = sparseQueueIndex;
+       queueInfo[1].queueCount                                 = 1u;
+       queueInfo[1].pQueuePriorities                   = &queuePriority;
+
+       // VK_KHR_get_physical_device_properties2 is used if enabledFeatures.pNext != 0
        deviceInfo.sType                                                = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
        deviceInfo.pNext                                                = enabledFeatures.pNext ? &enabledFeatures : DE_NULL;
-       deviceInfo.queueCreateInfoCount                 = 1u;
-       deviceInfo.pQueueCreateInfos                    = &queueInfo;
+       deviceInfo.queueCreateInfoCount                 = numQueues;
+       deviceInfo.pQueueCreateInfos                    = queueInfo;
        deviceInfo.enabledExtensionCount                = (deUint32)extensionPtrs.size();
        deviceInfo.ppEnabledExtensionNames              = (extensionPtrs.empty() ? DE_NULL : &extensionPtrs[0]);
        deviceInfo.enabledLayerCount                    = (deUint32)layerPtrs.size();
@@ -261,6 +269,8 @@ public:
 
        deUint32                                                        getUniversalQueueFamilyIndex    (void) const    { return m_universalQueueFamilyIndex;                           }
        VkQueue                                                         getUniversalQueue                               (void) const;
+       deUint32                                                        getSparseQueueFamilyIndex               (void) const    { return m_sparseQueueFamilyIndex;                                      }
+       VkQueue                                                         getSparseQueue                                  (void) const;
 
 private:
        static VkPhysicalDeviceFeatures         filterDefaultDeviceFeatures             (const VkPhysicalDeviceFeatures& deviceFeatures);
@@ -270,10 +280,11 @@ private:
        const InstanceDriver                            m_instanceInterface;
 
        const VkPhysicalDevice                          m_physicalDevice;
-
-       const deUint32                                          m_universalQueueFamilyIndex;
        const vector<string>                            m_deviceExtensions;
        const DeviceFeatures                            m_deviceFeatures;
+
+       const deUint32                                          m_universalQueueFamilyIndex;
+       const deUint32                                          m_sparseQueueFamilyIndex;
        const VkPhysicalDeviceProperties        m_deviceProperties;
 
        const Unique<VkDevice>                          m_device;
@@ -285,16 +296,12 @@ DefaultDevice::DefaultDevice (const PlatformInterface& vkPlatform, const tcu::Co
        , m_instance                                    (createInstance(vkPlatform, m_instanceExtensions, cmdLine))
        , m_instanceInterface                   (vkPlatform, *m_instance)
        , m_physicalDevice                              (chooseDevice(m_instanceInterface, *m_instance, cmdLine))
-       , m_universalQueueFamilyIndex   (findQueueFamilyIndexWithCaps(m_instanceInterface, m_physicalDevice, VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT))
        , m_deviceExtensions                    (filterExtensions(enumerateDeviceExtensionProperties(m_instanceInterface, m_physicalDevice, DE_NULL)))
        , m_deviceFeatures                              (m_instanceInterface, m_physicalDevice, m_instanceExtensions, m_deviceExtensions)
+       , m_universalQueueFamilyIndex   (findQueueFamilyIndexWithCaps(m_instanceInterface, m_physicalDevice, VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT))
+       , m_sparseQueueFamilyIndex              (m_deviceFeatures.coreFeatures.features.sparseBinding ? findQueueFamilyIndexWithCaps(m_instanceInterface, m_physicalDevice, VK_QUEUE_SPARSE_BINDING_BIT) : 0)
        , m_deviceProperties                    (getPhysicalDeviceProperties(m_instanceInterface, m_physicalDevice))
-       , m_device                                              (createDefaultDevice(m_instanceInterface,
-                                                                                                                m_physicalDevice,
-                                                                                                                m_universalQueueFamilyIndex,
-                                                                                                                m_deviceFeatures.coreFeatures,
-                                                                                                                m_deviceExtensions,
-                                                                                                                cmdLine))
+       , m_device                                              (createDefaultDevice(m_instanceInterface, m_physicalDevice, m_universalQueueFamilyIndex, m_sparseQueueFamilyIndex, m_deviceFeatures.coreFeatures, m_deviceExtensions, cmdLine))
        , m_deviceInterface                             (m_instanceInterface, *m_device)
 {
 }
@@ -308,9 +315,16 @@ VkQueue DefaultDevice::getUniversalQueue (void) const
        return getDeviceQueue(m_deviceInterface, *m_device, m_universalQueueFamilyIndex, 0);
 }
 
-namespace
+VkQueue DefaultDevice::getSparseQueue (void) const
 {
+       if (!m_deviceFeatures.coreFeatures.features.sparseBinding)
+               TCU_THROW(NotSupportedError, "Sparse binding not supported.");
+
+       return getDeviceQueue(m_deviceInterface, *m_device, m_sparseQueueFamilyIndex, 0);
+}
 
+namespace
+{
 // Allocator utilities
 
 vk::Allocator* createAllocator (DefaultDevice* device)
@@ -352,6 +366,8 @@ vk::VkDevice                                                        Context::getDevice                                              (void) const { return m_device->getDe
 const vk::DeviceInterface&                             Context::getDeviceInterface                             (void) const { return m_device->getDeviceInterface();                   }
 deUint32                                                               Context::getUniversalQueueFamilyIndex   (void) const { return m_device->getUniversalQueueFamilyIndex(); }
 vk::VkQueue                                                            Context::getUniversalQueue                              (void) const { return m_device->getUniversalQueue();                    }
+deUint32                                                               Context::getSparseQueueFamilyIndex              (void) const { return m_device->getSparseQueueFamilyIndex();    }
+vk::VkQueue                                                            Context::getSparseQueue                                 (void) const { return m_device->getSparseQueue();                               }
 vk::Allocator&                                                 Context::getDefaultAllocator                    (void) const { return *m_allocator;                                                             }
 
 // TestCase
index f2bb700422db13670e4140f7d1005a98d9124788..0c5b10f5b2179c52adc21589e95e0eb757c40b68 100644 (file)
@@ -72,7 +72,8 @@ public:
        const vk::DeviceInterface&                                      getDeviceInterface                              (void) const;
        deUint32                                                                        getUniversalQueueFamilyIndex    (void) const;
        vk::VkQueue                                                                     getUniversalQueue                               (void) const;
-
+       deUint32                                                                        getSparseQueueFamilyIndex               (void) const;
+       vk::VkQueue                                                                     getSparseQueue                                  (void) const;
        vk::Allocator&                                                          getDefaultAllocator                             (void) const;
 
 protected: