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) : coordBits(22), uvwBits(16), colorThreshold(0.0f), colorMask(true) 51 { 52 } 53 }; 54 55 struct IntLookupPrecision 56 { 57 IVec3 coordBits; //!< Bits per coordinate component before any transformations. Assumed to be floating-point. 58 IVec3 uvwBits; //!< Bits per component in final per-level UV(W) coordinates. Assumed to be fixed-point. 59 UVec4 colorThreshold; //!< Threshold for match. 60 BVec4 colorMask; //!< Channel mask for comparison. 61 IntLookupPrecisiontcu::IntLookupPrecision62 IntLookupPrecision(void) : coordBits(22), uvwBits(16), colorThreshold(0), colorMask(true) 63 { 64 } 65 }; 66 67 /*--------------------------------------------------------------------*//*! 68 * \brief Lod computation precision parameters. 69 *//*--------------------------------------------------------------------*/ 70 struct LodPrecision 71 { 72 int derivateBits; //!< Number of bits in derivates. (Floating-point) 73 int lodBits; //!< Number of bits in final lod (accuracy of log2()). (Fixed-point) 74 LodPrecisiontcu::LodPrecision75 LodPrecision(void) : derivateBits(22), lodBits(16) 76 { 77 } 78 LodPrecisiontcu::LodPrecision79 LodPrecision(int derivateBits_, int lodBits_) : derivateBits(derivateBits_), lodBits(lodBits_) 80 { 81 } 82 }; 83 84 enum TexLookupScaleMode 85 { 86 TEX_LOOKUP_SCALE_MINIFY = 0, 87 TEX_LOOKUP_SCALE_MAGNIFY, 88 89 TEX_LOOKUP_SCALE_MODE_LAST 90 }; 91 92 Vec4 computeFixedPointThreshold(const IVec4 &bits); 93 Vec4 computeFloatingPointThreshold(const IVec4 &bits, const Vec4 &value); 94 Vec4 computeColorBitsThreshold(const IVec4 &bits, const IVec4 &numAccurateBits); 95 96 Vec2 computeLodBoundsFromDerivates(const float dudx, const float dudy, const LodPrecision &prec); 97 Vec2 computeLodBoundsFromDerivates(const float dudx, const float dvdx, const float dudy, const float dvdy, 98 const LodPrecision &prec); 99 Vec2 computeLodBoundsFromDerivates(const float dudx, const float dvdx, const float dwdx, const float dudy, 100 const float dvdy, const float dwdy, const LodPrecision &prec); 101 Vec2 computeCubeLodBoundsFromDerivates(const Vec3 &coord, const Vec3 &coordDx, const Vec3 &coordDy, const int faceSize, 102 const LodPrecision &prec); 103 104 Vec2 clampLodBounds(const Vec2 &lodBounds, const Vec2 &lodMinMax, const LodPrecision &prec); 105 106 bool isLookupResultValid(const Texture1DView &texture, const Sampler &sampler, const LookupPrecision &prec, 107 const float coord, const Vec2 &lodBounds, const Vec4 &result); 108 bool isLookupResultValid(const Texture2DView &texture, const Sampler &sampler, const LookupPrecision &prec, 109 const Vec2 &coord, const Vec2 &lodBounds, const Vec4 &result); 110 bool isLookupResultValid(const TextureCubeView &texture, const Sampler &sampler, const LookupPrecision &prec, 111 const Vec3 &coord, const Vec2 &lodBounds, const Vec4 &result); 112 bool isLookupResultValid(const Texture1DArrayView &texture, const Sampler &sampler, const LookupPrecision &prec, 113 const Vec2 &coord, const Vec2 &lodBounds, const Vec4 &result); 114 bool isLookupResultValid(const Texture2DArrayView &texture, const Sampler &sampler, const LookupPrecision &prec, 115 const Vec3 &coord, const Vec2 &lodBounds, const Vec4 &result); 116 bool isLookupResultValid(const Texture3DView &texture, const Sampler &sampler, const LookupPrecision &prec, 117 const Vec3 &coord, const Vec2 &lodBounds, const Vec4 &result); 118 bool isLookupResultValid(const TextureCubeArrayView &texture, const Sampler &sampler, const LookupPrecision &prec, 119 const IVec4 &coordBits, const Vec4 &coord, const Vec2 &lodBounds, const Vec4 &result); 120 121 bool isLevel1DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 122 TexLookupScaleMode scaleMode, const LookupPrecision &prec, const float coordX, 123 const int coordY, const Vec4 &result); 124 bool isLevel1DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 125 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const float coordX, 126 const int coordY, const IVec4 &result); 127 bool isLevel1DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 128 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const float coordX, 129 const int coordY, const UVec4 &result); 130 131 bool isLevel2DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 132 TexLookupScaleMode scaleMode, const LookupPrecision &prec, const Vec2 &coord, 133 const int coordZ, const Vec4 &result); 134 bool isLevel2DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 135 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const Vec2 &coord, 136 const int coordZ, const IVec4 &result); 137 bool isLevel2DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 138 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const Vec2 &coord, 139 const int coordZ, const UVec4 &result); 140 141 bool isLevel3DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 142 TexLookupScaleMode scaleMode, const LookupPrecision &prec, const Vec3 &coord, 143 const Vec4 &result); 144 bool isLevel3DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 145 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const Vec3 &coord, 146 const IVec4 &result); 147 bool isLevel3DLookupResultValid(const ConstPixelBufferAccess &access, const Sampler &sampler, 148 TexLookupScaleMode scaleMode, const IntLookupPrecision &prec, const Vec3 &coord, 149 const UVec4 &result); 150 151 bool isLinearSampleResultValid(const ConstPixelBufferAccess &level, const Sampler &sampler, const LookupPrecision &prec, 152 const Vec2 &coord, const int coordZ, const Vec4 &result); 153 154 bool isGatherOffsetsResultValid(const Texture2DView &texture, const Sampler &sampler, const LookupPrecision &prec, 155 const Vec2 &coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4 &result); 156 bool isGatherOffsetsResultValid(const Texture2DView &texture, const Sampler &sampler, const IntLookupPrecision &prec, 157 const Vec2 &coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4 &result); 158 bool isGatherOffsetsResultValid(const Texture2DView &texture, const Sampler &sampler, const IntLookupPrecision &prec, 159 const Vec2 &coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4 &result); 160 161 bool isGatherOffsetsResultValid(const Texture2DArrayView &texture, const Sampler &sampler, const LookupPrecision &prec, 162 const Vec3 &coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4 &result); 163 bool isGatherOffsetsResultValid(const Texture2DArrayView &texture, const Sampler &sampler, 164 const IntLookupPrecision &prec, const Vec3 &coord, int componentNdx, 165 const IVec2 (&offsets)[4], const IVec4 &result); 166 bool isGatherOffsetsResultValid(const Texture2DArrayView &texture, const Sampler &sampler, 167 const IntLookupPrecision &prec, const Vec3 &coord, int componentNdx, 168 const IVec2 (&offsets)[4], const UVec4 &result); 169 170 // \note For cube textures, gather is only defined without offset. 171 bool isGatherResultValid(const TextureCubeView &texture, const Sampler &sampler, const LookupPrecision &prec, 172 const Vec3 &coord, int componentNdx, const Vec4 &result); 173 bool isGatherResultValid(const TextureCubeView &texture, const Sampler &sampler, const IntLookupPrecision &prec, 174 const Vec3 &coord, int componentNdx, const IVec4 &result); 175 bool isGatherResultValid(const TextureCubeView &texture, const Sampler &sampler, const IntLookupPrecision &prec, 176 const Vec3 &coord, int componentNdx, const UVec4 &result); 177 178 } // namespace tcu 179 180 #endif // _TCUTEXLOOKUPVERIFIER_HPP 181