1 #ifndef _TCUTEXVERIFIERUTIL_HPP
2 #define _TCUTEXVERIFIERUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
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 Internal utilities shared between TexLookup and TexCompare verifiers.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTexture.hpp"
31 namespace TexVerifierUtil
34 // Error bound utilities
36 float computeFloatingPointError (const float value, const int numAccurateBits);
37 float computeFixedPointError (const int numAccurateBits);
40 inline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits)
42 Vector<float, Size> res;
43 for (int ndx = 0; ndx < Size; ndx++)
44 res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]);
49 inline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits)
51 Vector<float, Size> res;
52 for (int ndx = 0; ndx < Size; ndx++)
53 res[ndx] = computeFixedPointError(numAccurateBits[ndx]);
57 // Sampler introspection
59 inline bool isNearestMipmapFilter (const Sampler::FilterMode mode)
61 return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST;
64 inline bool isLinearMipmapFilter (const Sampler::FilterMode mode)
66 return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR;
69 inline bool isMipmapFilter (const Sampler::FilterMode mode)
71 return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode);
74 inline bool isLinearFilter (const Sampler::FilterMode mode)
76 return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR;
79 inline bool isNearestFilter (const Sampler::FilterMode mode)
81 return !isLinearFilter(mode);
84 inline Sampler::FilterMode getLevelFilter (const Sampler::FilterMode mode)
86 return isLinearFilter(mode) ? Sampler::LINEAR : Sampler::NEAREST;
89 inline bool isWrapModeSupported (const Sampler::WrapMode mode)
91 return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL;
96 Vec2 computeNonNormalizedCoordBounds (const bool normalizedCoords, const int dim, const float coord, const int coordBits, const int uvBits);
97 void getPossibleCubeFaces (const Vec3& coord, const IVec3& bits, CubeFace* faces, int& numFaces);
99 Sampler getUnnormalizedCoordSampler (const Sampler& sampler);
100 int wrap (Sampler::WrapMode mode, int c, int size);
105 #endif // _TCUTEXVERIFIERUTIL_HPP