1 #ifndef _VKIMAGEUTIL_HPP
2 #define _VKIMAGEUTIL_HPP
3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Imagination Technologies Ltd.
9 * Copyright (c) 2015 Google Inc.
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
25 * \brief Utilities for images.
26 *//*--------------------------------------------------------------------*/
29 #include "tcuTexture.hpp"
30 #include "tcuCompressedTexture.hpp"
35 bool isFloatFormat (VkFormat format);
36 bool isUnormFormat (VkFormat format);
37 bool isSnormFormat (VkFormat format);
38 bool isIntFormat (VkFormat format);
39 bool isUintFormat (VkFormat format);
40 bool isDepthStencilFormat (VkFormat format);
41 bool isCompressedFormat (VkFormat format);
42 bool isSrgbFormat (VkFormat format);
44 bool isSupportedByFramework (VkFormat format);
46 tcu::TextureFormat mapVkFormat (VkFormat format);
47 tcu::CompressedTexFormat mapVkCompressedFormat (VkFormat format);
48 tcu::TextureFormat getDepthCopyFormat (VkFormat combinedFormat);
49 tcu::TextureFormat getStencilCopyFormat (VkFormat combinedFormat);
51 tcu::Sampler mapVkSampler (const VkSamplerCreateInfo& samplerCreateInfo);
52 tcu::Sampler::CompareMode mapVkSamplerCompareOp (VkCompareOp compareOp);
53 tcu::Sampler::WrapMode mapVkSamplerAddressMode (VkSamplerAddressMode addressMode);
54 tcu::Sampler::FilterMode mapVkMinTexFilter (VkFilter filter, VkSamplerMipmapMode mipMode);
55 tcu::Sampler::FilterMode mapVkMagTexFilter (VkFilter filter);
57 VkFilter mapFilterMode (tcu::Sampler::FilterMode filterMode);
58 VkSamplerMipmapMode mapMipmapMode (tcu::Sampler::FilterMode filterMode);
59 VkSamplerAddressMode mapWrapMode (tcu::Sampler::WrapMode wrapMode);
60 VkCompareOp mapCompareMode (tcu::Sampler::CompareMode mode);
61 VkFormat mapTextureFormat (const tcu::TextureFormat& format);
62 VkFormat mapCompressedTextureFormat (const tcu::CompressedTexFormat format);
63 VkSamplerCreateInfo mapSampler (const tcu::Sampler& sampler, const tcu::TextureFormat& format, float minLod = 0.0f, float maxLod = 1000.0f);
65 void imageUtilSelfTest (void);
67 // \todo [2017-05-18 pyry] Consider moving this to tcu
68 struct PlanarFormatDescription
78 CHANNEL_R = (1u<<0), // Has "R" (0) channel
79 CHANNEL_G = (1u<<1), // Has "G" (1) channel
80 CHANNEL_B = (1u<<2), // Has "B" (2) channel
81 CHANNEL_A = (1u<<3), // Has "A" (3) channel
86 deUint8 elementSizeBytes;
88 deUint8 heightDivisor;
94 deUint8 type; // tcu::TextureChannelClass value
95 deUint8 offsetBits; // Offset in element in bits
96 deUint8 sizeBits; // Value size in bits
97 deUint8 strideBytes; // Pixel stride (in bytes), usually plane elementSize
101 deUint8 presentChannels;
102 Plane planes[MAX_PLANES];
103 Channel channels[MAX_CHANNELS];
105 inline bool hasChannelNdx (deUint32 ndx) const
107 DE_ASSERT(de::inBounds(ndx, 0u, 4u));
108 return (presentChannels & (1u<<ndx)) != 0;
112 bool isYCbCrFormat (VkFormat format);
113 PlanarFormatDescription getPlanarFormatDescription (VkFormat format);
114 const PlanarFormatDescription& getYCbCrPlanarFormatDescription (VkFormat format);
115 int getPlaneCount (VkFormat format);
116 VkImageAspectFlagBits getPlaneAspect (deUint32 planeNdx);
117 deUint32 getAspectPlaneNdx (VkImageAspectFlagBits planeAspect);
118 bool isChromaSubsampled (VkFormat format);
120 tcu::PixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo,
121 const tcu::UVec2& size,
122 const deUint32* planeRowPitches,
123 void* const* planePtrs,
124 deUint32 channelNdx);
125 tcu::ConstPixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo,
126 const tcu::UVec2& size,
127 const deUint32* planeRowPitches,
128 const void* const* planePtrs,
129 deUint32 channelNdx);
133 #endif // _VKIMAGEUTIL_HPP