15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    OES_standard_derivatives
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_OES_standard_derivatives
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    John Kessenich
125bd8deadSopenharmony_ci    OpenGL Architecture Review Board
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciContact
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Benj Lipchak (benj.lipchak 'at' amd.com)
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciNotice
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Copyright (c) 2005-2013 The Khronos Group Inc. Copyright terms at
215bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ciSpecification Update Policy
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
265bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL ES Working Group. For
275bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
285bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
295bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
305bd8deadSopenharmony_ci    described in more detail at
315bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciStatus
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    Ratified by the Khronos BOP, March 20, 2008.
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ciVersion
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    Date: July 18, 2007 Revision: 0.99
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciNumber
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    OpenGL ES Extension #45
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ciDependencies
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    OpenGL ES 2.0 is required.
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ciOverview
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    The standard derivative built-in functions and semantics from OpenGL 2.0 are
525bd8deadSopenharmony_ci    optional for OpenGL ES 2.0.  When this extension is available, these
535bd8deadSopenharmony_ci    built-in functions are also available, as is a hint controlling the
545bd8deadSopenharmony_ci    quality/performance trade off.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ciIssues
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    None.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ciNew Procedures and Functions
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    None
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciNew Tokens
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    Accepted by the <target> parameter of Hint and by the <pname> parameter of
675bd8deadSopenharmony_ci    GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev:
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci        FRAGMENT_SHADER_DERIVATIVE_HINT_OES            0x8B8B
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ciNew Keywords
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    None.
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ciNew Built-in Functions
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    dFdx()
785bd8deadSopenharmony_ci    dFdy()  
795bd8deadSopenharmony_ci    fwidth()
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ciNew Macro Definitions
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    #define GL_OES_standard_derivatives 1
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 2.0 specification:
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    In section 5.2 (Hints), add the following to the list of supported hints:
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci    FRAGMENT_SHADER_DERIVATIVE_HINT_OES
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    Derivative accuracy for fragment processing built-in functions dFdx, dFdy
925bd8deadSopenharmony_ci    and fwidth.
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL ES Shading Language specification:
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    Replace section 8.8 (Fragment Processing Functions) with the following 
975bd8deadSopenharmony_ci    paragraphs:
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci    Fragment processing functions are only available in fragment shaders.
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    The built-in derivative functions dFdx, dFdy, and fwidth are optional, and
1025bd8deadSopenharmony_ci    must be enabled by
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    #extension GL_OES_standard_derivatives : enable
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci    before being used.  
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    Derivatives may be computationally expensive and/or numerically unstable.  
1095bd8deadSopenharmony_ci    Therefore, an OpenGL ES implementation may approximate the true derivatives
1105bd8deadSopenharmony_ci    by using a fast but not entirely accurate derivative computation.
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    The expected behavior of a derivative is specified using forward/backward 
1135bd8deadSopenharmony_ci    differencing.
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    Forward differencing:
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci    F(x+dx) - F(x)   is approximately equal to    dFdx(x).dx                  1a
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    dFdx(x)          is approximately equal to    F(x+dx) - F(x)              1b
1205bd8deadSopenharmony_ci                                                  --------------
1215bd8deadSopenharmony_ci                                                       dx
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Backward differencing:
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci    F(x-dx) - F(x)   is approximately equal to    -dFdx(x).dx                 2a
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci    dFdx(x)          is approximately equal to    F(x) - F(x-dx)              2b
1285bd8deadSopenharmony_ci                                                  --------------
1295bd8deadSopenharmony_ci                                                       dx
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci    With single-sample rasterization, dx <= 1.0 in equations 1b and 2b.  For
1335bd8deadSopenharmony_ci    multi-sample rasterization, dx < 2.0 in equations 1b and 2b.
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci    dFdy is approximated similarly, with y replacing x.
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci    An OpenGL ES implementation may use the above or other methods to perform
1385bd8deadSopenharmony_ci    the calculation, subject to the following conditions:
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    1. The method may use piecewise linear approximations.  Such linear
1415bd8deadSopenharmony_ci       approximations imply that higher order derivatives, dFdx(dFdx(x)) and
1425bd8deadSopenharmony_ci       above, are undefined.
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    2. The method may assume that the function evaluated is continuous.
1455bd8deadSopenharmony_ci       Therefore derivatives within the body of a non-uniform conditional are
1465bd8deadSopenharmony_ci       undefined.
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci    3. The method may differ per fragment, subject to the constraint that the
1495bd8deadSopenharmony_ci       method may vary by window coordinates, not screen coordinates.  The
1505bd8deadSopenharmony_ci       invariance requirement described in section 3.1 of the OpenGL ES 2.0 
1515bd8deadSopenharmony_ci       specification is relaxed for derivative calculations, because the method 
1525bd8deadSopenharmony_ci       may be a function of fragment location.
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci    Other properties that are desirable, but not required, are:
1555bd8deadSopenharmony_ci
1565bd8deadSopenharmony_ci    4. Functions should be evaluated within the interior of a primitive
1575bd8deadSopenharmony_ci       (interpolated, not extrapolated).
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    5. Functions for dFdx should be evaluated while holding y constant.
1605bd8deadSopenharmony_ci       Functions for dFdy should be evaluated while holding x constant.  
1615bd8deadSopenharmony_ci       However, mixed higher order derivatives, like dFdx(dFdy(y)) and 
1625bd8deadSopenharmony_ci       dFdy(dFdx(x)) are undefined.
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci    6. Derivatives of constant arguments should be 0.
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ci    In some implementations, varying degrees of derivative accuracy may be
1675bd8deadSopenharmony_ci    obtained by providing GL hints (section 5.6 of the OpenGL ES 2.0
1685bd8deadSopenharmony_ci    specification), allowing a user to make an image quality versus speed trade
1695bd8deadSopenharmony_ci    off.
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    GLSL ES functions
1735bd8deadSopenharmony_ci    =================
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    genType dFdx (genType p)
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    Returns the derivative in x using local differencing for the input argument
1785bd8deadSopenharmony_ci    p. 
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci    genType dFdy (genType p)
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    Returns the derivative in y using local differencing for the input argument
1835bd8deadSopenharmony_ci    p.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci    These two functions are commonly used to estimate the filter width used to
1865bd8deadSopenharmony_ci    anti-alias procedural textures.  We are assuming that the expression is
1875bd8deadSopenharmony_ci    being evaluated in parallel on a SIMD array so that at any given point in
1885bd8deadSopenharmony_ci    time the value of the function is known at the grid points represented by
1895bd8deadSopenharmony_ci    the SIMD array.  Local differencing between SIMD array elements can
1905bd8deadSopenharmony_ci    therefore be used to derive dFdx, dFdy, etc.
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    genType fwidth (genType p)
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci    Returns the sum of the absolute derivative in x and y using local
1955bd8deadSopenharmony_ci    differencing for the input argument p, i.e.:
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    abs (dFdx (p)) + abs (dFdy (p));
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ciNew State
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    Add to Table 6.27: Hints
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ciGet Value                    Type  Get Command  Initial Value  Description 
2045bd8deadSopenharmony_ci---------                    ----  -----------  -------------  -----------
2055bd8deadSopenharmony_ciFRAGMENT_SHADER_DERIVATIVE_  Z3    GetIntegerv  DONT_CARE      Fragment shader
2065bd8deadSopenharmony_ciHINT_OES                                                       derivative
2075bd8deadSopenharmony_ci                                                               accuracy hint
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ciRevision History
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci    7/07/2005  Created.
2125bd8deadSopenharmony_ci    7/06/2006  Removed from main specification document.
2135bd8deadSopenharmony_ci    7/18/2007  Updated to match desktop GLSL spec and added hint.
214