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 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Utilities for images.
25 *//*--------------------------------------------------------------------*/
27 #include "tcuDefs.hpp"
30 #include "vkPlatform.hpp"
31 #include "vkMemUtil.hpp"
33 #include "tcuTexture.hpp"
34 #include "tcuCompressedTexture.hpp"
45 BORDER_COLOR_OPAQUE_BLACK,
46 BORDER_COLOR_OPAQUE_WHITE,
47 BORDER_COLOR_TRANSPARENT_BLACK,
52 bool isSupportedSamplableFormat (const vk::InstanceInterface& instanceInterface,
53 vk::VkPhysicalDevice device,
55 bool isLinearFilteringSupported (const vk::InstanceInterface& instanceInterface,
56 vk::VkPhysicalDevice device,
58 vk::VkImageTiling tiling);
60 vk::VkBorderColor getFormatBorderColor (BorderColor color, vk::VkFormat format);
62 /*--------------------------------------------------------------------*//*!
63 * Gets a tcu::TextureLevel initialized with data from a VK color
66 * The VkImage must be non-multisampled and able to be used as a source
67 * operand for transfer operations.
68 *//*--------------------------------------------------------------------*/
69 de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface& vk,
72 deUint32 queueFamilyIndex,
73 vk::Allocator& allocator,
76 const tcu::UVec2& renderSize);
78 /*--------------------------------------------------------------------*//*!
79 * Uploads data from a test texture to a destination VK image.
81 * The VkImage must be non-multisampled and able to be used as a
82 * destination operand for transfer operations.
83 *//*--------------------------------------------------------------------*/
84 void uploadTestTexture (const vk::DeviceInterface& vk,
87 deUint32 queueFamilyIndex,
88 vk::Allocator& allocator,
89 const TestTexture& testTexture,
90 vk::VkImage destImage);
95 TestTexture (const tcu::TextureFormat& format, int width, int height, int depth);
96 TestTexture (const tcu::CompressedTexFormat& format, int width, int height, int depth);
97 virtual ~TestTexture (void);
99 virtual int getNumLevels (void) const = 0;
100 virtual deUint32 getSize (void) const;
101 virtual int getArraySize (void) const { return 1; }
103 virtual bool isCompressed (void) const { return !m_compressedLevels.empty(); }
104 virtual deUint32 getCompressedSize (void) const;
106 virtual tcu::PixelBufferAccess getLevel (int level, int layer) = 0;
107 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const = 0;
109 virtual tcu::CompressedTexture& getCompressedLevel (int level, int layer);
110 virtual const tcu::CompressedTexture& getCompressedLevel (int level, int layer) const;
112 virtual std::vector<vk::VkBufferImageCopy> getBufferCopyRegions (void) const;
113 virtual void write (deUint8* destPtr) const;
116 void populateLevels (const std::vector<tcu::PixelBufferAccess>& levels);
117 void populateCompressedLevels (tcu::CompressedTexFormat format, const std::vector<tcu::PixelBufferAccess>& decompressedLevels);
119 static void fillWithGradient (const tcu::PixelBufferAccess& levelAccess);
122 std::vector<tcu::CompressedTexture*> m_compressedLevels;
125 class TestTexture1D : public TestTexture
128 tcu::Texture1D m_texture;
131 TestTexture1D (const tcu::TextureFormat& format, int width);
132 TestTexture1D (const tcu::CompressedTexFormat& format, int width);
133 virtual ~TestTexture1D (void);
135 virtual int getNumLevels (void) const;
136 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
137 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
138 virtual const tcu::Texture1D& getTexture (void) const;
141 class TestTexture1DArray : public TestTexture
144 tcu::Texture1DArray m_texture;
147 TestTexture1DArray (const tcu::TextureFormat& format, int width, int arraySize);
148 TestTexture1DArray (const tcu::CompressedTexFormat& format, int width, int arraySize);
149 virtual ~TestTexture1DArray (void);
151 virtual int getNumLevels (void) const;
152 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
153 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
154 virtual const tcu::Texture1DArray& getTexture (void) const;
155 virtual int getArraySize (void) const;
158 class TestTexture2D : public TestTexture
161 tcu::Texture2D m_texture;
164 TestTexture2D (const tcu::TextureFormat& format, int width, int height);
165 TestTexture2D (const tcu::CompressedTexFormat& format, int width, int height);
166 virtual ~TestTexture2D (void);
168 virtual int getNumLevels (void) const;
169 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
170 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
171 virtual const tcu::Texture2D& getTexture (void) const;
174 class TestTexture2DArray : public TestTexture
177 tcu::Texture2DArray m_texture;
180 TestTexture2DArray (const tcu::TextureFormat& format, int width, int height, int arraySize);
181 TestTexture2DArray (const tcu::CompressedTexFormat& format, int width, int height, int arraySize);
182 virtual ~TestTexture2DArray (void);
184 virtual int getNumLevels (void) const;
185 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
186 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
187 virtual const tcu::Texture2DArray& getTexture (void) const;
188 virtual int getArraySize (void) const;
191 class TestTexture3D : public TestTexture
194 tcu::Texture3D m_texture;
197 TestTexture3D (const tcu::TextureFormat& format, int width, int height, int depth);
198 TestTexture3D (const tcu::CompressedTexFormat& format, int width, int height, int depth);
199 virtual ~TestTexture3D (void);
201 virtual int getNumLevels (void) const;
202 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
203 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
204 virtual const tcu::Texture3D& getTexture (void) const;
207 class TestTextureCube : public TestTexture
210 tcu::TextureCube m_texture;
213 TestTextureCube (const tcu::TextureFormat& format, int size);
214 TestTextureCube (const tcu::CompressedTexFormat& format, int size);
215 virtual ~TestTextureCube (void);
217 virtual int getNumLevels (void) const;
218 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
219 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
220 virtual int getArraySize (void) const;
221 virtual const tcu::TextureCube& getTexture (void) const;
224 class TestTextureCubeArray: public TestTexture
227 tcu::TextureCubeArray m_texture;
230 TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize);
231 TestTextureCubeArray (const tcu::CompressedTexFormat& format, int size, int arraySize);
232 virtual ~TestTextureCubeArray (void);
234 virtual int getNumLevels (void) const;
235 virtual tcu::PixelBufferAccess getLevel (int level, int layer);
236 virtual const tcu::ConstPixelBufferAccess getLevel (int level, int layer) const;
237 virtual int getArraySize (void) const;
238 virtual const tcu::TextureCubeArray& getTexture (void) const;
244 #endif // _VKTPIPELINEIMAGEUTIL_HPP