Limit changes by xor to upper 8 bits in mixed atomic tests am: 6bc3c7a634 am: eef2e71...
[platform/upstream/VK-GL-CTS.git] / framework / common / tcuTexVerifierUtil.hpp
1 #ifndef _TCUTEXVERIFIERUTIL_HPP
2 #define _TCUTEXVERIFIERUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  *//*!
22  * \file
23  * \brief Internal utilities shared between TexLookup and TexCompare verifiers.
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "tcuTexture.hpp"
28
29 namespace tcu
30 {
31 namespace TexVerifierUtil
32 {
33
34 // Error bound utilities
35
36 float           computeFloatingPointError                       (const float value, const int numAccurateBits);
37 float           computeFixedPointError                          (const int numAccurateBits);
38
39 template<int Size>
40 inline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits)
41 {
42         Vector<float, Size> res;
43         for (int ndx = 0; ndx < Size; ndx++)
44                 res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]);
45         return res;
46 }
47
48 template<int Size>
49 inline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits)
50 {
51         Vector<float, Size> res;
52         for (int ndx = 0; ndx < Size; ndx++)
53                 res[ndx] = computeFixedPointError(numAccurateBits[ndx]);
54         return res;
55 }
56
57 // Sampler introspection
58
59 inline bool isNearestMipmapFilter (const Sampler::FilterMode mode)
60 {
61         return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST;
62 }
63
64 inline bool isLinearMipmapFilter (const Sampler::FilterMode mode)
65 {
66         return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR;
67 }
68
69 inline bool isMipmapFilter (const Sampler::FilterMode mode)
70 {
71         return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode);
72 }
73
74 inline bool isLinearFilter (const Sampler::FilterMode mode)
75 {
76         return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR;
77 }
78
79 inline bool isNearestFilter (const Sampler::FilterMode mode)
80 {
81         return !isLinearFilter(mode);
82 }
83
84 inline Sampler::FilterMode getLevelFilter (const Sampler::FilterMode mode)
85 {
86         return isLinearFilter(mode) ? Sampler::LINEAR : Sampler::NEAREST;
87 }
88
89 inline bool isWrapModeSupported (const Sampler::WrapMode mode)
90 {
91         return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL;
92 }
93
94 // Misc utilities
95
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);
98
99 Sampler         getUnnormalizedCoordSampler                     (const Sampler& sampler);
100 int                     wrap                                                            (Sampler::WrapMode mode, int c, int size);
101
102 } // TexVerifierUtil
103 } // tcu
104
105 #endif // _TCUTEXVERIFIERUTIL_HPP