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