1 #ifndef _VKTSAMPLEVERIFIERUTIL_HPP
2 #define _VKTSAMPLEVERIFIERUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 Google Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief GPU image sample verification
24 *//*--------------------------------------------------------------------*/
26 #include "vktSampleVerifier.hpp"
29 #include "tcuFloatFormat.hpp"
30 #include "tcuTexture.hpp"
35 namespace texture_filtering
40 float addUlp (float num,
43 deInt32 mod (const deInt32 a,
45 deInt32 mirror (const deInt32 n);
47 tcu::Vec2 calcLodBounds (const tcu::Vec3& dPdx,
48 const tcu::Vec3& dPdy,
49 const tcu::IVec3 size,
53 tcu::UVec2 calcLevelBounds (const tcu::Vec2& lodBounds,
55 vk::VkSamplerMipmapMode mipmapFilter);
56 tcu::Vec2 calcLevelLodBounds (const tcu::Vec2& lodBounds,
59 void wrapTexelGridCoordLinear (tcu::IVec3& baseTexel,
60 tcu::IVec3& texelGridOffset,
63 void calcTexelBaseOffset (const tcu::IVec3& gridCoord,
65 tcu::IVec3& baseTexel,
66 tcu::IVec3& texelGridOffset);
67 void calcTexelGridCoordRange (const tcu::Vec3& unnormalizedCoordMin,
68 const tcu::Vec3& unnormalizedCoordMax,
70 tcu::IVec3& gridCoordMin,
71 tcu::IVec3& gridCoordMax);
72 void calcUnnormalizedCoordRange (const tcu::Vec4& coord,
73 const tcu::IVec3& levelSize,
74 const tcu::FloatFormat& internalFormat,
75 tcu::Vec3& unnormalizedCoordMin,
76 tcu::Vec3& unnormalizedCoordMax);
77 void calcCubemapFaceCoords (const tcu::Vec3& r,
78 const tcu::Vec3& drdx,
79 const tcu::Vec3& drdy,
84 int calcCandidateCubemapFaces (const tcu::Vec3& r);
85 deInt32 wrapTexelCoord (const deInt32 coord,
87 const vk::VkSamplerAddressMode wrap);
88 void wrapCubemapEdge (const tcu::IVec2& coord,
89 const tcu::IVec2& size,
93 void wrapCubemapCorner (const tcu::IVec2& coord,
94 const tcu::IVec2& size,
98 tcu::IVec2& cornerCoord0,
99 tcu::IVec2& cornerCoord1,
100 tcu::IVec2& cornerCoord2);
102 void convertFormat (const void* pixelPtr,
103 tcu::TextureFormat texFormat,
104 tcu::FloatFormat internalFormat,
105 tcu::Vec4& resultMin,
106 tcu::Vec4& resultMax);
109 bool isEqualRelEpsilon (const tcu::Vector<float, Size>& a, const tcu::Vector<float, Size>& b, const float epsilon)
111 for (int compNdx = 0; compNdx < Size; ++compNdx)
113 if (!isEqualRelEpsilon(a[compNdx], b[compNdx], epsilon))
123 bool isInRange (const tcu::Vector<float, Size>& v, const tcu::Vector<float, Size>& min, const tcu::Vector<float, Size>& max)
125 for (int compNdx = 0; compNdx < Size; ++compNdx)
127 if (v[compNdx] < min[compNdx] || v[compNdx] > max[compNdx])
137 tcu::Vector<float, Size> floor (const tcu::Vector<float, Size>& v)
139 tcu::Vector<float, Size> result;
141 for (int compNdx = 0; compNdx < Size; ++compNdx)
143 result[compNdx] = (float)deFloor(v[compNdx]);
150 tcu::Vector<float, Size> ceil (const tcu::Vector<float, Size>& v)
152 tcu::Vector<float, Size> result;
154 for (int compNdx = 0; compNdx < Size; ++compNdx)
156 result[compNdx] = (float)deCeil(v[compNdx]);
163 tcu::Vector<float, Size> abs (const tcu::Vector<float, Size>& v)
165 tcu::Vector<float, Size> result;
167 for (int compNdx = 0; compNdx < Size; ++compNdx)
169 result[compNdx] = de::abs(v[compNdx]);
176 } // texture_filtering
179 #endif // _VKTSAMPLEVERIFIERUTIL_HPP