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,
67 vk::VkBorderColor getFormatBorderColor (BorderColor color, vk::VkFormat format);
69 /*--------------------------------------------------------------------*//*!
70 * Gets a tcu::TextureLevel initialized with data from a VK color
73 * The VkImage must be non-multisampled and able to be used as a source
74 * operand for transfer operations.
75 *//*--------------------------------------------------------------------*/
76 de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface& vk,
79 deUint32 queueFamilyIndex,
80 vk::Allocator& allocator,
83 const tcu::UVec2& renderSize);
85 /*--------------------------------------------------------------------*//*!
86 * Uploads data from a test texture to a destination VK image.
88 * The VkImage must be non-multisampled and able to be used as a
89 * destination operand for transfer operations.
90 *//*--------------------------------------------------------------------*/
91 void uploadTestTexture (const vk::DeviceInterface& vk,
94 deUint32 queueFamilyIndex,
95 vk::Allocator& allocator,
96 const TestTexture& testTexture,
97 vk::VkImage destImage);
102 TestTexture (const tcu::TextureFormat& format, int width, int height, int depth);
103 TestTexture (const tcu::CompressedTexFormat& format, int width, int height, int depth);
104 virtual ~TestTexture (void);
106 virtual int getNumLevels (void) const = 0;
107 virtual deUint32 getSize (void) const;
108 virtual int getArraySize (void) const { return 1; }
110 virtual bool isCompressed (void) const { return !m_compressedLevels.empty(); }
111 virtual deUint32 getCompressedSize (void) const;
113 virtual tcu::PixelBufferAccess getLevel (int level, int layer) = 0;
114 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const = 0;
116 virtual tcu::CompressedTexture& getCompressedLevel (int level, int layer);
117 virtual const tcu::CompressedTexture& getCompressedLevel (int level, int layer) const;
119 virtual std::vector<vk::VkBufferImageCopy> getBufferCopyRegions (void) const;
120 virtual void write (deUint8* destPtr) const;
123 void populateLevels (const std::vector<tcu::PixelBufferAccess>& levels);
124 void populateCompressedLevels (const tcu::CompressedTexFormat& format, const std::vector<tcu::PixelBufferAccess>& decompressedLevels);
126 static void fillWithGradient (const tcu::PixelBufferAccess& levelAccess);
129 std::vector<tcu::CompressedTexture*> m_compressedLevels;
132 class TestTexture1D : public TestTexture
135 tcu::Texture1D m_texture;
138 TestTexture1D (const tcu::TextureFormat& format, int width);
139 TestTexture1D (const tcu::CompressedTexFormat& format, int width);
140 virtual ~TestTexture1D (void);
142 virtual int getNumLevels (void) const;
143 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
144 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
145 virtual const tcu::Texture1D& getTexture (void) const;
148 class TestTexture1DArray : public TestTexture
151 tcu::Texture1DArray m_texture;
154 TestTexture1DArray (const tcu::TextureFormat& format, int width, int arraySize);
155 TestTexture1DArray (const tcu::CompressedTexFormat& format, int width, int arraySize);
156 virtual ~TestTexture1DArray (void);
158 virtual int getNumLevels (void) const;
159 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
160 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
161 virtual const tcu::Texture1DArray& getTexture (void) const;
162 virtual int getArraySize (void) const;
165 class TestTexture2D : public TestTexture
168 tcu::Texture2D m_texture;
171 TestTexture2D (const tcu::TextureFormat& format, int width, int height);
172 TestTexture2D (const tcu::CompressedTexFormat& format, int width, int height);
173 virtual ~TestTexture2D (void);
175 virtual int getNumLevels (void) const;
176 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
177 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
178 virtual const tcu::Texture2D& getTexture (void) const;
181 class TestTexture2DArray : public TestTexture
184 tcu::Texture2DArray m_texture;
187 TestTexture2DArray (const tcu::TextureFormat& format, int width, int height, int arraySize);
188 TestTexture2DArray (const tcu::CompressedTexFormat& format, int width, int height, int arraySize);
189 virtual ~TestTexture2DArray (void);
191 virtual int getNumLevels (void) const;
192 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
193 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
194 virtual const tcu::Texture2DArray& getTexture (void) const;
195 virtual int getArraySize (void) const;
198 class TestTexture3D : public TestTexture
201 tcu::Texture3D m_texture;
204 TestTexture3D (const tcu::TextureFormat& format, int width, int height, int depth);
205 TestTexture3D (const tcu::CompressedTexFormat& format, int width, int height, int depth);
206 virtual ~TestTexture3D (void);
208 virtual int getNumLevels (void) const;
209 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
210 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
211 virtual const tcu::Texture3D& getTexture (void) const;
214 class TestTextureCube : public TestTexture
217 tcu::TextureCube m_texture;
220 TestTextureCube (const tcu::TextureFormat& format, int size);
221 TestTextureCube (const tcu::CompressedTexFormat& format, int size);
222 virtual ~TestTextureCube (void);
224 virtual int getNumLevels (void) const;
225 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
226 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
227 virtual int getArraySize (void) const;
228 virtual const tcu::TextureCube& getTexture (void) const;
231 class TestTextureCubeArray: public TestTexture
234 tcu::TextureCubeArray m_texture;
237 TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize);
238 TestTextureCubeArray (const tcu::CompressedTexFormat& format, int size, int arraySize);
239 virtual ~TestTextureCubeArray (void);
241 virtual int getNumLevels (void) const;
242 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
243 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
244 virtual int getArraySize (void) const;
245 virtual const tcu::TextureCubeArray& getTexture (void) const;
251 #endif // _VKTPIPELINEIMAGEUTIL_HPP