1 #ifndef _TCUTEXLOOKUPVERIFIER_HPP
2 #define _TCUTEXLOOKUPVERIFIER_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 Texture lookup simulator that is capable of verifying generic
24 * lookup results based on accuracy parameters.
25 *//*--------------------------------------------------------------------*/
27 #include "tcuDefs.hpp"
28 #include "tcuTexture.hpp"
33 /*--------------------------------------------------------------------*//*!
34 * \brief Generic lookup precision parameters.
36 * For (assumed) floating-point values recision is defined by number of
37 * accurate bits in significand. Maximum number of accurate bits supported
38 * is 23 (limit of single-precision FP).
40 * For fixed-point values precision is defined by number of bits in
41 * the fractional part.
42 *//*--------------------------------------------------------------------*/
43 struct LookupPrecision
45 IVec3 coordBits; //!< Bits per coordinate component before any transformations. Assumed to be floating-point.
46 IVec3 uvwBits; //!< Bits per component in final per-level UV(W) coordinates. Assumed to be fixed-point.
47 Vec4 colorThreshold; //!< Threshold for match.
48 BVec4 colorMask; //!< Channel mask for comparison.
50 LookupPrecision (void)
53 , colorThreshold (0.0f)
59 struct IntLookupPrecision
61 IVec3 coordBits; //!< Bits per coordinate component before any transformations. Assumed to be floating-point.
62 IVec3 uvwBits; //!< Bits per component in final per-level UV(W) coordinates. Assumed to be fixed-point.
63 UVec4 colorThreshold; //!< Threshold for match.
64 BVec4 colorMask; //!< Channel mask for comparison.
66 IntLookupPrecision (void)
75 /*--------------------------------------------------------------------*//*!
76 * \brief Lod computation precision parameters.
77 *//*--------------------------------------------------------------------*/
80 int derivateBits; //!< Number of bits in derivates. (Floating-point)
81 int lodBits; //!< Number of bits in final lod (accuracy of log2()). (Fixed-point)
90 enum TexLookupScaleMode
92 TEX_LOOKUP_SCALE_MINIFY = 0,
93 TEX_LOOKUP_SCALE_MAGNIFY,
95 TEX_LOOKUP_SCALE_MODE_LAST
98 Vec4 computeFixedPointThreshold (const IVec4& bits);
99 Vec4 computeFloatingPointThreshold (const IVec4& bits, const Vec4& value);
101 Vec2 computeLodBoundsFromDerivates (const float dudx, const float dudy, const LodPrecision& prec);
102 Vec2 computeLodBoundsFromDerivates (const float dudx, const float dvdx, const float dudy, const float dvdy, const LodPrecision& prec);
103 Vec2 computeLodBoundsFromDerivates (const float dudx, const float dvdx, const float dwdx, const float dudy, const float dvdy, const float dwdy, const LodPrecision& prec);
104 Vec2 computeCubeLodBoundsFromDerivates (const Vec3& coord, const Vec3& coordDx, const Vec3& coordDy, const int faceSize, const LodPrecision& prec);
106 Vec2 clampLodBounds (const Vec2& lodBounds, const Vec2& lodMinMax, const LodPrecision& prec);
108 bool isLookupResultValid (const Texture1DView& texture, const Sampler& sampler, const LookupPrecision& prec, const float coord, const Vec2& lodBounds, const Vec4& result);
109 bool isLookupResultValid (const Texture2DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result);
110 bool isLookupResultValid (const TextureCubeView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
111 bool isLookupResultValid (const Texture1DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result);
112 bool isLookupResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
113 bool isLookupResultValid (const Texture3DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
114 bool isLookupResultValid (const TextureCubeArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const IVec4& coordBits, const Vec4& coord, const Vec2& lodBounds, const Vec4& result);
116 bool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const float coordX, const int coordY, const Vec4& result);
117 bool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const IVec4& result);
118 bool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const UVec4& result);
120 bool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result);
121 bool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const IVec4& result);
122 bool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const UVec4& result);
124 bool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec3& coord, const Vec4& result);
125 bool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const IVec4& result);
126 bool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const UVec4& result);
128 bool isLinearSampleResultValid (const ConstPixelBufferAccess& level, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result);
130 bool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result);
131 bool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result);
132 bool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result);
134 bool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result);
135 bool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result);
136 bool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result);
138 // \note For cube textures, gather is only defined without offset.
139 bool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, int componentNdx, const Vec4& result);
140 bool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec4& result);
141 bool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const UVec4& result);
145 #endif // _TCUTEXLOOKUPVERIFIER_HPP