Merge vk-gl-cts/vulkan-cts-1.0.2 into vk-gl-cts/master
authorPyry Haulos <phaulos@google.com>
Thu, 9 Mar 2017 23:41:19 +0000 (15:41 -0800)
committerPyry Haulos <phaulos@google.com>
Thu, 9 Mar 2017 23:41:19 +0000 (15:41 -0800)
Change-Id: Ic82729c2a686a720ac8c2775b8a2dc92a25989b1

1  2 
external/vulkancts/modules/vulkan/shaderexecutor/vktOpaqueTypeIndexingTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp
external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp

@@@ -407,6 -463,246 +463,225 @@@ static vk::VkImageViewType getVkImageVi
        }
  }
  
 -              const VkCommandPoolCreateInfo           cmdPoolInfo             =
 -              {
 -                      VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
 -                      DE_NULL,
 -                      (VkCommandPoolCreateFlags)VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
 -                      context.getUniversalQueueFamilyIndex(),
 -              };
 -              const Unique<VkCommandPool>                     cmdPool                 (createCommandPool(vkd, device, &cmdPoolInfo));
 -              const VkCommandBufferAllocateInfo       allocInfo               =
 -              {
 -                      VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
 -                      DE_NULL,
 -                      *cmdPool,
 -                      VK_COMMAND_BUFFER_LEVEL_PRIMARY,
 -                      1u,
 -              };
 -              const Unique<VkCommandBuffer>           cmdBuf                  (allocateCommandBuffer(vkd, device, &allocInfo));
 -              const VkCommandBufferBeginInfo          beginInfo               =
