• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_frag_depth
4
5Name Strings
6
7    GL_EXT_frag_depth
8
9Contributors
10
11    Maurice Ribble
12    Robert Simpson
13    Jeff Leger
14    Bruce Merry
15    Acorn Pooley
16
17Contact
18
19    Maurice Ribble (mribble 'at' qualcomm.com)
20
21Notice
22
23    None
24
25Status
26
27    Draft
28
29Version
30
31    Date: July 21, 2010
32
33Number
34
35    OpenGL ES Extension #86
36
37Dependencies
38
39    OpenGL ES 2.0 is required.
40
41    This extension is written against the OpenGL ES 2.0 specification, and
42    the OpenGL ES Shading Language 1.0.17 specification.
43
44    OES_fragment_precision_high affects the definitions of this extension.
45
46Overview
47
48    This extension adds the ability to set the depth value of a fragment from
49    within the fragment shader.  Then this per-fragment depth value is used
50    for depth testing.  This extension adds a built-in GLSL fragment shader
51    special varible to set the depth value.
52
53    Much graphics hardware has the ability to do early depth testing before the
54    fragment shader.  On such hardware there may be a performance penality for
55    using this feature so use this feature only when needed.
56
57Issues
58
59    (1) Should the GLSL keyword be gl_FragDepth or gl_FragDepthEXT?
60
61    RESOLVED: OpenGL has discussed this in the past and the agreement was that
62    we should use gl_FragDepthEXT.
63
64    (2) What should the precission qualifier be for gl_FragDepthEXT?
65
66    RESOLVED: If the OES_fragment_precision_high is supported then highp is
67    used, but if OES_fragment_precision_high not supported then mediump is
68    used.
69
70New Procedures and Functions
71
72    None
73
74New Tokens
75
76    None
77
78New Keywords
79
80    gl_FragDepthEXT
81
82New Built-in Functions
83
84    None
85
86New Macro Definitions
87
88    #define GL_EXT_frag_depth 1
89
90Additions to Appendix A.3 Invariance Rules
91
92    Rule 4: All fragment shaders that either conditionally or unconditionally
93    assign gl_FragCoord.z to gl_FragDepthEXT are depth-invariant with respect
94    to each other, for those fragments where the assignment to gl_FragDepthEXT
95    actually is done.
96
97Additions to Chapter 7 of the OpenGL ES Shading Language specification:
98
99    Make the following changes to section 7.2 (Fragment Shader Special
100    Varibles).
101
102    Replace the last sentence in the first paragraph with this:
103
104    "Fragment shaders output values to the OpenGL ES pipeline using the
105    built-in variables gl_FragColor, gl_FragData, and gl_FragDepthEXT, unless the
106    discard keyword is executed."
107
108    Add this between the first and second paragraphs:
109
110    "The built-in varible gl_FragDepthEXT is optional, and must be enabled by
111
112    #extension GL_EXT_frag_depth : enable
113
114    before being used."
115
116    Replace the first sentence in the second paragraph with this:
117
118    "It is not a requirement for the fragment shader to write to gl_FragColor,
119    gl_FragData, or gl_FragDepthEXT."
120
121    Add this paragraph after the paragraph that starts with "Writing to
122    gl_FragColor":
123
124    "Writing to gl_FragDepthEXT will establish the depth value for the fragment
125    being processed. If MSAA is enabled, the depth value is copied to all
126    samples corresponding to the fragment. If depth buffering is enabled, and
127    no shader writes gl_FragDepthEXT, then the fixed function value for depth
128    will be used as the fragment's depth value. If a shader statically assigns
129    a value to gl_FragDepthEXT, and there is an execution path through the
130    shader that does not set gl_FragDepthEXT, then the value of the fragment's
131    depth may be undefined for executions of the shader that take that path.
132    That is, if the set of linked fragment shaders statically contain a write
133    to gl_FragDepthEXT, then it is responsible for always writing it."
134
135    Replace the paragraph that starts with "If a shader executes the discard"
136    with this:
137
138    "If a shader executes the discard keyword, the fragment is discarded, and
139    the values of any user-defined fragment outputs, gl_FragDepthEXT,
140    gl_FragColor, and gl_FragData become irrelevant."
141
142    Replace the last sentence of the 9th paragraph with the following:
143
144    The z component is the depth value that would be used for the fragment's
145    depth if the shader contained no writes to gl_FragDepthEXT.  This is useful
146    for invariance if a shader conditionally computes gl_FragDepthEXT but
147    otherwise wants the fixed functionality fragment depth.
148
149    Add this to the list of built-in varibles:
150
151    If OES_fragment_precision_high is supported add this:
152      "highp float gl_FragDepthEXT;"
153    otherwise add this:
154      "mediump float gl_FragDepthEXT;"
155
156New State
157
158    None
159
160Revision History
161
162    6/14/2010  Created.
163    6/14/2010  Added language to cover MSAA.
164    6/15/2010  Fixed some typos.
165    7/2/2010   Fixed issues from Bruce.
166                Added wording to Appendix A.3.
167                Added issues 1 and 2.
168    7/8/2010   Changed from OES to EXT.
169               Various updates from NV version of this extension.
170    7/21/2010  Resolved issues 1 and 2.
171
172