Cherry-pick framework changes from 41702fa7
authorPyry Haulos <phaulos@google.com>
Fri, 14 Oct 2016 21:28:37 +0000 (14:28 -0700)
committerPyry Haulos <phaulos@google.com>
Fri, 14 Oct 2016 21:28:55 +0000 (14:28 -0700)
Change-Id: Id2f016dd7034cd688494613b4f4aa74c4f373902

external/vulkancts/framework/vulkan/vkImageUtil.cpp
external/vulkancts/framework/vulkan/vkImageUtil.hpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.hpp

index 8be42c8..75de934 100644 (file)
@@ -709,7 +709,7 @@ static VkBorderColor mapBorderColor (tcu::TextureChannelClass channelClass, cons
        return VK_BORDER_COLOR_LAST;
 }
 
-VkSamplerCreateInfo mapSampler (const tcu::Sampler& sampler, const tcu::TextureFormat& format)
+VkSamplerCreateInfo mapSampler (const tcu::Sampler& sampler, const tcu::TextureFormat& format, float minLod, float maxLod)
 {
        const bool                                      compareEnabled  = (sampler.compare != tcu::Sampler::COMPAREMODE_NONE);
        const VkCompareOp                       compareOp               = (compareEnabled) ? (mapCompareMode(sampler.compare)) : (VK_COMPARE_OP_ALWAYS);
@@ -732,8 +732,8 @@ VkSamplerCreateInfo mapSampler (const tcu::Sampler& sampler, const tcu::TextureF
                1.0f,                                                                                                           // maxAnisotropy
                (VkBool32)(compareEnabled ? VK_TRUE : VK_FALSE),                        // compareEnable
                compareOp,                                                                                                      // compareOp
-               0.0f,                                                                                                           // minLod
-               (isMipmapEnabled ? 1000.0f : 0.25f),                                            // maxLod
+               (isMipmapEnabled ? minLod : 0.0f),                                                      // minLod
+               (isMipmapEnabled ? maxLod : 0.25f),                                                     // maxLod
                borderColor,                                                                                            // borderColor
                (VkBool32)(sampler.normalizedCoords ? VK_FALSE : VK_TRUE),      // unnormalizedCoords
        };
index 06f6e09..0a5ebef 100644 (file)
@@ -56,7 +56,7 @@ VkSamplerMipmapMode                   mapMipmapMode                           (tcu::Sampler::FilterMode filterMode);
 VkSamplerAddressMode           mapWrapMode                                     (tcu::Sampler::WrapMode wrapMode);
 VkCompareOp                                    mapCompareMode                          (tcu::Sampler::CompareMode mode);
 VkFormat                                       mapTextureFormat                        (const tcu::TextureFormat& format);
-VkSamplerCreateInfo                    mapSampler                                      (const tcu::Sampler& sampler, const tcu::TextureFormat& format);
+VkSamplerCreateInfo                    mapSampler                                      (const tcu::Sampler& sampler, const tcu::TextureFormat& format, float minLod = 0.0f, float maxLod = 1000.0f);
 
 void                                           imageUtilSelfTest                       (void);
 
index de720d9..ed5ba91 100644 (file)
@@ -357,6 +357,27 @@ de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface&     v
        return resultLevel;
 }
 
