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 }; 89 90 enum TexLookupScaleMode 91 { 92 TEX_LOOKUP_SCALE_MINIFY = 0, 93 TEX_LOOKUP_SCALE_MAGNIFY, 94 95 TEX_LOOKUP_SCALE_MODE_LAST 96 }; 97 98 Vec4 computeFixedPointThreshold (const IVec4& bits); 99 Vec4 computeFloatingPointThreshold (const IVec4& bits, const Vec4& value); 100 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); 105 106 Vec2 clampLodBounds (const Vec2& lodBounds, const Vec2& lodMinMax, const LodPrecision& prec); 107 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); 115 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); 119 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); 123 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); 127 128 bool isLinearSampleResultValid (const ConstPixelBufferAccess& level, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result); 129 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); 133 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); 137 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); 142 143 } // tcu 144 145 #endif // _TCUTEXLOOKUPVERIFIER_HPP 146