1e5c31af7Sopenharmony_ci#ifndef _TCUTEXLOOKUPVERIFIER_HPP 2e5c31af7Sopenharmony_ci#define _TCUTEXLOOKUPVERIFIER_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * drawElements Quality Program Tester Core 5e5c31af7Sopenharmony_ci * ---------------------------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci * limitations under the License. 20e5c31af7Sopenharmony_ci * 21e5c31af7Sopenharmony_ci *//*! 22e5c31af7Sopenharmony_ci * \file 23e5c31af7Sopenharmony_ci * \brief Texture lookup simulator that is capable of verifying generic 24e5c31af7Sopenharmony_ci * lookup results based on accuracy parameters. 25e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 28e5c31af7Sopenharmony_ci#include "tcuTexture.hpp" 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_cinamespace tcu 31e5c31af7Sopenharmony_ci{ 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 34e5c31af7Sopenharmony_ci * \brief Generic lookup precision parameters. 35e5c31af7Sopenharmony_ci * 36e5c31af7Sopenharmony_ci * For (assumed) floating-point values recision is defined by number of 37e5c31af7Sopenharmony_ci * accurate bits in significand. Maximum number of accurate bits supported 38e5c31af7Sopenharmony_ci * is 23 (limit of single-precision FP). 39e5c31af7Sopenharmony_ci * 40e5c31af7Sopenharmony_ci * For fixed-point values precision is defined by number of bits in 41e5c31af7Sopenharmony_ci * the fractional part. 42e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 43e5c31af7Sopenharmony_cistruct LookupPrecision 44e5c31af7Sopenharmony_ci{ 45e5c31af7Sopenharmony_ci IVec3 coordBits; //!< Bits per coordinate component before any transformations. Assumed to be floating-point. 46e5c31af7Sopenharmony_ci IVec3 uvwBits; //!< Bits per component in final per-level UV(W) coordinates. Assumed to be fixed-point. 47e5c31af7Sopenharmony_ci Vec4 colorThreshold; //!< Threshold for match. 48e5c31af7Sopenharmony_ci BVec4 colorMask; //!< Channel mask for comparison. 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ci LookupPrecision (void) 51e5c31af7Sopenharmony_ci : coordBits (22) 52e5c31af7Sopenharmony_ci , uvwBits (16) 53e5c31af7Sopenharmony_ci , colorThreshold (0.0f) 54e5c31af7Sopenharmony_ci , colorMask (true) 55e5c31af7Sopenharmony_ci { 56e5c31af7Sopenharmony_ci } 57e5c31af7Sopenharmony_ci}; 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_cistruct IntLookupPrecision 60e5c31af7Sopenharmony_ci{ 61e5c31af7Sopenharmony_ci IVec3 coordBits; //!< Bits per coordinate component before any transformations. Assumed to be floating-point. 62e5c31af7Sopenharmony_ci IVec3 uvwBits; //!< Bits per component in final per-level UV(W) coordinates. Assumed to be fixed-point. 63e5c31af7Sopenharmony_ci UVec4 colorThreshold; //!< Threshold for match. 64e5c31af7Sopenharmony_ci BVec4 colorMask; //!< Channel mask for comparison. 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_ci IntLookupPrecision (void) 67e5c31af7Sopenharmony_ci : coordBits (22) 68e5c31af7Sopenharmony_ci , uvwBits (16) 69e5c31af7Sopenharmony_ci , colorThreshold (0) 70e5c31af7Sopenharmony_ci , colorMask (true) 71e5c31af7Sopenharmony_ci { 72e5c31af7Sopenharmony_ci } 73e5c31af7Sopenharmony_ci}; 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 76e5c31af7Sopenharmony_ci * \brief Lod computation precision parameters. 77e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 78e5c31af7Sopenharmony_cistruct LodPrecision 79e5c31af7Sopenharmony_ci{ 80e5c31af7Sopenharmony_ci int derivateBits; //!< Number of bits in derivates. (Floating-point) 81e5c31af7Sopenharmony_ci int lodBits; //!< Number of bits in final lod (accuracy of log2()). (Fixed-point) 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci LodPrecision (void) 84e5c31af7Sopenharmony_ci : derivateBits (22) 85e5c31af7Sopenharmony_ci , lodBits (16) 86e5c31af7Sopenharmony_ci { 87e5c31af7Sopenharmony_ci } 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci LodPrecision (int derivateBits_, int lodBits_) 90e5c31af7Sopenharmony_ci : derivateBits (derivateBits_) 91e5c31af7Sopenharmony_ci , lodBits (lodBits_) 92e5c31af7Sopenharmony_ci {} 93e5c31af7Sopenharmony_ci}; 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_cienum TexLookupScaleMode 96e5c31af7Sopenharmony_ci{ 97e5c31af7Sopenharmony_ci TEX_LOOKUP_SCALE_MINIFY = 0, 98e5c31af7Sopenharmony_ci TEX_LOOKUP_SCALE_MAGNIFY, 99e5c31af7Sopenharmony_ci 100e5c31af7Sopenharmony_ci TEX_LOOKUP_SCALE_MODE_LAST 101e5c31af7Sopenharmony_ci}; 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ciVec4 computeFixedPointThreshold (const IVec4& bits); 104e5c31af7Sopenharmony_ciVec4 computeFloatingPointThreshold (const IVec4& bits, const Vec4& value); 105e5c31af7Sopenharmony_ciVec4 computeColorBitsThreshold (const IVec4& bits, const IVec4& numAccurateBits); 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ciVec2 computeLodBoundsFromDerivates (const float dudx, const float dudy, const LodPrecision& prec); 108e5c31af7Sopenharmony_ciVec2 computeLodBoundsFromDerivates (const float dudx, const float dvdx, const float dudy, const float dvdy, const LodPrecision& prec); 109e5c31af7Sopenharmony_ciVec2 computeLodBoundsFromDerivates (const float dudx, const float dvdx, const float dwdx, const float dudy, const float dvdy, const float dwdy, const LodPrecision& prec); 110e5c31af7Sopenharmony_ciVec2 computeCubeLodBoundsFromDerivates (const Vec3& coord, const Vec3& coordDx, const Vec3& coordDy, const int faceSize, const LodPrecision& prec); 111e5c31af7Sopenharmony_ci 112e5c31af7Sopenharmony_ciVec2 clampLodBounds (const Vec2& lodBounds, const Vec2& lodMinMax, const LodPrecision& prec); 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_cibool isLookupResultValid (const Texture1DView& texture, const Sampler& sampler, const LookupPrecision& prec, const float coord, const Vec2& lodBounds, const Vec4& result); 115e5c31af7Sopenharmony_cibool isLookupResultValid (const Texture2DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result); 116e5c31af7Sopenharmony_cibool isLookupResultValid (const TextureCubeView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result); 117e5c31af7Sopenharmony_cibool isLookupResultValid (const Texture1DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const Vec2& lodBounds, const Vec4& result); 118e5c31af7Sopenharmony_cibool isLookupResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result); 119e5c31af7Sopenharmony_cibool isLookupResultValid (const Texture3DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, const Vec2& lodBounds, const Vec4& result); 120e5c31af7Sopenharmony_cibool isLookupResultValid (const TextureCubeArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const IVec4& coordBits, const Vec4& coord, const Vec2& lodBounds, const Vec4& result); 121e5c31af7Sopenharmony_ci 122e5c31af7Sopenharmony_cibool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const float coordX, const int coordY, const Vec4& result); 123e5c31af7Sopenharmony_cibool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const IVec4& result); 124e5c31af7Sopenharmony_cibool isLevel1DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const float coordX, const int coordY, const UVec4& result); 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_cibool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result); 127e5c31af7Sopenharmony_cibool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const IVec4& result); 128e5c31af7Sopenharmony_cibool isLevel2DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec2& coord, const int coordZ, const UVec4& result); 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_cibool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const LookupPrecision& prec, const Vec3& coord, const Vec4& result); 131e5c31af7Sopenharmony_cibool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const IVec4& result); 132e5c31af7Sopenharmony_cibool isLevel3DLookupResultValid (const ConstPixelBufferAccess& access, const Sampler& sampler, TexLookupScaleMode scaleMode, const IntLookupPrecision& prec, const Vec3& coord, const UVec4& result); 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_cibool isLinearSampleResultValid (const ConstPixelBufferAccess& level, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, const int coordZ, const Vec4& result); 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result); 137e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result); 138e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec2& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result); 139e5c31af7Sopenharmony_ci 140e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const Vec4& result); 141e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const IVec4& result); 142e5c31af7Sopenharmony_cibool isGatherOffsetsResultValid (const Texture2DArrayView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec2 (&offsets)[4], const UVec4& result); 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci// \note For cube textures, gather is only defined without offset. 145e5c31af7Sopenharmony_cibool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const LookupPrecision& prec, const Vec3& coord, int componentNdx, const Vec4& result); 146e5c31af7Sopenharmony_cibool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const IVec4& result); 147e5c31af7Sopenharmony_cibool isGatherResultValid (const TextureCubeView& texture, const Sampler& sampler, const IntLookupPrecision& prec, const Vec3& coord, int componentNdx, const UVec4& result); 148e5c31af7Sopenharmony_ci 149e5c31af7Sopenharmony_ci} // tcu 150e5c31af7Sopenharmony_ci 151e5c31af7Sopenharmony_ci#endif // _TCUTEXLOOKUPVERIFIER_HPP 152