• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_conservative_depth
4
5Name String
6
7    GL_ARB_conservative_depth
8
9Contact
10
11    Graham Sellers, AMD (graham.sellers 'at' amd.com)
12
13Contributors
14
15    Pierre Boudier, AMD
16    Graham Sellers, AMD
17
18Notice
19
20    Copyright (c) 2011-2013 The Khronos Group Inc. Copyright terms at
21        http://www.khronos.org/registry/speccopyright.html
22
23Specification Update Policy
24
25    Khronos-approved extension specifications are updated in response to
26    issues and bugs prioritized by the Khronos OpenGL Working Group. For
27    extensions which have been promoted to a core Specification, fixes will
28    first appear in the latest version of that core Specification, and will
29    eventually be backported to the extension document. This policy is
30    described in more detail at
31        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
32
33Status
34
35    Complete. Approved by the ARB on 2011/06/20.
36    Approved by the Khronos Promoters on 2011/07/29.
37
38Version
39
40    Last Modified Date:         06/20/2010
41    Author Revision:            6
42
43Number
44
45    ARB Extension #111
46
47Dependencies
48
49    OpenGL 3.0 is required.
50
51    This extension is written against the OpenGL Shading Language Version 4.00.
52
53Overview
54
55    There is a common optimization for hardware accelerated implementation of
56    OpenGL which relies on an early depth test to be run before the fragment
57    shader so that the shader evaluation can be skipped if the fragment ends
58    up being discarded because it is occluded.
59
60    This optimization does not affect the final rendering, and is typically
61    possible when the fragment does not change the depth programmatically.
62    (i.e.: it does not write to the built-in gl_FragDepth output). There are,
63    however a class of operations on the depth in the shader which could
64    still be performed while allowing the early depth test to operate.
65
66    This extension allows the application to pass enough information to the
67    GL implementation to activate such optimizations safely.
68
69New Procedures and Functions
70
71    None.
72
73New Tokens
74
75    None.
76
77Additions to the AGL/GLX/WGL Specifications
78
79    None.
80
81Modifications to the OpenGL Shading Language Specification version 1.50.9
82
83Additions to Chapter 1 of the OpenGL Shading Language 4.00.08 Specification (Introduction)
84
85    None.
86
87Additions to Chapter 2 of the OpenGL Shading Language 4.00.08 Specification (Overview of OpenGL Shading)
88
89    None.
90
91Additions to Chapter 3 of the OpenGL Shading Language 4.00.08 Specification (Basics)
92
93    Add a new Section 3.3.x, GL_ARB_conservative_depth Extension
94
95    Including the following line in a shader can be used to control the language
96    features described in this extension:
97
98        #extension GL_ARB_conservative_depth: <behavior>
99
100    where <behavior> is as described in section 3.3.
101
102    A new preprocessor #define is added to the OpenGL Shading Language:
103
104        #define GL_ARB_conservative_depth 1
105
106Additions to Chapter 4 of the OpenGL Shading Language 4.00.08 Specification (Variables and Types)
107
108    Modify Section 4.3.8.2 (Output Layout Qualifiers) page 47
109
110    Modify the paragraph beginning: "Fragment shaders allow output layout
111    qualifiers only..."
112
113        Fragment shaders allow output layout qualifiers only on the interface
114        out, or for the purposes of redeclaring the built-in variable
115        gl_FragDepth (ses Section 7.2, Fragment Shader Special Variables).
116
117    Insert the following before the paragraph beginning: "Geometry shaders can
118    have three types of output layout qualifiers..."
119
120        The built-in fragment shader variable gl_FragDepth may be redeclared using
121        one of the following layout qualifiers.
122
123        layout-qualifier-id
124            depth_any
125            depth_greater
126            depth_less
127            depth_unchanged
128
129        For example:
130
131            layout (depth_greater) out float gl_FragDepth;
132
133        The layout qualifier for gl_FragDepth specifies constraints on the final
134        value of gl_FragDepth written by any shader invocation.  GL implementations
135        may perform optimizations assuming that the depth test fails (or passes)
136        for a given fragment if all values of gl_FragDepth consistent with the layout
137        qualifier would fail (or pass).  If the final value of gl_FragDepth
138        is inconsistent with its layout qualifier, the result of the depth test for
139        the corresponding fragment is undefined.  However, no error will be
140        generated in this case.  When the depth test passes and depth writes are
141        enabled, the value written to the depth buffer is always the value of
142        gl_FragDepth, whether or not it is consistent with the layout qualifier.
143
144        By default, gl_FragDepth assumes the <depth_any> layout qualifier. When
145        the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler
146        will note any assignment to gl_FragDepth modifying it in an unknown way,
147        and depth testing will always be performed after the shader has executed.
148        When the layout qualifier is "depth_greater", the GL will assume that the
149        final value of gl_FragDepth is greater than or equal to the fragment's
150        interpolated depth value, as given by the <z> component of gl_FragCoord.
151        When the layout qualifier is <depth_less>, the GL will assume that any
152        modification of gl_FragDepth will only decrease its value. When the
153        layout qualifier is <depth_unchanged>, the shader compiler will honor
154        any modification to gl_FragDepth, but the rest of the GL assume that
155        gl_FragDepth is not assigned a new value.
156
157        Redeclarations of gl_FragDepth are performed as follows:
158
159            // redeclaration that changes nothing is allowed
160
161            out float gl_FragDepth;
162
163            // assume it may be modified in any way
164            layout (depth_any) out float gl_FragDepth;
165
166            // assume it may be modified such that its value will only increase
167            layout (depth_greater) out float gl_FragDepth;
168
169            // assume it may be modified such that its value will only decrease
170            layout (depth_less) out float gl_FragDepth;
171
172            // assume it will not be modified
173            layout (depth_unchanged) out float gl_FragDepth;
174
175        If gl_FragDepth is redeclared in any fragment shader in a program, it must
176        be redeclared in all fragment shaders in that program that have static
177        assignments to gl_FragDepth. All redeclarations of gl_FragDepth in all
178        fragment shaders in a single program must have the same set of qualifiers.
179        Within any shader, the first redeclarations of gl_FragDepth must appear
180        before any use of gl_FragDepth. The built-in gl_FragDepth is only
181        predeclared in fragment shaders, so redeclaring it in any other shader
182        language will be illegal.
183
184Revision History
185
186    Rev.    Date      Author    Changes
187    ----  --------    --------  -----------------------------------------
188     6     6/20/2011  wwlk      approved by ARB
189     5     1/27/2011  johnk     Update with edits from reviews of the core spec.
190     4    12/17/2010  johnk     Correct gl_Depth -> gl_FragDepth
191                                Make the code examples fit within the width of
192                                actual paper.
193
194     3    04/01/2010  gsellers  Minor cleanup. Update to GLSL 4.00.
195     2    12/01/2009  gsellers  Internal updates
196     1    11/03/2009  pboudier  Initial draft
197