Fix missing dependency on sparse binds
[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 float           computeColorBitsError                           (const int bits, const int numAccurateBits);
39
40 template<int Size>
41 inline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits)
42 {
43         Vector<float, Size> res;
44         for (int ndx = 0; ndx < Size; ndx++)
45                 res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]);
46         return res;
47 }
48
49 template<int Size>
50 inline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits)
51 {
52         Vector<float, Size> res;
53         for (int ndx = 0; ndx < Size; ndx++)
54                 res[ndx] = computeFixedPointError(numAccurateBits[ndx]);
55         return res;
56 }
57
58 template<int Size>
59 inline Vector<float, Size> computeColorBitsError(const Vector<deInt32, Size>& bits, const Vector<deInt32, Size>& numAccurateBits)
60 {
61         Vector<float, Size> res;
62         for (int ndx = 0; ndx < Size; ndx++)
63                 res[ndx] = computeColorBitsError(bits[ndx], numAccurateBits[ndx]);
64         return res;
65 }
66
67 // Sampler introspection
68
69 inline bool isNearestMipmapFilter(const Sampler::FilterMode mode)
70 {
71         return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::CUBIC_MIPMAP_NEAREST;
72 }
73
74 inline bool isLinearMipmapFilter(const Sampler::FilterMode mode)
75 {
76         return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR || mode == Sampler::CUBIC_MIPMAP_LINEAR;
77 }
78
79 inline bool isMipmapFilter(const Sampler::FilterMode mode)
80 {
81         return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode);
82 }
83
84 inline bool isNearestFilter(const Sampler::FilterMode mode)
85 {
86         return mode == Sampler::NEAREST || mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::NEAREST_MIPMAP_LINEAR;
87 }
88
89 inline bool isLinearFilter(const Sampler::FilterMode mode)
90 {
91         return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR;
92 }
93
94 inline bool isCubicFilter(const Sampler::FilterMode mode)
95 {
96         return mode == Sampler::CUBIC || mode == Sampler::CUBIC_MIPMAP_NEAREST || mode == Sampler::CUBIC_MIPMAP_LINEAR;
97 }
98
99 inline Sampler::FilterMode getLevelFilter(const Sampler::FilterMode mode)
100 {
101         if (isNearestFilter(mode))
102                 return Sampler::NEAREST;
103         if (isLinearFilter(mode))
104                 return Sampler::LINEAR;
105         return Sampler::CUBIC;
106 }
107
108 inline bool isWrapModeSupported (const Sampler::WrapMode mode)
109 {
110         return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL;
111 }
112
113 // Misc utilities
114
115 Vec2            computeNonNormalizedCoordBounds         (const bool normalizedCoords, const int dim, const float coord, const int coordBits, const int uvBits);
116 void            getPossibleCubeFaces                            (const Vec3& coord, const IVec3& bits, CubeFace* faces, int& numFaces);
117
118 Sampler         getUnnormalizedCoordSampler                     (const Sampler& sampler);
119 int                     wrap                                                            (Sampler::WrapMode mode, int c, int size);
120
121 } // TexVerifierUtil
122 } // tcu
123
124 #endif // _TCUTEXVERIFIERUTIL_HPP