• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    AMD_conservative_depth
4
5Name String
6
7    GL_AMD_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
18Status
19
20    In Progress
21
22Version
23
24    Last Modified Date:         10/25/2010
25    Author Revision:            4
26
27Number
28
29    385
30
31Dependencies
32
33    OpenGL 3.0 is required.
34
35    This extension is written against the OpenGL Shading Language Version 4.00.
36
37Overview
38
39    There is a common optimization for hardware accelerated implementation of
40    OpenGL which relies on an early depth test to be run before the fragment
41    shader so that the shader evaluation can be skipped if the fragment ends
42    up being discarded because it is occluded.
43
44    This optimization does not affect the final rendering, and is typically
45    possible when the fragment does not change the depth programmatically.
46    (i.e.: it does not write to the built-in gl_FragDepth output). There are,
47    however a class of operations on the depth in the shader which could
48    still be performed while allowing the early depth test to operate.
49
50    This extension allows the application to pass enough information to the
51    GL implementation to activate such optimizations safely.
52
53New Procedures and Functions
54
55    None.
56
57New Tokens
58
59    None.
60
61Additions to the AGL/GLX/WGL Specifications
62
63    None.
64
65Modifications to the OpenGL Shading Language Specification version 1.50.9
66
67Additions to Chapter 1 of the OpenGL Shading Language 4.00.08 Specification (Introduction)
68
69    None.
70
71Additions to Chapter 2 of the OpenGL Shading Language 4.00.08 Specification (Overview of OpenGL Shading)
72
73    None.
74
75Additions to Chapter 3 of the OpenGL Shading Language 4.00.08 Specification (Basics)
76
77    Add a new Section 3.3.x, GL_AMD_conservative_depth Extension
78
79    Including the following line in a shader can be used to control the language
80    features described in this extension:
81
82        #extension GL_AMD_conservative_depth: <behavior>
83
84    where <behavior> is as described in section 3.3.
85
86    A new preprocessor #define is added to the OpenGL Shading Language:
87
88        #define GL_AMD_conservative_depth 1
89
90Additions to Chapter 4 of the OpenGL Shading Language 4.00.08 Specification (Variables and Types)
91
92    Modify Section 4.3.8.2 (Output Layout Qualifiers) page 47
93
94    Modify the paragraph beginning: "Fragment shaders allow output layout
95    qualifiers only..."
96
97        Fragment shaders allow output layout qualifiers only on the interface
98        out, or for the purposes of redeclaring the built-in variable
99        gl_FragDepth (see Section 7.1, Built-In Language Variables).
100
101    Insert the following before the paragraph beginning: "Geometry shaders can
102    have three types of output layout qualifiers..."
103
104        The built-in fragment shader variable gl_FragDepth may be redeclared
105        using one of the following layout qualifiers.
106
107        layout-qualifier-id
108            depth_any
109            depth_greater
110            depth_less
111            depth_unchanged
112
113        For example:
114
115            layout (depth_greater) out float gl_FragDepth;
116
117        The layout qualifier for gl_FragDepth controls how the GL will interpret
118        assignments to the gl_FragDepth out variable for the purpose of depth
119        testing. Any assignment to gl_FragDepth will be honored by the shader
120        and the updated value of gl_FragDepth will still be written to the
121        depth buffer if it is determined that the depth write should occur.
122        However, depending on the layout qualifier of gl_FragDepth and the
123        current state of depth testing, the GL may perform optimizations or
124        reordering of operations to depth test and writes to improve performance.
125
126        By default, gl_FragDepth assumes the <depth_any> layout qualifier. When
127        the layout qualifier for gl_FragDepth is <depth_any>, the shader compiler
128        will note any assignment to gl_FragDepth modifying it in an unknown way,
129        and depth testing will always be performed after the shader has executed.
130        When the layout qualifier is <depth_greater>, the GL will assume that
131        any modification of gl_FragDepth will only increase its value. When the
132        layout qualifier is <depth_less>, the GL will assume that any
133        modification of gl_FragDepth will only decrease its value. When the
134        layout qualifier is <depth_unchanged>, the shader compiler will honor
135        any modification to gl_FragDepth, but the rest of the GL assume that
136        gl_FragDepth is not assigned a new value.
137
138        If a shader redeclares gl_FragDepth using the <depth_greater>,
139        <depth_less> or <depth_unchanged> and then violates this contract, the
140        results of the depth test may be inaccurate and any resulting rendering
141        will produce undefined results. However, no error is generated.
142
143        Redeclarations are performed as follows:
144
145            out float gl_FragDepth;                             // Redeclaration that changes nothing is allowed
146
147            layout (depth_any) out float gl_FragDepth;          // Assume that gl_FragDepth may be modified in any way
148            layout (depth_greater) out float gl_FragDepth;      // Assume that gl_FragDepth may be modified such that its value will only increase
149            layout (depth_less) out float gl_FragDepth;         // Assume that gl_FragDepth may be modified such that its value will only decrease
150            layout (depth_unchanged) out float gl_FragDepth;    // Assume that gl_FragDepth will not be modified
151
152        If gl_FragDepth is redeclared in any fragment shader in a program, it must
153        be redeclared in all fragment shaders in that program that have static
154        assignments to gl_FragDepth. All redeclarations of gl_FragDepth in all
155        fragment shaders in a single program must have the same set of qualifiers.
156        Within any shader, the first redeclarations of gl_FragDepth must appear
157        before any use of gl_FragDepth. The built-in gl_FragDepth is only
158        predeclared in fragment shaders, so redeclaring it in any other shader
159        language will be illegal.
160
161Revision History
162
163    Rev.    Date      Author    Changes
164    ----  --------    --------  -----------------------------------------
165
166     4    25/10/2010  gsellers  Apply patch from idr.
167     3    04/01/2010  gsellers  Minor cleanup. Update to GLSL 4.00.
168     2    12/01/2009  gsellers  Internal updates
169     1    11/03/2009  pboudier  Initial draft
170