1e5c31af7Sopenharmony_ci------------------------------------------------------------------------- 2e5c31af7Sopenharmony_cidrawElements Quality Program Test Specification 3e5c31af7Sopenharmony_ci----------------------------------------------- 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ciCopyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci 7e5c31af7Sopenharmony_ciLicensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ciyou may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ciYou may obtain a copy of the License at 10e5c31af7Sopenharmony_ci 11e5c31af7Sopenharmony_ci http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci 13e5c31af7Sopenharmony_ciUnless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_cidistributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ciWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ciSee the License for the specific language governing permissions and 17e5c31af7Sopenharmony_cilimitations under the License. 18e5c31af7Sopenharmony_ci------------------------------------------------------------------------- 19e5c31af7Sopenharmony_ci Precision tests for built-in functions 20e5c31af7Sopenharmony_ci 21e5c31af7Sopenharmony_ciTests: 22e5c31af7Sopenharmony_ci + dEQP-GLES3.functional.shaders.builtin_functions.precision.* 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ciThese tests check that the GLSL built-in numerical functions produce 26e5c31af7Sopenharmony_ciresults that are compliant with the range and precision requirements in 27e5c31af7Sopenharmony_cithe GLSL ES specification. 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ciThe tests operate by calling the functions with predefined (mostly 30e5c31af7Sopenharmony_cirandom) input values in either the vertex or the fragment shader. The 31e5c31af7Sopenharmony_ciresult is stored in a transform feedback buffer or in a framebuffer 32e5c31af7Sopenharmony_cipixel, and then read and compared to a reference interval of acceptable 33e5c31af7Sopenharmony_civalues. Functions are tested with all possible vector and matrix sizes. 34e5c31af7Sopenharmony_ciIn the test log floating point numbers are printed out as hexadecimal 35e5c31af7Sopenharmony_ciconstants of the form used in e.g. C99. 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_ciWhere the GLSL specification does not specify a particular precision, 38e5c31af7Sopenharmony_cithe tests try to make reasonable requirements. When behavior at 39e5c31af7Sopenharmony_ciinfinities hasn't been otherwise specified, C99 Appendix F is used as a 40e5c31af7Sopenharmony_cireference. Moreover, the highp precision requirements have been adapted 41e5c31af7Sopenharmony_cito lowp and mediump precisions even though the GLSL specification 42e5c31af7Sopenharmony_cidoesn't provide any guarantees about them. For instance, mediump and 43e5c31af7Sopenharmony_cilowp operations are expected to produce either an infinity or the 44e5c31af7Sopenharmony_cimaximum/minimum value on overflow. 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ciThe acceptable results are constrained further by only allowing values 47e5c31af7Sopenharmony_cifrom within the codomain of the function. Thus, for instance, sin(x) is 48e5c31af7Sopenharmony_cinot allowed to return a number greater than 1 even when when the nominal 49e5c31af7Sopenharmony_cierror bound would be greater. 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ciA number of functions have been defined as derived forms. This means 52e5c31af7Sopenharmony_cithat they are required to produce only results that their expansions 53e5c31af7Sopenharmony_cicould produce, given the precision requirements for the constituent 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_cioperations. 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_ci* Arithmetic operations 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ciThese are as defined in the GLSL ES specification. 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ci| operation | precision | domain | 62e5c31af7Sopenharmony_ci|-----------+-----------+-----------------------------| 63e5c31af7Sopenharmony_ci| x + y | < 1 ULP | | 64e5c31af7Sopenharmony_ci| x / y | 2.5 ULP | 2^-126 <= abs(y) <= 2^127-1 | 65e5c31af7Sopenharmony_ci| x - y | < 1 ULP | | 66e5c31af7Sopenharmony_ci| x * y | < 1 ULP | | 67e5c31af7Sopenharmony_ci 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ci* Trigonometric functions 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_ciThe precisions for trigonometric functions have been adapted from OpenCL 72e5c31af7Sopenharmony_cifast relaxed math and half-float specifications. Hyperbolic functions 73e5c31af7Sopenharmony_citake their precisions from standard formulae as derived forms. 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_ciPrimitives: 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci| function | precision | domain | prec qual | 78e5c31af7Sopenharmony_ci|------------+----------------+---------------------+---------------| 79e5c31af7Sopenharmony_ci| sin(x) | 2^-11 | -pi <= x <= pi | highp | 80e5c31af7Sopenharmony_ci| | 2^-12 * abs(x) | elsewhere | highp | 81e5c31af7Sopenharmony_ci| | 2 ULP | | mediump, lowp | 82e5c31af7Sopenharmony_ci| cos(x) | 2^-11 | -pi <= x <= pi | highp | 83e5c31af7Sopenharmony_ci| | 2^-12 * abs(x) | elsewhere | highp | 84e5c31af7Sopenharmony_ci| | 2 ULP | | mediump, lowp | 85e5c31af7Sopenharmony_ci| asin(x) | 4 ULP | -1 <= x <= 1 | highp | 86e5c31af7Sopenharmony_ci| | 2 ULP | -1 <= x <= 1 | mediump, lowp | 87e5c31af7Sopenharmony_ci| acos(x) | 4 ULP | -1 <= x <= 1 | highp | 88e5c31af7Sopenharmony_ci| | 2 ULP | -1 <= x <= 1 | mediump, lowp | 89e5c31af7Sopenharmony_ci| atan(x, y) | 6 ULP | !(x == 0 && y == 0) | highp | 90e5c31af7Sopenharmony_ci| | 2 ULP | !(x == 0 && y == 0) | mediump, lowp | 91e5c31af7Sopenharmony_ci| atan(x) | 5 ULP | | highp | 92e5c31af7Sopenharmony_ci| | 2 ULP | | mediump, lowp | 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ciDerived functions: 95e5c31af7Sopenharmony_ci 96e5c31af7Sopenharmony_ci| function | defined as | 97e5c31af7Sopenharmony_ci|------------+----------------------------------| 98e5c31af7Sopenharmony_ci| radians(x) | (pi / 180.0) * x | 99e5c31af7Sopenharmony_ci| degrees(x) | (180.0 / pi) * x | 100e5c31af7Sopenharmony_ci| tan(x) | sin(x) * (1.0 / cos(x)) | 101e5c31af7Sopenharmony_ci| sinh(x) | (exp(x) - exp(-x)) / 2.0 | 102e5c31af7Sopenharmony_ci| cosh(x) | (exp(x) + exp(-x)) / 2.0 | 103e5c31af7Sopenharmony_ci| tanh(x) | sinh(x) / cosh(x) | 104e5c31af7Sopenharmony_ci| asinh(x) | log(x + sqrt(x * x + 1.0)) | 105e5c31af7Sopenharmony_ci| acosh(x) | log(x + sqrt((x+1.0) * (x-1.0))) | 106e5c31af7Sopenharmony_ci| atanh(x) | 0.5 * log(1.0 + x / (1.0 - x)) | 107e5c31af7Sopenharmony_ci 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci* Exponential functions 110e5c31af7Sopenharmony_ci 111e5c31af7Sopenharmony_ciThe precisions for exponential functions for mediump and lowp have been 112e5c31af7Sopenharmony_ciadapted from the OpenCL half-float specification. 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ciPrimitives: 115e5c31af7Sopenharmony_ci 116e5c31af7Sopenharmony_ci| function | precision | domain | prec qual | 117e5c31af7Sopenharmony_ci|----------------+----------------------+----------------------+-----------| 118e5c31af7Sopenharmony_ci| exp(x) | (3 + 2 * abs(x)) ULP | | highp | 119e5c31af7Sopenharmony_ci| | (2 + 2 * abs(x)) ULP | | mediump | 120e5c31af7Sopenharmony_ci| | 2 ULP | | lowp | 121e5c31af7Sopenharmony_ci| log(x) | 2^-21 | 0.5 <= x && x <= 0.5 | highp | 122e5c31af7Sopenharmony_ci| | 3 ULP | elsewhere | highp | 123e5c31af7Sopenharmony_ci| | 2^-7 | 0.5 <= x && x <= 0.5 | mediump | 124e5c31af7Sopenharmony_ci| | 2 ULP | elsewhere | mediump | 125e5c31af7Sopenharmony_ci| | 2 ULP | | lowp | 126e5c31af7Sopenharmony_ci| exp(x) | (3 + 2 * abs(x)) ULP | | highp | 127e5c31af7Sopenharmony_ci| | (2 + 2 * abs(x)) ULP | | mediump | 128e5c31af7Sopenharmony_ci| | 2 ULP | | lowp | 129e5c31af7Sopenharmony_ci| log2(x) | 2^-21 | 0.5 <= x && x <= 0.5 | highp | 130e5c31af7Sopenharmony_ci| | 3 ULP | elsewhere | highp | 131e5c31af7Sopenharmony_ci| | 2^-7 | 0.5 <= x && x <= 0.5 | mediump | 132e5c31af7Sopenharmony_ci| | 2 ULP | elsewhere | mediump | 133e5c31af7Sopenharmony_ci| | 2 ULP | | lowp | 134e5c31af7Sopenharmony_ci| inversesqrt(x) | 2 ULP | | | 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_ciDerived functions: 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ci| function | defined as | 139e5c31af7Sopenharmony_ci|----------+----------------------| 140e5c31af7Sopenharmony_ci| pow(x) | exp2(y * log2(x)) | 141e5c31af7Sopenharmony_ci| sqrt(x) | 1.0 / inversesqrt(x) | 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci* Common functions 145e5c31af7Sopenharmony_ci 146e5c31af7Sopenharmony_ciThe operations that don't do any arithmetic are required to produce 147e5c31af7Sopenharmony_ciexact results. The round() function is allowed to round in either 148e5c31af7Sopenharmony_cidirection on a tie. 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ciPrimitives: 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci| function | precision | 153e5c31af7Sopenharmony_ci|------------------+-----------| 154e5c31af7Sopenharmony_ci| abs(x) | 0 | 155e5c31af7Sopenharmony_ci| sign(x) | 0 | 156e5c31af7Sopenharmony_ci| floor(x) | 0 | 157e5c31af7Sopenharmony_ci| trunc(x) | 0 | 158e5c31af7Sopenharmony_ci| round(x) | special | 159e5c31af7Sopenharmony_ci| roundEven(x) | 0 | 160e5c31af7Sopenharmony_ci| ceil(x) | 0 | 161e5c31af7Sopenharmony_ci| modf(x, i) | 0 | 162e5c31af7Sopenharmony_ci| min(x, y) | 0 | 163e5c31af7Sopenharmony_ci| max(x, y) | 0 | 164e5c31af7Sopenharmony_ci| clamp(x, lo, hi) | 0 | 165e5c31af7Sopenharmony_ci| step(edge, x) | 0 | 166e5c31af7Sopenharmony_ci 167e5c31af7Sopenharmony_ciDerived functions: 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci| function | defined as | 170e5c31af7Sopenharmony_ci|-----------------------+------------------------------------------------| 171e5c31af7Sopenharmony_ci| fract(x) | x - floor(x) | 172e5c31af7Sopenharmony_ci| mod(x, y) | x - y * floor(x / y) | 173e5c31af7Sopenharmony_ci| mix(x, y, a) | x * (1 - a) + y * a | 174e5c31af7Sopenharmony_ci| smoothstep(e0, e1, x) | { float t = clamp((x - e0) / (e1 - e0),0,1); | 175e5c31af7Sopenharmony_ci| | return t * t * (3 - 2*t); } | 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_ci* Geometric and matrix functions 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ciThese are generally defined as derived forms with reference algorithms. 181e5c31af7Sopenharmony_ciFor determinant and inverse operations only 2x2 matrices are tested: 182e5c31af7Sopenharmony_cithere are a number of possible algorithms for larger matrices, and the 183e5c31af7Sopenharmony_cispecification does not provide precision requirements for these operations. 184