15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_shader_precision 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_shader_precision 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci John Kessenich ( john.kessenich 'at' intel.com ) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Bill Licea-Kane, AMD 165bd8deadSopenharmony_ci Chris Dodd, Nvidia 175bd8deadSopenharmony_ci Jeff Bolz, Nvidia 185bd8deadSopenharmony_ci Pat Brown, Nvidia 195bd8deadSopenharmony_ci Piers Daniell, Nvidia 205bd8deadSopenharmony_ci Ian Romanick, Intel 215bd8deadSopenharmony_ci Daniel Koch, Transgaming 225bd8deadSopenharmony_ci Frank ??, Qualcomm 235bd8deadSopenharmony_ci Jeremy Sandmel, Apple 245bd8deadSopenharmony_ci Jeff Daniels 255bd8deadSopenharmony_ci Greg Roth, Nvidia 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNotice 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at 305bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciSpecification Update Policy 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 355bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 365bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 375bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 385bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 395bd8deadSopenharmony_ci described in more detail at 405bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciStatus 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci Complete. Approved by the ARB on June 9, 2010. 455bd8deadSopenharmony_ci Approved by the Khronos Board of Promoters on July 23, 2010. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ciVersion 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci Last Modified Date: 2010-04-29 505bd8deadSopenharmony_ci Author Revision: 6.0 515bd8deadSopenharmony_ci $Date$ $Revision$ 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ciNumber 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci ARB Extension #98 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ciDependencies 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci This extension is written against OpenGL 4.0. 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci OpenGL 4.0 is required. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ciOverview 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci This extension more clearly restricts the precision requirements of 665bd8deadSopenharmony_ci implementations of the GLSL specification. These include precision of 675bd8deadSopenharmony_ci arithmetic operations (operators '+', '/', ...), transcendentals (log, exp, 685bd8deadSopenharmony_ci pow, reciprocal sqrt, ...), when NaNs (not a number) and INFs (infinities) will 695bd8deadSopenharmony_ci be supported and generated, and denorm flushing behavior. Trigonometric 705bd8deadSopenharmony_ci built-ins and some other categories of built-ins are not addressed. 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ciIP Status 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci No known IP claims. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ciNew Procedures and Functions 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci None. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciNew Types 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci None. 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ciNew Tokens 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci None, unless we add switches. 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language 4.00 Specification 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 915bd8deadSopenharmony_ci language features described in the extension: 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci #extension GL_ARB_shader_precision : <behavior> 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci where <behavior> is as specified in section 3.3. 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci #define GL_ARB_shader_precision 1 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ciChanges to Section 4.1.4 Floats 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Keep the first two sentences of the second paragraph: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci As an input value to one of the processing units, a single-precision or double- 1065bd8deadSopenharmony_ci precision floating-point variable is expected to match the corresponding IEEE 1075bd8deadSopenharmony_ci 754 floating-point definition for precision and dynamic range. Floating-point 1085bd8deadSopenharmony_ci variables within a shader are also encoded according to the IEEE 754 1095bd8deadSopenharmony_ci specification for single-precision floating-point values.... 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci Remove the remainder of the paragraph: 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci ...However, it is not 1145bd8deadSopenharmony_ci required that the precision of internal processing match the IEEE 754 floating- 1155bd8deadSopenharmony_ci point specification for floating-point operations, but the guidelines for 1165bd8deadSopenharmony_ci precision established by the OpenGL Graphics System Specification must be met. 1175bd8deadSopenharmony_ci Similarly, treatment of conditions such as divide by 0 may lead to an 1185bd8deadSopenharmony_ci unspecified result, but in no case should such a condition lead to the 1195bd8deadSopenharmony_ci interruption or termination of processing. Generally, there are no signaling 1205bd8deadSopenharmony_ci NaNs, and operating on NaNs (Not a Number) or infs (positive or negative 1215bd8deadSopenharmony_ci infinities) gives undefined results. 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci replacing it with the following: 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci ...See section 4.5.1 Range and Precision for more details on precision and 1265bd8deadSopenharmony_ci usage of NaNs (Not a Number) and Infs (positive or negative infinities). 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ciAdd to Section 4.5.1 Range and Precision 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci The precision of stored single and double precision floating-point variables is 1315bd8deadSopenharmony_ci defined by the IEEE 754 standard for 32-bit and 64-bit floating-point numbers. 1325bd8deadSopenharmony_ci This includes support for NaNs (Not a Number) and Infs (positive or negative 1335bd8deadSopenharmony_ci infinities). 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ci The following rules apply to both single and double precision operations: 1365bd8deadSopenharmony_ci Dividing by 0 results in the appropriately signed IEEE Inf. Any denormalized 1375bd8deadSopenharmony_ci value input into a shader or potentially generated by an operation in a shader 1385bd8deadSopenharmony_ci can be flushed to 0. In general, correct signedness of 0 is not required. The 1395bd8deadSopenharmony_ci rounding mode cannot be set and is undefined. Support for signaling NaNs is 1405bd8deadSopenharmony_ci not required and exceptions are never raised. Operations and built-in functions 1415bd8deadSopenharmony_ci that operate on a NaN are not required to return a NaN as the result. 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci Precisions are expressed in terms of maximum relative error in units of ULP 1445bd8deadSopenharmony_ci (units in the last place). 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci For single precision operations 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci Operation Precision 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci a+b, a-b, a*b correctly rounded 1515bd8deadSopenharmony_ci <, =<, ==, >, >= correct result 1525bd8deadSopenharmony_ci a/b, 1.0/b <= 2.5 ULP 1535bd8deadSopenharmony_ci a*b+c correctly rounded single operation or 1545bd8deadSopenharmony_ci sequence of two correctly rounded operations 1555bd8deadSopenharmony_ci fma() same as a*b+c 1565bd8deadSopenharmony_ci pow <= 16 ULP 1575bd8deadSopenharmony_ci exp, exp2 <= 3 ULP 1585bd8deadSopenharmony_ci log, log2 <= 3 ULP 1595bd8deadSopenharmony_ci sqrt <= 3 ULP 1605bd8deadSopenharmony_ci inversesqrt <= 2 ULP 1615bd8deadSopenharmony_ci conversions correctly rounded 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci Built-in functions defined in the specification with an equation built from the 1645bd8deadSopenharmony_ci above operations inherit the above errors. These include, for example, the 1655bd8deadSopenharmony_ci geometric functions, the common functions, and many of the matrix functions. 1665bd8deadSopenharmony_ci Built-in functions not listed above and not defined as equations of the above 1675bd8deadSopenharmony_ci have undefined precision. These include, for example, the trigonometric 1685bd8deadSopenharmony_ci functions and determinant. 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci Double precision operations: 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci TBD. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ciChanges to Section 8.3 Common Functions 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci In the table for intBitsToFloat, uintBitsToFloat, and packDouble2x32, change 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci If an inf or NaN is passed in, it will not signal, and the resulting floating 1795bd8deadSopenharmony_ci point value is unspecified. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci To 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci If an inf or NaN is passed in, it will not signal, and the resulting floating 1845bd8deadSopenharmony_ci point value will be a NaN. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ciIssues 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci1. Operations like fma(), pow(), etc. might not be as precise as specified. To 1895bd8deadSopenharmony_cikeep backward compatibility, this implies vendors finding out what precisions they do 1905bd8deadSopenharmony_cihave. Possibly also either new built-ins or modes are needed to access 1915bd8deadSopenharmony_cihardware's ability to deliver the more precise versions of what is found. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci2. The specification is currently lacking in edge case behavior. How much of this 1945bd8deadSopenharmony_cishould refer to existing IEEE and language specifications versus be reproduced 1955bd8deadSopenharmony_cihere? 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ciRevision History 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci Revision 1, johnk, 2010-04-29 2005bd8deadSopenharmony_ci - Working Draft 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci Revision 2, johnk, 2010-05-06 2035bd8deadSopenharmony_ci - Don't require operations on NaNs to return NaNs. 2045bd8deadSopenharmony_ci - Change from EXT to ARB. 2055bd8deadSopenharmony_ci 206