1 #ifndef _VKTPIPELINEIMAGEUTIL_HPP
2 #define _VKTPIPELINEIMAGEUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Imagination Technologies Ltd.
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and/or associated documentation files (the
12 * "Materials"), to deal in the Materials without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Materials, and to
15 * permit persons to whom the Materials are furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice(s) and this permission notice shall be included
19 * in all copies or substantial portions of the Materials.
21 * The Materials are Confidential Information as defined by the
22 * Khronos Membership Agreement until designated non-confidential by Khronos,
23 * at which point this condition clause shall be removed.
25 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
35 * \brief Utilities for images.
36 *//*--------------------------------------------------------------------*/
38 #include "tcuDefs.hpp"
41 #include "vkPlatform.hpp"
42 #include "vkMemUtil.hpp"
44 #include "tcuTexture.hpp"
45 #include "tcuCompressedTexture.hpp"
56 BORDER_COLOR_OPAQUE_BLACK,
57 BORDER_COLOR_OPAQUE_WHITE,
58 BORDER_COLOR_TRANSPARENT_BLACK,
63 bool isSupportedSamplableFormat (const vk::InstanceInterface& instanceInterface,
64 vk::VkPhysicalDevice device,
66 bool isLinearFilteringSupported (const vk::InstanceInterface& instanceInterface,
67 vk::VkPhysicalDevice device,
69 vk::VkImageTiling tiling);
71 vk::VkBorderColor getFormatBorderColor (BorderColor color, vk::VkFormat format);
73 /*--------------------------------------------------------------------*//*!
74 * Gets a tcu::TextureLevel initialized with data from a VK color
77 * The VkImage must be non-multisampled and able to be used as a source
78 * operand for transfer operations.
79 *//*--------------------------------------------------------------------*/
80 de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface& vk,
83 deUint32 queueFamilyIndex,
84 vk::Allocator& allocator,
87 const tcu::UVec2& renderSize);
89 /*--------------------------------------------------------------------*//*!
90 * Uploads data from a test texture to a destination VK image.
92 * The VkImage must be non-multisampled and able to be used as a
93 * destination operand for transfer operations.
94 *//*--------------------------------------------------------------------*/
95 void uploadTestTexture (const vk::DeviceInterface& vk,
98 deUint32 queueFamilyIndex,
99 vk::Allocator& allocator,
100 const TestTexture& testTexture,
101 vk::VkImage destImage);
106 TestTexture (const tcu::TextureFormat& format, int width, int height, int depth);
107 TestTexture (const tcu::CompressedTexFormat& format, int width, int height, int depth);
108 virtual ~TestTexture (void);
110 virtual int getNumLevels (void) const = 0;
111 virtual deUint32 getSize (void) const;
112 virtual int getArraySize (void) const { return 1; }
114 virtual bool isCompressed (void) const { return !m_compressedLevels.empty(); }
115 virtual deUint32 getCompressedSize (void) const;
117 virtual tcu::PixelBufferAccess getLevel (int level, int layer) = 0;
118 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const = 0;
120 virtual tcu::CompressedTexture& getCompressedLevel (int level, int layer);
121 virtual const tcu::CompressedTexture& getCompressedLevel (int level, int layer) const;
123 virtual std::vector<vk::VkBufferImageCopy> getBufferCopyRegions (void) const;
124 virtual void write (deUint8* destPtr) const;
127 void populateLevels (const std::vector<tcu::PixelBufferAccess>& levels);
128 void populateCompressedLevels (tcu::CompressedTexFormat format, const std::vector<tcu::PixelBufferAccess>& decompressedLevels);
130 static void fillWithGradient (const tcu::PixelBufferAccess& levelAccess);
133 std::vector<tcu::CompressedTexture*> m_compressedLevels;
136 class TestTexture1D : public TestTexture
139 tcu::Texture1D m_texture;
142 TestTexture1D (const tcu::TextureFormat& format, int width);
143 TestTexture1D (const tcu::CompressedTexFormat& format, int width);
144 virtual ~TestTexture1D (void);
146 virtual int getNumLevels (void) const;
147 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
148 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
149 virtual const tcu::Texture1D& getTexture (void) const;
152 class TestTexture1DArray : public TestTexture
155 tcu::Texture1DArray m_texture;
158 TestTexture1DArray (const tcu::TextureFormat& format, int width, int arraySize);
159 TestTexture1DArray (const tcu::CompressedTexFormat& format, int width, int arraySize);
160 virtual ~TestTexture1DArray (void);
162 virtual int getNumLevels (void) const;
163 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
164 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
165 virtual const tcu::Texture1DArray& getTexture (void) const;
166 virtual int getArraySize (void) const;
169 class TestTexture2D : public TestTexture
172 tcu::Texture2D m_texture;
175 TestTexture2D (const tcu::TextureFormat& format, int width, int height);
176 TestTexture2D (const tcu::CompressedTexFormat& format, int width, int height);
177 virtual ~TestTexture2D (void);
179 virtual int getNumLevels (void) const;
180 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
181 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
182 virtual const tcu::Texture2D& getTexture (void) const;
185 class TestTexture2DArray : public TestTexture
188 tcu::Texture2DArray m_texture;
191 TestTexture2DArray (const tcu::TextureFormat& format, int width, int height, int arraySize);
192 TestTexture2DArray (const tcu::CompressedTexFormat& format, int width, int height, int arraySize);
193 virtual ~TestTexture2DArray (void);
195 virtual int getNumLevels (void) const;
196 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
197 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
198 virtual const tcu::Texture2DArray& getTexture (void) const;
199 virtual int getArraySize (void) const;
202 class TestTexture3D : public TestTexture
205 tcu::Texture3D m_texture;
208 TestTexture3D (const tcu::TextureFormat& format, int width, int height, int depth);
209 TestTexture3D (const tcu::CompressedTexFormat& format, int width, int height, int depth);
210 virtual ~TestTexture3D (void);
212 virtual int getNumLevels (void) const;
213 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
214 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
215 virtual const tcu::Texture3D& getTexture (void) const;
218 class TestTextureCube : public TestTexture
221 tcu::TextureCube m_texture;
224 TestTextureCube (const tcu::TextureFormat& format, int size);
225 TestTextureCube (const tcu::CompressedTexFormat& format, int size);
226 virtual ~TestTextureCube (void);
228 virtual int getNumLevels (void) const;
229 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
230 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
231 virtual int getArraySize (void) const;
232 virtual const tcu::TextureCube& getTexture (void) const;
235 class TestTextureCubeArray: public TestTexture
238 tcu::TextureCubeArray m_texture;
241 TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize);
242 TestTextureCubeArray (const tcu::CompressedTexFormat& format, int size, int arraySize);
243 virtual ~TestTextureCubeArray (void);
245 virtual int getNumLevels (void) const;
246 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
247 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
248 virtual int getArraySize (void) const;
249 virtual const tcu::TextureCubeArray& getTexture (void) const;
255 #endif // _VKTPIPELINEIMAGEUTIL_HPP