1e5c31af7Sopenharmony_ci#ifndef _TCUTEXVERIFIERUTIL_HPP 2e5c31af7Sopenharmony_ci#define _TCUTEXVERIFIERUTIL_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 Internal utilities shared between TexLookup and TexCompare verifiers. 24e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 27e5c31af7Sopenharmony_ci#include "tcuTexture.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_cinamespace tcu 30e5c31af7Sopenharmony_ci{ 31e5c31af7Sopenharmony_cinamespace TexVerifierUtil 32e5c31af7Sopenharmony_ci{ 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ci// Error bound utilities 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_cifloat computeFloatingPointError (const float value, const int numAccurateBits); 37e5c31af7Sopenharmony_cifloat computeFixedPointError (const int numAccurateBits); 38e5c31af7Sopenharmony_cifloat computeColorBitsError (const int bits, const int numAccurateBits); 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_citemplate<int Size> 41e5c31af7Sopenharmony_ciinline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits) 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_ci Vector<float, Size> res; 44e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < Size; ndx++) 45e5c31af7Sopenharmony_ci res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]); 46e5c31af7Sopenharmony_ci return res; 47e5c31af7Sopenharmony_ci} 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_citemplate<int Size> 50e5c31af7Sopenharmony_ciinline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits) 51e5c31af7Sopenharmony_ci{ 52e5c31af7Sopenharmony_ci Vector<float, Size> res; 53e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < Size; ndx++) 54e5c31af7Sopenharmony_ci res[ndx] = computeFixedPointError(numAccurateBits[ndx]); 55e5c31af7Sopenharmony_ci return res; 56e5c31af7Sopenharmony_ci} 57e5c31af7Sopenharmony_ci 58e5c31af7Sopenharmony_citemplate<int Size> 59e5c31af7Sopenharmony_ciinline Vector<float, Size> computeColorBitsError(const Vector<deInt32, Size>& bits, const Vector<deInt32, Size>& numAccurateBits) 60e5c31af7Sopenharmony_ci{ 61e5c31af7Sopenharmony_ci Vector<float, Size> res; 62e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < Size; ndx++) 63e5c31af7Sopenharmony_ci res[ndx] = computeColorBitsError(bits[ndx], numAccurateBits[ndx]); 64e5c31af7Sopenharmony_ci return res; 65e5c31af7Sopenharmony_ci} 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci// Sampler introspection 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ciinline bool isNearestMipmapFilter(const Sampler::FilterMode mode) 70e5c31af7Sopenharmony_ci{ 71e5c31af7Sopenharmony_ci return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::CUBIC_MIPMAP_NEAREST; 72e5c31af7Sopenharmony_ci} 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ciinline bool isLinearMipmapFilter(const Sampler::FilterMode mode) 75e5c31af7Sopenharmony_ci{ 76e5c31af7Sopenharmony_ci return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR || mode == Sampler::CUBIC_MIPMAP_LINEAR; 77e5c31af7Sopenharmony_ci} 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ciinline bool isMipmapFilter(const Sampler::FilterMode mode) 80e5c31af7Sopenharmony_ci{ 81e5c31af7Sopenharmony_ci return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode); 82e5c31af7Sopenharmony_ci} 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ciinline bool isNearestFilter(const Sampler::FilterMode mode) 85e5c31af7Sopenharmony_ci{ 86e5c31af7Sopenharmony_ci return mode == Sampler::NEAREST || mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::NEAREST_MIPMAP_LINEAR; 87e5c31af7Sopenharmony_ci} 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ciinline bool isLinearFilter(const Sampler::FilterMode mode) 90e5c31af7Sopenharmony_ci{ 91e5c31af7Sopenharmony_ci return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR; 92e5c31af7Sopenharmony_ci} 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ciinline bool isCubicFilter(const Sampler::FilterMode mode) 95e5c31af7Sopenharmony_ci{ 96e5c31af7Sopenharmony_ci return mode == Sampler::CUBIC || mode == Sampler::CUBIC_MIPMAP_NEAREST || mode == Sampler::CUBIC_MIPMAP_LINEAR; 97e5c31af7Sopenharmony_ci} 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ciinline Sampler::FilterMode getLevelFilter(const Sampler::FilterMode mode) 100e5c31af7Sopenharmony_ci{ 101e5c31af7Sopenharmony_ci if (isNearestFilter(mode)) 102e5c31af7Sopenharmony_ci return Sampler::NEAREST; 103e5c31af7Sopenharmony_ci if (isLinearFilter(mode)) 104e5c31af7Sopenharmony_ci return Sampler::LINEAR; 105e5c31af7Sopenharmony_ci return Sampler::CUBIC; 106e5c31af7Sopenharmony_ci} 107e5c31af7Sopenharmony_ci 108e5c31af7Sopenharmony_ciinline bool isWrapModeSupported (const Sampler::WrapMode mode) 109e5c31af7Sopenharmony_ci{ 110e5c31af7Sopenharmony_ci return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL; 111e5c31af7Sopenharmony_ci} 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ci// Misc utilities 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ciVec2 computeNonNormalizedCoordBounds (const bool normalizedCoords, const int dim, const float coord, const int coordBits, const int uvBits); 116e5c31af7Sopenharmony_civoid getPossibleCubeFaces (const Vec3& coord, const IVec3& bits, CubeFace* faces, int& numFaces); 117e5c31af7Sopenharmony_ci 118e5c31af7Sopenharmony_ciSampler getUnnormalizedCoordSampler (const Sampler& sampler); 119e5c31af7Sopenharmony_ciint wrap (Sampler::WrapMode mode, int c, int size); 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci} // TexVerifierUtil 122e5c31af7Sopenharmony_ci} // tcu 123e5c31af7Sopenharmony_ci 124e5c31af7Sopenharmony_ci#endif // _TCUTEXVERIFIERUTIL_HPP 125