• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    OES_standard_derivatives
4
5Name Strings
6
7    GL_OES_standard_derivatives
8
9Contributors
10
11    John Kessenich
12    OpenGL Architecture Review Board
13
14Contact
15
16    Benj Lipchak (benj.lipchak 'at' amd.com)
17
18Notice
19
20    Copyright (c) 2005-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 ES 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    Ratified by the Khronos BOP, March 20, 2008.
36
37Version
38
39    Date: July 18, 2007 Revision: 0.99
40
41Number
42
43    OpenGL ES Extension #45
44
45Dependencies
46
47    OpenGL ES 2.0 is required.
48
49Overview
50
51    The standard derivative built-in functions and semantics from OpenGL 2.0 are
52    optional for OpenGL ES 2.0.  When this extension is available, these
53    built-in functions are also available, as is a hint controlling the
54    quality/performance trade off.
55
56Issues
57
58    None.
59
60New Procedures and Functions
61
62    None
63
64New Tokens
65
66    Accepted by the <target> parameter of Hint and by the <pname> parameter of
67    GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
68
69        FRAGMENT_SHADER_DERIVATIVE_HINT_OES            0x8B8B
70
71New Keywords
72
73    None.
74
75New Built-in Functions
76
77    dFdx()
78    dFdy()
79    fwidth()
80
81New Macro Definitions
82
83    #define GL_OES_standard_derivatives 1
84
85Additions to Chapter 5 of the OpenGL ES 2.0 specification:
86
87    In section 5.2 (Hints), add the following to the list of supported hints:
88
89    FRAGMENT_SHADER_DERIVATIVE_HINT_OES
90
91    Derivative accuracy for fragment processing built-in functions dFdx, dFdy
92    and fwidth.
93
94Additions to Chapter 8 of the OpenGL ES Shading Language specification:
95
96    Replace section 8.8 (Fragment Processing Functions) with the following
97    paragraphs:
98
99    Fragment processing functions are only available in fragment shaders.
100
101    The built-in derivative functions dFdx, dFdy, and fwidth are optional, and
102    must be enabled by
103
104    #extension GL_OES_standard_derivatives : enable
105
106    before being used.
107
108    Derivatives may be computationally expensive and/or numerically unstable.
109    Therefore, an OpenGL ES implementation may approximate the true derivatives
110    by using a fast but not entirely accurate derivative computation.
111
112    The expected behavior of a derivative is specified using forward/backward
113    differencing.
114
115    Forward differencing:
116
117    F(x+dx) - F(x)   is approximately equal to    dFdx(x).dx                  1a
118
119    dFdx(x)          is approximately equal to    F(x+dx) - F(x)              1b
120                                                  --------------
121                                                       dx
122
123    Backward differencing:
124
125    F(x-dx) - F(x)   is approximately equal to    -dFdx(x).dx                 2a
126
127    dFdx(x)          is approximately equal to    F(x) - F(x-dx)              2b
128                                                  --------------
129                                                       dx
130
131
132    With single-sample rasterization, dx <= 1.0 in equations 1b and 2b.  For
133    multi-sample rasterization, dx < 2.0 in equations 1b and 2b.
134
135    dFdy is approximated similarly, with y replacing x.
136
137    An OpenGL ES implementation may use the above or other methods to perform
138    the calculation, subject to the following conditions:
139
140    1. The method may use piecewise linear approximations.  Such linear
141       approximations imply that higher order derivatives, dFdx(dFdx(x)) and
142       above, are undefined.
143
144    2. The method may assume that the function evaluated is continuous.
145       Therefore derivatives within the body of a non-uniform conditional are
146       undefined.
147
148    3. The method may differ per fragment, subject to the constraint that the
149       method may vary by window coordinates, not screen coordinates.  The
150       invariance requirement described in section 3.1 of the OpenGL ES 2.0
151       specification is relaxed for derivative calculations, because the method
152       may be a function of fragment location.
153
154    Other properties that are desirable, but not required, are:
155
156    4. Functions should be evaluated within the interior of a primitive
157       (interpolated, not extrapolated).
158
159    5. Functions for dFdx should be evaluated while holding y constant.
160       Functions for dFdy should be evaluated while holding x constant.
161       However, mixed higher order derivatives, like dFdx(dFdy(y)) and
162       dFdy(dFdx(x)) are undefined.
163
164    6. Derivatives of constant arguments should be 0.
165
166    In some implementations, varying degrees of derivative accuracy may be
167    obtained by providing GL hints (section 5.6 of the OpenGL ES 2.0
168    specification), allowing a user to make an image quality versus speed trade
169    off.
170
171
172    GLSL ES functions
173    =================
174
175    genType dFdx (genType p)
176
177    Returns the derivative in x using local differencing for the input argument
178    p.
179
180    genType dFdy (genType p)
181
182    Returns the derivative in y using local differencing for the input argument
183    p.
184
185    These two functions are commonly used to estimate the filter width used to
186    anti-alias procedural textures.  We are assuming that the expression is
187    being evaluated in parallel on a SIMD array so that at any given point in
188    time the value of the function is known at the grid points represented by
189    the SIMD array.  Local differencing between SIMD array elements can
190    therefore be used to derive dFdx, dFdy, etc.
191
192    genType fwidth (genType p)
193
194    Returns the sum of the absolute derivative in x and y using local
195    differencing for the input argument p, i.e.:
196
197    abs (dFdx (p)) + abs (dFdy (p));
198
199New State
200
201    Add to Table 6.27: Hints
202
203Get Value                    Type  Get Command  Initial Value  Description
204---------                    ----  -----------  -------------  -----------
205FRAGMENT_SHADER_DERIVATIVE_  Z3    GetIntegerv  DONT_CARE      Fragment shader
206HINT_OES                                                       derivative
207                                                               accuracy hint
208
209Revision History
210
211    7/07/2005  Created.
212    7/06/2006  Removed from main specification document.
213    7/18/2007  Updated to match desktop GLSL spec and added hint.
214