+namespace
+{
+
+VkImageAspectFlags getImageAspectFlags (const tcu::TextureFormat textureFormat)
+{
+       VkImageAspectFlags imageAspectFlags = 0;
+
+       if (tcu::hasDepthComponent(textureFormat.order))
+               imageAspectFlags |= VK_IMAGE_ASPECT_DEPTH_BIT;
+
+       if (tcu::hasStencilComponent(textureFormat.order))
+               imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
+
+       if (imageAspectFlags == 0)
+               imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
+
+       return imageAspectFlags;
+}
+
+} // anonymous
+
 void uploadTestTexture (const DeviceInterface&                 vk,
                                                VkDevice                                                device,
                                                VkQueue                                                 queue,
@@ -371,7 +392,7 @@ void uploadTestTexture (const DeviceInterface&                      vk,
        Move<VkCommandPool>                             cmdPool;
        Move<VkCommandBuffer>                   cmdBuffer;
        Move<VkFence>                                   fence;
-       std::vector<deUint32>                   levelDataSizes;
+       const VkImageAspectFlags                imageAspectFlags        = getImageAspectFlags(srcTexture.getTextureFormat());
 
        // Calculate buffer size
        bufferSize =  (srcTexture.isCompressed())? srcTexture.getCompressedSize(): srcTexture.getSize();
@@ -457,11 +478,11 @@ void uploadTestTexture (const DeviceInterface&                    vk,
                VK_QUEUE_FAMILY_IGNORED,                                                // deUint32                                     dstQueueFamilyIndex;
                destImage,                                                                              // VkImage                                      image;
                {                                                                                               // VkImageSubresourceRange      subresourceRange;
-                       VK_IMAGE_ASPECT_COLOR_BIT,                              // VkImageAspect        aspect;
-                       0u,                                                                             // deUint32                     baseMipLevel;
-                       (deUint32)srcTexture.getNumLevels(),    // deUint32                     mipLevels;
-                       0u,                                                                             // deUint32                     baseArraySlice;
-                       (deUint32)srcTexture.getArraySize(),    // deUint32                     arraySize;
+                       imageAspectFlags,                                               // VkImageAspectFlags   aspectMask;
+                       0u,                                                                             // deUint32                             baseMipLevel;
+                       (deUint32)srcTexture.getNumLevels(),    // deUint32                             mipLevels;
+                       0u,                                                                             // deUint32                             baseArraySlice;
+                       (deUint32)srcTexture.getArraySize(),    // deUint32                             arraySize;
                }
        };
 
@@ -477,11 +498,11 @@ void uploadTestTexture (const DeviceInterface&                    vk,
                VK_QUEUE_FAMILY_IGNORED,                                                // deUint32                                     dstQueueFamilyIndex;
                destImage,                                                                              // VkImage                                      image;
                {                                                                                               // VkImageSubresourceRange      subresourceRange;
-                       VK_IMAGE_ASPECT_COLOR_BIT,                              // VkImageAspect        aspect;
-                       0u,                                                                             // deUint32                     baseMipLevel;
-                       (deUint32)srcTexture.getNumLevels(),    // deUint32                     mipLevels;
-                       0u,                                                                             // deUint32                     baseArraySlice;
-                       (deUint32)srcTexture.getArraySize(),    // deUint32                     arraySize;
+                       imageAspectFlags,                                               // VkImageAspectFlags   aspectMask;
+                       0u,                                                                             // deUint32                             baseMipLevel;
+                       (deUint32)srcTexture.getNumLevels(),    // deUint32                             mipLevels;
+                       0u,                                                                             // deUint32                             baseArraySlice;
+                       (deUint32)srcTexture.getArraySize(),    // deUint32                             arraySize;
                }
        };
 
@@ -524,7 +545,6 @@ void uploadTestTexture (const DeviceInterface&                      vk,
        VK_CHECK(vk.waitForFences(device, 1, &fence.get(), true, ~(0ull) /* infinity */));
 }
 
-
 // Utilities for test textures
 
 template<typename TcuTextureType>
@@ -545,7 +565,6 @@ std::vector<tcu::PixelBufferAccess> getLevelsVector (const TcuTextureType& textu
        return levels;
 }
 
-
 // TestTexture
 
 TestTexture::TestTexture (const tcu::TextureFormat& format, int width, int height, int depth)
@@ -642,7 +661,7 @@ std::vector<VkBufferImageCopy> TestTexture::getBufferCopyRegions (void) const
 {
        std::vector<deUint32>                   offsetMultiples;
        std::vector<VkBufferImageCopy>  regions;
-       deUint32                                                layerDataOffset = 0;
+       deUint32                                                layerDataOffset = 0;
 
        offsetMultiples.push_back(4);
 
@@ -684,6 +703,18 @@ std::vector<VkBufferImageCopy> TestTexture::getBufferCopyRegions (void) const
        }
        else
        {
+               std::vector<VkImageAspectFlags> imageAspects;
+               tcu::TextureFormat                              textureFormat   = getTextureFormat();
+
+               if (tcu::hasDepthComponent(textureFormat.order))
+                       imageAspects.push_back(VK_IMAGE_ASPECT_DEPTH_BIT);
+
+               if (tcu::hasStencilComponent(textureFormat.order))
+                       imageAspects.push_back(VK_IMAGE_ASPECT_STENCIL_BIT);
+
+               if (imageAspects.empty())
+                       imageAspects.push_back(VK_IMAGE_ASPECT_COLOR_BIT);
+
                offsetMultiples.push_back(getLevel(0, 0).getFormat().getPixelSize());
 
                for (int levelNdx = 0; levelNdx < getNumLevels(); levelNdx++)
@@ -694,26 +725,29 @@ std::vector<VkBufferImageCopy> TestTexture::getBufferCopyRegions (void) const
 
                                layerDataOffset = getNextMultiple(offsetMultiples, layerDataOffset);
 
-                               const VkBufferImageCopy layerRegion =
+                               for (size_t aspectIndex = 0; aspectIndex < imageAspects.size(); ++aspectIndex)
                                {
-                                       layerDataOffset,                                                // VkDeviceSize                         bufferOffset;
-                                       (deUint32)level.getWidth(),                             // deUint32                                     bufferRowLength;
-                                       (deUint32)level.getHeight(),                    // deUint32                                     bufferImageHeight;
-                                       {                                                                               // VkImageSubresourceLayers     imageSubresource;
-                                               VK_IMAGE_ASPECT_COLOR_BIT,
-                                               (deUint32)levelNdx,
-                                               (deUint32)layerNdx,
-                                               1u
-                                       },
-                                       { 0u, 0u, 0u },                                                 // VkOffset3D                   imageOffset;
-                                       {                                                                               // VkExtent3D                   imageExtent;
-                                               (deUint32)level.getWidth(),
-                                               (deUint32)level.getHeight(),
-                                               (deUint32)level.getDepth()
-                                       }
-                               };
-
-                               regions.push_back(layerRegion);
+                                       const VkBufferImageCopy layerRegion =
+                                       {
+                                               layerDataOffset,                                                // VkDeviceSize                         bufferOffset;
+                                               (deUint32)level.getWidth(),                             // deUint32                                     bufferRowLength;
+                                               (deUint32)level.getHeight(),                    // deUint32                                     bufferImageHeight;
+                                               {                                                                               // VkImageSubresourceLayers     imageSubresource;
+                                                       imageAspects[aspectIndex],
+                                                       (deUint32)levelNdx,
+                                                       (deUint32)layerNdx,
+                                                       1u
+                                               },
+                                               { 0u, 0u, 0u },                                                 // VkOffset3D                   imageOffset;
+                                               {                                                                               // VkExtent3D                   imageExtent;
+                                                       (deUint32)level.getWidth(),
+                                                       (deUint32)level.getHeight(),
+                                                       (deUint32)level.getDepth()
+                                               }
+                                       };
+
+                                       regions.push_back(layerRegion);
+                               }
                                layerDataOffset += level.getWidth() * level.getHeight() * level.getDepth() * level.getFormat().getPixelSize();
                        }
                }
