lin
2025-08-14 dae8bad597b6607a449b32bf76c523423f7720ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _TCUTEXVERIFIERUTIL_HPP
#define _TCUTEXVERIFIERUTIL_HPP
/*-------------------------------------------------------------------------
 * drawElements Quality Program Tester Core
 * ----------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Internal utilities shared between TexLookup and TexCompare verifiers.
 *//*--------------------------------------------------------------------*/
 
#include "tcuDefs.hpp"
#include "tcuTexture.hpp"
 
namespace tcu
{
namespace TexVerifierUtil
{
 
// Error bound utilities
 
float        computeFloatingPointError            (const float value, const int numAccurateBits);
float        computeFixedPointError                (const int numAccurateBits);
 
template<int Size>
inline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits)
{
   Vector<float, Size> res;
   for (int ndx = 0; ndx < Size; ndx++)
       res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]);
   return res;
}
 
template<int Size>
inline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits)
{
   Vector<float, Size> res;
   for (int ndx = 0; ndx < Size; ndx++)
       res[ndx] = computeFixedPointError(numAccurateBits[ndx]);
   return res;
}
 
// Sampler introspection
 
inline bool isNearestMipmapFilter (const Sampler::FilterMode mode)
{
   return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST;
}
 
inline bool isLinearMipmapFilter (const Sampler::FilterMode mode)
{
   return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR;
}
 
inline bool isMipmapFilter (const Sampler::FilterMode mode)
{
   return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode);
}
 
inline bool isLinearFilter (const Sampler::FilterMode mode)
{
   return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR;
}
 
inline bool isNearestFilter (const Sampler::FilterMode mode)
{
   return !isLinearFilter(mode);
}
 
inline Sampler::FilterMode getLevelFilter (const Sampler::FilterMode mode)
{
   return isLinearFilter(mode) ? Sampler::LINEAR : Sampler::NEAREST;
}
 
inline bool isWrapModeSupported (const Sampler::WrapMode mode)
{
   return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL;
}
 
// Misc utilities
 
Vec2        computeNonNormalizedCoordBounds        (const bool normalizedCoords, const int dim, const float coord, const int coordBits, const int uvBits);
void        getPossibleCubeFaces                (const Vec3& coord, const IVec3& bits, CubeFace* faces, int& numFaces);
 
Sampler        getUnnormalizedCoordSampler            (const Sampler& sampler);
int            wrap                                (Sampler::WrapMode mode, int c, int size);
 
} // TexVerifierUtil
} // tcu
 
#endif // _TCUTEXVERIFIERUTIL_HPP