13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUTEXVERIFIERUTIL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUTEXVERIFIERUTIL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Internal utilities shared between TexLookup and TexCompare verifiers. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace TexVerifierUtil 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Error bound utilities 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat computeFloatingPointError (const float value, const int numAccurateBits); 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat computeFixedPointError (const int numAccurateBits); 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<int Size> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vector<float, Size> computeFloatingPointError (const Vector<float, Size>& value, const Vector<deInt32, Size>& numAccurateBits) 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vector<float, Size> res; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < Size; ndx++) 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry res[ndx] = computeFloatingPointError(value[ndx], numAccurateBits[ndx]); 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return res; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<int Size> 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vector<float, Size> computeFixedPointError (const Vector<deInt32, Size>& numAccurateBits) 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vector<float, Size> res; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < Size; ndx++) 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry res[ndx] = computeFixedPointError(numAccurateBits[ndx]); 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return res; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Sampler introspection 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isNearestMipmapFilter (const Sampler::FilterMode mode) 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return mode == Sampler::NEAREST_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_NEAREST; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isLinearMipmapFilter (const Sampler::FilterMode mode) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return mode == Sampler::NEAREST_MIPMAP_LINEAR || mode == Sampler::LINEAR_MIPMAP_LINEAR; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isMipmapFilter (const Sampler::FilterMode mode) 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isNearestMipmapFilter(mode) || isLinearMipmapFilter(mode); 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isLinearFilter (const Sampler::FilterMode mode) 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return mode == Sampler::LINEAR || mode == Sampler::LINEAR_MIPMAP_NEAREST || mode == Sampler::LINEAR_MIPMAP_LINEAR; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isNearestFilter (const Sampler::FilterMode mode) 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return !isLinearFilter(mode); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Sampler::FilterMode getLevelFilter (const Sampler::FilterMode mode) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isLinearFilter(mode) ? Sampler::LINEAR : Sampler::NEAREST; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isWrapModeSupported (const Sampler::WrapMode mode) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return mode != Sampler::MIRRORED_REPEAT_CL && mode != Sampler::REPEAT_CL; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Misc utilities 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec2 computeNonNormalizedCoordBounds (const bool normalizedCoords, const int dim, const float coord, const int coordBits, const int uvBits); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid getPossibleCubeFaces (const Vec3& coord, const IVec3& bits, CubeFace* faces, int& numFaces); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySampler getUnnormalizedCoordSampler (const Sampler& sampler); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint wrap (Sampler::WrapMode mode, int c, int size); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // TexVerifierUtil 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUTEXVERIFIERUTIL_HPP 106