15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_conservative_depth 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName String 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_conservative_depth 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Graham Sellers, AMD (graham.sellers 'at' amd.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Pierre Boudier, AMD 165bd8deadSopenharmony_ci Graham Sellers, AMD 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciNotice 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Copyright (c) 2011-2013 The Khronos Group Inc. Copyright terms at 215bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciSpecification Update Policy 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 265bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 275bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 285bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 295bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 305bd8deadSopenharmony_ci described in more detail at 315bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciStatus 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Complete. Approved by the ARB on 2011/06/20. 365bd8deadSopenharmony_ci Approved by the Khronos Promoters on 2011/07/29. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ciVersion 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci Last Modified Date: 06/20/2010 415bd8deadSopenharmony_ci Author Revision: 6 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ciNumber 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci ARB Extension #111 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ciDependencies 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci OpenGL 3.0 is required. 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci This extension is written against the OpenGL Shading Language Version 4.00. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ciOverview 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci There is a common optimization for hardware accelerated implementation of 565bd8deadSopenharmony_ci OpenGL which relies on an early depth test to be run before the fragment 575bd8deadSopenharmony_ci shader so that the shader evaluation can be skipped if the fragment ends 585bd8deadSopenharmony_ci up being discarded because it is occluded. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci This optimization does not affect the final rendering, and is typically 615bd8deadSopenharmony_ci possible when the fragment does not change the depth programmatically. 625bd8deadSopenharmony_ci (i.e.: it does not write to the built-in gl_FragDepth output). There are, 635bd8deadSopenharmony_ci however a class of operations on the depth in the shader which could 645bd8deadSopenharmony_ci still be performed while allowing the early depth test to operate. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci This extension allows the application to pass enough information to the 675bd8deadSopenharmony_ci GL implementation to activate such optimizations safely. 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciNew Procedures and Functions 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci None. 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ciNew Tokens 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci None. 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci None. 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification version 1.50.9 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ciAdditions to Chapter 1 of the OpenGL Shading Language 4.00.08 Specification (Introduction) 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci None. 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL Shading Language 4.00.08 Specification (Overview of OpenGL Shading) 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci None. 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL Shading Language 4.00.08 Specification (Basics) 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci Add a new Section 3.3.x, GL_ARB_conservative_depth Extension 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci Including the following line in a shader can be used to control the language 965bd8deadSopenharmony_ci features described in this extension: 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci #extension GL_ARB_conservative_depth: <behavior> 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci where <behavior> is as described in section 3.3. 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ci #define GL_ARB_conservative_depth 1 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL Shading Language 4.00.08 Specification (Variables and Types) 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci Modify Section 4.3.8.2 (Output Layout Qualifiers) page 47 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci Modify the paragraph beginning: "Fragment shaders allow output layout 1115bd8deadSopenharmony_ci qualifiers only..." 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci Fragment shaders allow output layout qualifiers only on the interface 1145bd8deadSopenharmony_ci out, or for the purposes of redeclaring the built-in variable 1155bd8deadSopenharmony_ci gl_FragDepth (ses Section 7.2, Fragment Shader Special Variables). 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci Insert the following before the paragraph beginning: "Geometry shaders can 1185bd8deadSopenharmony_ci have three types of output layout qualifiers..." 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci The built-in fragment shader variable gl_FragDepth may be redeclared using 1215bd8deadSopenharmony_ci one of the following layout qualifiers. 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci layout-qualifier-id 1245bd8deadSopenharmony_ci depth_any 1255bd8deadSopenharmony_ci depth_greater 1265bd8deadSopenharmony_ci depth_less 1275bd8deadSopenharmony_ci depth_unchanged 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci For example: 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci layout (depth_greater) out float gl_FragDepth; 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci The layout qualifier for gl_FragDepth specifies constraints on the final 1345bd8deadSopenharmony_ci value of gl_FragDepth written by any shader invocation. GL implementations 1355bd8deadSopenharmony_ci may perform optimizations assuming that the depth test fails (or passes) 1365bd8deadSopenharmony_ci for a given fragment if all values of gl_FragDepth consistent with the layout 1375bd8deadSopenharmony_ci qualifier would fail (or pass). If the final value of gl_FragDepth 1385bd8deadSopenharmony_ci is inconsistent with its layout qualifier, the result of the depth test for 1395bd8deadSopenharmony_ci the corresponding fragment is undefined. However, no error will be 1405bd8deadSopenharmony_ci generated in this case. When the depth test passes and depth writes are 1415bd8deadSopenharmony_ci enabled, the value written to the depth buffer is always the value of 1425bd8deadSopenharmony_ci gl_FragDepth, whether or not it is consistent with the layout qualifier. 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci By default, gl_FragDepth assumes the <depth_any> layout qualifier. When 1455bd8deadSopenharmony_ci the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler 1465bd8deadSopenharmony_ci will note any assignment to gl_FragDepth modifying it in an unknown way, 1475bd8deadSopenharmony_ci and depth testing will always be performed after the shader has executed. 1485bd8deadSopenharmony_ci When the layout qualifier is "depth_greater", the GL will assume that the 1495bd8deadSopenharmony_ci final value of gl_FragDepth is greater than or equal to the fragment's 1505bd8deadSopenharmony_ci interpolated depth value, as given by the <z> component of gl_FragCoord. 1515bd8deadSopenharmony_ci When the layout qualifier is <depth_less>, the GL will assume that any 1525bd8deadSopenharmony_ci modification of gl_FragDepth will only decrease its value. When the 1535bd8deadSopenharmony_ci layout qualifier is <depth_unchanged>, the shader compiler will honor 1545bd8deadSopenharmony_ci any modification to gl_FragDepth, but the rest of the GL assume that 1555bd8deadSopenharmony_ci gl_FragDepth is not assigned a new value. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci Redeclarations of gl_FragDepth are performed as follows: 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci // redeclaration that changes nothing is allowed 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci out float gl_FragDepth; 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci // assume it may be modified in any way 1645bd8deadSopenharmony_ci layout (depth_any) out float gl_FragDepth; 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci // assume it may be modified such that its value will only increase 1675bd8deadSopenharmony_ci layout (depth_greater) out float gl_FragDepth; 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci // assume it may be modified such that its value will only decrease 1705bd8deadSopenharmony_ci layout (depth_less) out float gl_FragDepth; 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci // assume it will not be modified 1735bd8deadSopenharmony_ci layout (depth_unchanged) out float gl_FragDepth; 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci If gl_FragDepth is redeclared in any fragment shader in a program, it must 1765bd8deadSopenharmony_ci be redeclared in all fragment shaders in that program that have static 1775bd8deadSopenharmony_ci assignments to gl_FragDepth. All redeclarations of gl_FragDepth in all 1785bd8deadSopenharmony_ci fragment shaders in a single program must have the same set of qualifiers. 1795bd8deadSopenharmony_ci Within any shader, the first redeclarations of gl_FragDepth must appear 1805bd8deadSopenharmony_ci before any use of gl_FragDepth. The built-in gl_FragDepth is only 1815bd8deadSopenharmony_ci predeclared in fragment shaders, so redeclaring it in any other shader 1825bd8deadSopenharmony_ci language will be illegal. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ciRevision History 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci Rev. Date Author Changes 1875bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 1885bd8deadSopenharmony_ci 6 6/20/2011 wwlk approved by ARB 1895bd8deadSopenharmony_ci 5 1/27/2011 johnk Update with edits from reviews of the core spec. 1905bd8deadSopenharmony_ci 4 12/17/2010 johnk Correct gl_Depth -> gl_FragDepth 1915bd8deadSopenharmony_ci Make the code examples fit within the width of 1925bd8deadSopenharmony_ci actual paper. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci 3 04/01/2010 gsellers Minor cleanup. Update to GLSL 4.00. 1955bd8deadSopenharmony_ci 2 12/01/2009 gsellers Internal updates 1965bd8deadSopenharmony_ci 1 11/03/2009 pboudier Initial draft 197