• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_derivative_control
4
5Name Strings
6
7    GL_ARB_derivative_control
8
9Contact
10
11    John Kessenich (cepheus 'at' frii.com)
12
13Contributors
14
15    Bill Licea-Kane, Qualcomm
16
17Notice
18
19    Copyright (c) 2014 The Khronos Group Inc. Copyright terms at
20        http://www.khronos.org/registry/speccopyright.html
21
22Specification Update Policy
23
24    Khronos-approved extension specifications are updated in response to
25    issues and bugs prioritized by the Khronos OpenGL Working Group. For
26    extensions which have been promoted to a core Specification, fixes will
27    first appear in the latest version of that core Specification, and will
28    eventually be backported to the extension document. This policy is
29    described in more detail at
30        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
31
32Status
33
34    Complete.
35    Approved by the ARB on June 26, 2014.
36    Ratified by the Khronos Board of Promoters on August 7, 2014.
37
38Version
39
40    Last Modified Date: 7-Aug-2014
41    Revision: 3
42
43Number
44
45    ARB Extension #163
46
47Dependencies
48
49    This extension is written against the GLSL 4.40 Specification.
50
51    OpenGL 4.0 and GLSL 4.00 or later are required.
52
53Overview
54
55    This extension provides control over the spacial granularity at which the
56    underlying implementation computes derivatives.
57
58    For example, for the coarse-granularity derivative, a single x derivative
59    could be computed for each 2x2 group of pixels, using that same derivative
60    value for all 4 pixels.  For the fine-granularity derivative, two
61    derivatives could be computed for each 2x2 group of pixels; one for the top
62    row and one for the bottom row.  Implementations vary somewhat on how this
63    is done.
64
65    To select the coarse derivative, use:
66
67        dFdxCoarse(p)
68        dFdyCoarse(p)
69        fwidthCoarse(p)
70
71    To select the fine derivative, use:
72
73        dFdxFine(p)
74        dFdyFine(p)
75        fwidthFine(p)
76
77    To select which ever is "better" (based on performance, API hints, or other
78    factors), use:
79
80        dFdx(p)
81        dFdy(p)
82        fwidth(p)
83
84    This last set is the set of previously existing built-ins for derivatives,
85    and continues to work in a backward compatible way.
86
87IP Status
88
89    No known IP claims.
90
91New Procedures and Functions
92
93    None.
94
95New Tokens
96
97    None.
98
99Modifications to the OpenGL Specification
100
101    None.
102
103Additions to the OpenGL Shading Language
104
105    Including the following line in a shader can be used to control the
106    language features described in this extension:
107
108        #extension GL_ARB_derivative_control : <behavior>
109
110    where <behavior> is as specified in section 3.3.
111
112    New preprocessor #defines are added to the OpenGL Shading Language:
113
114        #define GL_ARB_derivative_control 1
115
116Section 4.3.3 Constant Expressions
117
118    Update the following sentence:
119
120    "The following built-in functions must return 0 when evaluated with an
121    argument that is a constant expression.
122
123        dFdx
124        dFdy
125        fwidth
126        dFdxCoarse
127        dFdyCoarse
128        fwidthCoarse
129        dFdxFine
130        dFdyFine
131        fwidthFine"
132
133Section 8.13.1 Derivative Functions
134
135    After "dFdy is approximated similarly, with y replacing x.", add the
136    following:
137
138    "With multi-sample rasterization, for any given fragment or sample,
139    either neighboring fragments or samples may be considered.
140
141    "It is typical to consider a 2x2 square of fragments or samples, and
142    compute independent dFdxFine per row and independent dFdyFine per column,
143    while computing only a single dFdxCoarse and a single dFdyCoarse for the
144    entire 2x2 square.Thus, all second-order coarse derivatives, e.g.,
145    dFdxCoarse(dFdxCoarse(x)), may be 0, even for non-linear arguments.
146    However, second-order fine derivatives, e.g., dFdxFine(dFdxFine(x))
147    will properly reflect the difference between the independent fine
148    derivatives computed within the 2x2 square."
149
150    Remove the following paragraphs:
151
152    "A GL implementation may use the above or other methods to perform the
153    calculation, subject to the following conditions:
154
155    "The method may use piecewise linear approximations. Such linear
156    approximations imply that higher order derivatives, dFdx(dFdx(x)) and
157    above, are undefined.
158
159    "The method may assume that the function evaluated is continuous. Therefore
160    derivatives within nonuniform control flow are undefined."
161
162    Change the last paragraph before the table to say
163
164    "In some implementations, varying degrees of derivative accuracy for dFdx
165    and dFdy may be obtained by providing GL hints (section 21.4 "Hints" of the
166    OpenGL Graphics System Specification), allowing a user to make an image
167    quality versus speed trade off.These hints have no effect on dFdxCoarse,
168    dFdyCoarse, dFdxFineand dFdyFine."
169
170    Add the following built-in functions to the table:
171
172        genType dFdxFine(genType p)
173
174    "Returns the partial derivative of p with respect to the window x
175    coordinate.  Will use local differencing based on the value of p for the
176    current fragment and its immediate neighbor(s)."
177
178        genType dFdyFine(genType p)
179
180    "Returns the partial derivative of p with respect to the window y
181    coordinate.  Will use local differencing based on the value of p for the
182    current fragment and its immediate neighbor(s)."
183
184        genType fwidthFine(genType p)
185
186    "Return abs(dFdxFine(p)) + abs(dFdyFine(p))."
187
188        genType dFdxCoarse(genType p)
189
190    "Returns the partial derivative of p with respect to the window x
191    coordinate.  Will use local differencing based on the value of p for the
192    current fragment's neighbors, and will possibly, but not necessarily,
193    include the value of p for the current fragment.  That is, over a
194    given area, the implementation can compute x derivatives in fewer
195    unique locations than would be allowed for dFdxFine(p)."
196
197        genType dFdyCoarse(genType p)
198
199    "Returns the partial derivative of p with respect to the window y
200    coordinate.  Will use local differencing based on the value of p for the
201    current fragment's neighbors, and will possibly, but not necessarily,
202    include the value of p for the current fragment.  That is, over a
203    given area, the implementation can compute y derivatives in fewer
204    unique locations than would be allowed for dFdyFine(p)."
205
206        genType fwidthCoarse(genType p)
207
208    "Returns abs(dFdxCoarse(p)) + abs(dFdyCoarse(p))."
209
210    Change the existing descriptions to the following:
211
212        genType dFdx(genType p)
213
214    "Returns either dFdxFine(p) or dFdxCoarse(p), based on implementation
215    choice, presumably whichever is the faster, or by whichever is selected
216    in the API through quality-versus-speed hints."
217
218        genType dFdy(genType p)
219
220    "Returns either dFdyFine(p) or dFdyCoarse(p), based on implementation
221    choice, presumably whichever is the faster, or by whichever is selected
222    in the API through quality-versus-speed hints."
223
224    Doing the above change would remove:
225
226    [Old Language to remove...]
227    "These two functions are commonly used to estimate the
228    filter width used to anti-alias procedural textures. We
229    are assuming that the expression is being evaluated in
230    parallel on a SIMD array so that at any given point in
231    time the value of the function is known at the grid points
232    represented by the SIMD array. Local differencing
233    between SIMD array elements can therefore be used to
234    derive dFdx, dFdy, etc."
235
236        getType fwidth(getType p)
237
238    "Returns abs(dFdx(p)) + abs(dFdy(p))."
239
240Additions to the AGL/EGL/GLX/WGL Specifications
241
242    None.
243
244GLX Protocol
245
246    None.
247
248Errors
249
250    No new API errors.
251
252New State
253
254    None.
255
256New Implementation Dependent State
257
258    None.
259
260Conformance Tests
261
262    TBD
263
264Issues
265
266    1.  Allow support on pre-4.0 versions?
267
268        Resolution:  No, require 4.0.
269
270    2.  Define higher-order derivatives?  Currently we say they are undefined,
271        but don't see why they can't say more (like coarse is 0, and fine might
272        be something you'd expect).
273
274           dFdxFine(dFdyFine(a))      should work
275           dFdxCoarse(dFdyCoarse(a))  should work or be 0
276
277        Generally, the descriptive part of the derivative section may need
278        slight tweaking, based on the decisions made.
279
280        Resolution:  Yes, be more specific about how higher-order derivitives
281        behave.  See the changes to the descriptive part of section 8.13.1.
282
283Revision History
284
285    Revision 1, 17-Apr-2014 (JohnK)
286      - Create first version.
287    Revision 2, 12-May-2014 (JohnK)
288      - Write overview section
289    Revision 3, 7-Aug-2014 (JohnK)
290      - Match the core specification WRT to Bill's input derivatives, etc.
291      - Add Bill as a contributor.
292      - Close the issues.
293