15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_blend_equation_advanced
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_blend_equation_advanced
85bd8deadSopenharmony_ci    GL_NV_blend_equation_advanced_coherent
95bd8deadSopenharmony_ci
105bd8deadSopenharmony_ciContact
115bd8deadSopenharmony_ci
125bd8deadSopenharmony_ci    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciContributors
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA Corporation
175bd8deadSopenharmony_ci    Mathias Heyer, NVIDIA Corporation
185bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA Corporation
195bd8deadSopenharmony_ci    Daniel Koch, NVIDIA Corporation
205bd8deadSopenharmony_ci    Rik Cabanier, Adobe
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciStatus
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    NV_blend_equation_advanced is released in NVIDIA Driver Release
255bd8deadSopenharmony_ci    326.xx (June 2013).
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciVersion
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    Last Modified Date:         February 14, 2018
305bd8deadSopenharmony_ci    NVIDIA Revision:            10
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ciNumber
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ci    OpenGL Extension #433
355bd8deadSopenharmony_ci    OpenGL ES Extension #163
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ciDependencies
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    This extension is written against the OpenGL 4.1 Specification
405bd8deadSopenharmony_ci    (Compatibility Profile).
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    OpenGL 2.0 is required (for Desktop).
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    OpenGL ES 2.0 is required (for mobile).
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    EXT_blend_minmax is required (for mobile).
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    This extension interacts with OpenGL 4.0.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    This extension interacts with OpenGL 4.1 (Core Profile).
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    This extension interacts with OpenGL 4.3 or later.
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ci    This extension interacts with OpenGL ES 2.0.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    This extension interacts with OpenGL ES 3.0.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    This extension interacts with NV_path_rendering.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ciOverview
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    This extension adds a number of "advanced" blending equations that can be
635bd8deadSopenharmony_ci    used to perform new color blending operations, many of which are more
645bd8deadSopenharmony_ci    complex than the standard blend modes provided by unextended OpenGL.  This
655bd8deadSopenharmony_ci    extension provides two different extension string entries:
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    - NV_blend_equation_advanced:  Provides the new blending equations, but
685bd8deadSopenharmony_ci      guarantees defined results only if each sample is touched no more than
695bd8deadSopenharmony_ci      once in any single rendering pass.  The command BlendBarrierNV() is
705bd8deadSopenharmony_ci      provided to indicate a boundary between passes.
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    - NV_blend_equation_advanced_coherent:  Provides the new blending
735bd8deadSopenharmony_ci      equations, and guarantees that blending is done coherently and in API
745bd8deadSopenharmony_ci      primitive ordering.  An enable is provided to allow implementations to
755bd8deadSopenharmony_ci      opt out of fully coherent blending and instead behave as though only
765bd8deadSopenharmony_ci      NV_blend_equation_advanced were supported.
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ci    Some implementations may support NV_blend_equation_advanced without
795bd8deadSopenharmony_ci    supporting NV_blend_equation_advanced_coherent.
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    In unextended OpenGL, the set of blending equations is limited, and can be
825bd8deadSopenharmony_ci    expressed very simply.  The MIN and MAX blend equations simply compute
835bd8deadSopenharmony_ci    component-wise minimums or maximums of source and destination color
845bd8deadSopenharmony_ci    components.  The FUNC_ADD, FUNC_SUBTRACT, and FUNC_REVERSE_SUBTRACT
855bd8deadSopenharmony_ci    multiply the source and destination colors by source and destination
865bd8deadSopenharmony_ci    factors and either add the two products together or subtract one from the
875bd8deadSopenharmony_ci    other.  This limited set of operations supports many common blending
885bd8deadSopenharmony_ci    operations but precludes the use of more sophisticated transparency and
895bd8deadSopenharmony_ci    blending operations commonly available in many dedicated imaging APIs.
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    This extension provides a number of new "advanced" blending equations.
925bd8deadSopenharmony_ci    Unlike traditional blending operations using the FUNC_ADD equation, these
935bd8deadSopenharmony_ci    blending equations do not use source and destination factors specified by
945bd8deadSopenharmony_ci    BlendFunc.  Instead, each blend equation specifies a complete equation
955bd8deadSopenharmony_ci    based on the source and destination colors.  These new blend equations are
965bd8deadSopenharmony_ci    used for both RGB and alpha components; they may not be used to perform
975bd8deadSopenharmony_ci    separate RGB and alpha blending (via functions like
985bd8deadSopenharmony_ci    BlendEquationSeparate).
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    These blending operations are performed using premultiplied colors, where
1015bd8deadSopenharmony_ci    RGB colors stored in the framebuffer are considered to be multiplied by
1025bd8deadSopenharmony_ci    alpha (coverage).  The fragment color may be considered premultiplied or
1035bd8deadSopenharmony_ci    non-premultiplied, according the BLEND_PREMULTIPLIED_SRC_NV blending
1045bd8deadSopenharmony_ci    parameter (as specified by the new BlendParameteriNV function).  If
1055bd8deadSopenharmony_ci    fragment color is considered non-premultiplied, the (R,G,B) color
1065bd8deadSopenharmony_ci    components are multiplied by the alpha component prior to blending.  For
1075bd8deadSopenharmony_ci    non-premultiplied color components in the range [0,1], the corresponding
1085bd8deadSopenharmony_ci    premultiplied color component would have values in the range [0*A,1*A].
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    Many of these advanced blending equations are formulated where the result
1115bd8deadSopenharmony_ci    of blending source and destination colors with partial coverage have three
1125bd8deadSopenharmony_ci    separate contributions:  from the portions covered by both the source and
1135bd8deadSopenharmony_ci    the destination, from the portion covered only by the source, and from the
1145bd8deadSopenharmony_ci    portion covered only by the destination.  The blend parameter
1155bd8deadSopenharmony_ci    BLEND_OVERLAP_NV can be used to specify a correlation between source and
1165bd8deadSopenharmony_ci    destination pixel coverage.  If set to CONJOINT_NV, the source and
1175bd8deadSopenharmony_ci    destination are considered to have maximal overlap, as would be the case
1185bd8deadSopenharmony_ci    if drawing two objects on top of each other.  If set to DISJOINT_NV, the
1195bd8deadSopenharmony_ci    source and destination are considered to have minimal overlap, as would be
1205bd8deadSopenharmony_ci    the case when rendering a complex polygon tessellated into individual
1215bd8deadSopenharmony_ci    non-intersecting triangles.  If set to UNCORRELATED_NV (default), the
1225bd8deadSopenharmony_ci    source and destination coverage are assumed to have no spatial correlation
1235bd8deadSopenharmony_ci    within the pixel.
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci    In addition to the coherency issues on implementations not supporting
1265bd8deadSopenharmony_ci    NV_blend_equation_advanced_coherent, this extension has several
1275bd8deadSopenharmony_ci    limitations worth noting.  First, the new blend equations are not
1285bd8deadSopenharmony_ci    supported while rendering to more than one color buffer at once; an
1295bd8deadSopenharmony_ci    INVALID_OPERATION will be generated if an application attempts to render
1305bd8deadSopenharmony_ci    any primitives in this unsupported configuration.  Additionally, blending
1315bd8deadSopenharmony_ci    precision may be limited to 16-bit floating-point, which could result in a
1325bd8deadSopenharmony_ci    loss of precision and dynamic range for framebuffer formats with 32-bit
1335bd8deadSopenharmony_ci    floating-point components, and in a loss of precision for formats with 12-
1345bd8deadSopenharmony_ci    and 16-bit signed or unsigned normalized integer components.
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ciNew Procedures and Functions
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    void BlendParameteriNV(enum pname, int value);
1395bd8deadSopenharmony_ci    void BlendBarrierNV(void);
1405bd8deadSopenharmony_ci
1415bd8deadSopenharmony_ciNew Tokens
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci    Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and by
1445bd8deadSopenharmony_ci    the <pname> parameter of GetIntegerv, GetBooleanv, GetFloatv, GetDoublev
1455bd8deadSopenharmony_ci    and GetInteger64v:
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci        BLEND_ADVANCED_COHERENT_NV                      0x9285
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    Note:  The BLEND_ADVANCED_COHERENT_NV enable is provided if and only if
1505bd8deadSopenharmony_ci    the NV_blend_equation_advanced_coherent extension is supported.  On
1515bd8deadSopenharmony_ci    implementations supporting only NV_blend_equation_advanced, this enable is
1525bd8deadSopenharmony_ci    considered not to exist.
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci    Accepted by the <pname> parameter of BlendParameteriNV, GetBooleanv,
1555bd8deadSopenharmony_ci    GetIntegerv, GetInteger64v, GetFloatv, and GetDoublev:
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci        BLEND_PREMULTIPLIED_SRC_NV                      0x9280
1585bd8deadSopenharmony_ci        BLEND_OVERLAP_NV                                0x9281
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci    Accepted by the <value> parameter of BlendParameteriNV when <pname> is
1615bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_SRC_NV:
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci        TRUE
1645bd8deadSopenharmony_ci        FALSE
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ci    Accepted by the <value> parameter of BlendParameteriNV when <pname> is
1675bd8deadSopenharmony_ci    BLEND_OVERLAP_NV:
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci        UNCORRELATED_NV                                 0x9282
1705bd8deadSopenharmony_ci        DISJOINT_NV                                     0x9283
1715bd8deadSopenharmony_ci        CONJOINT_NV                                     0x9284
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    Accepted by the <mode> parameter of BlendEquation and BlendEquationi:
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci        ZERO                                            // reused from core
1765bd8deadSopenharmony_ci        SRC_NV                                          0x9286
1775bd8deadSopenharmony_ci        DST_NV                                          0x9287
1785bd8deadSopenharmony_ci        SRC_OVER_NV                                     0x9288
1795bd8deadSopenharmony_ci        DST_OVER_NV                                     0x9289
1805bd8deadSopenharmony_ci        SRC_IN_NV                                       0x928A
1815bd8deadSopenharmony_ci        DST_IN_NV                                       0x928B
1825bd8deadSopenharmony_ci        SRC_OUT_NV                                      0x928C
1835bd8deadSopenharmony_ci        DST_OUT_NV                                      0x928D
1845bd8deadSopenharmony_ci        SRC_ATOP_NV                                     0x928E
1855bd8deadSopenharmony_ci        DST_ATOP_NV                                     0x928F
1865bd8deadSopenharmony_ci        XOR_NV                                          0x1506
1875bd8deadSopenharmony_ci        MULTIPLY_NV                                     0x9294
1885bd8deadSopenharmony_ci        SCREEN_NV                                       0x9295
1895bd8deadSopenharmony_ci        OVERLAY_NV                                      0x9296
1905bd8deadSopenharmony_ci        DARKEN_NV                                       0x9297
1915bd8deadSopenharmony_ci        LIGHTEN_NV                                      0x9298
1925bd8deadSopenharmony_ci        COLORDODGE_NV                                   0x9299
1935bd8deadSopenharmony_ci        COLORBURN_NV                                    0x929A
1945bd8deadSopenharmony_ci        HARDLIGHT_NV                                    0x929B
1955bd8deadSopenharmony_ci        SOFTLIGHT_NV                                    0x929C
1965bd8deadSopenharmony_ci        DIFFERENCE_NV                                   0x929E
1975bd8deadSopenharmony_ci        EXCLUSION_NV                                    0x92A0
1985bd8deadSopenharmony_ci        INVERT                                          // reused from core
1995bd8deadSopenharmony_ci        INVERT_RGB_NV                                   0x92A3
2005bd8deadSopenharmony_ci        LINEARDODGE_NV                                  0x92A4
2015bd8deadSopenharmony_ci        LINEARBURN_NV                                   0x92A5
2025bd8deadSopenharmony_ci        VIVIDLIGHT_NV                                   0x92A6
2035bd8deadSopenharmony_ci        LINEARLIGHT_NV                                  0x92A7
2045bd8deadSopenharmony_ci        PINLIGHT_NV                                     0x92A8
2055bd8deadSopenharmony_ci        HARDMIX_NV                                      0x92A9
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci        HSL_HUE_NV                                      0x92AD
2085bd8deadSopenharmony_ci        HSL_SATURATION_NV                               0x92AE
2095bd8deadSopenharmony_ci        HSL_COLOR_NV                                    0x92AF
2105bd8deadSopenharmony_ci        HSL_LUMINOSITY_NV                               0x92B0
2115bd8deadSopenharmony_ci
2125bd8deadSopenharmony_ci        PLUS_NV                                         0x9291
2135bd8deadSopenharmony_ci        PLUS_CLAMPED_NV                                 0x92B1
2145bd8deadSopenharmony_ci        PLUS_CLAMPED_ALPHA_NV                           0x92B2
2155bd8deadSopenharmony_ci        PLUS_DARKER_NV                                  0x9292
2165bd8deadSopenharmony_ci        MINUS_NV                                        0x929F
2175bd8deadSopenharmony_ci        MINUS_CLAMPED_NV                                0x92B3
2185bd8deadSopenharmony_ci        CONTRAST_NV                                     0x92A1
2195bd8deadSopenharmony_ci        INVERT_OVG_NV                                   0x92B4
2205bd8deadSopenharmony_ci        RED_NV                                          0x1903
2215bd8deadSopenharmony_ci        GREEN_NV                                        0x1904
2225bd8deadSopenharmony_ci        BLUE_NV                                         0x1905
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci    NOTE:  These enums are not accepted by the <modeRGB> or <modeAlpha>
2255bd8deadSopenharmony_ci    parameters of BlendEquationSeparate or BlendEquationSeparatei.
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    NOTE:  The tokens XOR_NV, RED_NV, GREEN_NV, and BLUE_NV have the same
2285bd8deadSopenharmony_ci    values as core OpenGL API enumerants with names without the "_NV"
2295bd8deadSopenharmony_ci    suffixes.  Either #define can be used, but the non-suffixed #defines are
2305bd8deadSopenharmony_ci    not available in OpenGL ES 2.0 and XOR is not available in OpenGL ES 3.0.
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 4.1 Specification (OpenGL Operation)
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci    None.
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 4.1 Specification (Rasterization)
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci    None.
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 4.1 Specification (Per-Fragment
2415bd8deadSopenharmony_ciOperations and the Frame Buffer)
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    Modify Section 4.1.8, Blending (p. 359).
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    (modify the first paragraph, p. 361, allowing for new values in the
2465bd8deadSopenharmony_ci    <mode> parameter) ... <modeRGB> and <modeAlpha> must be one of
2475bd8deadSopenharmony_ci    FUNC_ADD, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MIN, or MAX as listed
2485bd8deadSopenharmony_ci    in Table 4.1.  <mode> must be one of the values in Table 4.1,
2495bd8deadSopenharmony_ci    or one of the blend equations listed in tables X.2, X.3, and X.4. ...
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci    (modify the third paragraph, p. 361, specifying minimum precision and
2525bd8deadSopenharmony_ci    dynamic range for blend operations) ... Blending computations are treated
2535bd8deadSopenharmony_ci    as if carried out in floating-point.  For the equations in table 4.1,
2545bd8deadSopenharmony_ci    blending computations will be performed with a precision and dynamic range
2555bd8deadSopenharmony_ci    no lower than that used to represent destination components.  For the
2565bd8deadSopenharmony_ci    equations in table X.2, X.3, and X.4, blending computations will be
2575bd8deadSopenharmony_ci    performed with a precision and dynamic range no lower than the smaller of
2585bd8deadSopenharmony_ci    that used to represent destination components or that used to represent
2595bd8deadSopenharmony_ci    16-bit floating-point values as described in section 2.1.1.
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    (add unnumbered subsection prior to "Dual Source Blending and Multiple
2625bd8deadSopenharmony_ci     Draw Buffers", p. 363)
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci    Advanced Blend Equations
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    The advanced blend equations are those listed in tables X.2, X.3, and X.4.
2675bd8deadSopenharmony_ci    Parameters related to the advanced blend equations can be set by calling
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci      void BlendParameteriNV(enum pname, int param);
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci    with <pname> set to BLEND_PREMULTIPLIED_SRC_NV or BLEND_OVERLAP_NV.  When
2725bd8deadSopenharmony_ci    <pname> is BLEND_PREMULTIPLIED_SRC_NV, the valid values for <param> are
2735bd8deadSopenharmony_ci    TRUE or FALSE.  When <pname> is BLEND_OVERLAP_NV, the valid values for
2745bd8deadSopenharmony_ci    <param> are UNCORRELATED_NV, CONJOINT_NV, and DISJOINT_NV.  An
2755bd8deadSopenharmony_ci    INVALID_ENUM error is generated if <pname> is not
2765bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_SRC_NV or BLEND_OVERLAP_NV, or if <param> is not a
2775bd8deadSopenharmony_ci    legal value for <pname>.
2785bd8deadSopenharmony_ci
2795bd8deadSopenharmony_ci    When using one of the equations in table X.2 or X.3, blending is performed
2805bd8deadSopenharmony_ci    according to the following equations:
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ci      R = f(Rs',Rd')*p0(As,Ad) + Y*Rs'*p1(As,Ad) + Z*Rd'*p2(As,Ad)
2835bd8deadSopenharmony_ci      G = f(Gs',Gd')*p0(As,Ad) + Y*Gs'*p1(As,Ad) + Z*Gd'*p2(As,Ad)
2845bd8deadSopenharmony_ci      B = f(Bs',Bd')*p0(As,Ad) + Y*Bs'*p1(As,Ad) + Z*Bd'*p2(As,Ad)
2855bd8deadSopenharmony_ci      A =          X*p0(As,Ad) +     Y*p1(As,Ad) +     Z*p2(As,Ad)
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci    where the function f and terms X, Y, and Z are specified in the table.
2885bd8deadSopenharmony_ci    The R, G, and B components of the source color used for blending are
2895bd8deadSopenharmony_ci    derived according to the premultiplied source color blending parameter,
2905bd8deadSopenharmony_ci    which is set by calling BlendParameteriNV with <pname> set to 
2915bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_SRC_NV, and <param> set to TRUE or FALSE.
2925bd8deadSopenharmony_ci    If the parameter is set to TRUE, the fragment color components are
2935bd8deadSopenharmony_ci    considered to have been premultiplied by the A component prior to
2945bd8deadSopenharmony_ci    blending.  The base source color (Rs',Gs',Bs') is obtained by dividing
2955bd8deadSopenharmony_ci    through by the A component:
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci      (Rs', Gs', Bs') =
2985bd8deadSopenharmony_ci        (0, 0, 0),              if As == 0
2995bd8deadSopenharmony_ci        (Rs/As, Gs/As, Bs/As),  otherwise
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci    If the premultiplied source color parameter is FALSE, the fragment color
3025bd8deadSopenharmony_ci    components are used as the base color:
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci      (Rs', Gs', Bs') = (Rs, Gs, Bs)
3055bd8deadSopenharmony_ci
3065bd8deadSopenharmony_ci    The destination color components are always considered to have been
3075bd8deadSopenharmony_ci    premultiplied by the destination A component and the base destination
3085bd8deadSopenharmony_ci    color (Rd', Gd', Bd') is obtained by dividing through by the A component:
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci      (Rd', Gd', Bd') =
3115bd8deadSopenharmony_ci        (0, 0, 0),               if Ad == 0
3125bd8deadSopenharmony_ci        (Rd/Ad, Gd/Ad, Bd/Ad),   otherwise
3135bd8deadSopenharmony_ci
3145bd8deadSopenharmony_ci    When blending using advanced blend equations, we expect that the R, G, and
3155bd8deadSopenharmony_ci    B components of premultiplied source and destination color inputs be
3165bd8deadSopenharmony_ci    stored as the product of non-premultiplied R, G, and B component values
3175bd8deadSopenharmony_ci    and the A component of the color.  If any R, G, or B component of a
3185bd8deadSopenharmony_ci    premultiplied input color is non-zero and the A component is zero, the
3195bd8deadSopenharmony_ci    color is considered ill-formed, and the corresponding component of the
3205bd8deadSopenharmony_ci    blend result will be undefined.
3215bd8deadSopenharmony_ci
3225bd8deadSopenharmony_ci    The weighting functions p0, p1, and p2 are defined in table X.1.  In these
3235bd8deadSopenharmony_ci    functions, the A components of the source and destination colors are taken
3245bd8deadSopenharmony_ci    to indicate the portion of the pixel covered by the fragment (source) and
3255bd8deadSopenharmony_ci    the fragments previously accumulated in the pixel (destination).  The
3265bd8deadSopenharmony_ci    functions p0, p1, and p2 approximate the relative portion of the pixel
3275bd8deadSopenharmony_ci    covered by the intersection of the source and destination, covered only by
3285bd8deadSopenharmony_ci    the source, and covered only by the destination, respectively.  These
3295bd8deadSopenharmony_ci    functions are specified by the blend overlap parameter, which can be set
3305bd8deadSopenharmony_ci    by calling BlendParameteriNV with <pname> set to BLEND_OVERLAP_NV.  <param>
3315bd8deadSopenharmony_ci    can be one of UNCORRELATED_NV (default), CONJOINT_NV, and DISJOINT_NV.
3325bd8deadSopenharmony_ci    UNCORRELATED_NV indicates that there is no correlation between the source
3335bd8deadSopenharmony_ci    and destination coverage.  CONJOINT_NV and DISJOINT_NV indicate that the
3345bd8deadSopenharmony_ci    source and destination coverage are considered to have maximal or minimal
3355bd8deadSopenharmony_ci    overlap, respectively.
3365bd8deadSopenharmony_ci
3375bd8deadSopenharmony_ci      Overlap Mode              Weighting Equations
3385bd8deadSopenharmony_ci      ---------------           --------------------------
3395bd8deadSopenharmony_ci      UNCORRELATED_NV           p0(As,Ad) = As*Ad
3405bd8deadSopenharmony_ci                                p1(As,Ad) = As*(1-Ad)
3415bd8deadSopenharmony_ci                                p2(As,Ad) = Ad*(1-As)
3425bd8deadSopenharmony_ci      CONJOINT_NV               p0(As,Ad) = min(As,Ad)
3435bd8deadSopenharmony_ci                                p1(As,Ad) = max(As-Ad,0)
3445bd8deadSopenharmony_ci                                p2(As,Ad) = max(Ad-As,0)
3455bd8deadSopenharmony_ci      DISJOINT_NV               p0(As,Ad) = max(As+Ad-1,0)
3465bd8deadSopenharmony_ci                                p1(As,Ad) = min(As,1-Ad)
3475bd8deadSopenharmony_ci                                p2(As,Ad) = min(Ad,1-As)
3485bd8deadSopenharmony_ci
3495bd8deadSopenharmony_ci      Table X.1, Advanced Blend Overlap Modes
3505bd8deadSopenharmony_ci
3515bd8deadSopenharmony_ci
3525bd8deadSopenharmony_ci      Mode                      Blend Coefficients
3535bd8deadSopenharmony_ci      --------------------      -----------------------------------
3545bd8deadSopenharmony_ci      ZERO                      (X,Y,Z)  = (0,0,0)
3555bd8deadSopenharmony_ci                                f(Cs,Cd) = 0
3565bd8deadSopenharmony_ci
3575bd8deadSopenharmony_ci      SRC_NV                    (X,Y,Z)  = (1,1,0)
3585bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cs
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci      DST_NV                    (X,Y,Z)  = (1,0,1)
3615bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cd
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ci      SRC_OVER_NV               (X,Y,Z)  = (1,1,1)
3645bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cs
3655bd8deadSopenharmony_ci
3665bd8deadSopenharmony_ci      DST_OVER_NV               (X,Y,Z)  = (1,1,1)
3675bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cd
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci      SRC_IN_NV                 (X,Y,Z)  = (1,0,0)
3705bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cs
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci      DST_IN_NV                 (X,Y,Z)  = (1,0,0)
3735bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cd
3745bd8deadSopenharmony_ci
3755bd8deadSopenharmony_ci      SRC_OUT_NV                (X,Y,Z)  = (0,1,0)
3765bd8deadSopenharmony_ci                                f(Cs,Cd) =  0
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci      DST_OUT_NV                (X,Y,Z)  = (0,0,1)
3795bd8deadSopenharmony_ci                                f(Cs,Cd) =  0
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci      SRC_ATOP_NV               (X,Y,Z)  = (1,0,1)
3825bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cs
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci      DST_ATOP_NV               (X,Y,Z)  = (1,1,0)
3855bd8deadSopenharmony_ci                                f(Cs,Cd) =  Cd
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ci      XOR_NV                    (X,Y,Z)  = (0,1,1)
3885bd8deadSopenharmony_ci                                f(Cs,Cd) =  0
3895bd8deadSopenharmony_ci
3905bd8deadSopenharmony_ci      MULTIPLY_NV               (X,Y,Z)  = (1,1,1)
3915bd8deadSopenharmony_ci                                f(Cs,Cd) = Cs*Cd
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci      SCREEN_NV                 (X,Y,Z)  = (1,1,1)
3945bd8deadSopenharmony_ci                                f(Cs,Cd) = Cs+Cd-Cs*Cd
3955bd8deadSopenharmony_ci
3965bd8deadSopenharmony_ci      OVERLAY_NV                (X,Y,Z)  = (1,1,1)
3975bd8deadSopenharmony_ci                                f(Cs,Cd) = 2*Cs*Cd, if Cd <= 0.5
3985bd8deadSopenharmony_ci                                           1-2*(1-Cs)*(1-Cd), otherwise
3995bd8deadSopenharmony_ci
4005bd8deadSopenharmony_ci      DARKEN_NV                 (X,Y,Z)  = (1,1,1)
4015bd8deadSopenharmony_ci                                f(Cs,Cd) = min(Cs,Cd)
4025bd8deadSopenharmony_ci
4035bd8deadSopenharmony_ci      LIGHTEN_NV                (X,Y,Z)  = (1,1,1)
4045bd8deadSopenharmony_ci                                f(Cs,Cd) = max(Cs,Cd)
4055bd8deadSopenharmony_ci
4065bd8deadSopenharmony_ci      COLORDODGE_NV             (X,Y,Z)  = (1,1,1)
4075bd8deadSopenharmony_ci                                f(Cs,Cd) =
4085bd8deadSopenharmony_ci                                  0, if Cd <= 0
4095bd8deadSopenharmony_ci                                  min(1,Cd/(1-Cs)), if Cd > 0 and Cs < 1
4105bd8deadSopenharmony_ci                                  1, if Cd > 0 and Cs >= 1
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ci      COLORBURN_NV              (X,Y,Z)  = (1,1,1)
4135bd8deadSopenharmony_ci                                f(Cs,Cd) =
4145bd8deadSopenharmony_ci                                  1, if Cd >= 1
4155bd8deadSopenharmony_ci                                  1 - min(1,(1-Cd)/Cs), if Cd < 1 and Cs > 0
4165bd8deadSopenharmony_ci                                  0, if Cd < 1 and Cs <= 0
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci      HARDLIGHT_NV              (X,Y,Z)  = (1,1,1)
4195bd8deadSopenharmony_ci                                f(Cs,Cd) = 2*Cs*Cd, if Cs <= 0.5
4205bd8deadSopenharmony_ci                                           1-2*(1-Cs)*(1-Cd), otherwise
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ci      SOFTLIGHT_NV              (X,Y,Z)  = (1,1,1)
4235bd8deadSopenharmony_ci                                f(Cs,Cd) =
4245bd8deadSopenharmony_ci                                  Cd-(1-2*Cs)*Cd*(1-Cd), 
4255bd8deadSopenharmony_ci                                    if Cs <= 0.5
4265bd8deadSopenharmony_ci                                  Cd+(2*Cs-1)*Cd*((16*Cd-12)*Cd+3), 
4275bd8deadSopenharmony_ci                                    if Cs > 0.5 and Cd <= 0.25
4285bd8deadSopenharmony_ci                                  Cd+(2*Cs-1)*(sqrt(Cd)-Cd),
4295bd8deadSopenharmony_ci                                    if Cs > 0.5 and Cd > 0.25
4305bd8deadSopenharmony_ci
4315bd8deadSopenharmony_ci      DIFFERENCE_NV             (X,Y,Z)  = (1,1,1)
4325bd8deadSopenharmony_ci                                f(Cs,Cd) = abs(Cd-Cs)
4335bd8deadSopenharmony_ci
4345bd8deadSopenharmony_ci      EXCLUSION_NV              (X,Y,Z)  = (1,1,1)
4355bd8deadSopenharmony_ci                                f(Cs,Cd) = Cs+Cd-2*Cs*Cd
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci      INVERT                    (X,Y,Z)  = (1,0,1)
4385bd8deadSopenharmony_ci                                f(Cs,Cd) = 1-Cd
4395bd8deadSopenharmony_ci
4405bd8deadSopenharmony_ci      INVERT_RGB_NV             (X,Y,Z)  = (1,0,1)
4415bd8deadSopenharmony_ci                                f(Cs,Cd) = Cs*(1-Cd)
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci      LINEARDODGE_NV            (X,Y,Z)  = (1,1,1)
4445bd8deadSopenharmony_ci                                f(Cs,Cd) =
4455bd8deadSopenharmony_ci                                  Cs+Cd, if Cs+Cd<=1
4465bd8deadSopenharmony_ci                                  1, otherwise
4475bd8deadSopenharmony_ci
4485bd8deadSopenharmony_ci      LINEARBURN_NV             (X,Y,Z)  = (1,1,1)
4495bd8deadSopenharmony_ci                                f(Cs,Cd) = 
4505bd8deadSopenharmony_ci                                  Cs+Cd-1, if Cs+Cd>1
4515bd8deadSopenharmony_ci                                  0, otherwise
4525bd8deadSopenharmony_ci
4535bd8deadSopenharmony_ci      VIVIDLIGHT_NV             (X,Y,Z)  = (1,1,1)
4545bd8deadSopenharmony_ci                                f(Cs,Cd) =
4555bd8deadSopenharmony_ci                                  1-min(1,(1-Cd)/(2*Cs)), if 0 < Cs < 0.5
4565bd8deadSopenharmony_ci                                  0, if Cs <= 0
4575bd8deadSopenharmony_ci                                  min(1,Cd/(2*(1-Cs))), if 0.5 <= Cs < 1
4585bd8deadSopenharmony_ci                                  1, if Cs >= 1
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci      LINEARLIGHT_NV            (X,Y,Z)  = (1,1,1)
4615bd8deadSopenharmony_ci                                f(Cs,Cd) = 
4625bd8deadSopenharmony_ci                                  1,            if 2*Cs+Cd>2
4635bd8deadSopenharmony_ci                                  2*Cs+Cd-1,    if 1 < 2*Cs+Cd <= 2
4645bd8deadSopenharmony_ci                                  0,            if 2*Cs+Cd<=1
4655bd8deadSopenharmony_ci
4665bd8deadSopenharmony_ci      PINLIGHT_NV               (X,Y,Z)  = (1,1,1)
4675bd8deadSopenharmony_ci                                f(Cs,Cd) =
4685bd8deadSopenharmony_ci                                  0,       if 2*Cs-1>Cd and Cs<0.5
4695bd8deadSopenharmony_ci                                  2*Cs-1,  if 2*Cs-1>Cd and Cs>=0.5
4705bd8deadSopenharmony_ci                                  2*Cs,    if 2*Cs-1<=Cd and Cs<0.5*Cd
4715bd8deadSopenharmony_ci                                  Cd,      if 2*Cs-1<=Cd and Cs>=0.5*Cd
4725bd8deadSopenharmony_ci                                ???
4735bd8deadSopenharmony_ci                                      
4745bd8deadSopenharmony_ci      HARDMIX_NV                (X,Y,Z) = (1,1,1)
4755bd8deadSopenharmony_ci                                f(Cs,Cd) = 0, if Cs+Cd<1
4765bd8deadSopenharmony_ci                                           1, otherwise
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ci      Table X.2, Advanced Blend Equations
4795bd8deadSopenharmony_ci
4805bd8deadSopenharmony_ci
4815bd8deadSopenharmony_ci    When using one of the HSL blend equations in table X.3 as the blend
4825bd8deadSopenharmony_ci    equation, the RGB color components produced by the function f() are
4835bd8deadSopenharmony_ci    effectively obtained by converting both the non-premultiplied source and
4845bd8deadSopenharmony_ci    destination colors to the HSL (hue, saturation, luminosity) color space,
4855bd8deadSopenharmony_ci    generating a new HSL color by selecting H, S, and L components from the
4865bd8deadSopenharmony_ci    source or destination according to the blend equation, and then converting
4875bd8deadSopenharmony_ci    the result back to RGB.  The HSL blend equations are only well defined
4885bd8deadSopenharmony_ci    when the values of the input color components are in the range [0..1].
4895bd8deadSopenharmony_ci    In the equations below, a blended RGB color is produced according to the
4905bd8deadSopenharmony_ci    following pseudocode:
4915bd8deadSopenharmony_ci
4925bd8deadSopenharmony_ci      float minv3(vec3 c) {
4935bd8deadSopenharmony_ci        return min(min(c.r, c.g), c.b);
4945bd8deadSopenharmony_ci      }
4955bd8deadSopenharmony_ci      float maxv3(vec3 c) {
4965bd8deadSopenharmony_ci        return max(max(c.r, c.g), c.b);
4975bd8deadSopenharmony_ci      }
4985bd8deadSopenharmony_ci      float lumv3(vec3 c) {
4995bd8deadSopenharmony_ci        return dot(c, vec3(0.30, 0.59, 0.11));
5005bd8deadSopenharmony_ci      }
5015bd8deadSopenharmony_ci      float satv3(vec3 c) {
5025bd8deadSopenharmony_ci        return maxv3(c) - minv3(c);
5035bd8deadSopenharmony_ci      }
5045bd8deadSopenharmony_ci
5055bd8deadSopenharmony_ci      // If any color components are outside [0,1], adjust the color to
5065bd8deadSopenharmony_ci      // get the components in range.
5075bd8deadSopenharmony_ci      vec3 ClipColor(vec3 color) {
5085bd8deadSopenharmony_ci        float lum = lumv3(color);
5095bd8deadSopenharmony_ci        float mincol = minv3(color);
5105bd8deadSopenharmony_ci        float maxcol = maxv3(color);
5115bd8deadSopenharmony_ci        if (mincol < 0.0) {
5125bd8deadSopenharmony_ci          color = lum + ((color-lum)*lum) / (lum-mincol);
5135bd8deadSopenharmony_ci        }
5145bd8deadSopenharmony_ci        if (maxcol > 1.0) {
5155bd8deadSopenharmony_ci          color = lum + ((color-lum)*(1-lum)) / (maxcol-lum);
5165bd8deadSopenharmony_ci        }
5175bd8deadSopenharmony_ci        return color;
5185bd8deadSopenharmony_ci      }
5195bd8deadSopenharmony_ci
5205bd8deadSopenharmony_ci      // Take the base RGB color <cbase> and override its luminosity
5215bd8deadSopenharmony_ci      // with that of the RGB color <clum>.
5225bd8deadSopenharmony_ci      vec3 SetLum(vec3 cbase, vec3 clum) {
5235bd8deadSopenharmony_ci        float lbase = lumv3(cbase);
5245bd8deadSopenharmony_ci        float llum = lumv3(clum);
5255bd8deadSopenharmony_ci        float ldiff = llum - lbase;
5265bd8deadSopenharmony_ci        vec3 color = cbase + vec3(ldiff);
5275bd8deadSopenharmony_ci        return ClipColor(color);
5285bd8deadSopenharmony_ci      }
5295bd8deadSopenharmony_ci
5305bd8deadSopenharmony_ci      // Take the base RGB color <cbase> and override its saturation with
5315bd8deadSopenharmony_ci      // that of the RGB color <csat>.  The override the luminosity of the
5325bd8deadSopenharmony_ci      // result with that of the RGB color <clum>.
5335bd8deadSopenharmony_ci      vec3 SetLumSat(vec3 cbase, vec3 csat, vec3 clum)
5345bd8deadSopenharmony_ci      {
5355bd8deadSopenharmony_ci        float minbase = minv3(cbase);
5365bd8deadSopenharmony_ci        float sbase = satv3(cbase);
5375bd8deadSopenharmony_ci        float ssat = satv3(csat);
5385bd8deadSopenharmony_ci        vec3 color;
5395bd8deadSopenharmony_ci        if (sbase > 0) {
5405bd8deadSopenharmony_ci          // Equivalent (modulo rounding errors) to setting the
5415bd8deadSopenharmony_ci          // smallest (R,G,B) component to 0, the largest to <ssat>,
5425bd8deadSopenharmony_ci          // and interpolating the "middle" component based on its
5435bd8deadSopenharmony_ci          // original value relative to the smallest/largest.
5445bd8deadSopenharmony_ci          color = (cbase - minbase) * ssat / sbase;
5455bd8deadSopenharmony_ci        } else {
5465bd8deadSopenharmony_ci          color = vec3(0.0);
5475bd8deadSopenharmony_ci        }
5485bd8deadSopenharmony_ci        return SetLum(color, clum);
5495bd8deadSopenharmony_ci      }
5505bd8deadSopenharmony_ci
5515bd8deadSopenharmony_ci
5525bd8deadSopenharmony_ci      Mode                      Result
5535bd8deadSopenharmony_ci      --------------------      ----------------------------------------
5545bd8deadSopenharmony_ci      HSL_HUE_NV                (X,Y,Z)  = (1,1,1)
5555bd8deadSopenharmony_ci                                f(Cs,Cd) = SetLumSat(Cs,Cd,Cd);
5565bd8deadSopenharmony_ci
5575bd8deadSopenharmony_ci      HSL_SATURATION_NV         (X,Y,Z)  = (1,1,1)
5585bd8deadSopenharmony_ci                                f(Cs,Cd) = SetLumSat(Cd,Cs,Cd);
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci      HSL_COLOR_NV              (X,Y,Z)  = (1,1,1)
5615bd8deadSopenharmony_ci                                f(Cs,Cd) = SetLum(Cs,Cd);
5625bd8deadSopenharmony_ci
5635bd8deadSopenharmony_ci      HSL_LUMINOSITY_NV         (X,Y,Z)  = (1,1,1)
5645bd8deadSopenharmony_ci                                f(Cs,Cd) = SetLum(Cd,Cs);
5655bd8deadSopenharmony_ci
5665bd8deadSopenharmony_ci      Table X.3, Hue-Saturation-Luminosity Advanced Blend Equations
5675bd8deadSopenharmony_ci
5685bd8deadSopenharmony_ci
5695bd8deadSopenharmony_ci    When using one of the equations in table X.4 as the blend equation, the
5705bd8deadSopenharmony_ci    source color used by these blending equations is interpreted according to
5715bd8deadSopenharmony_ci    the BLEND_PREMULTIPLIED_SRC_NV blending parameter.  The blending equations
5725bd8deadSopenharmony_ci    below are evaluated where the RGB source and destination color components
5735bd8deadSopenharmony_ci    are both considered to have been premultiplied by the corresponding A
5745bd8deadSopenharmony_ci    component.
5755bd8deadSopenharmony_ci
5765bd8deadSopenharmony_ci      (Rs', Gs', Bs') =
5775bd8deadSopenharmony_ci        (Rs, Gs, Bs),           if BLEND_PREMULTIPLIED_SRC_NV is TRUE
5785bd8deadSopenharmony_ci        (Rs*As, Gs*As, Bs*As),  if BLEND_PREMULTIPLIED_SRC_NV is FALSE
5795bd8deadSopenharmony_ci
5805bd8deadSopenharmony_ci      Mode                      Result
5815bd8deadSopenharmony_ci      --------------------      ----------------------------------------
5825bd8deadSopenharmony_ci      PLUS_NV                   (R,G,B,A) = (Rs'+Rd, Gs'+Gd, Bs'+Bd,As'+Ad)
5835bd8deadSopenharmony_ci
5845bd8deadSopenharmony_ci      PLUS_CLAMPED_NV           (R,G,B,A) = 
5855bd8deadSopenharmony_ci                                  (min(1,Rs'+Rd), min(1,Gs'+Gd),
5865bd8deadSopenharmony_ci                                   min(1,Bs'+Bd), min(1,As+Ad))
5875bd8deadSopenharmony_ci
5885bd8deadSopenharmony_ci      PLUS_CLAMPED_ALPHA_NV     (R,G,B,A) = 
5895bd8deadSopenharmony_ci                                  (min(min(1,As+Ad),Rs'+Rd),
5905bd8deadSopenharmony_ci                                   min(min(1,As+Ad),Gs'+Gd),
5915bd8deadSopenharmony_ci                                   min(min(1,As+Ad),Bs'+Bd), min(1,As+Ad))
5925bd8deadSopenharmony_ci
5935bd8deadSopenharmony_ci      PLUS_DARKER_NV            (R,G,B,A) = 
5945bd8deadSopenharmony_ci                                  (max(0,min(1,As+Ad)-((As-Rs')+(Ad-Rd))),
5955bd8deadSopenharmony_ci                                   max(0,min(1,As+Ad)-((As-Gs')+(Ad-Gd))),
5965bd8deadSopenharmony_ci                                   max(0,min(1,As+Ad)-((As-Bs')+(Ad-Bd))),
5975bd8deadSopenharmony_ci                                   min(1,As+Ad))
5985bd8deadSopenharmony_ci
5995bd8deadSopenharmony_ci      MINUS_NV                  (R,G,B,A) = (Rd-Rs', Gd-Gs', Bd-Bs', Ad-As)
6005bd8deadSopenharmony_ci
6015bd8deadSopenharmony_ci      MINUS_CLAMPED_NV          (R,G,B,A) = 
6025bd8deadSopenharmony_ci                                  (max(0,Rd-Rs'), max(0,Gd-Gs'),
6035bd8deadSopenharmony_ci                                   max(0,Bd-Bs'), max(0,Ad-As))
6045bd8deadSopenharmony_ci
6055bd8deadSopenharmony_ci      CONTRAST_NV               (R,G,B,A) = 
6065bd8deadSopenharmony_ci                                 (Ad/2 + 2*(Rd-Ad/2)*(Rs'-As/2),
6075bd8deadSopenharmony_ci                                  Ad/2 + 2*(Gd-Ad/2)*(Gs'-As/2),
6085bd8deadSopenharmony_ci                                  Ad/2 + 2*(Bd-Ad/2)*(Bs'-As/2),
6095bd8deadSopenharmony_ci                                  Ad)
6105bd8deadSopenharmony_ci
6115bd8deadSopenharmony_ci      INVERT_OVG_NV             (R,G,B,A) =
6125bd8deadSopenharmony_ci                                  (As*(1-Rd)+(1-As)*Rd,
6135bd8deadSopenharmony_ci                                   As*(1-Gd)+(1-As)*Gd,
6145bd8deadSopenharmony_ci                                   As*(1-Bd)+(1-As)*Bd,
6155bd8deadSopenharmony_ci                                   As+Ad-As*Ad)
6165bd8deadSopenharmony_ci
6175bd8deadSopenharmony_ci      RED_NV                    (R,G,B,A) = (Rs', Gd, Bd, Ad)
6185bd8deadSopenharmony_ci
6195bd8deadSopenharmony_ci      GREEN_NV                  (R,G,B,A) = (Rd, Gs', Bd, Ad)
6205bd8deadSopenharmony_ci
6215bd8deadSopenharmony_ci      BLUE_NV                   (R,G,B,A) = (Rd, Gd, Bs', Ad)
6225bd8deadSopenharmony_ci
6235bd8deadSopenharmony_ci      Table X.4, Additional RGB Blend Equations
6245bd8deadSopenharmony_ci
6255bd8deadSopenharmony_ci
6265bd8deadSopenharmony_ci    Advanced blending equations are supported only when rendering to a single
6275bd8deadSopenharmony_ci    color buffer using fragment color zero.  If any non-NONE draw buffer uses
6285bd8deadSopenharmony_ci    a blend equation found in table X.2, X.3, or X.4, the error
6295bd8deadSopenharmony_ci    INVALID_OPERATION is generated by [[Compatibility Profile:  Begin or any
6305bd8deadSopenharmony_ci    operation that implicitly calls Begin (such as DrawElements)]] [[Core
6315bd8deadSopenharmony_ci    Profile:  DrawArrays and the other drawing commands defined in section
6325bd8deadSopenharmony_ci    2.8.3]] if:
6335bd8deadSopenharmony_ci
6345bd8deadSopenharmony_ci      * the draw buffer for color output zero selects multiple color buffers
6355bd8deadSopenharmony_ci        (e.g., FRONT_AND_BACK in the default framebuffer); or
6365bd8deadSopenharmony_ci
6375bd8deadSopenharmony_ci      * the draw buffer for any other color output is not NONE.
6385bd8deadSopenharmony_ci
6395bd8deadSopenharmony_ci    [[ The following paragraph applies to NV_blend_equation_advanced only. ]]
6405bd8deadSopenharmony_ci
6415bd8deadSopenharmony_ci    When using advanced blending equations, applications should split their
6425bd8deadSopenharmony_ci    rendering into a collection of blending passes, none of which touch an
6435bd8deadSopenharmony_ci    individual sample more than once.  The results of blending are undefined
6445bd8deadSopenharmony_ci    if the sample being blended has been touched previously in the same pass.
6455bd8deadSopenharmony_ci    The command
6465bd8deadSopenharmony_ci
6475bd8deadSopenharmony_ci      void BlendBarrierNV(void);
6485bd8deadSopenharmony_ci
6495bd8deadSopenharmony_ci    specifies a boundary between passes when using advanced blend equations.
6505bd8deadSopenharmony_ci    Any command that causes the value of a sample to be modified is considered
6515bd8deadSopenharmony_ci    to touch the sample, including clears, blended or unblended primitives,
6525bd8deadSopenharmony_ci    BlitFramebuffer copies, and direct updates by commands such as
6535bd8deadSopenharmony_ci    TexSubImage2D.
6545bd8deadSopenharmony_ci
6555bd8deadSopenharmony_ci    [[ The following paragraph applies to NV_blend_equation_advanced_coherent
6565bd8deadSopenharmony_ci       only. ]]
6575bd8deadSopenharmony_ci
6585bd8deadSopenharmony_ci    When using advanced blending equations, blending is typically done
6595bd8deadSopenharmony_ci    coherently and in primitive order.  When an individual sample is covered
6605bd8deadSopenharmony_ci    by multiple primitives, blending for that sample is performed sequentially
6615bd8deadSopenharmony_ci    in the order in which the primitives were submitted.  This coherent
6625bd8deadSopenharmony_ci    blending is enabled by default, but can be enabled or disabled by calling
6635bd8deadSopenharmony_ci    Enable or Disable with the symbolic constant BLEND_ADVANCED_COHERENT_NV.
6645bd8deadSopenharmony_ci    If coherent blending is disabled, applications should split their
6655bd8deadSopenharmony_ci    rendering into a collection of blending passes, none of which touch an
6665bd8deadSopenharmony_ci    individual sample more than once.  When coherent blending is disabled, the
6675bd8deadSopenharmony_ci    results of blending are undefined if the sample being blended has been
6685bd8deadSopenharmony_ci    touched previously in the same pass.  The command
6695bd8deadSopenharmony_ci
6705bd8deadSopenharmony_ci      void BlendBarrierNV(void);
6715bd8deadSopenharmony_ci
6725bd8deadSopenharmony_ci    specifies a boundary between passes when using advanced blend equations.
6735bd8deadSopenharmony_ci    Any command that causes the value of a sample to be modified is considered
6745bd8deadSopenharmony_ci    to touch the sample, including clears, blended or unblended primitives,
6755bd8deadSopenharmony_ci    BlitFramebuffer copies, and direct updates by commands such as
6765bd8deadSopenharmony_ci    TexSubImage2D.
6775bd8deadSopenharmony_ci
6785bd8deadSopenharmony_ci
6795bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 4.1 Specification (Special Functions)
6805bd8deadSopenharmony_ci
6815bd8deadSopenharmony_ci    None.
6825bd8deadSopenharmony_ci
6835bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 4.1 Specification (State and
6845bd8deadSopenharmony_ciState Requests)
6855bd8deadSopenharmony_ci
6865bd8deadSopenharmony_ci    None.
6875bd8deadSopenharmony_ci
6885bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 4.1 Specification (Invariance)
6895bd8deadSopenharmony_ci
6905bd8deadSopenharmony_ci    None.
6915bd8deadSopenharmony_ci
6925bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL/EGL Specifications
6935bd8deadSopenharmony_ci
6945bd8deadSopenharmony_ci    None.
6955bd8deadSopenharmony_ci
6965bd8deadSopenharmony_ciGLX Protocol
6975bd8deadSopenharmony_ci
6985bd8deadSopenharmony_ci    !!! TBD
6995bd8deadSopenharmony_ci
7005bd8deadSopenharmony_ciDependencies on OpenGL 4.0
7015bd8deadSopenharmony_ci
7025bd8deadSopenharmony_ci    If OpenGL 4.0 is not supported, references to the BlendEquationi API should
7035bd8deadSopenharmony_ci    be removed.
7045bd8deadSopenharmony_ci
7055bd8deadSopenharmony_ciDependencies on OpenGL 4.1 (Core Profile)
7065bd8deadSopenharmony_ci
7075bd8deadSopenharmony_ci    This extension throws an INVALID_OPERATION when Begin is called if advanced
7085bd8deadSopenharmony_ci    blend equations are used in conjunction with multiple draw buffers.  For
7095bd8deadSopenharmony_ci    the core profile of OpenGL 4.1 (and other versions of OpenGL), there is no
7105bd8deadSopenharmony_ci    Begin command; instead, the error is thrown by other rendering commands
7115bd8deadSopenharmony_ci    such as DrawArrays.  The language in this specification documenting the
7125bd8deadSopenharmony_ci    error has separate versions for the core and compatibility profiles.
7135bd8deadSopenharmony_ci
7145bd8deadSopenharmony_ciDependencies on OpenGL 4.3 or later (any Profile)
7155bd8deadSopenharmony_ci
7165bd8deadSopenharmony_ci    References to Chapter 4 are replaced with references to Chapter 17 (Writing
7175bd8deadSopenharmony_ci    Fragments and Samples to the Framebuffer).
7185bd8deadSopenharmony_ci    References to section 4.1.8 are replaced with references to section 17.3.8.
7195bd8deadSopenharmony_ci    References to Table 4.1 are replace with references to Table 17.1.
7205bd8deadSopenharmony_ci    References to section 2.1.1 are replaced with references to section 2.3.3.
7215bd8deadSopenharmony_ci
7225bd8deadSopenharmony_ciDependencies on OpenGL ES 2.0
7235bd8deadSopenharmony_ci
7245bd8deadSopenharmony_ci    If unextended OpenGL ES 2.0 is supported, references to BlendEquationi,
7255bd8deadSopenharmony_ci    BlendEquationSeparatei, GetInteger64v, and GetDoublev should be ignored.
7265bd8deadSopenharmony_ci
7275bd8deadSopenharmony_ci    Ignore any references to multiple draw buffers if EXT_draw_buffers or
7285bd8deadSopenharmony_ci    NV_draw_buffers is not supported.
7295bd8deadSopenharmony_ci
7305bd8deadSopenharmony_ciDependencies on EXT_blend_minmax
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci    Requires EXT_blend_minmax on OpenGL ES 2.0 implementations and references
7335bd8deadSopenharmony_ci    to MIN and MAX should be replace by references to MIN_EXT and MAX_EXT as
7345bd8deadSopenharmony_ci    introduced by that extension.
7355bd8deadSopenharmony_ci
7365bd8deadSopenharmony_ciDependencies on OpenGL ES 3.0
7375bd8deadSopenharmony_ci
7385bd8deadSopenharmony_ci    If unextended OpenGL ES 3.0 is supported, references to BlendEquationi,
7395bd8deadSopenharmony_ci    BlendEquationSeparatei, and GetDoublev should be ignored.
7405bd8deadSopenharmony_ci
7415bd8deadSopenharmony_ciDependencies on NV_path_rendering
7425bd8deadSopenharmony_ci
7435bd8deadSopenharmony_ci    When NV_path_rendering is supported, covering geometry generated by the
7445bd8deadSopenharmony_ci    commands CoverFillPathNV, CoverFillPathInstancedNV, CoverStrokePathNV, and
7455bd8deadSopenharmony_ci    CoverStrokePathInstancedNV will automatically be blended coherently
7465bd8deadSopenharmony_ci    relative to previous geometry when using the blend equations in this
7475bd8deadSopenharmony_ci    extension.  This guarantee is provided even on implementations supporting
7485bd8deadSopenharmony_ci    only NV_blend_equation_advanced.
7495bd8deadSopenharmony_ci
7505bd8deadSopenharmony_ci    Insert the following language after the discussion of the BlendBarrierNV()
7515bd8deadSopenharmony_ci    command for both extensions:
7525bd8deadSopenharmony_ci
7535bd8deadSopenharmony_ci      [[ For NV_blend_equation_advanced only: ]]
7545bd8deadSopenharmony_ci
7555bd8deadSopenharmony_ci      The commands CoverFillPathNV, CoverFillPathInstancedNV,
7565bd8deadSopenharmony_ci      CoverStrokePathNV, and CoverStrokePathInstancedNV are considered to
7575bd8deadSopenharmony_ci      start a new blending pass, as though BlendBarrierNV were called prior to
7585bd8deadSopenharmony_ci      the cover operation.  If a cover primitive is followed by subsequent
7595bd8deadSopenharmony_ci      non-cover primitives using advanced blend equations and touching the
7605bd8deadSopenharmony_ci      same samples, applications must call BlendBarrierNV after the cover
7615bd8deadSopenharmony_ci      primitives to ensure defined blending results.
7625bd8deadSopenharmony_ci
7635bd8deadSopenharmony_ci      [[ For NV_blend_equation_advanced_coherent, the language immediately
7645bd8deadSopenharmony_ci         above should be used, but the first sentence should be prefixed with
7655bd8deadSopenharmony_ci         "When coherent blending is disabled, ...". ]]
7665bd8deadSopenharmony_ci
7675bd8deadSopenharmony_ciErrors
7685bd8deadSopenharmony_ci
7695bd8deadSopenharmony_ci    If any non-NONE draw buffer uses a blend equation found in table X.2, X.3,
7705bd8deadSopenharmony_ci    or X.4, the error INVALID_OPERATION is generated by Begin or any operation
7715bd8deadSopenharmony_ci    that implicitly calls Begin (such as DrawElements) if:
7725bd8deadSopenharmony_ci
7735bd8deadSopenharmony_ci      * the draw buffer for color output zero selects multiple color buffers
7745bd8deadSopenharmony_ci        (e.g., FRONT_AND_BACK in the default framebuffer); or
7755bd8deadSopenharmony_ci
7765bd8deadSopenharmony_ci      * the draw buffer for any other color output is not NONE.
7775bd8deadSopenharmony_ci
7785bd8deadSopenharmony_ci    If BlendParameteriNV is called and <pname> is not 
7795bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_SRC_NV or BLEND_OVERLAP_NV the error INVALID_ENUM is
7805bd8deadSopenharmony_ci    generated.
7815bd8deadSopenharmony_ci
7825bd8deadSopenharmony_ci    If BlendParameteriNV is called with <pname> set to
7835bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_SRC_NV the error INVALID_ENUM is generated if <param>
7845bd8deadSopenharmony_ci    is not TRUE or FALSE.
7855bd8deadSopenharmony_ci
7865bd8deadSopenharmony_ci    If BlendParameteriNV is called with <pname> set to BLEND_OVERLAP_NV the
7875bd8deadSopenharmony_ci    error INVALID_ENUM is generated if <param> is not one of UNCORRELATED_NV,
7885bd8deadSopenharmony_ci    DISJOINT_NV, or CONJOINT_NV.
7895bd8deadSopenharmony_ci
7905bd8deadSopenharmony_ciNew State
7915bd8deadSopenharmony_ci                                             Initial
7925bd8deadSopenharmony_ci    Get Value             Type  Get Command   Value         Description               Sec    Attribute
7935bd8deadSopenharmony_ci    --------------------  ----  ------------  ------------  ------------------------  -----  ------------
7945bd8deadSopenharmony_ci    BLEND_ADVANCED_        B    IsEnabled     TRUE          are advanced blending     4.1.8  color-buffer
7955bd8deadSopenharmony_ci      COHERENT_NV                                           equations guaranteed to
7965bd8deadSopenharmony_ci                                                            be evaluated coherently?
7975bd8deadSopenharmony_ci    BLEND_PREMULTIPLIED_   B    GetBooleanv   TRUE          use premultiplied src     4.1.8  color-buffer
7985bd8deadSopenharmony_ci      SRC_NV                                                colors with advanced
7995bd8deadSopenharmony_ci                                                            blend equations
8005bd8deadSopenharmony_ci    BLEND_OVERLAP_NV       Z3   GetIntegerv   UNCORRELATED  correlation of src/dst    4.1.8  color-buffer
8015bd8deadSopenharmony_ci                                                _NV         coverage within a pixel
8025bd8deadSopenharmony_ci
8035bd8deadSopenharmony_ci    Note:  The BLEND_ADVANCED_COHERENT_NV enable is provided if and only if
8045bd8deadSopenharmony_ci    the NV_blend_equation_advanced_coherent extension is supported.  On
8055bd8deadSopenharmony_ci    implementations supporting only NV_blend_equation_advanced, this enable is
8065bd8deadSopenharmony_ci    considered not to exist.
8075bd8deadSopenharmony_ci
8085bd8deadSopenharmony_ciNew Implementation Dependent State
8095bd8deadSopenharmony_ci
8105bd8deadSopenharmony_ci    None.
8115bd8deadSopenharmony_ci
8125bd8deadSopenharmony_ciNVIDIA Implementation Details
8135bd8deadSopenharmony_ci
8145bd8deadSopenharmony_ci    Older versions of this extension specification and early shipping
8155bd8deadSopenharmony_ci    implementations supported the COLORDODGE_NV and COLORBURN_NV equations
8165bd8deadSopenharmony_ci    without the special case discussed in issue (34). This should be fixed for
8175bd8deadSopenharmony_ci    newer driver releases.
8185bd8deadSopenharmony_ci
8195bd8deadSopenharmony_ciIssues
8205bd8deadSopenharmony_ci
8215bd8deadSopenharmony_ci    (1) How should these new blending operations be supported?
8225bd8deadSopenharmony_ci
8235bd8deadSopenharmony_ci      RESOLVED:  Provide a separate blend equation for each of the various
8245bd8deadSopenharmony_ci      blending operations.
8255bd8deadSopenharmony_ci
8265bd8deadSopenharmony_ci    (2) Many of these blending operations involve complicated computations on
8275bd8deadSopenharmony_ci        the RGB color components, but corresponding alpha operations are
8285bd8deadSopenharmony_ci        typically very simple.  How should blending on the alpha channel work?
8295bd8deadSopenharmony_ci
8305bd8deadSopenharmony_ci      RESOLVED:  Each new blend equation provides one equation for color and
8315bd8deadSopenharmony_ci      another for alpha.  In this extension, separate advanced blend equations
8325bd8deadSopenharmony_ci      for color and alpha are not supported; BlendEquationSeparate does not
8335bd8deadSopenharmony_ci      accept these enums.
8345bd8deadSopenharmony_ci
8355bd8deadSopenharmony_ci      This extension contemplated separate blend equations for RGB and alpha,
8365bd8deadSopenharmony_ci      perhaps with only basic equations for alpha, but we chose to tie RGB and
8375bd8deadSopenharmony_ci      alpha blending together for simplicity.
8385bd8deadSopenharmony_ci
8395bd8deadSopenharmony_ci    (3) Should we provide explicit support for premultiplied colors?
8405bd8deadSopenharmony_ci
8415bd8deadSopenharmony_ci      RESOLVED:  Yes.  Many of the imaging APIs supporting similar blend
8425bd8deadSopenharmony_ci      equations use premultiplied colors, some exclusively.  Additionally,
8435bd8deadSopenharmony_ci      many equations are simpler to express and compute with premultiplied
8445bd8deadSopenharmony_ci      colors.
8455bd8deadSopenharmony_ci
8465bd8deadSopenharmony_ci      In this extension, we choose to treat the destination colors and the
8475bd8deadSopenharmony_ci      blend result as premultiplied.  We considered providing a blend
8485bd8deadSopenharmony_ci      parameter supporting non-premultiplied destinations, but chose to
8495bd8deadSopenharmony_ci      support only premultiplied destinations for mathematical simplicity.
8505bd8deadSopenharmony_ci
8515bd8deadSopenharmony_ci    (4) Should we support blending where some, but not all, colors are
8525bd8deadSopenharmony_ci        premultiplied?  For example, there may be cases where the source
8535bd8deadSopenharmony_ci        fragment colors are not premultiplied, but where the destination
8545bd8deadSopenharmony_ci        colors are premultiplied.
8555bd8deadSopenharmony_ci
8565bd8deadSopenharmony_ci      RESOLVED:  Yes, we will provide support for non-premultiplied fragment
8575bd8deadSopenharmony_ci      colors (via a blending parameter), in which case the RGB color
8585bd8deadSopenharmony_ci      components are multiplied by alpha prior to blending.  
8595bd8deadSopenharmony_ci
8605bd8deadSopenharmony_ci      We considered requiring premultiplication in the fragment shader, but
8615bd8deadSopenharmony_ci      opted to provide a fixed-function premultiply operation for cases where
8625bd8deadSopenharmony_ci      it was inconvenient to modify the fragment shader to perform the
8635bd8deadSopenharmony_ci      multiplication, or where no fragment shader is executed (e.g.,
8645bd8deadSopenharmony_ci      fixed-function fragment processing, blits via the NV_draw_texture
8655bd8deadSopenharmony_ci      extension).
8665bd8deadSopenharmony_ci
8675bd8deadSopenharmony_ci    (5) Should we support different types of correlation between source and
8685bd8deadSopenharmony_ci        destination coverage in partially covered pixels?  If so, how?
8695bd8deadSopenharmony_ci
8705bd8deadSopenharmony_ci      RESOLVED:  We will provide a blend parameter allowing for multiple
8715bd8deadSopenharmony_ci      versions of many blending equations based on the "correlation" between
8725bd8deadSopenharmony_ci      source and destination coverage.  For pixels with partial opacity, there
8735bd8deadSopenharmony_ci      might be three different blend cases:  (a) where the portions of the
8745bd8deadSopenharmony_ci      pixel covered by the primitives are considered to have minimal overlap
8755bd8deadSopenharmony_ci      (e.g., abutting primitives in a mesh), (b) where the portions of the
8765bd8deadSopenharmony_ci      pixel covered by the primitives are considered to have maximal overlap
8775bd8deadSopenharmony_ci      (e.g., overlapping geometry), (c) where the portions of the pixel
8785bd8deadSopenharmony_ci      covered by the primitives are considered uncorrelated.
8795bd8deadSopenharmony_ci
8805bd8deadSopenharmony_ci    (6) Should we support swapping source and destination coverage in advanced
8815bd8deadSopenharmony_ci        blends?  If so, how?
8825bd8deadSopenharmony_ci
8835bd8deadSopenharmony_ci      RESOLVED:  In the current version, we don't support fully general
8845bd8deadSopenharmony_ci      swapping.  We do provide several pairs of blend equations that are
8855bd8deadSopenharmony_ci      equivalent, other than swapping source and destination colors.  For
8865bd8deadSopenharmony_ci      example, we provide complementary blend equations SRC_OVER_NV, where the
8875bd8deadSopenharmony_ci      source color is considered to be "over" the destination, and
8885bd8deadSopenharmony_ci      DST_OVER_NV, where the destination color is considered to be "over the
8895bd8deadSopenharmony_ci      source.  Having pairs of equations such as "SRC_OVER" and "DST_OVER"
8905bd8deadSopenharmony_ci      seems to be common practice in various imaging APIs.
8915bd8deadSopenharmony_ci
8925bd8deadSopenharmony_ci      Alternately, we could provide a blend parameter that simply swaps source
8935bd8deadSopenharmony_ci      and destination for arbitrary blend equations.  In the example above, we
8945bd8deadSopenharmony_ci      could provide a single blend equation OVER_NV, where the source color is
8955bd8deadSopenharmony_ci      considered "over" when unswapped and the destination color is considered
8965bd8deadSopenharmony_ci      "over" when swapped.
8975bd8deadSopenharmony_ci
8985bd8deadSopenharmony_ci    (7) Should we generalize the blending operation, replacing the notions of
8995bd8deadSopenharmony_ci        "source" and "destination" colors with more generic "A" and "B"
9005bd8deadSopenharmony_ci        parameters, which might be obtained from a variety of sources
9015bd8deadSopenharmony_ci        (fragment color, one of <N> color attachment points, some additional
9025bd8deadSopenharmony_ci        source of textures/images)?
9035bd8deadSopenharmony_ci
9045bd8deadSopenharmony_ci      RESOLVED:  Not in this extension; the only blending operation we support
9055bd8deadSopenharmony_ci      takes a fragment color (which could be obtained from an arbitrary
9065bd8deadSopenharmony_ci      source, either through a fragment shader, fixed function fragment
9075bd8deadSopenharmony_ci      processing, or an imaging API such as NV_draw_texture) and a destination
9085bd8deadSopenharmony_ci      color, performs a blend, and stores the result in the buffer from which
9095bd8deadSopenharmony_ci      the destination color was extracted.
9105bd8deadSopenharmony_ci
9115bd8deadSopenharmony_ci    (8) How should we expose the various combinations of blending modes?
9125bd8deadSopenharmony_ci
9135bd8deadSopenharmony_ci      RESOLVED:  The base blending equation is specified by the same
9145bd8deadSopenharmony_ci      BlendEquation() API supported for regular OpenGL blending.  Additional
9155bd8deadSopenharmony_ci      parameters (such as pre-multiplied source colors, overlap mode, source
9165bd8deadSopenharmony_ci      destination swapping, input selection) can be specified via the
9175bd8deadSopenharmony_ci      BlendParameteriNV() API.
9185bd8deadSopenharmony_ci
9195bd8deadSopenharmony_ci      We could provide for a "general" blend equation API specifying multiple
9205bd8deadSopenharmony_ci      parameters at once, such as:
9215bd8deadSopenharmony_ci
9225bd8deadSopenharmony_ci        void BlendEquationGeneralNV(enum blend, enum overlap, 
9235bd8deadSopenharmony_ci                                    boolean swapSrcDst);
9245bd8deadSopenharmony_ci
9255bd8deadSopenharmony_ci      but that API would require applications to pass parameters that are
9265bd8deadSopenharmony_ci      always the same (e.g., overlap as UNCORRELATED_NV) and wouldn't be
9275bd8deadSopenharmony_ci      easily extensible.  Note that there are several features that we've
9285bd8deadSopenharmony_ci      chosen not to include but might be usefully added as blend parameters in
9295bd8deadSopenharmony_ci      the future -- see issues (3), (6), and (7), for example.
9305bd8deadSopenharmony_ci
9315bd8deadSopenharmony_ci    (9) What limitations apply to the new blend modes?
9325bd8deadSopenharmony_ci
9335bd8deadSopenharmony_ci      RESOLVED:  In the current implementation, these blend equations are not
9345bd8deadSopenharmony_ci      supported with more than one color buffer; if this is attempted, a
9355bd8deadSopenharmony_ci      draw-time error is generated.  This limitation is similar in nature to
9365bd8deadSopenharmony_ci      one for dual-source blending, which implementations are not required to
9375bd8deadSopenharmony_ci      support in conjunction with multiple color buffers.  This limitation may
9385bd8deadSopenharmony_ci      be relaxed in a future version of this extension.
9395bd8deadSopenharmony_ci
9405bd8deadSopenharmony_ci    (10) What precision is used in the computations for these blending
9415bd8deadSopenharmony_ci         equations?
9425bd8deadSopenharmony_ci
9435bd8deadSopenharmony_ci      RESOLVED:  There are no minimum precision requirements specified in
9445bd8deadSopenharmony_ci      OpenGL 4.1, though one would expect implementations to blend with at
9455bd8deadSopenharmony_ci      least the precision used to store destination color components.  This
9465bd8deadSopenharmony_ci      extension provides this as a minimum baseline for existing blending
9475bd8deadSopenharmony_ci      equations.
9485bd8deadSopenharmony_ci
9495bd8deadSopenharmony_ci      For the new equations, we specify a minimum precision that is the
9505bd8deadSopenharmony_ci      smaller of the precision of the destination buffer or the precision of
9515bd8deadSopenharmony_ci      16-bit floating-point computations.  For most formats, this meets the
9525bd8deadSopenharmony_ci      limit for basic blend equations.  However, there may be precision loss
9535bd8deadSopenharmony_ci      if these new blending equations are used with 12-bit unsigned normalized
9545bd8deadSopenharmony_ci      components, 16-bit unsigned or signed normalized components, or 32-bit
9555bd8deadSopenharmony_ci      floating-point components.
9565bd8deadSopenharmony_ci
9575bd8deadSopenharmony_ci      This restriction is specified so that implementations are not required
9585bd8deadSopenharmony_ci      to support the large number of blending equations specified here with
9595bd8deadSopenharmony_ci      full 32-bit floating-point computations.
9605bd8deadSopenharmony_ci
9615bd8deadSopenharmony_ci    (11) When targeting a fixed-point buffer, are input color components
9625bd8deadSopenharmony_ci         clamped to [-1,1] for signed normalized color buffers or to [0,1] for
9635bd8deadSopenharmony_ci         unsigned normalized color buffers?
9645bd8deadSopenharmony_ci
9655bd8deadSopenharmony_ci      RESOLVED:  We will use the same clamping behavior as for basic blend
9665bd8deadSopenharmony_ci      equations, where fragment color components are clamped to [0,1] prior to
9675bd8deadSopenharmony_ci      blending for unsigned normalized color targets.
9685bd8deadSopenharmony_ci
9695bd8deadSopenharmony_ci      Note that the OpenGL 4.1 specification, against which this spec is
9705bd8deadSopenharmony_ci      written, had an oversight related signed normalized color buffers.  It
9715bd8deadSopenharmony_ci      specifies [0,1] clamping for all "fixed point" targets, which is clearly
9725bd8deadSopenharmony_ci      not desired for signed normalized color buffers.  Fragment shader color
9735bd8deadSopenharmony_ci      outputs should be clamped to [-1,+1] in this case; this was fixed in
9745bd8deadSopenharmony_ci      OpenGL 4.2 (bug 6849).
9755bd8deadSopenharmony_ci
9765bd8deadSopenharmony_ci    (12) What happens when converting a premultiplied color with an alpha of
9775bd8deadSopenharmony_ci         zero to a non-premultiplied color?
9785bd8deadSopenharmony_ci
9795bd8deadSopenharmony_ci      RESOLVED:  We specify that a premultiplied color of (0,0,0,0) should
9805bd8deadSopenharmony_ci      produce non-premultiplied (R,G,B) values of (0,0,0).  A premultiplied
9815bd8deadSopenharmony_ci      color with an alpha of zero and a non-zero R, G, or B component is
9825bd8deadSopenharmony_ci      considered to be ill-formed and will produce undefined blending results.
9835bd8deadSopenharmony_ci
9845bd8deadSopenharmony_ci      For a non-premultiplied color (R',G',B',A'), the corresponding
9855bd8deadSopenharmony_ci      premultiplied color (R,G,B,A) should satisfy the equation:
9865bd8deadSopenharmony_ci
9875bd8deadSopenharmony_ci        (R,G,B,A) = (R'*A', G'*A', B'*A', A')
9885bd8deadSopenharmony_ci
9895bd8deadSopenharmony_ci      If the alpha of a non-premultiplied color is zero, the corresponding
9905bd8deadSopenharmony_ci      premultiplied color (R,G,B,A) should be (0,0,0,0).
9915bd8deadSopenharmony_ci
9925bd8deadSopenharmony_ci      We specify that ill-formed premultiplied colors produce undefined
9935bd8deadSopenharmony_ci      blending results to enable certain performance optimizations.  In many
9945bd8deadSopenharmony_ci      of these blending equations, the alpha component used as a denominator
9955bd8deadSopenharmony_ci      to compute the non-premultiplied color ends up being multiplied by the
9965bd8deadSopenharmony_ci      same alpha component in the coverage, resulting in cancellation.  For
9975bd8deadSopenharmony_ci      example, implementations may want to substitute a premultiplied
9985bd8deadSopenharmony_ci      destination color into the last term of the basic blend equation:
9995bd8deadSopenharmony_ci
10005bd8deadSopenharmony_ci        R = f(Rs',Rd')*p0(As,Ad) + Y*Rs'*p1(As,Ad) + Z*Rd'*p2(As,Ad)
10015bd8deadSopenharmony_ci          =                                    ... + Z*Rd'*(Ad*(1-As))
10025bd8deadSopenharmony_ci          =                                    ... + Z*(Rd'*Ad)*(1-As)
10035bd8deadSopenharmony_ci          =                                    ... + Z* Rd * (1-As)
10045bd8deadSopenharmony_ci
10055bd8deadSopenharmony_ci      This substitution would be invalid for ill-formed premultiplied
10065bd8deadSopenharmony_ci      destination colors.  We choose to specify undefined results for invalid
10075bd8deadSopenharmony_ci      input colors rather than requiring implementations to skip such
10085bd8deadSopenharmony_ci      optimizations or include logic to check for zero alpha values for each
10095bd8deadSopenharmony_ci      input.
10105bd8deadSopenharmony_ci
10115bd8deadSopenharmony_ci    (13) Should we provide "advanced" RGB blend equations for modes commonly
10125bd8deadSopenharmony_ci         used in dedicated imaging APIs that can already be expressed with
10135bd8deadSopenharmony_ci         current OpenGL blending modes?
10145bd8deadSopenharmony_ci
10155bd8deadSopenharmony_ci      RESOLVED:  Yes; we will provide a number of "advanced" blend equations
10165bd8deadSopenharmony_ci      for basic computations that can be done with existing blend equations.
10175bd8deadSopenharmony_ci      This allows applications wanting to use these advanced modes to use them
10185bd8deadSopenharmony_ci      exclusively, without having to figure out which blends are not supported
10195bd8deadSopenharmony_ci      and generate separate BlendEquation/BlendFunc state for each.
10205bd8deadSopenharmony_ci
10215bd8deadSopenharmony_ci    (14) How do the advanced RGB blend equations interact with sRGB color
10225bd8deadSopenharmony_ci         buffers?  In particular, how does it interact with storing
10235bd8deadSopenharmony_ci         premultiplied color values in the framebuffer?
10245bd8deadSopenharmony_ci
10255bd8deadSopenharmony_ci      RESOLVED:  When targeting an sRGB color buffer with the blend equations
10265bd8deadSopenharmony_ci      in this extension, we will convert the destination colors from sRGB to
10275bd8deadSopenharmony_ci      linear and will convert the linear blend result back to sRGB when
10285bd8deadSopenharmony_ci      writing it to the framebuffer.  This approach is no different from
10295bd8deadSopenharmony_ci      regular blends.
10305bd8deadSopenharmony_ci
10315bd8deadSopenharmony_ci      sRGB conversions will affect premultiplied colors differently than
10325bd8deadSopenharmony_ci      non-premultiplied colors since:
10335bd8deadSopenharmony_ci
10345bd8deadSopenharmony_ci        linear_to_srgb(C*A) != A * linear_to_srgb(C)
10355bd8deadSopenharmony_ci
10365bd8deadSopenharmony_ci      When storing an sRGB-encoded value into an sRGB texture or renderbuffer,
10375bd8deadSopenharmony_ci      we expect that the values will be extracted as sRGB colors in a
10385bd8deadSopenharmony_ci      subsequent texturing, blending, or display operation.  The fetched sRGB
10395bd8deadSopenharmony_ci      color components will be converted back to linear.  Except from rounding
10405bd8deadSopenharmony_ci      errors in converting the color components to fixed-point, converting to
10415bd8deadSopenharmony_ci      and from sRGB will not modify the color, with or without
10425bd8deadSopenharmony_ci      premultiplication.
10435bd8deadSopenharmony_ci
10445bd8deadSopenharmony_ci    (15) The HSL blend equations are "color surgery" operations where
10455bd8deadSopenharmony_ci         components from the source and destination colors are mixed.  Are
10465bd8deadSopenharmony_ci         there any problems using these equations with premultiplied color
10475bd8deadSopenharmony_ci         components?
10485bd8deadSopenharmony_ci
10495bd8deadSopenharmony_ci      RESOLVED:  Like all of the "f/X/Y/Z" blends, the function f() in HSL
10505bd8deadSopenharmony_ci      blend equations are expressed in terms of non-premultiplied colors,
10515bd8deadSopenharmony_ci      which implies a division operation prior to evaluating f().  However, it
10525bd8deadSopenharmony_ci      may be possible to perform some or all of the blending operation using
10535bd8deadSopenharmony_ci      pre-multiplied colors directly.  In particular, the luminosity and
10545bd8deadSopenharmony_ci      saturation of a color with components scaled by alpha is equal to alpha
10555bd8deadSopenharmony_ci      times the luminosity or saturation of the un-scaled color:
10565bd8deadSopenharmony_ci
10575bd8deadSopenharmony_ci        lumv3(C*A) = A * lumv3(C)
10585bd8deadSopenharmony_ci        satv3(C*A) = A * satv3(C)
10595bd8deadSopenharmony_ci
10605bd8deadSopenharmony_ci    (16) How should we express the blending equations?
10615bd8deadSopenharmony_ci
10625bd8deadSopenharmony_ci      RESOLVED:  In general, we will use the formulation found in the PDF and
10635bd8deadSopenharmony_ci      SVG specifications, which define each blend in terms of four parameters:
10645bd8deadSopenharmony_ci
10655bd8deadSopenharmony_ci        * a function f(Cs,Cd) specifies the blended color contribution in the
10665bd8deadSopenharmony_ci          portion of the pixel containing both the source and destination;
10675bd8deadSopenharmony_ci
10685bd8deadSopenharmony_ci        * a constant X specifies whether the region containing both the source
10695bd8deadSopenharmony_ci          and destination contributes to the final alpha;
10705bd8deadSopenharmony_ci
10715bd8deadSopenharmony_ci        * a constant Y specifies whether the region containing only the source
10725bd8deadSopenharmony_ci          contributes to the final color and alpha; and
10735bd8deadSopenharmony_ci
10745bd8deadSopenharmony_ci        * a constant Z specifies whether the region containing only the
10755bd8deadSopenharmony_ci          destination contributes to the final color and alpha.
10765bd8deadSopenharmony_ci
10775bd8deadSopenharmony_ci       This formulation is relatively compact and nicely illustrates the
10785bd8deadSopenharmony_ci       contributions from the three relevant combinations of source and
10795bd8deadSopenharmony_ci       destination coverage; the portion of the pixel covered by neither the
10805bd8deadSopenharmony_ci       source nor the destination contributes nothing to color or alpha.
10815bd8deadSopenharmony_ci
10825bd8deadSopenharmony_ci       Additionally, we specify three functions p0(As,Ad), p1(As,Ad), and
10835bd8deadSopenharmony_ci       p2(As,Ad) specifying the relative portion of the pixel covered by both
10845bd8deadSopenharmony_ci       the source and destination, just the source, and just the destination,
10855bd8deadSopenharmony_ci       respectively.  These functions are defined according to the overlap
10865bd8deadSopenharmony_ci       blend parameter; the most common mode (UNCORRELATED) defines:
10875bd8deadSopenharmony_ci
10885bd8deadSopenharmony_ci         p0(As,Ad) = As*Ad
10895bd8deadSopenharmony_ci         p1(As,Ad) = As*(1-Ad)
10905bd8deadSopenharmony_ci         p2(As,Ad) = Ad*(1-As)
10915bd8deadSopenharmony_ci
10925bd8deadSopenharmony_ci       There are certain special-purpose blending equations that don't fit
10935bd8deadSopenharmony_ci       this general model (modes that mix RGB or HSL components from the
10945bd8deadSopenharmony_ci       source and destination).  These blends don't fit nicely into the
10955bd8deadSopenharmony_ci       mathematical formulas above and are instead defined separately as a
10965bd8deadSopenharmony_ci       component-by-component operation.
10975bd8deadSopenharmony_ci
10985bd8deadSopenharmony_ci    (17) How should we express the equations for the HSL blend equations?
10995bd8deadSopenharmony_ci
11005bd8deadSopenharmony_ci      RESOLVED:  The equations used by this specification are loosely adapted
11015bd8deadSopenharmony_ci      from similar code in the version 1.7 of the PDF (Portable Document
11025bd8deadSopenharmony_ci      Format) specification.  The equations have been modified to use
11035bd8deadSopenharmony_ci      GLSL-style "vec3" syntax.  Additionally, they use vector math in the
11045bd8deadSopenharmony_ci      pseudocode overriding the saturation of a base color instead of using
11055bd8deadSopenharmony_ci      "C_min", "C_mid", and "C_max" syntax effectively defining references to
11065bd8deadSopenharmony_ci      the three components of the base color.
11075bd8deadSopenharmony_ci
11085bd8deadSopenharmony_ci      Alternately, we could have specified functions for converting (R,G,B)
11095bd8deadSopenharmony_ci      colors to and from an (H,S,L) color space.  But we decided not to do
11105bd8deadSopenharmony_ci      that because actual (H,S,L) colors are never used in the pipeline.
11115bd8deadSopenharmony_ci
11125bd8deadSopenharmony_ci    (18) What issues apply to the PLUS and MINUS equations?
11135bd8deadSopenharmony_ci
11145bd8deadSopenharmony_ci      RESOLVED:  The PLUS and MINUS equations provide arithmetically simple
11155bd8deadSopenharmony_ci      operations; we simply perform a component-wise add or subtract
11165bd8deadSopenharmony_ci      operations.  The most interesting question is how and where clamping is
11175bd8deadSopenharmony_ci      performed.  The original Porter-Duff compositing specification provided
11185bd8deadSopenharmony_ci      a "plus" equation intended to support blending between two images,
11195bd8deadSopenharmony_ci      effectively performing:
11205bd8deadSopenharmony_ci
11215bd8deadSopenharmony_ci        weight * image1 + (1-weight) * image2
11225bd8deadSopenharmony_ci
11235bd8deadSopenharmony_ci      If the components of <image1>, <image2>, and <weight> are all in [0,1],
11245bd8deadSopenharmony_ci      there is no need for clamping.  However, in a general add with no
11255bd8deadSopenharmony_ci      <weight> built in, there is no guarantee that adding components of two
11265bd8deadSopenharmony_ci      images will remain inside the range [0,1].  When using fixed-point
11275bd8deadSopenharmony_ci      unsigned normalized color buffers, the sum will automatically be clamped
11285bd8deadSopenharmony_ci      to [0,1] when stored in the framebuffer.  However, there may be cases
11295bd8deadSopenharmony_ci      with floating-point color buffers where not clamping the sum also makes
11305bd8deadSopenharmony_ci      sense.
11315bd8deadSopenharmony_ci
11325bd8deadSopenharmony_ci      Additionally, when storing premultiplied colors, it may also be
11335bd8deadSopenharmony_ci      desirable to clamp R/G/B components to the range [0,A].  Premultiplied
11345bd8deadSopenharmony_ci      colors effectively store "R*A" in the R channel, where "R" is the
11355bd8deadSopenharmony_ci      non-premultiplied color and A is alpha.  Clamping this value to A
11365bd8deadSopenharmony_ci      ensures that the non-premultiplied form of R is in [0,1].
11375bd8deadSopenharmony_ci
11385bd8deadSopenharmony_ci      To handle all possible cases, we provide five "PLUS" and "MINUS"
11395bd8deadSopenharmony_ci      equations.
11405bd8deadSopenharmony_ci
11415bd8deadSopenharmony_ci        PLUS_NV:  Add color and alpha components without clamping.
11425bd8deadSopenharmony_ci
11435bd8deadSopenharmony_ci        PLUS_CLAMPED_NV:  Add color and alpha components; clamp each sum to
11445bd8deadSopenharmony_ci        1.0.
11455bd8deadSopenharmony_ci
11465bd8deadSopenharmony_ci        PLUS_CLAMPED_ALPHA_NV:  Add color and alpha components.  Clamp the
11475bd8deadSopenharmony_ci        alpha sum to 1.0; clamp the color sums to the alpha result (i.e., the
11485bd8deadSopenharmony_ci        clamped alpha sum).  Note that if premultiplied inputs are clamped
11495bd8deadSopenharmony_ci        properly where 0<=R,G,B<=A, this equation isn't needed since the color
11505bd8deadSopenharmony_ci        sums will always be less than the alpha sum.
11515bd8deadSopenharmony_ci
11525bd8deadSopenharmony_ci        MINUS_NV:  Subtract the source color and alpha components from the
11535bd8deadSopenharmony_ci        destination without clamping.
11545bd8deadSopenharmony_ci
11555bd8deadSopenharmony_ci        MINUS_CLAMPED_NV:  Subtract the source color and alpha components from
11565bd8deadSopenharmony_ci        the destination; clamp the difference to 0.0.
11575bd8deadSopenharmony_ci
11585bd8deadSopenharmony_ci      We don't bother clamping in "unexpected" direction.  We don't bother
11595bd8deadSopenharmony_ci      clamping sums to be greater than or equal to zero or differences to be
11605bd8deadSopenharmony_ci      less than or equal to one; either case would require an unclamped input
11615bd8deadSopenharmony_ci      with a negative component.
11625bd8deadSopenharmony_ci
11635bd8deadSopenharmony_ci      Note that when blending to an unsigned fixed-point buffer, the clamped
11645bd8deadSopenharmony_ci      and non-clamped versions of "PLUS" and "MINUS" produce the same results,
11655bd8deadSopenharmony_ci      since inputs and outputs are both clamped to [0,1].
11665bd8deadSopenharmony_ci
11675bd8deadSopenharmony_ci      Note that the LINEARDODGE_NV equation is another form of "PLUS"; in the
11685bd8deadSopenharmony_ci      area of intersection, the source and destination colors are added and
11695bd8deadSopenharmony_ci      clamped to 1.0.
11705bd8deadSopenharmony_ci
11715bd8deadSopenharmony_ci    (19) Should we provide a blend parameter to clamp the destination color
11725bd8deadSopenharmony_ci         (when read) to [0,1]?  What about clamping premultiplied RGB
11735bd8deadSopenharmony_ci         components to [0,a]?
11745bd8deadSopenharmony_ci
11755bd8deadSopenharmony_ci      RESOLVED:  No.  We expect the most common use case to involve unsigned
11765bd8deadSopenharmony_ci      normalized color buffers, where components will automatically be clamped
11775bd8deadSopenharmony_ci      to [0,1] by virtue of how they're stored in the framebuffer.  It doesn't
11785bd8deadSopenharmony_ci      seem worth the trouble to add a clamp-on-read feature to clamp to [0,a]
11795bd8deadSopenharmony_ci      when it seems easy enough to program colors to stay in range.
11805bd8deadSopenharmony_ci
11815bd8deadSopenharmony_ci    (20) Should we provide a blend parameter to clamp final color or alpha
11825bd8deadSopenharmony_ci         output components to [0,1]?  What about clamping premultiplied RGB
11835bd8deadSopenharmony_ci         outputs to [0,a]?
11845bd8deadSopenharmony_ci
11855bd8deadSopenharmony_ci      RESOLVED:  As above, when writing the blend results to unsigned
11865bd8deadSopenharmony_ci      normalized targets, output components will automatically be clamped to
11875bd8deadSopenharmony_ci      [0,1] by virtue of how they're stored in the framebuffer.  It doesn't
11885bd8deadSopenharmony_ci      seem worth the trouble to clamp to [0,a], either.  Most of the blend
11895bd8deadSopenharmony_ci      equations supported by this extension will produce outputs with
11905bd8deadSopenharmony_ci      premultiplied color component values in the range [0,a] as long as the
11915bd8deadSopenharmony_ci      inputs also have that property.  One exception is PLUS_NV, but we
11925bd8deadSopenharmony_ci      explicitly provide a PLUS_CLAMPED_ALPHA_NV equation to for that case.
11935bd8deadSopenharmony_ci
11945bd8deadSopenharmony_ci    (21) Should we provide an equation like the VG_BLEND_SOFTLIGHT_SVG_KHR
11955bd8deadSopenharmony_ci         blending equation in the KHR_advanced_blending extension to OpenVG?
11965bd8deadSopenharmony_ci
11975bd8deadSopenharmony_ci      RESOLVED:  No.  The KHR_advanced_blending appears to have specified a
11985bd8deadSopenharmony_ci      equation implementing the "soft-light" compositing property in a working
11995bd8deadSopenharmony_ci      draft of a SVG 1.2 specification, as described here:
12005bd8deadSopenharmony_ci
12015bd8deadSopenharmony_ci        http://www.w3.org/TR/2004/WD-SVG12-20041027/
12025bd8deadSopenharmony_ci          rendering.html#compositing
12035bd8deadSopenharmony_ci
12045bd8deadSopenharmony_ci      This version of the specification appears to have been abandoned.  The
12055bd8deadSopenharmony_ci      equations for the "soft-light" property in the SVG Compositing
12065bd8deadSopenharmony_ci      Specification at:
12075bd8deadSopenharmony_ci
12085bd8deadSopenharmony_ci        http://www.w3.org/TR/SVGCompositing/
12095bd8deadSopenharmony_ci
12105bd8deadSopenharmony_ci      match the SOFTLIGHT_NV equation provided by this extension and
12115bd8deadSopenharmony_ci      VG_BLEND_SOFTLIGHT_KHR (no "SVG") in KHR_advanced_blending.
12125bd8deadSopenharmony_ci
12135bd8deadSopenharmony_ci      Additionally, the equations in the SVG 1.2 draft and the
12145bd8deadSopenharmony_ci      KHR_advanced_blending extension both appear to contain clear errors in
12155bd8deadSopenharmony_ci      the first and second cases.  Both begin with "(cd*(as-(1-cd/ad)*..." in
12165bd8deadSopenharmony_ci      the KHR spec but should be "(cd*(as+(1-cd/ad)*...".  Both of these sign
12175bd8deadSopenharmony_ci      errors are corrected in the "SVG" functions in this extension.  With the
12185bd8deadSopenharmony_ci      errors, there is a local minimum at Cs=0.5 (where we switch from the
12195bd8deadSopenharmony_ci      first form to the second or third) and the function has a major
12205bd8deadSopenharmony_ci      discontinuity at Cd=0.125 when Cs>0.5 (where we switch from the second
12215bd8deadSopenharmony_ci      form to the third).  For example, when Cs=0.8 and Cd=0.125, the second
12225bd8deadSopenharmony_ci      form of the KHR extension would generate a result of -0.00625 and the
12235bd8deadSopenharmony_ci      third form would generate a result of ~0.26213.  Note that the corrected
12245bd8deadSopenharmony_ci      equations still aren't continuous at Cd=0.125; the fixed second and
12255bd8deadSopenharmony_ci      third forms generate 0.25625 and 0.26213, respectively, when Cs=0.8 and
12265bd8deadSopenharmony_ci      Cd=0.125.
12275bd8deadSopenharmony_ci
12285bd8deadSopenharmony_ci    (22) What issues apply to the INVERT and INVERT_OVG_NV equations?
12295bd8deadSopenharmony_ci
12305bd8deadSopenharmony_ci      RESOLVED:  The INVERT and INVERT_OVG_NV equations were included to
12315bd8deadSopenharmony_ci      provide functionality similar to the same VG_BLEND_INVERT_KHR blend
12325bd8deadSopenharmony_ci      equation provided by the KHR_advanced_blending extension to OpenVG and
12335bd8deadSopenharmony_ci      similar equations in a few other compositing APIs/standards.
12345bd8deadSopenharmony_ci
12355bd8deadSopenharmony_ci      Unfortunately, the equation specified by the KHR extension has issues.
12365bd8deadSopenharmony_ci      The apparent intent of this blend equation is to use the source alpha to
12375bd8deadSopenharmony_ci      blend between the destination color and an inverted form of the
12385bd8deadSopenharmony_ci      destination color.  This description conceptually matches the
12395bd8deadSopenharmony_ci      description in the KHR extension:
12405bd8deadSopenharmony_ci
12415bd8deadSopenharmony_ci        (1 - asrc) * c'dst + asrc * (1 - c'dst)
12425bd8deadSopenharmony_ci
12435bd8deadSopenharmony_ci      However, since source and destination colors are premultiplied, the
12445bd8deadSopenharmony_ci      expression "1-c'dst" doesn't correctly invert the destination color.  To
12455bd8deadSopenharmony_ci      invert a premultiplied destination color, "adst-c'dst" should be used.
12465bd8deadSopenharmony_ci      For example, if the premultiplied destination color is 50% gray and 50%
12475bd8deadSopenharmony_ci      opaque (adst=0.5), the RGBA destination color will be
12485bd8deadSopenharmony_ci      (0.25,0.25,0.25,0.5).  Inverting the color components via "1-c'dst"
12495bd8deadSopenharmony_ci      would yield RGB component values of 0.75, which isn't consistent with an
12505bd8deadSopenharmony_ci      alpha of 0.5.  Inverting via "adst-c'dst" would yield correct RGB
12515bd8deadSopenharmony_ci      component values of 0.25.
12525bd8deadSopenharmony_ci
12535bd8deadSopenharmony_ci      Additionally, the alpha computed for this equation in the KHR extension
12545bd8deadSopenharmony_ci      is the standard "asrc+adst*(1-asrc)", equivalent to X=Y=Z=1 in our
12555bd8deadSopenharmony_ci      normal formulation.  However, given that the source color doesn't
12565bd8deadSopenharmony_ci      contribute at all, having "Y=1" doesn't make a whole lot of sense.  The
12575bd8deadSopenharmony_ci      INVERT equation used in this extension uses X=Z=1 and Y=0, which means
12585bd8deadSopenharmony_ci      that blending with this equation never changes destination alpha.
12595bd8deadSopenharmony_ci
12605bd8deadSopenharmony_ci      We provide a separate blend equation INVERT_OVG_NV to provide 
12615bd8deadSopenharmony_ci      compatibility with the formulation in the KHR extension.  The math in
12625bd8deadSopenharmony_ci      the KHR extension does perform a "valid" blending operation -- it will
12635bd8deadSopenharmony_ci      produce results that remain in [0,1] when inputs are in [0,1], and its
12645bd8deadSopenharmony_ci      results are continuous.  It can't be expressed directly via our f/X/Y/Z
12655bd8deadSopenharmony_ci      parameterization, but it does match our general f/X/Y/Z model if you
12665bd8deadSopenharmony_ci      consider all three areas to contribute where:
12675bd8deadSopenharmony_ci
12685bd8deadSopenharmony_ci        * the intersection area contributes the inverted destination color
12695bd8deadSopenharmony_ci        * the destination-only area contributes the destination color
12705bd8deadSopenharmony_ci        * the source-only area contributes full white
12715bd8deadSopenharmony_ci
12725bd8deadSopenharmony_ci      Note that INVERT and INVERT_OVG_NV equations are mathematically
12735bd8deadSopenharmony_ci      equivalent when the destination is opaque (i.e., adst=1.0); in this
12745bd8deadSopenharmony_ci      case, "1-c'dst" and "adst-c'dst" are equivalent.  In our f/X/Y/Z model,
12755bd8deadSopenharmony_ci      the full destination coverage means there is no "source-only" area in
12765bd8deadSopenharmony_ci      this case.
12775bd8deadSopenharmony_ci
12785bd8deadSopenharmony_ci    (23) What issues apply to the PLUS_DARKER_NV blend equation?
12795bd8deadSopenharmony_ci
12805bd8deadSopenharmony_ci      RESOLVED:  The PLUS_DARKER_NV equation corresponds to an equation
12815bd8deadSopenharmony_ci      provided in the Quartz 2D API from Apple.  The public documentation for
12825bd8deadSopenharmony_ci      this equation specifies the color computed by this operation as:
12835bd8deadSopenharmony_ci
12845bd8deadSopenharmony_ci        R = MAX(0, 1 - ((1 - D) + (1 - S)))
12855bd8deadSopenharmony_ci
12865bd8deadSopenharmony_ci      This equation appears to want to invert the source and destination
12875bd8deadSopenharmony_ci      colors, add the two inverted colors, and then invert the result.
12885bd8deadSopenharmony_ci
12895bd8deadSopenharmony_ci      However, this equation appears to assume opaque source and destination
12905bd8deadSopenharmony_ci      colors.  As noted in the discussion for INVERT_OVG_NV, inverting a color
12915bd8deadSopenharmony_ci      via "1-C" doesn't make any sense.  We've reformulated the equations to
12925bd8deadSopenharmony_ci      use pre-multipled colors and invert with "A-C" in a manner similar to
12935bd8deadSopenharmony_ci      that described in this email thread:
12945bd8deadSopenharmony_ci
12955bd8deadSopenharmony_ci        http://www.mail-archive.com/whatwg@lists.whatwg.org/msg06536.html
12965bd8deadSopenharmony_ci
12975bd8deadSopenharmony_ci      which appears to be the "darker" mode implemented in the Safari browser
12985bd8deadSopenharmony_ci      (at least in 2007).  Our formulation is equivalent to the one in the
12995bd8deadSopenharmony_ci      Quartz 2D documentation when As=Ad=1.
13005bd8deadSopenharmony_ci
13015bd8deadSopenharmony_ci    (24) Should we apply the f/X/Y/Z formulation to blend equations where the
13025bd8deadSopenharmony_ci         equations can be expressed this way only if one or more of X, Y, or
13035bd8deadSopenharmony_ci         Z are neither zero nor one?
13045bd8deadSopenharmony_ci
13055bd8deadSopenharmony_ci      RESOLVED:  No.  The f/X/Y/Z model subdivides a pixel into four regions
13065bd8deadSopenharmony_ci      based on the alpha of the source and the destination, three of which
13075bd8deadSopenharmony_ci      (intersection, source only, destination only) either contribute or don't
13085bd8deadSopenharmony_ci      contribute color and coverage based on the given blend equation.  The
13095bd8deadSopenharmony_ci      figure below depicts a pixel where the source and destination both have
13105bd8deadSopenharmony_ci      coverage of 0.5 (50%).  The picture assigns source coverage to the upper
13115bd8deadSopenharmony_ci      left portion of the pixel and the destination coverage to the upper
13125bd8deadSopenharmony_ci      right, and assumes an UNCORRELATED model.  In this case, the pixel is
13135bd8deadSopenharmony_ci      divided into four areas of equal size.  The area of intersection is at
13145bd8deadSopenharmony_ci      the top, and its color and coverage are controlled by the f() and X
13155bd8deadSopenharmony_ci      parameters.  The source-only and destination-only regions are on the
13165bd8deadSopenharmony_ci      left and right, respectively, and color and coverage are both controlled
13175bd8deadSopenharmony_ci      by the Y and Z parameters.
13185bd8deadSopenharmony_ci
13195bd8deadSopenharmony_ci                    +-----------+
13205bd8deadSopenharmony_ci                    |\_  f/X  _/|
13215bd8deadSopenharmony_ci          source    |  \_   _/  |  destination
13225bd8deadSopenharmony_ci          (upper ==>| Y  \_/  Z |    (upper
13235bd8deadSopenharmony_ci           left)    |   _/ \_   | <== right)
13245bd8deadSopenharmony_ci                    | _/     \_ |
13255bd8deadSopenharmony_ci                    |/         \|
13265bd8deadSopenharmony_ci                    +-----------+
13275bd8deadSopenharmony_ci
13285bd8deadSopenharmony_ci      The PLUS_NV equation could be expressed with f(Cs,Cd) = Cs+Cd, X=2, Y=1,
13295bd8deadSopenharmony_ci      and Z=1.  The X=2 term effectively has the source and destination *both*
13305bd8deadSopenharmony_ci      contribute coverage in the area of intersection.  The MINUS_NV equation
13315bd8deadSopenharmony_ci      could be expressed with f(Cs,Cd) = Cd-Cs, X=1, Y=-1, and Z=1.  The Y=-1
13325bd8deadSopenharmony_ci      term effectively has the source-only portion of the pixel *remove*
13335bd8deadSopenharmony_ci      coverage.  Both of these don't match the physical model, and would yield
13345bd8deadSopenharmony_ci      odd results when combined with conjoint or disjoint overlap modes.
13355bd8deadSopenharmony_ci
13365bd8deadSopenharmony_ci    (25) Should we provide more specialized versions of CONJOINT_NV and
13375bd8deadSopenharmony_ci         DISJOINT_NV?
13385bd8deadSopenharmony_ci
13395bd8deadSopenharmony_ci      RESOLVED:  Not in this extension.  In the future, we could add new
13405bd8deadSopenharmony_ci      overlap modes such as:
13415bd8deadSopenharmony_ci
13425bd8deadSopenharmony_ci        NON_INTERSECTING_NV:  Like DISJOINT_NV, except that it assumes that
13435bd8deadSopenharmony_ci        As+Ad<=1.  This might be interesting when rendering polygons with
13445bd8deadSopenharmony_ci        POLYGON_SMOOTH?
13455bd8deadSopenharmony_ci
13465bd8deadSopenharmony_ci        DST_INSIDE_NV, SRC_INSIDE_NV:  Like CONJOINT_NV, except that it
13475bd8deadSopenharmony_ci        assumes that the destination coverage is fully inside the source or
13485bd8deadSopenharmony_ci        vice versa.  For DST_INSIDE, the p0/p1/p2 terms would be Ad, As-Ad,
13495bd8deadSopenharmony_ci        and 0, respectively.
13505bd8deadSopenharmony_ci
13515bd8deadSopenharmony_ci      For all three of these modes, the specialized versions would have
13525bd8deadSopenharmony_ci      simpler and possibly more efficient math.  We're not going to add any of
13535bd8deadSopenharmony_ci      these modes in this extension, however.
13545bd8deadSopenharmony_ci
13555bd8deadSopenharmony_ci    (26) Should the blend equations have a common prefix (e.g.,
13565bd8deadSopenharmony_ci    "BLEND_SRC_OVER") or just use forms without a prefix?
13575bd8deadSopenharmony_ci
13585bd8deadSopenharmony_ci      RESOLVED:  Use forms without a prefix where the tokens are only used in
13595bd8deadSopenharmony_ci      the context of blending (i.e., via the BlendEquation API).  We will use
13605bd8deadSopenharmony_ci      a "BLEND_" prefix to identify BlendParameter <pname> values because
13615bd8deadSopenharmony_ci      those tokens can also be used in the general GetIntegerv API.  Note that
13625bd8deadSopenharmony_ci      in current OpenGL, some parameters have their own Get* API (e.g.,
13635bd8deadSopenharmony_ci      TexParameter), while others use the general GetInteger queries (e.g.,
13645bd8deadSopenharmony_ci      PointParameter).
13655bd8deadSopenharmony_ci
13665bd8deadSopenharmony_ci    (27) Should we use standard GL enums for the blend equations that already
13675bd8deadSopenharmony_ci    have these names?
13685bd8deadSopenharmony_ci
13695bd8deadSopenharmony_ci      RESOLVED:  Yes, to minimize the number of new enums.  The primary risk
13705bd8deadSopenharmony_ci      is that reusing standard enum definitions would be problematic if a
13715bd8deadSopenharmony_ci      future core version wanted to use these parameters in the same place
13725bd8deadSopenharmony_ci      with a different meaning.  However, all such names are in common use in
13735bd8deadSopenharmony_ci      various compositing standards and our semantics are consistent with
13745bd8deadSopenharmony_ci      those standards.
13755bd8deadSopenharmony_ci
13765bd8deadSopenharmony_ci    (28) What other APIs support blend equations similar to the ones provided
13775bd8deadSopenharmony_ci         here, and how does the feature set compare?
13785bd8deadSopenharmony_ci
13795bd8deadSopenharmony_ci      RESOLVED:  Khronos' OpenVG 1.1 vector graphics library provides a
13805bd8deadSopenharmony_ci      variety of basic blending equations, with additional modes provided by
13815bd8deadSopenharmony_ci      the KHR_advanced_blending extension:
13825bd8deadSopenharmony_ci
13835bd8deadSopenharmony_ci      * http://www.khronos.org/registry/vg/specs/openvg-1.1.pdf
13845bd8deadSopenharmony_ci      * http://www.khronos.org/registry/vg/extensions/KHR/advanced_blending.txt
13855bd8deadSopenharmony_ci
13865bd8deadSopenharmony_ci      The World Wide Web Consortium (W3C)'s Scalable Vector Graphics format
13875bd8deadSopenharmony_ci      supports a variety of blending equations in its compositing
13885bd8deadSopenharmony_ci      specification:
13895bd8deadSopenharmony_ci
13905bd8deadSopenharmony_ci      * http://www.w3.org/TR/SVGCompositing
13915bd8deadSopenharmony_ci
13925bd8deadSopenharmony_ci      W3C also has a CSS standard (Compositing and Blending Level 1):
13935bd8deadSopenharmony_ci
13945bd8deadSopenharmony_ci      * http://www.w3.org/TR/compositing-1/
13955bd8deadSopenharmony_ci
13965bd8deadSopenharmony_ci      Adobe's widely-used Portable Document Format (PDF) specification
13975bd8deadSopenharmony_ci      provides numerous blending equations in its "Transparency" section:
13985bd8deadSopenharmony_ci
13995bd8deadSopenharmony_ci      * http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/
14005bd8deadSopenharmony_ci          pdf_reference_1-7.pdf
14015bd8deadSopenharmony_ci
14025bd8deadSopenharmony_ci      Adobe's SWF (Flash) File Format Specification
14035bd8deadSopenharmony_ci
14045bd8deadSopenharmony_ci      * http://www.adobe.com/go/swfspec
14055bd8deadSopenharmony_ci
14065bd8deadSopenharmony_ci      Various "2D" graphics APIs, including Oracle's JavaFX, Apple's Quartz
14075bd8deadSopenharmony_ci      2D, Qt's QPainter class, and X Window System's X Rendering Extension
14085bd8deadSopenharmony_ci      also support a variety of blending equations:
14095bd8deadSopenharmony_ci
14105bd8deadSopenharmony_ci      * http://docs.oracle.com/javafx/2/api/javafx/scene/effect/BlendMode.html
14115bd8deadSopenharmony_ci
14125bd8deadSopenharmony_ci      * http://developer.apple.com/library/ios/#documentation/GraphicsImaging/
14135bd8deadSopenharmony_ci          Reference/CGContext/Reference/reference.html
14145bd8deadSopenharmony_ci
14155bd8deadSopenharmony_ci      * http://doc.qt.digia.com/4.7/qpainter.html#composition-modes
14165bd8deadSopenharmony_ci
14175bd8deadSopenharmony_ci      * http://www.x.org/releases/current/doc/renderproto/renderproto.txt
14185bd8deadSopenharmony_ci
14195bd8deadSopenharmony_ci      The following table indicates the set of blend equations from this
14205bd8deadSopenharmony_ci      extension that are supported in these various standards or APIs.  "X"
14215bd8deadSopenharmony_ci      indicates that the equation is supported.  For OpenVG, "E" indicates
14225bd8deadSopenharmony_ci      that the equation is supported by the KHR_advanced_blending extension.
14235bd8deadSopenharmony_ci      "XO" that the indicates that the equation is supported with conjoint and
14245bd8deadSopenharmony_ci      disjoint overlap modes; others support only the uncorrelated overlap
14255bd8deadSopenharmony_ci      mode.
14265bd8deadSopenharmony_ci
14275bd8deadSopenharmony_ci        Blending Equation       OVG   SVG   PDF   SWF   JFX   Q2D   QPT   XRE
14285bd8deadSopenharmony_ci        --------------------   ----- ----- ----- ----- ----- ----- ----- -----
14295bd8deadSopenharmony_ci        ZERO                     E     X     -     -     -     X     X     XO
14305bd8deadSopenharmony_ci        SRC_NV                   X     X     -     X     -     X     X     XO
14315bd8deadSopenharmony_ci        DST_NV                   E     X     -     -     -     -     X     XO
14325bd8deadSopenharmony_ci        SRC_OVER_NV              X     X     X     X     X     X     X     XO
14335bd8deadSopenharmony_ci        DST_OVER_NV              X     X     -     -     -     X     X     XO
14345bd8deadSopenharmony_ci        SRC_IN_NV                X     X     -     -     -     X     X     XO
14355bd8deadSopenharmony_ci        DST_IN_NV                X     X     -     X     -     X     X     XO
14365bd8deadSopenharmony_ci        SRC_OUT_NV               E     X     -     -     -     X     X     XO
14375bd8deadSopenharmony_ci        DST_OUT_NV               E     X     -     X     -     X     X     XO
14385bd8deadSopenharmony_ci        SRC_ATOP_NV              E     X     -     -     X     X     X     XO
14395bd8deadSopenharmony_ci        DST_ATOP_NV              E     X     -     -     -     X     X     XO
14405bd8deadSopenharmony_ci        XOR_NV                   E     X     -     -     -     X     X     XO
14415bd8deadSopenharmony_ci        MULTIPLY_NV              X     X     X     X     X     X     X     X
14425bd8deadSopenharmony_ci        SCREEN_NV                X     X     X     X     X     X     X     X
14435bd8deadSopenharmony_ci        OVERLAY_NV               E     X     X     X     X     X     X     X
14445bd8deadSopenharmony_ci        DARKEN_NV                X     X     X     X     X     X     X     X
14455bd8deadSopenharmony_ci        LIGHTEN_NV               X     X     X     X     X     X     X     X
14465bd8deadSopenharmony_ci        COLORDODGE_NV            E     X     X     -     X     X     X     X
14475bd8deadSopenharmony_ci        COLORBURN_NV             E     X     X     -     X     X     X     X
14485bd8deadSopenharmony_ci        HARDLIGHT_NV             E     X     X     X     X     X     X     X
14495bd8deadSopenharmony_ci        SOFTLIGHT_NV             E     X     X     -     X     X     X     X
14505bd8deadSopenharmony_ci        DIFFERENCE_NV            E     X     X     X     X     X     X     X
14515bd8deadSopenharmony_ci        EXCLUSION_NV             E     X     X     -     X     X     X     X
14525bd8deadSopenharmony_ci        INVERT                   -     -     -     X     -     -     -     -
14535bd8deadSopenharmony_ci        INVERT_RGB_NV            -     -     -     -     -     -     -     -
14545bd8deadSopenharmony_ci        LINEARDODGE_NV           E     -     -     -     -     -     -     -
14555bd8deadSopenharmony_ci        LINEARBURN_NV            E     -     -     -     -     -     -     -
14565bd8deadSopenharmony_ci        VIVIDLIGHT_NV            E     -     -     -     -     -     -     -
14575bd8deadSopenharmony_ci        LINEARLIGHT_NV           E     -     -     -     -     -     -     -
14585bd8deadSopenharmony_ci        PINLIGHT_NV              E     -     -     -     -     -     -     -
14595bd8deadSopenharmony_ci        HARDMIX_NV               E     -     -     -     -     -     -     -
14605bd8deadSopenharmony_ci        HSL_HUE_NV               -     -     X     -     -     X     -     X
14615bd8deadSopenharmony_ci        HSL_SATURATION_NV        -     -     X     -     -     X     -     X
14625bd8deadSopenharmony_ci        HSL_COLOR_NV             -     -     X     -     -     X     -     X
14635bd8deadSopenharmony_ci        HSL_LUMINOSITY_NV        -     -     X     -     -     X     -     X
14645bd8deadSopenharmony_ci        PLUS_NV /
14655bd8deadSopenharmony_ci        PLUS_CLAMPED_NV /        X     X     -     X     X     X     X     X
14665bd8deadSopenharmony_ci        PLUS_CLAMPED_ALPHA_NV
14675bd8deadSopenharmony_ci        PLUS_DARKER_NV           -     -     -     -     -     X     -     -
14685bd8deadSopenharmony_ci        MINUS_NV /               E     -     -     X     -     -     -     -
14695bd8deadSopenharmony_ci        MINUS_CLAMPED_NV
14705bd8deadSopenharmony_ci        CONTRAST_NV              -     -     -     -     -     -     -     -
14715bd8deadSopenharmony_ci        INVERT_OVG_NV            E     -     -     -     -     -     -     -
14725bd8deadSopenharmony_ci        RED_NV                   -     -     -     -     X     -     -     -
14735bd8deadSopenharmony_ci        GREEN_NV                 -     -     -     -     X     -     -     -
14745bd8deadSopenharmony_ci        BLUE_NV                  -     -     -     -     X     -     -     -
14755bd8deadSopenharmony_ci
14765bd8deadSopenharmony_ci        OpenGL COLOR_LOGIC_OP    -     -     -     -     -     -     X     -
14775bd8deadSopenharmony_ci        (not in this extension)
14785bd8deadSopenharmony_ci
14795bd8deadSopenharmony_ci        Notes:  
14805bd8deadSopenharmony_ci
14815bd8deadSopenharmony_ci        * The PLUS_NV, PLUS_CLAMPED_NV, and PLUS_CLAMPED_ALPHA_NV equations
14825bd8deadSopenharmony_ci          are very similar and may be indistinguishable when the destination
14835bd8deadSopenharmony_ci          buffer components are stored in normalized [0,1] numeric spaces, as
14845bd8deadSopenharmony_ci          is the case in most of these standards.  The MINUS_NV and
14855bd8deadSopenharmony_ci          MINUS_CLAMPED_NV equations behave similarly.
14865bd8deadSopenharmony_ci
14875bd8deadSopenharmony_ci        * The SWF specification has a mode called "invert", but it's not clear
14885bd8deadSopenharmony_ci          whether the mode is implemented using INVERT, INVERT_OVG_NV, or some
14895bd8deadSopenharmony_ci          other equation.
14905bd8deadSopenharmony_ci
14915bd8deadSopenharmony_ci    (29) Should we provide an extension that can be supported on
14925bd8deadSopenharmony_ci         implementations that may not provide fully coherent blending when
14935bd8deadSopenharmony_ci         using the new equations?  If so, how will this support be provided
14945bd8deadSopenharmony_ci         and what limitations apply?
14955bd8deadSopenharmony_ci
14965bd8deadSopenharmony_ci      RESOLVED:  Yes, this functionality is useful not just for general 3D
14975bd8deadSopenharmony_ci      rendering, but also for 2D rendering operations (where the primitives
14985bd8deadSopenharmony_ci      rendered may be less complex).  As indicated in the issue above, the
14995bd8deadSopenharmony_ci      blend equations provided by this extension are already very commonly
15005bd8deadSopenharmony_ci      used in 2D rendering.  Accelerating them on a wide range of GPUs, old
15015bd8deadSopenharmony_ci      and new, would be very useful.
15025bd8deadSopenharmony_ci
15035bd8deadSopenharmony_ci      Older NVIDIA GPUs are able to support these blending equations as long
15045bd8deadSopenharmony_ci      as rendering is split into distinct passes and no pixel is touched more
15055bd8deadSopenharmony_ci      than once in any given pass.  For such GPUs, we specify that the results
15065bd8deadSopenharmony_ci      of blending are undefined if a single pixel (or sample) is touched more
15075bd8deadSopenharmony_ci      than once in a pass, and provide the command BlendBarrierNV() to allow
15085bd8deadSopenharmony_ci      applications to delimit boundaries between passes.  As long as rendering
15095bd8deadSopenharmony_ci      commands can be split into passes with barriers, advanced blending will
15105bd8deadSopenharmony_ci      work "normally" even on these older GPUs.
15115bd8deadSopenharmony_ci
15125bd8deadSopenharmony_ci      Since there are two distinct levels of capability, we will advertise two
15135bd8deadSopenharmony_ci      different extension string entries:
15145bd8deadSopenharmony_ci
15155bd8deadSopenharmony_ci        - GL_NV_blend_equation_advanced:  Provides the new blending
15165bd8deadSopenharmony_ci          functionality without support for full coherence (older GPUs).
15175bd8deadSopenharmony_ci
15185bd8deadSopenharmony_ci        - GL_NV_blend_equation_advanced_coherent:  Provides the new blending
15195bd8deadSopenharmony_ci          functionality with full coherence.
15205bd8deadSopenharmony_ci
15215bd8deadSopenharmony_ci      Since the functionality of these two extensions is nearly identical, we
15225bd8deadSopenharmony_ci      document them in a single extension specification.
15235bd8deadSopenharmony_ci
15245bd8deadSopenharmony_ci    (30) On implementations that don't support fully coherent blending, should
15255bd8deadSopenharmony_ci         we provide any convenience features so that "2D" applications aren't
15265bd8deadSopenharmony_ci         required to manually sprinkle BlendBarrierNV() throughout the code?
15275bd8deadSopenharmony_ci
15285bd8deadSopenharmony_ci      RESOLVED:  Yes.  When using NV_blend_equation_advanced in conjunction
15295bd8deadSopenharmony_ci      with NV_path_rendering commands like CoverFillPathNV and
15305bd8deadSopenharmony_ci      CoverStrokePathNV, the driver will assist in ensuring coherent and
15315bd8deadSopenharmony_ci      properly ordered blending by inserting implicit blend barriers before
15325bd8deadSopenharmony_ci      rendering each cover primitive.
15335bd8deadSopenharmony_ci
15345bd8deadSopenharmony_ci    (31) When we generate fragments using the automatic coherence guarantees
15355bd8deadSopenharmony_ci         from NV_path_rendering commands like CoverFillPathNV, what happens if
15365bd8deadSopenharmony_ci         a pixel touched by CoverFillPathNV had already been touched by a
15375bd8deadSopenharmony_ci         previous non-NVpr rendering command without an intervening call to
15385bd8deadSopenharmony_ci         BlendBarrierNV?  What happens if a pixel touched by CoverFillPathNV
15395bd8deadSopenharmony_ci         is subsequently touched by a subsequent non-NVpr without an
15405bd8deadSopenharmony_ci         intervening call to BlendBarrierNV?
15415bd8deadSopenharmony_ci
15425bd8deadSopenharmony_ci      RESOLVED:  We specify that a blend barrier is inserted prior to each
15435bd8deadSopenharmony_ci      cover primitives, so that cover primitives are blended coherently
15445bd8deadSopenharmony_ci      relative to geometry from previous primitives (cover or otherwise).  We
15455bd8deadSopenharmony_ci      do not guarantee that a blend barrier is inserted after each cover
15465bd8deadSopenharmony_ci      primitive, so applications need to call BlendBarrierNV manually if
15475bd8deadSopenharmony_ci      subsequent non-cover primitives are rendered to the same set of pixels.
15485bd8deadSopenharmony_ci
15495bd8deadSopenharmony_ci    (32) On implementations supporting fully coherent blending, should we
15505bd8deadSopenharmony_ci         provide some mode allowing implementations to opt out of coherent
15515bd8deadSopenharmony_ci         blending?
15525bd8deadSopenharmony_ci
15535bd8deadSopenharmony_ci      RESOLVED:  Yes.  We will provide an enable allowing applications to
15545bd8deadSopenharmony_ci      disable coherent blending in case where (a) implementations are able to
15555bd8deadSopenharmony_ci      provide higher-performance implementations if they don't have to worry
15565bd8deadSopenharmony_ci      about full coherence and/or ordering and (b) applications are willing to
15575bd8deadSopenharmony_ci      use BlendBarrierNV() to take advantage of the higher-performance
15585bd8deadSopenharmony_ci      implementation.  The enable will be on by default, which means that
15595bd8deadSopenharmony_ci      advanced blending on fully capable implementations will be "safe" unless
15605bd8deadSopenharmony_ci      explicitly disabled.
15615bd8deadSopenharmony_ci
15625bd8deadSopenharmony_ci    (33) When fully coherent blending is disabled or not supported,
15635bd8deadSopenharmony_ci         BlendBarrierNV() is used to indicate boundaries between passes.
15645bd8deadSopenharmony_ci         Should any other commands in the OpenGL API also implicitly serve as
15655bd8deadSopenharmony_ci         blend barriers?
15665bd8deadSopenharmony_ci
15675bd8deadSopenharmony_ci      RESOLVED:  In general, no.  Except for the NV_path_rendering case above,
15685bd8deadSopenharmony_ci      we will require applications manually use BlendBarrierNV().  There may
15695bd8deadSopenharmony_ci      be other operations that indirectly cause blend results to become
15705bd8deadSopenharmony_ci      coherent (in an implementation-dependent way), but we don't attempt to
15715bd8deadSopenharmony_ci      provide any explicit guarantees.  Except for path rendering cover
15725bd8deadSopenharmony_ci      primitives (see issues 30 and 31), applications should always call
15735bd8deadSopenharmony_ci      BlendBarrierNV() between possibly overlapping passes.
15745bd8deadSopenharmony_ci
15755bd8deadSopenharmony_ci      Note that implementations of this extension may use texture mapping
15765bd8deadSopenharmony_ci      hardware to source the framebuffer for blending and may end up caching
15775bd8deadSopenharmony_ci      pre-blended texel values.  This can cause subsequent texture fetches to
15785bd8deadSopenharmony_ci      return stale values unless the texture is re-bound, the
15795bd8deadSopenharmony_ci      TextureBarrierNV() command from the NV_texture_barrier extension is
15805bd8deadSopenharmony_ci      used, or some other action is taken to break the "rendering feedback
15815bd8deadSopenharmony_ci      loop".  The existing spec already defines that texel fetches produce
15825bd8deadSopenharmony_ci      undefined results when a texture object is bound both as a texture and
15835bd8deadSopenharmony_ci      attached to the current draw framebuffer, with or without advanced blend
15845bd8deadSopenharmony_ci      equations.  See the "Rendering Feedback Loops" section (p. 316 in the
15855bd8deadSopenharmony_ci      OpenGL 4.1 Compatibility Profile specification) for more information.
15865bd8deadSopenharmony_ci
15875bd8deadSopenharmony_ci    (34) How should the blend equations COLORDODGE_NV and COLORBURN_NV be
15885bd8deadSopenharmony_ci         expressed mathematically?
15895bd8deadSopenharmony_ci
15905bd8deadSopenharmony_ci      RESOLVED:  We changed the definition of these equations after the
15915bd8deadSopenharmony_ci      NV_blend_equation_advanced spec was originally published, as discussed
15925bd8deadSopenharmony_ci      below.  These changes add new special cases to the COLORDODGE_NV and
15935bd8deadSopenharmony_ci      COLORBURN_NV equations that are found in newer compositing standard
15945bd8deadSopenharmony_ci      specifications and in a number of implementations of old and new
15955bd8deadSopenharmony_ci      standards.  We believe that the omission of the special case in other
15965bd8deadSopenharmony_ci      older specifications is a bug.  We have no plans to add new blend
15975bd8deadSopenharmony_ci      equation tokens to support "equivalent" modes without the new special
15985bd8deadSopenharmony_ci      case.
15995bd8deadSopenharmony_ci
16005bd8deadSopenharmony_ci      Note, however, that older versions of this extension and older NVIDIA
16015bd8deadSopenharmony_ci      drivers implementing it will lack these special cases.  A driver update
16025bd8deadSopenharmony_ci      may be required to get the new behavior.
16035bd8deadSopenharmony_ci      
16045bd8deadSopenharmony_ci      There is some disagreement in different published specifications about
16055bd8deadSopenharmony_ci      how these two blend equations should be handled.  At the time this
16065bd8deadSopenharmony_ci      extension was initially developed, all specifications we found that
16075bd8deadSopenharmony_ci      specified blending equations mathematically (see issue 28) were written
16085bd8deadSopenharmony_ci      the same way.  Since then, we discovered that newer working drafts of
16095bd8deadSopenharmony_ci      the W3C Compositing and Blending Level 1 specification (for CSS and SVG)
16105bd8deadSopenharmony_ci      express "color-burn" as follows (translated to our nomenclature):
16115bd8deadSopenharmony_ci
16125bd8deadSopenharmony_ci        if (Cd == 1)            // their Cb (backdrop) is our Cd (destination)
16135bd8deadSopenharmony_ci          f(Cs,Cd) = 1          // their B() is our f()
16145bd8deadSopenharmony_ci        else if (Cs == 0)
16155bd8deadSopenharmony_ci          f(Cs,Cd) = 0
16165bd8deadSopenharmony_ci        else
16175bd8deadSopenharmony_ci          f(Cs,Cd) = 1 - min(1, (1-Cd)/Cs)
16185bd8deadSopenharmony_ci
16195bd8deadSopenharmony_ci      http://www.w3.org/TR/2013/WD-compositing-1-20131010/
16205bd8deadSopenharmony_ci        #blendingcolorburn
16215bd8deadSopenharmony_ci
16225bd8deadSopenharmony_ci      Earlier versions of the same W3C specification, an older SVG compositing
16235bd8deadSopenharmony_ci      draft specification, the Adobe PDF specification (and the ISO 32000-1
16245bd8deadSopenharmony_ci      standard), and the KHR_advanced_blending extension to OpenVG all specify
16255bd8deadSopenharmony_ci      the following equation without the initial special case:
16265bd8deadSopenharmony_ci
16275bd8deadSopenharmony_ci        if (Cs == 0)
16285bd8deadSopenharmony_ci          f(Cs,Cd) = 0
16295bd8deadSopenharmony_ci        else
16305bd8deadSopenharmony_ci          f(Cs,Cd) = 1 - min(1, (1-Cd)/Cs)
16315bd8deadSopenharmony_ci
16325bd8deadSopenharmony_ci        http://www.w3.org/TR/2012/WD-compositing-20120816/
16335bd8deadSopenharmony_ci          #blendingcolorburn
16345bd8deadSopenharmony_ci        http://www.w3.org/TR/2011/WD-SVGCompositing-20110315/
16355bd8deadSopenharmony_ci        http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/
16365bd8deadSopenharmony_ci          pdfs/pdf_reference_1-7.pdf
16375bd8deadSopenharmony_ci        http://www.khronos.org/registry/vg/extensions/KHR/
16385bd8deadSopenharmony_ci          advanced_blending.txt
16395bd8deadSopenharmony_ci
16405bd8deadSopenharmony_ci      For the Adobe PDF specification, the corrected blend equations are
16415bd8deadSopenharmony_ci      published in an Adobe supplement to ISO 32000-1 and are expected to be
16425bd8deadSopenharmony_ci      accepted in a future version of the standard:
16435bd8deadSopenharmony_ci
16445bd8deadSopenharmony_ci        http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/
16455bd8deadSopenharmony_ci          devnet/pdf/pdfs/adobe_supplement_iso32000_1.pdf
16465bd8deadSopenharmony_ci
16475bd8deadSopenharmony_ci      The author's understanding is that multiple shipping implementations of
16485bd8deadSopenharmony_ci      these blending modes implement the special case for "Cd==1" above,
16495bd8deadSopenharmony_ci      including various Adobe products and the open-source Ghostscript
16505bd8deadSopenharmony_ci      project.
16515bd8deadSopenharmony_ci
16525bd8deadSopenharmony_ci      We believe that the extra special case in this specification is
16535bd8deadSopenharmony_ci      consistent with the physical model of color burning.  Burning is
16545bd8deadSopenharmony_ci      described in
16555bd8deadSopenharmony_ci
16565bd8deadSopenharmony_ci        http://en.wikipedia.org/wiki/Dodging_and_burning
16575bd8deadSopenharmony_ci
16585bd8deadSopenharmony_ci      as making a print with normal exposure, and then adding additional
16595bd8deadSopenharmony_ci      exposure to darken the overall image.  In the general equation:
16605bd8deadSopenharmony_ci
16615bd8deadSopenharmony_ci        1 - min(1, (1-Cd)/Cs)
16625bd8deadSopenharmony_ci
16635bd8deadSopenharmony_ci      Cs operates as a sort of fudge factor where a value of 1.0 implies no
16645bd8deadSopenharmony_ci      additional exposure time and 0.0 implies arbitrarily long additional
16655bd8deadSopenharmony_ci      exposure time, where the initial amount of exposure (1-Cd) is multiplied
16665bd8deadSopenharmony_ci      by 1/Cs and then clamped to maximum exposure by the min() operation.
16675bd8deadSopenharmony_ci      The Cd==1 special case here implies that we get zero exposure in the
16685bd8deadSopenharmony_ci      initial print, since 1-Cd==0.  No amount of extra exposure time will
16695bd8deadSopenharmony_ci      generate any additional exposure.  This would imply that the final
16705bd8deadSopenharmony_ci      result should have zero exposure and thus a final f() value of 1.  This
16715bd8deadSopenharmony_ci      matches the initial special case.  Without that special case, we would
16725bd8deadSopenharmony_ci      hit the second special case if Cs==0 (infinite exposure time), which
16735bd8deadSopenharmony_ci      would yield an incorrect final value of 0 (full exposure).
16745bd8deadSopenharmony_ci
16755bd8deadSopenharmony_ci      A similar issue applies to COLORDODGE_NV, where some specifications
16765bd8deadSopenharmony_ci      include a special case for Cb==0 while others do not.  We have added a
16775bd8deadSopenharmony_ci      special case there as well.
16785bd8deadSopenharmony_ci
16795bd8deadSopenharmony_ci    (35) For "HSL" blend equations, the blend equation involves a clipping
16805bd8deadSopenharmony_ci         step where colors may be "clipped" if the blend would produce
16815bd8deadSopenharmony_ci         components are outside the range [0,1]. Are there inputs where this
16825bd8deadSopenharmony_ci         blend could produce ill-defined or nonsensical results?
16835bd8deadSopenharmony_ci         
16845bd8deadSopenharmony_ci      RESOLVED: Yes, the results of HSL blend equations are undefined if the
16855bd8deadSopenharmony_ci      input colors have components outside the range [0,1]. Even if the input
16865bd8deadSopenharmony_ci      colors are in-range, the basic color adjustment done in these blends
16875bd8deadSopenharmony_ci      could produce result components outside the range [0,1]. To compensate,
16885bd8deadSopenharmony_ci      the ClipColor() function in the specification interpolates the result
16895bd8deadSopenharmony_ci      color and a greyscale value that matches the luminance of the result.
16905bd8deadSopenharmony_ci      The math for the clipping operation assumes the luminance of the result
16915bd8deadSopenharmony_ci      color is in the range [0,1]. If that isn't the case, the clipping
16925bd8deadSopenharmony_ci      operation could result in a divide by zero (when all result components
16935bd8deadSopenharmony_ci      have the same out-of-bounds value) or perform an otherwise nonsensical
16945bd8deadSopenharmony_ci      computation.
16955bd8deadSopenharmony_ci
16965bd8deadSopenharmony_ci
16975bd8deadSopenharmony_ciRevision History
16985bd8deadSopenharmony_ci    
16995bd8deadSopenharmony_ci    Rev.    Date    Author    Changes
17005bd8deadSopenharmony_ci    ----  --------  --------  ----------------------------------------------
17015bd8deadSopenharmony_ci    10    02/14/18  pdaniell  Fix ClipColor() equation where in the
17025bd8deadSopenharmony_ci                              "if (maxcol > 1.0)" body the "(color-lum)*lum"
17035bd8deadSopenharmony_ci                              term should have been "(color-lum)*(1-lum)".
17045bd8deadSopenharmony_ci                              Also add new issue 35 for the case where the
17055bd8deadSopenharmony_ci                              inputs to SetLum() are outside the range
17065bd8deadSopenharmony_ci                              [0..1] and could cause a divide-by-zero in
17075bd8deadSopenharmony_ci                              ClipColor().
17085bd8deadSopenharmony_ci    
17095bd8deadSopenharmony_ci     9    09/30/14  pbrown    Fix incorrectly specified color clamping in
17105bd8deadSopenharmony_ci                              the HSL blend modes.
17115bd8deadSopenharmony_ci
17125bd8deadSopenharmony_ci     8    02/26/14  pbrown    For non-coherent blending, clarify that all
17135bd8deadSopenharmony_ci                              writes to a sample are considered to "touch"
17145bd8deadSopenharmony_ci                              that sample and require a BlendBarrierOES call
17155bd8deadSopenharmony_ci                              before blending overlapping geometry.  Clears,
17165bd8deadSopenharmony_ci                              non-blended geometry, and copies by
17175bd8deadSopenharmony_ci                              BlitFramebuffer or TexSubImage are all
17185bd8deadSopenharmony_ci                              considered to "touch" a sample (bug 11738).
17195bd8deadSopenharmony_ci                              Specify that non-premultiplied values
17205bd8deadSopenharmony_ci                              corresponding to ill-conditioned premultiplied
17215bd8deadSopenharmony_ci                              colors such as (1,1,1,0) are undefined (bug
17225bd8deadSopenharmony_ci                              11739).  Update issue (12) related to
17235bd8deadSopenharmony_ci                              ill-conditioned premultiplied colors.
17245bd8deadSopenharmony_ci
17255bd8deadSopenharmony_ci     7    11/06/13  pbrown    Fix the language about non-coherent blending
17265bd8deadSopenharmony_ci                              to specify that results are undefined only if an
17275bd8deadSopenharmony_ci                              individual *sample* is touched more than once
17285bd8deadSopenharmony_ci                              (instead of *pixel*).  Minor language tweaks to
17295bd8deadSopenharmony_ci                              use "equations" consistently, instead of
17305bd8deadSopenharmony_ci                              sometimes using "modes".
17315bd8deadSopenharmony_ci
17325bd8deadSopenharmony_ci     6    10/21/13  pbrown    Add NV-suffixed names for tokens reusing values
17335bd8deadSopenharmony_ci                              from core OpenGL enums (XOR, RED, GREEN, BLUE)
17345bd8deadSopenharmony_ci                              that are not in core OpenGL ES 2.0.  This allows
17355bd8deadSopenharmony_ci                              code targeting both APIs to use the same
17365bd8deadSopenharmony_ci                              NV-suffixed #defines.  Some older versions of
17375bd8deadSopenharmony_ci                              the OpenGL "glext.h" header will not have the
17385bd8deadSopenharmony_ci                              NV-suffixed names.
17395bd8deadSopenharmony_ci
17405bd8deadSopenharmony_ci     5    10/21/13  pbrown    Add a reference to the Adobe supplement to
17415bd8deadSopenharmony_ci                              ISO 32000-1, which includes the corrected
17425bd8deadSopenharmony_ci                              equations for COLORDODGE_NV and COLORBURN_NV.
17435bd8deadSopenharmony_ci                              Move "NVIDIA Implementation Details" down
17445bd8deadSopenharmony_ci                              a bit in the spec.
17455bd8deadSopenharmony_ci
17465bd8deadSopenharmony_ci     4    10/16/13  pbrown    Modify the definition of COLORDODGE_NV and
17475bd8deadSopenharmony_ci                              COLORBURN_NV to match de facto standard
17485bd8deadSopenharmony_ci                              implemenations and new CSS/SVG compositing
17495bd8deadSopenharmony_ci                              spec; add issue (34).
17505bd8deadSopenharmony_ci
17515bd8deadSopenharmony_ci     3    08/19/13  pbrown    Fix typos in the OpenGL ES 2.0 and 3.0
17525bd8deadSopenharmony_ci                              interactions sections.
17535bd8deadSopenharmony_ci
17545bd8deadSopenharmony_ci     2    07/25/13  mjk       Add W3C CSS compositing reference.
17555bd8deadSopenharmony_ci
17565bd8deadSopenharmony_ci     1              pbrown    Internal revisions.
1757