• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_blend_func_extended
4
5Name Strings
6
7    GL_EXT_blend_func_extended
8
9Contact
10
11    Mark Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com)
12
13Contributors
14
15    Daniel Koch, NVIDIA
16    Slawomir Grajewski, Intel
17    Chris Dalton, NVIDIA
18    Brian Salomon, Google
19
20    From ARB_blend_func_extended...
21
22    Graham Sellers, AMD
23    Mark Young, AMD
24    Nick Haemel, AMD
25    Pierre Boudier, AMD
26    Mais Alnasser, AMD
27    Jeff Bolz, NVIDIA
28    Pat Brown, NVIDIA
29    Ian Stewart, NVIDIA
30    Jon Leech, Khronos
31
32Status
33
34    Complete
35
36    Exposed in ES contexts in NVIDIA drivers 358.00 (Septmeber 2015)
37    and later.
38
39Version
40
41    Last Modified Date:         August 25, 2015
42    Revision:                   6
43
44Number
45
46    OpenGL ES Extension #247
47
48Dependencies
49
50    This extension is written against the OpenGL ES 3.1 (June 4, 2014)
51    specification, but can apply to earlier versions back to ES 2.0.
52
53    GLSL version 300 and 310 language is written against The OpenGL ES
54    Shading Language (July 11, 2012).
55
56    GLSL version 100 language is written against The OpenGL ES Shading
57    Language (May 12, 2009).
58
59    The NV_draw_buffers and EXT_draw_buffers extensions trivially affect
60    the definition of this extension.
61
62    The EXT_draw_buffers_indexed extension affects the definition of
63    this extension.
64
65Overview
66
67    This extension provides an ES version of the ARB_blend_func_extended
68    functionality.
69
70    Traditional OpenGL includes fixed-function blending that combines
71    source colors with the existing content of a render buffer in
72    a variety of ways.  A number of extensions have enhanced this
73    functionality by adding further sources of blending weights and
74    methods to combine them. However, the inputs to the fixed-function
75    blending units are constrained to a source color (as output from
76    fragment shading), destination color (as the current content of the
77    frame buffer) or constants that may be used in their place.
78
79    This extension adds new blending functions whereby a fragment
80    shader may output two colors, one of which is treated as the
81    source color, and the other used as a blending factor for either
82    source or destination colors.  Furthermore, this extension increases
83    orthogonality by allowing the SRC_ALPHA_SATURATE function to be used
84    as the destination weight.
85
86    Because of the limitations of the OpenGL ES 2.0 shading language,
87    new built-in variables (gl_SecondaryFragColorEXT,
88    gl_SecondaryFragDataEXT) are added to the ES 1.00 shading language
89    rather than introduce more complex features for user-defined fragment
90    outputs.  Because such built-in variable are deprecated in ES 3.0,
91    these variables are NOT available in the OpenGL ES 3.xx shading
92    language verisons.
93
94IP Status
95
96    No known IP claims.
97
98New Procedures and Functions
99
100    void BindFragDataLocationIndexedEXT(uint program, uint colorNumber,
101                                        uint index, const char * name);
102
103    int GetFragDataIndexEXT(uint program, const char * name);
104
105    void BindFragDataLocationEXT(uint program, uint colorNumber, const char * name)
106
107    int GetProgramResourceLocationIndexEXT(uint program, enum programInterface, const char *name);
108
109New Tokens
110
111    Accepted by the <src> and <dst> parameters of BlendFunc and
112    BlendFunciEXT, and by the <srcRGB>, <dstRGB>, <srcAlpha> and <dstAlpha>
113    parameters of BlendFuncSeparate and BlendFuncSeparateiEXT:
114
115        SRC1_COLOR_EXT                                  0x88F9
116        SRC1_ALPHA_EXT                                  0x8589  // OpenGL 1.5 token value
117        ONE_MINUS_SRC1_COLOR_EXT                        0x88FA
118        ONE_MINUS_SRC1_ALPHA_EXT                        0x88FB
119        SRC_ALPHA_SATURATE_EXT                          0x0308
120
121    Accepted in the <props> array of GetProgramResourceiv:
122
123        LOCATION_INDEX_EXT                              0x930F
124
125    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
126    and GetFloatv:
127
128        MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT                0x88FC
129
130Additions to Chapter 7 of the OpenGL ES 3.1 Specification (Programs and
131Shaders)
132
133   Add a row to table 7.2 "GetProgramResourceiv properties and supported
134   interfaces" (page 82):
135
136   Property            Supported Interfaces
137   ------------------  --------------------
138   LOCATION_INDEX_EXT  PROGRAM_OUTPUT
139
140   Modify section 7.3.1.1 "Naming Active Resources" subsection to include
141   after the LOCATION paragraph (page 84):
142
143   "For the property LOCATION_INDEX_EXT, a single integer identifying the
144   fragment color index of an active fragment shader output variable
145   is written to params. If the active variable is not an output for a
146   fragment shader, the value -1 will be written to params."
147
148   Modify (page 87) the paragraph introducing GetProgramResourceLocation
149   to begin:
150
151   "The commands
152
153        int GetProgramResourceLocation( uint program,
154            enum programInterface, const char *name );
155        int GetProgramResourceLocationIndexEXT( uint program,
156            enum programInterface, const char *name );
157
158    return the location or the fragment color index, respectively,
159    assigned to the variable named name in interface programInterface
160    of program object program."
161
162    Change the ending of the same paragraph to read:
163
164    "For GetProgramResourceLocationIndexEXT, programInterface must be
165    PROGRAM_OUTPUT. The value -1 will be returned by either command if
166    an error occurs, if name does not identify an active variable on
167    programInterface, or if name identifies an active variable that
168    does not have a valid location assigned, as described above. The
169    locations returned by these commands are the same locations returned
170    when querying the LOCATION and LOCATION_INDEX resource properties."
171
172    Change the next paragaph to begin:
173
174    "A string provided to GetProgramResourceLocation or
175    GetProgramResourceLocationIndexEXT is considered to match an active
176    variable if ..."
177
178    Change the last paragraph of the section (page 88) to read:
179
180    ... "If the string specifies an element of an array variable,
181    GetProgramResourceLocation and GetProgramResourceLocationIndexEXT
182    return the location or fragment color index assigned to that
183    element. If it specifies the base name of an array, it identifies
184    the resources associated with the first element of the array."
185
186Additions to Chapter 14 of the OpenGL ES 3.1 Specification (Programmable
187Fragment Processing)
188
189    Modify section 14.2.3 "Shader Outputs" subsection to include:
190
191    "The binding of a user-defined varying out variable to a fragment color number
192    can be specified explicitly. The command
193
194        void BindFragDataLocationIndexedEXT(uint program, uint colorNumber,
195                                            uint index, const char * name);
196
197    specifies that the varying out variable name in <program> should
198    be bound to fragment color <colorNumber> when the program is next
199    linked. <index> may be zero or one to specify that the color
200    be used as either the first or second color input to the blend
201    equation, respectively, as described in Section 15.1.5 (Blending).
202    If <name> was bound previously, its assigned binding is replaced
203    with colorNumber. <name> must be a null-terminated string. The error
204    INVALID_VALUE is generated if <colorNumber> is equal or greater
205    than the value of MAX_DRAW_BUFFERS and <index> is zero,
206    or if <colorNumber> is equal or greater than the value of
207    MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT and <index> is greater than or
208    equal to one.  The command
209
210        void BindFragDataLocationEXT(uint program, uint colorNumber,
211                                     const char * name)
212
213    is equivalent to calling BindFragDataLocationIndexedEXT with the
214    same values for <program>, <colorNumber> and <name>, and with <index>
215    set to zero.
216
217    When a program is linked, any varying out variables without
218    a binding specified through BindFragDataLocationIndexedEXT or
219    BindFragDataLocationEXT will automatically be bound to fragment
220    colors and indices by the GL.  All such assignments will use color
221    indices of zero.  Such bindings can be queried using the commands
222    GetFragDataLocation and GetFragDataIndexEXT.  Output binding
223    assignments will cause LinkProgram to fail:
224
225      * if the number of active outputs is greater than the value of
226        MAX_DRAW_BUFFERS_EXT;
227
228      * if the program has an active output assigned to a location greater
229        than or equal to the value of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT
230        and has an active output assigned an index greater than or equal
231        to one;
232
233      * if more than one varying out variable is bound to the same number
234        and index; or
235
236      * if the explicit binding assignments do not leave enough space
237        for the linker to automatically assign a location for a varying
238        out array, which requires multiple contiguous locations.
239
240    BindFragDataLocationIndexedEXT may be issued before any shader objects
241    are attached to a program object. Hence it is allowed to bind any
242    name (except a name starting with gl_) to a color number and index,
243    including a name that is never used as a varying out variable in
244    any fragment shader object.  Assigned bindings for variables that
245    do not exist are ignored."
246
247    Add to end of section:
248
249    "The command
250
251        int GetFragDataIndexEXT(uint program, const char * name);
252
253    returns the index of the fragment color to which the variable <name>
254    was bound when the program object <program> was last linked. If
255    program has not been successfully linked, the error INVALID_OPERATION
256    is generated. If name is not a varying out variable, or if an error
257    occurs, -1 will be returned.  The command is equivalent to
258
259        GetProgramResourceLocationIndex(program, PROGRAM_OUTPUT, name);"
260
261Additions to Chapter 15 of the OpenGL ES 3.1 Specification (Writing
262Fragments and Samples to the Framebuffer)
263
264    Modify section 15.1.5.2 "Blend Functions":
265
266    Change the first paragraph to read:
267
268    "The weighting factors used by the blend equation are determined by
269    the blend functions. There are four possible sources for weighting
270    factors. These are the constant color (Rc, Gc, Bc, Ac) (see
271    BlendColor, p. 211), the first source color (Rs0, Gs0, Bs0, As0),
272    the second source color (Rs1, Gs1, Bs1, As1), and the destination
273    color (the existing content of the draw buffer). Additionally the
274    special constants ZERO and ONE are available as weighting factors."
275
276    Modify Table 15.2 (RGB and ALPHA source and destination blend
277    functions ...) as follows
278
279                                                            RGB Blend Factors                   Alpha Blend Factors
280        Value                                               (Sr, Sg, Sb) or (Dr, Dg, Db)        Sa or Da
281        -----                                               ----------------------------        -------------------
282        ZERO                                                (0, 0, 0)                           0
283        ONE                                                 (1, 1, 1)                           1
284        SRC_COLOR                                           (Rs0, Gs0, Bs0)                     As0
285        ONE_MINUS_SRC_COLOR                                 (1, 1, 1) - (Rs0, Gs0, Bs0)         1 - As0
286        DST_COLOR                                           (Rd, Gd, Bd)                        Ad
287        ONE_MINUS_DST_COLOR                                 (1, 1, 1) - (Rd, Gd, Bd)            1 - Ad
288        SRC_ALPHA                                           (As0, As0, As0)                     As0
289        ONE_MINUS_SRC_ALPHA                                 (1, 1, 1) - (As0, As0, As0)         1 - As0
290        DST_ALPHA                                           (Ad, Ad, Ad)                        Ad
291        ONE_MINUS_DST_ALPHA                                 (1, 1, 1) - (Ad, Ad, Ad)            1 - Ad
292        CONSTANT_COLOR                                      (Rc, Gc, Bc)                        Ac
293        ONE_MINUS_CONSTANT_COLOR                            (1, 1, 1) - (Rc, Gc, Bc)            1 - Ac
294        CONSTANT_ALPHA                                      (Ac, Ac, Ac)                        Ac
295        ONE_MINUS_CONSTANT_ALPHA                            (1, 1, 1) - (Ac, Ac, Ac)            1 - Ac
296        SRC_ALPHA_SATURATE                                  (f, f, f)                           1                       New (for ES 2.x)
297        SRC1_COLOR_EXT                                      (Rs1, Gs1, Bs1)                     As1                     New
298        ONE_MINUS_SRC1_COLOR_EXT                            (1, 1, 1) - (Rs1, Gs1, Bs1)         1 - As1                 New
299        SRC1_ALPHA_EXT                                      (As1, As1, As1)                     As1                     New
300        ONE_MINUS_SRC1_ALPHA_EXT                            (1, 1, 1) - (As1, As1, As1)         1 - As1                 New
301
302    For ES 2.0, remove table's footnote saying (ES 3.x already has this
303    removed):
304
305        SRC_ALPHA_SATURATE is valid only for source RGB and alpha
306        blending functions.
307
308    Add the following subsections to Section 5.1.5 Blending, at the end
309    of the subsection 15.1.5.2 "Blend Functions":
310
311    "15.1.5.X  Dual Source Blending and Multiple Draw Buffers
312
313    Blend functions that require the second color input, <Rs1, Gs1, Bs1,
314    As1> (SRC1_COLOR_EXT, SRC1_ALPHA_EXT, ONE_MINUS_SRC1_COLOR_EXT, or
315    ONE_MINUS_SRC1_ALPHA_EXT) may consume hardware resources that could
316    otherwise be used for rendering to multiple draw buffers. Therefore,
317    the number of draw buffers that can be attached to a frame buffer
318    may be lower when using dual-source blending.
319
320    The maximum number of draw buffers that may be attached to a
321    single frame buffer when using dual-source blending functions is
322    implementation dependent and can be queried by calling GetIntegerv
323    with the symbolic constant MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT. When
324    using dual-source blending, MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT should be
325    used in place of MAX_DRAW_BUFFERS_EXT to determine the maximum number
326    of draw buffers that may be attached to a single frame buffer. The
327    value of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT must be at least 1. If
328    the value of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT is 1, then dual-source
329    blending and multiple draw buffers cannot be used simultaneously.
330
331    If either blend function is set to one of the second source factors
332    (SRC1_COLOR_EXT, SRC1_ALPHA_EXT, ONE_MINUS_SRC1_COLOR_EXT, or
333    ONE_MINUS_SRC1_ALPHA_EXT) for any draw buffer and any draw buffers
334    equal to or greater than the value of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT
335    have values other than NONE, the error INVALID_OPERATION is generated
336    by drawing commands.
337
338    15.1.5.Y  Generation of Second Color Source for Blending
339
340    Rendering using any of the blend functions that consume the second
341    input color (SRC1_COLOR_EXT, ONE_MINUS_SRC1_COLOR_EXT, SRC1_ALPHA_EXT
342    or ONE_MINUS_SRC1_ALPHA_EXT) using a shader that does not output
343    a second source color will produce undefined results.  To produce
344    input for the second source color, a shader must be used that outputs
345    a second source color.
346
347    When using a GLSL version 300 es or higher fragment shader with
348    dual-source blending functions, the color output varyings are bound
349    to the first (index 0) and second (index 1) inputs of a draw buffer
350    using BindFragDataLocationIndexedEXT as described in the "Shader
351    Outputs" subsection of Section 3.12.2 or by layout qualifiers for
352    location=/n/ and index=/m/. Data written to the first of these outputs
353    becomes the first source color input to the blender (corresponding
354    to SRC_COLOR and SRC_ALPHA). Data written to the second of these
355    outputs generates the second source color input to the blender
356    (corresponding to SRC1_COLOR_EXT and SRC1_ALPHA_EXT).
357
358    Alternatively if the GLSL version 100 fragment shader is used (where
359    user-defined color outputs are unsupported, hence a user-defined
360    color output is not available for BindFragDataLocationIndexEXT), the
361    gl_FragColor and gl_SecondaryFragColorEXT fragment outputs correspond
362    to the first and second source color respectively.  Similarly the
363    gl_FragData and gl_SecondaryFragDataEXT fragment output arrays
364    correspond to the first and second source color respectively of each
365    color buffer output.
366
367    If the second color input to the blender is not written in the
368    shader, or if no output is bound to the second input of a blender,
369    the result of the blending operation is not defined.
370
371    Other shading languages may define similar methods for producing
372    the first and second color inputs to blending equations."
373
374Additions to the OpenGL ES Shading Language 1.00 Specification
375
376    Including the following line in a shader can be used to control the
377    language features described in this extension:
378
379      #extension GL_EXT_blend_func_extended : <behavior>
380
381    where <behavior> is as specified in section 3.4.
382
383    A new preprocessor #define is added to the OpenGL ES Shading Language:
384
385      #define GL_EXT_blend_func_extended 1
386
387    Modify paragraphs in section 7.2 "Fragment Shader Special Variables" as follows:
388
389    First paragraph, second sentence:
390
391    "Fragment shaders output values to the OpenGL ES pipeline using
392    the built-in variables gl_FragColor, gl_SecondaryFragColorEXT,
393    gl_FragData, and gl_SecondaryFragDataEXT, unless the discard keyword
394    is executed."
395
396    Second paragraph, first sentence:
397
398    "It is not a requirement for the fragment shader to write to
399    either gl_FragColor, gl_SecondaryFragColorEXT, gl_FragData, or
400    gl_SecondaryFragDataEXT."
401
402    Add after the fourth paragraph:
403
404    "Writing to gl_SecondaryFragColorEXT specifies a second fragment color
405    that will be used by the subsequent fixed functionality pipeline for
406    dual source blending. If subsequent fixed functionality consumes the
407    second fragment color and an execution of a fragment shader does
408    not write a value to gl_SecondaryFragColorEXT then the secondary
409    fragment color consumed is undefined."
410
411    Add after the fifth paragraph:
412
413    "The variable gl_SecondaryFragDataEXT is an array. Writing to
414    gl_SecondaryFragDataEXT[n] specifies the secondary fragment data that
415    will be used by the subsequent fixed functionality pipeline for data n
416    for dual source blending. If subsequent fixed functionality consumes
417    secondary fragment data and an execution of a fragment shader does
418    not write a value to it, then the secondary fragment data consumed
419    is undefined."
420
421    Modify the sixth paragraph to read:
422
423    "If a shader statically assigns a value to gl_FragColor or
424    gl_SecondaryFragColorEXT, it may not assign a value to any
425    element of gl_FragData or gl_SecondaryFragDataEXT. If a shader
426    statically writes a value to any element of gl_FragData or
427    gl_SecondaryFragDataEXT, it may not assign a value to gl_FragColor
428    or gl_SecondaryFragColorEXT. That is, a shader may assign values to
429    either the set of gl_FragColor and gl_SecondaryFragColorEXT or the
430    set of gl_FragData and gl_SecondaryFragDataEXT, but not both."
431
432    Modify the eighth paragraph to read:
433
434    "If a shader executes the discard keyword, the fragment is discarded,
435    and the values of gl_FragColor, gl_SecondaryFragColorEXT, gl_FragData,
436    and gl_SecondaryFragDataEXT become irrelevant."
437
438    Add these built-in variable to the list "accessible from a fragment shader":
439
440        mediump vec4 gl_SecondaryFragColorEXT;
441        mediump vec4 gl_SecondaryFragDataEXT[gl_MaxDualSourceDrawBuffersEXT];
442
443    Add to section 7.4 "Built-In Constants" the following constant:
444
445        const mediump int gl_MaxDualSourceDrawBuffersEXT = 1;
446
447Additions to the OpenGL ES Shading Language 3.00 and 3.10 Specification
448
449    Including the following line in a shader can be used to control the
450    language features described in this extension:
451
452      #extension GL_EXT_blend_func_extended : <behavior>
453
454    where <behavior> is as specified in section 3.4.
455
456    A new preprocessor #define is added to the OpenGL ES Shading Language:
457
458      #define GL_EXT_blend_func_extended 1
459
460    Modify section 4.4.2 "Output Layout Qualifiers":
461
462    Change the second paragraph to read:
463
464    "Fragment shaders allow output layout qualifiers only on the interface
465    qualifier out. The layout qualifier identifier for fragment shader
466    outputs is:
467
468        layout-qualifier-id
469            location = integer-constant
470            index = integer-constant
471
472    Each of these qualifiers may appear at most once. If index is
473    specified, location must also be specified.  If index is not
474    specified, the value 0 is used."
475
476    Add an additional example to the end of the fourth paragraph's example:
477
478    "And,
479
480        layout(location = 3, index = 1) out vec4 factor;
481
482    will establish that the fragment shader output factor is copied out
483    to fragment color 3 as the second (index one) input to the blend
484    equation."
485
486    Change the first sentence of the second to last paragraph to read:
487
488    "If there is more than one fragment output, the location must
489    be specified for all outputs unless the EXT_blend_func_extended
490    extension is enabled in which case more than one unassigned fragment
491    output locations are allowed though they must be assigned to unique
492    locations assigned with glBindFragDataLocationIndexedEXT prior to
493    linking."
494
495    Add to section 7.4 "Built-In Constants" the following constant:
496
497        const mediump int gl_MaxDualSourceDrawBuffersEXT = 1;
498
499Dependencies on OpenGL ES 3.0
500
501    If OpenGL ES 3.0 or higher is not supported (meaning OpenGL ES 2.0
502    support only), remove all references to the functions:
503
504        BindFragDataLocationIndexedEXT
505        GetFragDataIndexEXT
506        BindFragDataLocationEXT
507        GetProgramResourceLocationIndexEXT
508
509    Also ignore the additions to chapters 7 and 14 and the paragraph in
510    section 15.1.5.Y related to GLSL version 300 es or higher.
511
512    When OpenGL ES 3.0 or higher, the "Additions to the OpenGL ES
513    Shading Language 1.00 Specification" applies to the version 100
514    shading language, but not later versions.
515
516Dependencies on OpenGL ES 3.1
517
518    If OpenGL ES 3.1 or higher is not supported (meaning OpenGL ES 3.0
519    or earlier), remove all references to the function
520
521        GetProgramResourceLocationIndexEXT
522
523    because program resource queries are added by ES 3.1.
524
525    Also ignore the additions to chapter 7.
526
527Dependencies on EXT_draw_buffers or NV_draw_buffers
528
529    Using dual-source blending functions may consume additional outputs
530    from hardware shading units and therefore can reduce the number
531    of draw buffers that may be attached to a single frame buffer when
532    dual-source blending functions are enabled. In this case, the value
533    of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT may be less than the value of
534    MAX_DRAW_BUFFERS_EXT. If EXT_draw_buffers or NV_draw_buffers is not
535    supported then the value of MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT must
536    be 1. Furthermore, the discussion in the subsection entitled "Dual
537    Source Blending and Multiple Draw Buffers" may be discarded.
538
539Dependencies on EXT_draw_buffers_indexed
540
541    If EXT_draw_buffers_indexed is not supported, all references to
542    BlendFunciEXT and BlendFuncSeparateiEXT should be removed. In this
543    case, the blend functions for all attached draw buffers will be the
544    same.
545
546Errors
547
548    The error INVALID_OPERATION is generated by Begin or any
549    procedure that implicitly calls Begin if any draw buffer has a
550    blend function requiring the second color input (SRC1_COLOR_EXT,
551    ONE_MINUS_SRC1_COLOR_EXT, SRC1_ALPHA_EXT or ONE_MINUS_SRC1_ALPHA_EXT),
552    and a framebuffer is bound that has more than the value of
553    MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT-1 active color attachments.
554
555New State
556
557    None
558
559    While no changes to table 20.12 (Pixel Operations) are strictly
560    necessary, new enumerations are supported for the BLEND_SRC_RGB,
561    BLEND_SRC_ALPHA, BLEND_DST_RGB, and BLEND_DST_ALPHA state to support
562    SRC1_COLOR_EXT, SRC1_ALPHA_EXT, ONE_MINUS_SRC1_COLOR_EXT, and
563    ONE_MINUS_SRC1_ALPHA_EXT (and for ES 2.0, SRC_ALPHA_SATURATE_EXT).
564
565New Implementation Dependent State
566
567    Get Value                        Type  Get Command     Minimum Value    Description             Sec.
568    ---------                        ----  -----------     -------------    -------------------     ------
569    MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT Z+    GetIntegerv     1                Maximum number of       15.1.5
570                                                                            active draw buffers
571                                                                            when using dual-source
572                                                                            blending
573
574Example Use Cases
575
576    There are several potential uses for this functionality. A first
577    example is in the implementation of sub-pixel accurate font rendering
578    algorithms.  Given a known layout of pixel elements (red, green
579    and blue components), coverage may be calculated independently for
580    each element and passed to the blender in the second source color
581    as a per-channel opacity. To use this mode, use the following blend
582    functions:
583
584        glBlendFunc(GL_SRC1_COLOR_EXT, GL_ONE_MINUS_SRC1_COLOR_EXT);
585
586    As a second example, consider a partially reflective colored glass
587    window.  It will attenuate light passing through it, and reflect
588    some of the light that strikes it. Using an appropriate combination
589    of functions, this effect may be simulated in a single pass using
590    only fixed-function blending hardware. In this case, the following
591    blend functions may be used:
592
593        glBlendFunc(GL_SRC_ALPHA, GL_SRC1_COLOR_EXT);
594
595Issues
596
597    0.  What should this extension be named?
598
599    RESOLVED:  EXT_blend_func_extended, matching the name of
600    ARB_blend_func_extended upon which this extension is based but
601    providing a multi-vendor extension for ES implementations.
602
603    1.  Is this extension compatible with the ARB_blend_func_extended
604    version?
605
606    RESOLVED:  Yes.  This extension is 100% functionally identical to
607    ARB_blend_func_extended but for the ES 2.x and 3.x APIs.
608
609    The token values are _EXT suffixed but have the same values as
610    the ARB_blend_func_extended tokens.
611
612    Philosophically if this extension is going for 100% parity and
613    functionality with ARB_blend_func_extended, it should simply add
614    all the stuff in ARB_blend_func_extended...
615
616    2.  Should the next commands be EXT suffixed?
617
618    RESOLVED:  Yes.  This is not an OES extension.
619
620    This means source code coming from a desktop environment should
621    call eglGetProcAddress on function names with the EXT suffix.
622    However because extension functions are called through function
623    pointers, this is only a minor change isolated to function pointer
624    initialization.
625
626    2.  Should this extension allow ES 2.0 contexts to use
627    GL_SRC_ALPHA_SATURATE for the destination blend function?
628
629    RESOLVED:  Yes, the ARB_blend_func_extended extension adds support
630    for using GL_SRC_ALPHA_SATURATE as the destination factor as "bonus"
631    functionality.
632
633    ES 3.x already allows GL_SRC_ALPHA_SATURATE for the destination
634    factor so this additional functionality is new only to ES 2.0 contexts
635    supporting this extension.
636
637    We expect no GPU hardware capable of dual-source blending to not
638    also support GL_SRC_ALPHA_SATURATE as the destination factor.
639
640    3.  Should this extension provide the glBindFragDataLocation and
641    glBindFragDataLocationIndexed functionality?
642
643    RESOLVED:  Yes.  With EXT suffixes.
644
645    4.  Should this really be OES_blend_func_extended?
646
647    RESOLVED:  Go with EXT is for expediency.
648
649    Additionally this extension supports functionality such
650    GL_SRC_ALPHA_SATURATE that all desktop GPU hardware is assumed to
651    have.  ES-only vendors might not want this in an OES extension.
652
653    The same could be said for the glBindFragDataLocation* functionality.
654
655    5.  Does this extension need an interaction with
656    OES_blend_equation_separate?
657
658    RESOLVED:  No, that's an ES 1.1 extension.  ES 2.0 and on all support
659    separate blend functions.
660
661    6.  Are there any OpenGL ES Shading Language interactions?
662
663    RESOLVED: Yes, to use this extension, a #extension line will be needed
664    in the shader requesting the EXT_blend_func_extended functionality.
665    Example:
666
667        #extension GL_EXT_blend_func_extended : require
668
669    The ARB_blend_func_extended functionality does NOT require a special
670    #extension line to use its functionality because the ARB version
671    relies on existing GLSL functionality that allows for multiple
672    fragment outputs as part of supporting multiple render targets.
673    In the ARB version, then glBindFragDataLocationIndexed can bind
674    these unassigned locations to different source output colors.
675    But GLSL OpenGL ES 3.00 and 3.10 both explicitly preclude more than
676    one fragment shader output with an unassigned location.  Hence a
677    #extension is needed to relax this error condition.  And then this
678    extension's glBindFragDataLocationIndexedEXT must be used to assign
679    locations as necessary.
680
681    7.  Can the indexed location be assigned explicitly in the shader?
682
683    RESOLVED:  Yes, for ES 3.x shaders where the GLSL ES 3.x supports
684    layout qualifiers.  ES 2.0 does not support the layout qualifier or
685    user-defined fragment outputs.
686
687    8.  Should both the layout qualifier mechanism and the
688    glBindFragDataLocationIndexed-style API for specifying the index of
689    a user-defined fragment shader output be supported?
690
691    RESOLVED:  Yes, both should be supported.  This makes it easier
692    for existing applications to port to ES 3.0 as both mechanisms are
693    available.
694
695    FYI: The "layout(location=0,index=1)" type syntax for dual-source
696    blending was introduced to OpenGL in GLSL 3.30 and 4.00 in
697    conjunction with OpenGL 3.3 and 4.0 respectively.  The original
698    ARB_blend_func_extended was written with respect to OpenGL 3.2 and
699    intended to support dual-source blending without the need to extend
700    the GLSL language by instead supporting assignment if the fragment
701    output index via glBindFragDataLocationIndexed.
702
703    9.  How to support OpenGL ES 2.0 where user-defined fragment shader
704    outputs are not supported?
705
706    RESOLVED:  Introduce new gl_SecondaryFragColorEXT and
707    gl_SecondaryFragDataEXT built-in variables for specifying the second
708    source color.
709
710    These built-ins are only available in the ES 1.00 shader language
711    version.
712
713    It is important to provide an ES 2.0 mechanism because WebGL 1.0 is
714    based on ES 2.0.  Chrome's internal command buffer mechanism is also
715    based around ES 2.0 and Skia intends to use this extension.
716
717    This includes adding a gl_MaxDualSourceDrawBuffersEXT
718    implementation-dependent constant.
719
720    10. Does the version 100 syntax (gl_SecondaryFragColorEXT,
721    gl_SecondaryFragDataEXT) work in an ES 3.0 context?
722
723    RESOLVED:  Yes.  For compatibility reasons, an ES 3.0 context
724    advertising EXT_blend_func_extended must support the built-ins for
725    the fragment shader secondary color outputs.
726
727    11. How many elements should be in the gl_SecondaryFragDataEXT array?
728
729    RESOLVED: The gl_SecondaryFragDataEXT array should have as
730    many elements as the GLSL built-in implementation constant
731    gl_MaxDualSourceDrawBuffersEXT which should be the value of the
732    context's GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT implementation-dependent
733    constant.
734
735    This means the number of elements in gl_SecondaryFragDataEXT is
736    different than the number of gl_FragData elements.
737
738    12. What precision should the gl_SecondaryFragColorEXT and
739    gl_SecondaryFragDataEXT be?
740
741    RESOLVED:  mediump.  This is consistent with gl_FragColor and
742    gl_FragData.
743
744    13. Should gl_MaxDualSourceDrawBuffersEXT be exposed in both ES 2.0
745    (where it sizes the gl_SecondaryFragDataEXT array) and also 3.x
746    contexts (where there is no fixed-function array)?
747
748    RESOLVED:  Implementation-wise, it is easiest to expose this
749    implementation-dependent constant for all ES contexts.
750
751    As a practical matter, we don't expect any implementations will
752    advertise any value other than 1 for this constant.
753
754    Note:  There is no implementation-dependent GLSL constant comparable
755    to gl_MaxDualSourceDrawBuffersEXT in ARB_blend_func_extended
756    (or OpenGL 3.3/4.0 introducing the ARB_blend_func_extended
757    functionality).
758
759    14. Any more issues?
760
761    RESOLVED:  See the issues in the ARB_blend_func_extended
762    specification.  This extension resolves those issues to match the
763    ARB extension version.
764
765Revision History
766
767    Rev.    Date    Author     Changes
768    ----  --------  ---------  -----------------------------------------
769     1    05/22/15  mjk        Initial revision.
770     2    07/06/15  mjk        Proper ES 2.0 interactions; complete.
771     3    07/08/15  mjk        Feedback from Brian
772     4    07/08/15  mjk        Feedback from Daniel
773     5    07/29/15  mjk        ES 3.x contexts (as well as 2.0) expose
774                               gl_MaxDualSourceDrawBuffersEXT
775     6    08/25/15  mjk        Update status
776