+ //! Test image with 1-pixel dimensions and no mipmaps
+ class TestImage
+ {
+ public:
+                                                               TestImage               (Context& context, TextureType texType, tcu::TextureFormat format, const void* colorValue);
+       VkImageView                                     getImageView    (void) const { return *m_imageView; }
+ private:
+       const Unique<VkImage>           m_image;
+       const UniquePtr<Allocation>     m_allocation;
+       const Unique<VkImageView>       m_imageView;
+ };
+ Move<VkImage> createTestImage (const DeviceInterface& vkd, VkDevice device, TextureType texType, tcu::TextureFormat format)
+ {
+       const VkImageCreateInfo         createInfo              =
+       {
+               VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
+               DE_NULL,
+               (texType == TEXTURE_TYPE_CUBE ? (VkImageCreateFlags)VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : (VkImageCreateFlags)0),
+               getVkImageType(texType),
+               mapTextureFormat(format),
+               makeExtent3D(1, 1, 1),
+               1u,
+               (texType == TEXTURE_TYPE_CUBE) ? 6u : 1u,
+               VK_SAMPLE_COUNT_1_BIT,
+               VK_IMAGE_TILING_OPTIMAL,
+               VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT,
+               VK_SHARING_MODE_EXCLUSIVE,
+               0u,
+               DE_NULL,
+               VK_IMAGE_LAYOUT_UNDEFINED
+       };
+       return createImage(vkd, device, &createInfo);
+ }
+ de::MovePtr<Allocation> allocateAndBindMemory (const DeviceInterface& vkd, VkDevice device, Allocator& allocator, VkImage image)
+ {
+       de::MovePtr<Allocation>         alloc   = allocator.allocate(getImageMemoryRequirements(vkd, device, image), MemoryRequirement::Any);
+       VK_CHECK(vkd.bindImageMemory(device, image, alloc->getMemory(), alloc->getOffset()));
+       return alloc;
+ }
+ Move<VkImageView> createTestImageView (const DeviceInterface& vkd, VkDevice device, VkImage image, TextureType texType, tcu::TextureFormat format)
+ {
+       const bool                                      isDepthImage    = format.order == tcu::TextureFormat::D;
+       const VkImageViewCreateInfo     createInfo              =
+       {
+               VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
+               DE_NULL,
+               (VkImageViewCreateFlags)0,
+               image,
+               getVkImageViewType(texType),
+               mapTextureFormat(format),
+               {
+                       VK_COMPONENT_SWIZZLE_IDENTITY,
+                       VK_COMPONENT_SWIZZLE_IDENTITY,
+                       VK_COMPONENT_SWIZZLE_IDENTITY,
+                       VK_COMPONENT_SWIZZLE_IDENTITY,
+               },
+               {
+                       (VkImageAspectFlags)(isDepthImage ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT),
+                       0u,
+                       1u,
+                       0u,
+                       (texType == TEXTURE_TYPE_CUBE ? 6u : 1u)
+               }
+       };
+       return createImageView(vkd, device, &createInfo);
+ }
+ TestImage::TestImage (Context& context, TextureType texType, tcu::TextureFormat format, const void* colorValue)
+       : m_image               (createTestImage                (context.getDeviceInterface(), context.getDevice(), texType, format))
+       , m_allocation  (allocateAndBindMemory  (context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), *m_image))
+       , m_imageView   (createTestImageView    (context.getDeviceInterface(), context.getDevice(), *m_image, texType, format))
+ {
+       const DeviceInterface&          vkd                                     = context.getDeviceInterface();
+       const VkDevice                          device                          = context.getDevice();
+       const size_t                            pixelSize                       = (size_t)format.getPixelSize();
+       const deUint32                          numLayers                       = (texType == TEXTURE_TYPE_CUBE) ? 6u : 1u;
+       const size_t                            numReplicas                     = (size_t)numLayers;
+       const size_t                            stagingBufferSize       = pixelSize*numReplicas;
+       const VkBufferCreateInfo        stagingBufferInfo       =
+       {
+               VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
+               DE_NULL,
+               (VkBufferCreateFlags)0u,
+               (VkDeviceSize)stagingBufferSize,
+               (VkBufferCreateFlags)VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
+               VK_SHARING_MODE_EXCLUSIVE,
+               0u,
+               DE_NULL,
+       };
+       const Unique<VkBuffer>          stagingBuffer           (createBuffer(vkd, device, &stagingBufferInfo));
+       const UniquePtr<Allocation>     alloc                           (context.getDefaultAllocator().allocate(getBufferMemoryRequirements(vkd, device, *stagingBuffer), MemoryRequirement::HostVisible));
+       VK_CHECK(vkd.bindBufferMemory(device, *stagingBuffer, alloc->getMemory(), alloc->getOffset()));
+       for (size_t ndx = 0; ndx < numReplicas; ++ndx)
+               deMemcpy((deUint8*)alloc->getHostPtr() + ndx*pixelSize, colorValue, pixelSize);
+       {
 -              const VkImageAspectFlags                        imageAspect             = (VkImageAspectFlags)(format.order == tcu::TextureFormat::D ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT);
 -              const VkBufferImageCopy                         copyInfo                =
++              const Unique<VkCommandPool>             cmdPool                 (createCommandPool(vkd, device, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, context.getUniversalQueueFamilyIndex()));
++              const Unique<VkCommandBuffer>   cmdBuf                  (allocateCommandBuffer(vkd, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
++              const VkCommandBufferBeginInfo  beginInfo               =
+               {
+                       VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+                       DE_NULL,
+                       (VkCommandBufferUsageFlags)VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
+                       (const VkCommandBufferInheritanceInfo*)DE_NULL,
+               };
 -              const VkImageMemoryBarrier                      preCopyBarrier  =
++              const VkImageAspectFlags                imageAspect             = (VkImageAspectFlags)(format.order == tcu::TextureFormat::D ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT);
++              const VkBufferImageCopy                 copyInfo                =
+               {
+                       0u,
+                       1u,
+                       1u,
+                       {
+                               imageAspect,
+                               0u,
+                               0u,
+                               numLayers
+                       },
+                       { 0u, 0u, 0u },
+                       { 1u, 1u, 1u }
+               };
 -              const VkImageMemoryBarrier                      postCopyBarrier =
++              const VkImageMemoryBarrier              preCopyBarrier  =
+               {
+                       VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
+                       DE_NULL,
+                       (VkAccessFlags)0u,
+                       (VkAccessFlags)VK_ACCESS_TRANSFER_WRITE_BIT,
+                       VK_IMAGE_LAYOUT_UNDEFINED,
+                       VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+                       VK_QUEUE_FAMILY_IGNORED,
+                       VK_QUEUE_FAMILY_IGNORED,
+                       *m_image,
+                       {
+                               imageAspect,
+                               0u,
+                               1u,
+                               0u,
+                               numLayers
+                       }
+               };
 -                      const VkFenceCreateInfo         fenceInfo       =
 -                      {
 -                              VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
 -                              DE_NULL,
 -                              (VkFenceCreateFlags)0,
 -                      };
 -                      const Unique<VkFence>           fence           (createFence(vkd, device, &fenceInfo));
 -                      const VkSubmitInfo                      submitInfo      =
++              const VkImageMemoryBarrier              postCopyBarrier =
+               {
+                       VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
+                       DE_NULL,
+                       (VkAccessFlags)VK_ACCESS_TRANSFER_WRITE_BIT,
+                       (VkAccessFlags)VK_ACCESS_SHADER_READ_BIT,
+                       VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+                       VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                       VK_QUEUE_FAMILY_IGNORED,
+                       VK_QUEUE_FAMILY_IGNORED,
+                       *m_image,
+                       {
+                               imageAspect,
+                               0u,
+                               1u,
+                               0u,
+                               numLayers
+                       }
+               };
+               VK_CHECK(vkd.beginCommandBuffer(*cmdBuf, &beginInfo));
+               vkd.cmdPipelineBarrier(*cmdBuf,
+                                                          (VkPipelineStageFlags)VK_PIPELINE_STAGE_HOST_BIT,
+                                                          (VkPipelineStageFlags)VK_PIPELINE_STAGE_TRANSFER_BIT,
+                                                          (VkDependencyFlags)0u,
+                                                          0u,
+                                                          (const VkMemoryBarrier*)DE_NULL,
+                                                          0u,
+                                                          (const VkBufferMemoryBarrier*)DE_NULL,
+                                                          1u,
+                                                          &preCopyBarrier);
+               vkd.cmdCopyBufferToImage(*cmdBuf, *stagingBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1u, &copyInfo);
+               vkd.cmdPipelineBarrier(*cmdBuf,
+                                                          (VkPipelineStageFlags)VK_PIPELINE_STAGE_TRANSFER_BIT,
+                                                          (VkPipelineStageFlags)VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+                                                          (VkDependencyFlags)0u,
+                                                          0u,
+                                                          (const VkMemoryBarrier*)DE_NULL,
+                                                          0u,
+                                                          (const VkBufferMemoryBarrier*)DE_NULL,
+                                                          1u,
+                                                          &postCopyBarrier);
+               VK_CHECK(vkd.endCommandBuffer(*cmdBuf));
+               {
++                      const Unique<VkFence>   fence           (createFence(vkd, device));
++                      const VkSubmitInfo              submitInfo      =
+                       {
+                               VK_STRUCTURE_TYPE_SUBMIT_INFO,
+                               DE_NULL,
+                               0u,
+                               (const VkSemaphore*)DE_NULL,
+                               (const VkPipelineStageFlags*)DE_NULL,
+                               1u,
+                               &cmdBuf.get(),
+                               0u,
+                               (const VkSemaphore*)DE_NULL,
+                       };
+                       VK_CHECK(vkd.queueSubmit(context.getUniversalQueue(), 1u, &submitInfo, *fence));
+                       VK_CHECK(vkd.waitForFences(device, 1u, &fence.get(), VK_TRUE, ~0ull));
+               }
+       }
+ }
+ typedef SharedPtr<TestImage> TestImageSp;
  // SamplerIndexingCaseInstance
  
  class SamplerIndexingCaseInstance : public OpaqueTypeIndexingTestInstance
@@@ -1908,17 -1963,39 +1917,20 @@@ void ComputeShaderExecutor::execute (in
        Move<VkDescriptorPool>                  descriptorPool;
        Move<VkDescriptorSetLayout>             descriptorSetLayout;
        Move<VkDescriptorSet>                   descriptorSet;
+       const deUint32                                  numDescriptorSets               = (m_extraResourcesLayout != 0) ? 2u : 1u;
        Move<VkFence>                                   fence;
  
-       initBuffers(ctx, numValues);
+       DE_ASSERT((m_extraResourcesLayout != 0) == (extraResources != 0));
+       initBuffers(numValues);
  
        // Setup input buffer & copy data
-       uploadInputBuffer(ctx, inputs, numValues);
+       uploadInputBuffer(inputs, numValues);
  
        // Create command pool
 -      {
 -              const VkCommandPoolCreateInfo cmdPoolParams =
 -              {
 -                      VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,             // VkStructureType              sType;
 -                      DE_NULL,                                                                                // const void*                  pNext;
 -                      VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,                   // VkCmdPoolCreateFlags flags;
 -                      queueFamilyIndex                                                                // deUint32                             queueFamilyIndex;
 -              };
 -
 -              cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
 -      }
 +      cmdPool = createCommandPool(vk, vkDevice, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
  
        // Create command buffer
 -      const VkCommandBufferAllocateInfo cmdBufferParams =
 -      {
 -              VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType                      sType;
 -              DE_NULL,                                                                                // const void*                          pNext;
 -              *cmdPool,                                                                               // VkCmdPool                            cmdPool;
 -              VK_COMMAND_BUFFER_LEVEL_PRIMARY,                                // VkCmdBufferLevel                     level;
 -              1u                                                                                              // deUint32                                     bufferCount;
 -      };
 -
        const VkCommandBufferBeginInfo cmdBufferBeginInfo =
        {
                VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                                      sType;
        }
  
        // Create fence
 -      {
 -              const VkFenceCreateInfo fenceParams =
 -              {
 -                      VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,    // VkStructureType              sType;
 -                      DE_NULL,                                                                // const void*                  pNext;
 -                      0u                                                                              // VkFenceCreateFlags   flags;
 -              };
 -              fence = createFence(vk, vkDevice, &fenceParams);
 -      }
 +      fence = createFence(vk, vkDevice);
  
-       const int maxValuesPerInvocation        = ctx.getDeviceProperties().limits.maxComputeWorkGroupSize[0];
-       int                                     curOffset               = 0;
-       const deUint32          inputStride             = getInputStride();
-       const deUint32          outputStride    = getOutputStride();
+       const int                       maxValuesPerInvocation  = m_context.getDeviceProperties().limits.maxComputeWorkGroupSize[0];
+       int                                     curOffset                               = 0;
+       const deUint32          inputStride                             = getInputStride();
+       const deUint32          outputStride                    = getOutputStride();
  
        while (curOffset < numValues)
        {