• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _TCUTEXLOOKUPVERIFIER_HPP
2 #define _TCUTEXLOOKUPVERIFIER_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 Texture lookup simulator that is capable of verifying generic
24  *		  lookup results based on accuracy parameters.
25  *//*--------------------------------------------------------------------*/
26 
27 #include "tcuDefs.hpp"
28 #include "tcuTexture.hpp"
29 
30 namespace tcu
31 {
32 
33 /*--------------------------------------------------------------------*//*!
34  * \brief Generic lookup precision parameters.
35  *
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).
39  *
40  * For fixed-point values precision is defined by number of bits in
41  * the fractional part.
42  *//*--------------------------------------------------------------------*/
43 struct LookupPrecision
44 {
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.
49 
LookupPrecisiontcu::LookupPrecision50 	LookupPrecision (void)
51 		: coordBits			(22)
52 		, uvwBits			(16)
53 		, colorThreshold	(0.0f)
54 		, colorMask			(true)
55 	{
56 	}
57 };
58 
59 struct IntLookupPrecision
60 {
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.
65 
IntLookupPrecisiontcu::IntLookupPrecision66 	IntLookupPrecision (void)
67 		: coordBits			(22)
68 		, uvwBits			(16)
69 		, colorThreshold	(0)
70 		, colorMask			(true)
71 	{
72 	}
73 };
74 
75 /*--------------------------------------------------------------------*//*!
76  * \brief Lod computation precision parameters.
77  *//*--------------------------------------------------------------------*/
78 struct LodPrecision
79 {
80 	int			derivateBits;	//!< Number of bits in derivates. (Floating-point)
81 	int			lodBits;		//!< Number of bits in final lod (accuracy of log2()). (Fixed-point)
82 
LodPrecisiontcu::LodPrecision83 	LodPrecision (void)
84 		: derivateBits	(22)
85 		, lodBits		(16)
86 	{
87 	}
88 
LodPrecisiontcu::LodPrecision89 	LodPrecision (int derivateBits_, int lodBits_)
90 		: derivateBits	(derivateBits_)
91 		, lodBits		(lodBits_)
92 	{}
93 };
94 
95 enum TexLookupScaleMode
96 {
97 	TEX_LOOKUP_SCALE_MINIFY	= 0,
98 	TEX_LOOKUP_SCALE_MAGNIFY,
99 
100 	TEX_LOOKUP_SCALE_MODE_LAST
101 };
102 
103 Vec4		computeFixedPointThreshold			(const IVec4& bits);
104 Vec4		computeFloatingPointThreshold		(const IVec4& bits, const Vec4& value);
105 Vec4		computeColorBitsThreshold			(const IVec4& bits, const IVec4& numAccurateBits);
106 
107 Vec2		computeLodBoundsFromDerivates		(const float dudx, const float dudy, const LodPrecision& prec);
108 Vec2		computeLodBoundsFromDerivates		(const float dudx, const float dvdx, const float dudy, const float dvdy, const LodPrecision& prec);
109 Vec2		computeLodBoundsFromDerivates		(const float dudx, const float dvdx, const float dwdx, const float dudy, const float dvdy, const float dwdy, const LodPrecision& prec);
110 Vec2		computeCubeLodBoundsFromDerivates	(const Vec3& coord, const Vec3& coordDx, const Vec3& coordDy, const int faceSize, const LodPrecision& prec);
111 
112 Vec2		clampLodBounds						(const Vec2& lodBounds, const Vec2& lodMinMax, const LodPrecision& prec);
113 
114 bool		isLookupResultValid					(const Texture1DView&			texture, const Sampler& sampler, const LookupPrecision& prec, const float coord, const Vec2& lodBounds, const Vec4& result);
115 bool		isLookupResultValid					(const Texture2DView&			texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result);
116 bool		isLookupResultValid					(const TextureCubeView&			texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
117 bool		isLookupResultValid					(const Texture1DArrayView&		texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result);
118 bool		isLookupResultValid					(const Texture2DArrayView&		texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
119 bool		isLookupResultValid					(const Texture3DView&			texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result);
120 bool		isLookupResultValid					(const TextureCubeArrayView&	texture, const Sampler& sampler, const LookupPrecision& prec, const IVec4& coordBits, const Vec4& coord, const Vec2& lodBounds, const Vec4& result);
121 
122 bool		isLevel1DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const float coordX, const int coordY, const Vec4& result);
123 bool		isLevel1DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const IVec4& result);
124 bool		isLevel1DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const UVec4& result);
125 
126 bool		isLevel2DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result);
127 bool		isLevel2DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const IVec4& result);
128 bool		isLevel2DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const UVec4& result);
129 
130 bool		isLevel3DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec3& coord, const Vec4& result);
131 bool		isLevel3DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const IVec4& result);
132 bool		isLevel3DLookupResultValid			(const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const UVec4& result);
133 
134 bool		isLinearSampleResultValid			(const ConstPixelBufferAccess& level, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result);
135 
136 bool		isGatherOffsetsResultValid			(const Texture2DView&		texture, const Sampler& sampler, const LookupPrecision& prec,		const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result);
137 bool		isGatherOffsetsResultValid			(const Texture2DView&		texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result);
138 bool		isGatherOffsetsResultValid			(const Texture2DView&		texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result);
139 
140 bool		isGatherOffsetsResultValid			(const Texture2DArrayView&	texture, const Sampler& sampler, const LookupPrecision& prec,		const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result);
141 bool		isGatherOffsetsResultValid			(const Texture2DArrayView&	texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result);
142 bool		isGatherOffsetsResultValid			(const Texture2DArrayView&	texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result);
143 
144 // \note For cube textures, gather is only defined without offset.
145 bool		isGatherResultValid					(const TextureCubeView&		texture, const Sampler& sampler, const LookupPrecision& prec,		const Vec3& coord, int componentNdx, const Vec4& result);
146 bool		isGatherResultValid					(const TextureCubeView&		texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec3& coord, int componentNdx, const IVec4& result);
147 bool		isGatherResultValid					(const TextureCubeView&		texture, const Sampler& sampler, const IntLookupPrecision& prec,	const Vec3& coord, int componentNdx, const UVec4& result);
148 
149 } // tcu
150 
151 #endif // _TCUTEXLOOKUPVERIFIER_HPP
152