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,
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();
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;
}
};
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;
}
};
VK_CHECK(vk.waitForFences(device, 1, &fence.get(), true, ~(0ull) /* infinity */));
}
-
// Utilities for test textures
template<typename TcuTextureType>
return levels;
}
-
// TestTexture
TestTexture::TestTexture (const tcu::TextureFormat& format, int width, int height, int depth)
{
std::vector<deUint32> offsetMultiples;
std::vector<VkBufferImageCopy> regions;
- deUint32 layerDataOffset = 0;
+ deUint32 layerDataOffset = 0;
offsetMultiples.push_back(4);
}
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++)
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();
}
}
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);
return m_texture;
}
+tcu::Texture1D& TestTexture1D::getTexture (void)
+{
+ return m_texture;
+}
// TestTexture1DArray
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)
return m_texture;
}
+tcu::Texture2D& TestTexture2D::getTexture (void)
+{
+ return m_texture;
+}
// TestTexture2DArray
return m_texture;
}
+tcu::Texture2DArray& TestTexture2DArray::getTexture (void)
+{
+ return m_texture;
+}
+
int TestTexture2DArray::getArraySize (void) const
{
return m_texture.getNumLayers();
return m_texture;
}
+tcu::Texture3D& TestTexture3D::getTexture (void)
+{
+ return m_texture;
+}
// TestTextureCube
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
return m_texture;
}
+tcu::TextureCube& TestTextureCube::getTexture (void)
+{
+ return m_texture;
+}
+
// TestTextureCubeArray
TestTextureCubeArray::TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize)
return m_texture;
}
+tcu::TextureCubeArray& TestTextureCubeArray::getTexture (void)
+{
+ return m_texture;
+}
+
} // pipeline
} // vkt
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);
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
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
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
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
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
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
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