@@ -793,8 +827,10 @@ void TestTexture::populateCompressedLevels (tcu::CompressedTexFormat format, con
                else
                {
                        // Generate random compressed data
-                       for (int byteNdx = 0; byteNdx < compressedLevel->getDataSize(); byteNdx++)
-                               compressedData[byteNdx] = 0xFF & random.getUint32();
+                       // Random initial values cause assertion during the decompression in case of COMPRESSEDTEXFORMAT_ETC1_RGB8 format
+                       if (format != tcu::COMPRESSEDTEXFORMAT_ETC1_RGB8)
+                               for (int byteNdx = 0; byteNdx < compressedLevel->getDataSize(); byteNdx++)
+                                       compressedData[byteNdx] = 0xFF & random.getUint32();
                }
 
                m_compressedLevels.push_back(compressedLevel);
@@ -856,6 +892,10 @@ const tcu::Texture1D& TestTexture1D::getTexture (void) const
        return m_texture;
 }
 
+tcu::Texture1D& TestTexture1D::getTexture (void)
+{
+       return m_texture;
+}
 
 // TestTexture1DArray
 
@@ -913,12 +953,16 @@ const tcu::Texture1DArray& TestTexture1DArray::getTexture (void) const
        return m_texture;
 }
 
+tcu::Texture1DArray& TestTexture1DArray::getTexture (void)
+{
+       return m_texture;
+}
+
 int TestTexture1DArray::getArraySize (void) const
 {
        return m_texture.getNumLayers();
 }
 
-
 // TestTexture2D
 
 TestTexture2D::TestTexture2D (const tcu::TextureFormat& format, int width, int height)
