• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_conservative_depth
4
5Name String
6
7    GL_EXT_conservative_depth
8
9Contact
10
11    Tobias Hector, Imagination Technologies (tobias.hector 'at' imgtec.com)
12
13Contributors
14
15    Contributors to the original ARB_conservative_depth
16    Ian Romanick
17    Daniel Koch
18
19Status
20
21    Final
22
23Version
24
25    Last Modified Date:         14/09/2016
26    Author Revision:            3
27
28Number
29
30    OpenGL ES Extension #268
31
32Dependencies
33
34    OpenGL ES 3.0 is required.
35
36    This extension is written against the OpenGL ES Shading Language Version 3.00.6
37
38Overview
39
40    There is a common optimization for hardware accelerated implementation of
41    OpenGL ES which relies on an early depth test to be run before the fragment
42    shader so that the shader evaluation can be skipped if the fragment ends
43    up being discarded because it is occluded.
44
45    This optimization does not affect the final rendering, and is typically
46    possible when the fragment does not change the depth programmatically.
47    (i.e.: it does not write to the built-in gl_FragDepth output). There are,
48    however a class of operations on the depth in the shader which could
49    still be performed while allowing the early depth test to operate.
50
51    This extension allows the application to pass enough information to the
52    GL implementation to activate such optimizations safely.
53
54New Procedures and Functions
55
56    None.
57
58New Tokens
59
60    None.
61
62Additions to Chapter 3 of the OpenGL ES Shading Language 3.00.06 Specification (Basics)
63
64    Add a new Section 3.5.x, GL_EXT_conservative_depth Extension
65
66    Including the following line in a shader can be used to control the language
67    features described in this extension:
68
69        #extension GL_EXT_conservative_depth: <behavior>
70
71    where <behavior> is as described in section 3.5.
72
73    A new preprocessor #define is added to the OpenGL Shading Language:
74
75        #define GL_EXT_conservative_depth 1
76
77Additions to Chapter 4 of the OpenGL Shading Language 3.00.06 Specification (Variables and Types)
78
79    Modify Section 4.3.8.2 (Output Layout Qualifiers) page 47
80
81    Modify the paragraph beginning: "Fragment shaders allow output layout
82    qualifiers only..."
83
84        Fragment shaders allow output layout qualifiers only on the interface
85        out, or for the purposes of redeclaring the built-in variable
86        gl_FragDepth (see Section 7.2, Fragment Shader Special Variables).
87
88    Insert the following at the end of the section:
89
90        The built-in fragment shader variable gl_FragDepth may be redeclared using
91        one of the following layout qualifiers.
92
93        layout-qualifier-id
94            depth_any
95            depth_greater
96            depth_less
97            depth_unchanged
98
99        For example:
100
101            layout (depth_greater) out float gl_FragDepth;
102
103        The layout qualifier for gl_FragDepth specifies constraints on the final
104        value of gl_FragDepth written by any shader invocation.  GL implementations
105        may perform optimizations assuming that the depth test fails (or passes)
106        for a given fragment if all values of gl_FragDepth consistent with the layout
107        qualifier would fail (or pass).  If the final value of gl_FragDepth
108        is inconsistent with its layout qualifier, the result of the depth test for
109        the corresponding fragment is undefined.  However, no error will be
110        generated in this case.  When the depth test passes and depth writes are
111        enabled, the value written to the depth buffer is always the value of
112        gl_FragDepth, whether or not it is consistent with the layout qualifier.
113
114        By default, gl_FragDepth assumes the <depth_any> layout qualifier. When
115        the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler
116        will note any assignment to gl_FragDepth modifying it in an unknown way,
117        and depth testing will always be performed after the shader has executed.
118        When the layout qualifier is "depth_greater", the GL will assume that the
119        final value of gl_FragDepth is greater than or equal to the fragment's
120        interpolated depth value, as given by the <z> component of gl_FragCoord.
121        When the layout qualifier is <depth_less>, the GL will assume that any
122        modification of gl_FragDepth will only decrease its value. When the
123        layout qualifier is <depth_unchanged>, the shader compiler will honor
124        any modification to gl_FragDepth, but the rest of the GL assume that
125        gl_FragDepth is not assigned a new value.
126
127        Redeclarations of gl_FragDepth are performed as follows:
128
129            // redeclaration that changes nothing is allowed
130
131            out float gl_FragDepth;
132
133            // assume it may be modified in any way
134            layout (depth_any) out float gl_FragDepth;
135
136            // assume it may be modified such that its value will only increase
137            layout (depth_greater) out float gl_FragDepth;
138
139            // assume it may be modified such that its value will only decrease
140            layout (depth_less) out float gl_FragDepth;
141
142            // assume it will not be modified
143            layout (depth_unchanged) out float gl_FragDepth;
144
145        Within any shader, the first redeclarations of gl_FragDepth must appear
146        before any use of gl_FragDepth. The built-in gl_FragDepth is only
147        predeclared in fragment shaders, so redeclaring it in any other shader
148        language will be illegal.
149
150Revision History
151
152    Rev.  Date        Author   Changes
153    ----  ----------  -------  -------------------------------------------------
154    1     08/09/2016  thector  Initial draft based on ARB_conservative_depth
155    2     12/09/2016  thector  Converted to EXT as per feedback from Ian Romanick
156    3     14/09/2016  thector  Removed reference to multiple fragment shaders as per Daniel Koch's feedback
157