@@ -965,6 +1009,10 @@ const tcu::Texture2D& TestTexture2D::getTexture (void) const
        return m_texture;
 }
 
+tcu::Texture2D& TestTexture2D::getTexture (void)
+{
+       return m_texture;
+}
 
 // TestTexture2DArray
 
@@ -1022,6 +1070,11 @@ const tcu::Texture2DArray& TestTexture2DArray::getTexture (void) const
        return m_texture;
 }
 
+tcu::Texture2DArray& TestTexture2DArray::getTexture (void)
+{
+       return m_texture;
+}
+
 int TestTexture2DArray::getArraySize (void) const
 {
        return m_texture.getNumLayers();
@@ -1074,6 +1127,10 @@ const tcu::Texture3D& TestTexture3D::getTexture (void) const
        return m_texture;
 }
 
+tcu::Texture3D& TestTexture3D::getTexture (void)
+{
+       return m_texture;
+}
 
 // TestTextureCube
 
@@ -1128,14 +1185,14 @@ int TestTextureCube::getNumLevels (void) const
        return m_texture.getNumLevels();
 }
 
-tcu::PixelBufferAccess TestTextureCube::getLevel (int level, int face)
+tcu::PixelBufferAccess TestTextureCube::getLevel (int level, int layer)
 {
-       return m_texture.getLevelFace(level, (tcu::CubeFace)face);
+       return m_texture.getLevelFace(level, tcuFaceMapping[layer]);
 }
 
-const tcu::ConstPixelBufferAccess TestTextureCube::getLevel (int level, int face) const
+const tcu::ConstPixelBufferAccess TestTextureCube::getLevel (int level, int layer) const
 {
-       return m_texture.getLevelFace(level, (tcu::CubeFace)face);
+       return m_texture.getLevelFace(level, tcuFaceMapping[layer]);
 }
 
 int TestTextureCube::getArraySize (void) const
@@ -1148,6 +1205,11 @@ const tcu::TextureCube& TestTextureCube::getTexture (void) const
        return m_texture;
 }
 
+tcu::TextureCube& TestTextureCube::getTexture (void)
+{
+       return m_texture;
+}
+
 // TestTextureCubeArray
 
 TestTextureCubeArray::TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize)
@@ -1211,5 +1273,10 @@ const tcu::TextureCubeArray& TestTextureCubeArray::getTexture (void) const
        return m_texture;
 }
 
+tcu::TextureCubeArray& TestTextureCubeArray::getTexture (void)
+{
+       return m_texture;
+}
+
 } // pipeline
 } // vkt
index 7c20ccb..6c66be5 100644 (file)
@@ -116,6 +116,9 @@ public:
        virtual std::vector<vk::VkBufferImageCopy>      getBufferCopyRegions            (void) const;
        virtual void                                                            write                                           (deUint8* destPtr) const;
 
+       virtual const tcu::TextureFormat&                       getTextureFormat                        (void) const = 0;
+       virtual tcu::UVec3                                                      getTextureDimension                     (void) const = 0;
+
 protected:
        void                                                                            populateLevels                          (const std::vector<tcu::PixelBufferAccess>& levels);
        void                                                                            populateCompressedLevels        (tcu::CompressedTexFormat format, const std::vector<tcu::PixelBufferAccess>& decompressedLevels);
@@ -132,14 +135,17 @@ private:
        tcu::Texture1D                                                          m_texture;
 
 public:
-                                                                                               TestTexture1D   (const tcu::TextureFormat& format, int width);
-                                                                                               TestTexture1D   (const tcu::CompressedTexFormat& format, int width);
-       virtual                                                                         ~TestTexture1D  (void);
+                                                                                               TestTexture1D           (const tcu::TextureFormat& format, int width);
+                                                                                               TestTexture1D           (const tcu::CompressedTexFormat& format, int width);
+       virtual                                                                         ~TestTexture1D          (void);
 
        virtual int getNumLevels (void) const;
-       virtual tcu::PixelBufferAccess                          getLevel                (int level, int layer);
-       virtual const tcu::ConstPixelBufferAccess       getLevel                (int level, int layer) const;
-       virtual const tcu::Texture1D&                           getTexture              (void) const;
+       virtual tcu::PixelBufferAccess                          getLevel                        (int level, int layer);
+       virtual const tcu::ConstPixelBufferAccess       getLevel                        (int level, int layer) const;
+       virtual const tcu::Texture1D&                           getTexture                      (void) const;
+       virtual tcu::Texture1D&                                         getTexture                      (void);
+       virtual const tcu::TextureFormat&                       getTextureFormat        (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension     (void) const { return tcu::UVec3(m_texture.getWidth(), 1, 1); }
 };
 
 class TestTexture1DArray : public TestTexture
@@ -156,7 +162,10 @@ public:
        virtual tcu::PixelBufferAccess                          getLevel                        (int level, int layer);
        virtual const tcu::ConstPixelBufferAccess       getLevel                        (int level, int layer) const;
        virtual const tcu::Texture1DArray&                      getTexture                      (void) const;
+       virtual tcu::Texture1DArray&                            getTexture                      (void);
        virtual int                                                                     getArraySize            (void) const;
+       virtual const tcu::TextureFormat&                       getTextureFormat        (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension     (void) const { return tcu::UVec3(m_texture.getWidth(), 1, 1); }
 };
 
 class TestTexture2D : public TestTexture
@@ -173,6 +182,9 @@ public:
        virtual tcu::PixelBufferAccess                          getLevel                        (int level, int layer);
        virtual const tcu::ConstPixelBufferAccess       getLevel                        (int level, int layer) const;
        virtual const tcu::Texture2D&                           getTexture                      (void) const;
+       virtual tcu::Texture2D&                                         getTexture                      (void);
+       virtual const tcu::TextureFormat&                       getTextureFormat        (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension     (void) const { return tcu::UVec3(m_texture.getWidth(), m_texture.getHeight(), 1); }
 };
 
 class TestTexture2DArray : public TestTexture
@@ -189,7 +201,10 @@ public:
        virtual tcu::PixelBufferAccess                          getLevel                        (int level, int layer);
        virtual const tcu::ConstPixelBufferAccess       getLevel                        (int level, int layer) const;
        virtual const tcu::Texture2DArray&                      getTexture                      (void) const;
+       virtual tcu::Texture2DArray&                            getTexture                      (void);
        virtual int                                                                     getArraySize            (void) const;
+       virtual const tcu::TextureFormat&                       getTextureFormat        (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension     (void) const { return tcu::UVec3(m_texture.getWidth(), m_texture.getHeight(), 1); }
 };
 
 class TestTexture3D : public TestTexture
@@ -206,6 +221,9 @@ public:
        virtual tcu::PixelBufferAccess                          getLevel                        (int level, int layer);
        virtual const tcu::ConstPixelBufferAccess       getLevel                        (int level, int layer) const;
        virtual const tcu::Texture3D&                           getTexture                      (void) const;
+       virtual tcu::Texture3D&                                         getTexture                      (void);
+       virtual const tcu::TextureFormat&                       getTextureFormat        (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension     (void) const { return tcu::UVec3(m_texture.getWidth(), m_texture.getHeight(), m_texture.getDepth()); }
 };
 
 class TestTextureCube : public TestTexture
@@ -223,6 +241,9 @@ public:
        virtual const tcu::ConstPixelBufferAccess       getLevel                                (int level, int layer) const;
        virtual int                                                                     getArraySize                    (void) const;
        virtual const tcu::TextureCube&                         getTexture                              (void) const;
+       virtual tcu::TextureCube&                                       getTexture                              (void);
+       virtual const tcu::TextureFormat&                       getTextureFormat                (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension             (void) const { return tcu::UVec3(m_texture.getSize(), m_texture.getSize(), 1); }
 };
 
 class TestTextureCubeArray: public TestTexture
@@ -240,6 +261,9 @@ public:
        virtual const tcu::ConstPixelBufferAccess       getLevel                                (int level, int layer) const;
        virtual int                                                                     getArraySize                    (void) const;
        virtual const tcu::TextureCubeArray&            getTexture                              (void) const;
+       virtual tcu::TextureCubeArray&                          getTexture                              (void);
+       virtual const tcu::TextureFormat&                       getTextureFormat                (void) const { return m_texture.getFormat(); }
+       virtual tcu::UVec3                                                      getTextureDimension             (void) const { return tcu::UVec3(m_texture.getSize(), m_texture.getSize(), 1); }
 };
 
 } // pipeline