15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_blend_func_extended 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_blend_func_extended 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Graham Sellers, AMD 125bd8deadSopenharmony_ci Mark Young, AMD 135bd8deadSopenharmony_ci Nick Haemel, AMD 145bd8deadSopenharmony_ci Pierre Boudier, AMD 155bd8deadSopenharmony_ci Mais Alnasser, AMD 165bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 175bd8deadSopenharmony_ci Pat Brown, NVIDIA 185bd8deadSopenharmony_ci Ian Stewart, NVIDIA 195bd8deadSopenharmony_ci Mark Kilgard, NVIDIA 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciContact 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Graham Sellers, AMD (graham.sellers 'at' amd.com) 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ciNotice 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ci Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at 285bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ciSpecification Update Policy 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 335bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 345bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 355bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 365bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 375bd8deadSopenharmony_ci described in more detail at 385bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciStatus 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci Complete. Approved by the ARB at the 2010/01/22 F2F meeting. 435bd8deadSopenharmony_ci Approved by the Khronos Board of Promoters on March 10, 2010. 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ciVersion 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci Last Modified Date: 05/22/2015 485bd8deadSopenharmony_ci Author Revision: 13 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciNumber 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci ARB Extension #78 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ciDependencies 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci OpenGL 1.0 is required. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci The ARB_fragment_shader extension is required. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci The EXT_gpu_shader4 extension is required. 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci The EXT_blend_func_separate extension interacts with this extension. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci The ARB_draw_buffers extension trivially affects the definition of this 655bd8deadSopenharmony_ci extension. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci The ARB_draw_buffers_blend extension affects the definition of this 685bd8deadSopenharmony_ci extension. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci This extension is written against the OpenGL 3.2 Specification (Compatibility Profile) 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ciOverview 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci Traditional OpenGL includes fixed-function blending that combines source 755bd8deadSopenharmony_ci colors with the existing content of a render buffer in a variety of ways. 765bd8deadSopenharmony_ci A number of extensions have enhanced this functionality by adding further 775bd8deadSopenharmony_ci sources of blending weights and methods to combine them. However, the inputs 785bd8deadSopenharmony_ci to the fixed-function blending units are constrained to a source color (as 795bd8deadSopenharmony_ci output from fragment shading), destination color (as the current content 805bd8deadSopenharmony_ci of the frame buffer) or constants that may be used in their place. 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci This extension adds new blending functions whereby a fragment shader may 835bd8deadSopenharmony_ci output two colors, one of which is treated as the source color, and the 845bd8deadSopenharmony_ci other used as a blending factor for either source or destination colors. 855bd8deadSopenharmony_ci Furthermore, this extension increases orthogonality by allowing the 865bd8deadSopenharmony_ci SRC_ALPHA_SATURATE function to be used as the destination weight. 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ciIP Status 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci No known IP claims. 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ciNew Procedures and Functions 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci void BindFragDataLocationIndexed(uint program, uint colorNumber, 955bd8deadSopenharmony_ci uint index, const char * name); 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci int GetFragDataIndex(uint program, const char * name); 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ciNew Tokens 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci Accepted by the <src> and <dst> parameters of BlendFunc and 1025bd8deadSopenharmony_ci BlendFunci, and by the <srcRGB>, <dstRGB>, <srcAlpha> and <dstAlpha> 1035bd8deadSopenharmony_ci parameters of BlendFuncSeparate and BlendFuncSeparatei: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci SRC1_COLOR 0x88F9 1065bd8deadSopenharmony_ci SRC1_ALPHA 1075bd8deadSopenharmony_ci ONE_MINUS_SRC1_COLOR 0x88FA 1085bd8deadSopenharmony_ci ONE_MINUS_SRC1_ALPHA 0x88FB 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv 1115bd8deadSopenharmony_ci and GetDoublev: 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.2 Specification (Compatibility Profile) (OpenGL Operation) 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci None. 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.2 Specification (Compatibility Profile) (Rasterization) 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci Modify the "Shader Outputs" subsection of Section 3.12.2, Shader Execution 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci Modify the text on p.297 beginning "The binding of a user-defined varying 1245bd8deadSopenharmony_ci out variable to a fragment..." 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci The binding of a user-defined varying out variable to a fragment color number 1275bd8deadSopenharmony_ci can be specified explicitly. The command 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci void BindFragDataLocationIndexed(uint program, uint colorNumber, uint index, const char * name); 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci specifies that the varying out variable name in <program> should be bound to 1325bd8deadSopenharmony_ci fragment color <colorNumber> when the program is next linked. <index> may be 1335bd8deadSopenharmony_ci zero or one to specify that the color be used as either the first or second 1345bd8deadSopenharmony_ci color input to the blend equation, respectively, as described in Section 4.1.8. 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci If <name> was bound previously, its assigned binding is replaced with 1375bd8deadSopenharmony_ci colorNumber. <name> must be a null-terminated string. The error INVALID_VALUE 1385bd8deadSopenharmony_ci is generated if <colorNumber> is equal or greater than MAX_DRAW_BUFFERS and 1395bd8deadSopenharmony_ci <index> is zero, or if <colorNumber> is equal or greater than 1405bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS and <index> is greater than or equal to one. 1415bd8deadSopenharmony_ci The command 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci void BindFragDataLocation(uint program, uint colorNumber, const char * name) 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci is equivalent to calling BindFragDataLocationIndexed with the same values 1465bd8deadSopenharmony_ci for <program>, <colorNumber> and <name>, and with <index> set to zero. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci When a program is linked, any varying out variables without a binding 1495bd8deadSopenharmony_ci specified through BindFragDataLocationIndexed or BindFragDataLocation will 1505bd8deadSopenharmony_ci automatically be bound to fragment colors and indices by the GL. All such 1515bd8deadSopenharmony_ci assignments will use color indices of zero. Such bindings can be queried 1525bd8deadSopenharmony_ci using the commands GetFragDataLocation and GetFragDataIndex. Output 1535bd8deadSopenharmony_ci binding assignments will cause LinkProgram to fail: 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci * if the number of active outputs is greater than the value of 1565bd8deadSopenharmony_ci MAX_DRAW_BUFFERS; 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci * if the program has an active output assigned to a location greater 1595bd8deadSopenharmony_ci than or equal to the value of MAX_DUAL_SOURCE_DRAW_BUFFERS and has an 1605bd8deadSopenharmony_ci active output assigned an index greater than or equal to one; 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci * if more than one varying out variable is bound to the same number and 1635bd8deadSopenharmony_ci index; or 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci * if the explicit binding assignments do not leave enough space for the 1665bd8deadSopenharmony_ci linker to automatically assign a location for a varying out array, 1675bd8deadSopenharmony_ci which requires multiple contiguous locations. 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci BindFragDataLocationIndexed may be issued before any shader objects are 1705bd8deadSopenharmony_ci attached to a program object. Hence it is allowed to bind any name (except a 1715bd8deadSopenharmony_ci name starting with gl_) to a color number and index, including a name that 1725bd8deadSopenharmony_ci is never used as a varying out variable in any fragment shader object. 1735bd8deadSopenharmony_ci Assigned bindings for variables that do not exist are ignored. 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci Add to the last paragraph on p.279 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci The command 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci int GetFragDataIndex(uint program, const char * name); 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci returns the index of the fragment color to which the variable <name> was bound 1825bd8deadSopenharmony_ci when the program object <program> was last linked. If program has not been 1835bd8deadSopenharmony_ci successfully linked, the error INVALID_OPERATION is generated. If name is not 1845bd8deadSopenharmony_ci a varying out variable, or if an error occurs, -1 will be returned. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.2 Specification (Compatibility Profile) (Per-Fragment Operations 1875bd8deadSopenharmony_ciand the Framebuffer) 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci Modify the first paragraph of the Blending Functions subsection of Section 1905bd8deadSopenharmony_ci 4.1.8 Blending (p. 292) as follows: 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci The weighting factors used by the blend equation are determined by the blend 1935bd8deadSopenharmony_ci functions. There are four possible sources for weighting factors. These are 1945bd8deadSopenharmony_ci the constant color (Rc, Gc, Bc, Ac) (see BlendColor, p. 211), the first 1955bd8deadSopenharmony_ci source color (Rs0, Gs0, Bs0, As0), the second source color 1965bd8deadSopenharmony_ci (Rs1, Gs1, Bs1, As1), and the destination color (the existing content of the 1975bd8deadSopenharmony_ci draw buffer). Additionally the special constants ZERO and ONE are 1985bd8deadSopenharmony_ci available as weighting factors. Blend functions are specified ... 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci Modify Table 4.2 (p. 213) as follows 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci RGB Blend Factors Alpha Blend Factors 2035bd8deadSopenharmony_ci Value (Sr, Sg, Sb) or (Dr, Dg, Db) Sa or Da 2045bd8deadSopenharmony_ci ----- ---------------------------- ------------------- 2055bd8deadSopenharmony_ci ZERO (0, 0, 0) 0 2065bd8deadSopenharmony_ci ONE (1, 1, 1) 1 2075bd8deadSopenharmony_ci SRC_COLOR (Rs0, Gs0, Bs0) As0 2085bd8deadSopenharmony_ci ONE_MINUS_SRC_COLOR (1, 1, 1) - (Rs0, Gs0, Bs0) 1 - As0 2095bd8deadSopenharmony_ci DST_COLOR (Rd, Gd, Bd) Ad 2105bd8deadSopenharmony_ci ONE_MINUS_DST_COLOR (1, 1, 1) - (Rd, Gd, Bd) 1 - Ad 2115bd8deadSopenharmony_ci SRC_ALPHA (As0, As0, As0) As0 2125bd8deadSopenharmony_ci ONE_MINUS_SRC_ALPHA (1, 1, 1) - (As0, As0, As0) 1 - As0 2135bd8deadSopenharmony_ci DST_ALPHA (Ad, Ad, Ad) Ad 2145bd8deadSopenharmony_ci ONE_MINUS_DST_ALPHA (1, 1, 1) - (Ad, Ad, Ad) 1 - Ad 2155bd8deadSopenharmony_ci CONSTANT_COLOR (Rc, Gc, Bc) Ac 2165bd8deadSopenharmony_ci ONE_MINUS_CONSTANT_COLOR (1, 1, 1) - (Rc, Gc, Bc) 1 - Ac 2175bd8deadSopenharmony_ci CONSTANT_ALPHA (Ac, Ac, Ac) Ac 2185bd8deadSopenharmony_ci ONE_MINUS_CONSTANT_ALPHA (1, 1, 1) - (Ac, Ac, Ac) 1 - Ac 2195bd8deadSopenharmony_ci SRC_ALPHA_SATURATE (f, f, f) 1 (Now allowed for dst) 2205bd8deadSopenharmony_ci SRC1_COLOR (Rs1, Gs1, Bs1) As1 New 2215bd8deadSopenharmony_ci ONE_MINUS_SRC1_COLOR (1, 1, 1) - (Rs1, Gs1, Bs1) 1 - As1 New 2225bd8deadSopenharmony_ci SRC1_ALPHA (As1, As1, As1) As1 New 2235bd8deadSopenharmony_ci ONE_MINUS_SRC1_ALPHA (1, 1, 1) - (As1, As1, As1) 1 - As1 New 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci Remove Footnote 1 from Table 4.2. 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ci Add the following subsections to Section 4.1.8 Blending, at the end of the 2285bd8deadSopenharmony_ci description of Blend Function (p. 294) 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci Dual Source Blending and Multiple Draw Buffers 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci Blend functions that require the second color input, <Rs1, Gs1, Bs1, As1> 2335bd8deadSopenharmony_ci (SRC1_COLOR, SRC1_ALPHA, ONE_MINUS_SRC1_COLOR, or 2345bd8deadSopenharmony_ci ONE_MINUS_SRC1_ALPHA) may consume hardware resources that could 2355bd8deadSopenharmony_ci otherwise be used for rendering to multiple draw buffers. Therefore, the 2365bd8deadSopenharmony_ci number of draw buffers that can be attached to a frame buffer may be lower 2375bd8deadSopenharmony_ci when using dual-source blending. 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci The maximum number of draw buffers that may be attached to a single frame 2405bd8deadSopenharmony_ci buffer when using dual-source blending functions is implementation dependent 2415bd8deadSopenharmony_ci and can be queried by calling GetIntegerv with the symbolic constant 2425bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS. When 2435bd8deadSopenharmony_ci using dual-source blending, MAX_DUAL_SOURCE_DRAW_BUFFERS should be used 2445bd8deadSopenharmony_ci in place of MAX_DRAW_BUFFERS to determine the maximum number of draw 2455bd8deadSopenharmony_ci buffers that may be attached to a single frame buffer. The value of 2465bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS must be at least 1. If the value of 2475bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS is 1, then dual-source blending and 2485bd8deadSopenharmony_ci multiple draw buffers cannot be used simultaneously. 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci If either blend function is set to one of the second source factors 2515bd8deadSopenharmony_ci (SRC1_COLOR, SRC1_ALPHA, ONE_MINUS_SRC1_COLOR, or 2525bd8deadSopenharmony_ci ONE_MINUS_SRC1_ALPHA) for any draw buffer and any draw buffers equal to 2535bd8deadSopenharmony_ci or greater than the value of MAX_DUAL_SOURCE_DRAW_BUFFERS have values other than NONE, 2545bd8deadSopenharmony_ci the error INVALID_OPERATION is generated by Begin, or any procedure that 2555bd8deadSopenharmony_ci implicitly calls Begin. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci Generation of Second Color Source for Blending 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci There is no way to generate the second source color using the fixed-function 2605bd8deadSopenharmony_ci fragment pipeline. Rendering using any of the blend functions that consume 2615bd8deadSopenharmony_ci the second input color (SRC1_COLOR, ONE_MINUS_SRC1_COLOR, 2625bd8deadSopenharmony_ci SRC1_ALPHA or ONE_MINUS_SRC1_ALPHA) using fixed function will produce 2635bd8deadSopenharmony_ci undefined results. To produce input for the second source color, a shader 2645bd8deadSopenharmony_ci must be used. 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci When using a GLSL fragment shader with dual-source blending functions, 2675bd8deadSopenharmony_ci the color output varyings are bound to the first and second inputs of a 2685bd8deadSopenharmony_ci draw buffer using BindFragDataLocationIndexed as described in the "Shader 2695bd8deadSopenharmony_ci Outputs" subsection of Section 3.12.2. Data written to the first of these outputs 2705bd8deadSopenharmony_ci becomes the first source color input to the blender (corresponding to 2715bd8deadSopenharmony_ci SRC_COLOR and SRC_ALPHA). Data written to the second of these outputs 2725bd8deadSopenharmony_ci generates the second source color input to the blender (corresponding to 2735bd8deadSopenharmony_ci SRC1_COLOR and SRC1_ALPHA). 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci If the second color input to the blender is not written in the shader, or if 2765bd8deadSopenharmony_ci no output is bound to the second input of a blender, the result of the blending 2775bd8deadSopenharmony_ci operation is not defined. 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci Other shading languages may define similar methods for producing the first 2805bd8deadSopenharmony_ci and second color inputs to blending equations. 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.2 Specification (Compatibility Profile) (Special 2835bd8deadSopenharmony_ciFunctions) 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci None. 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.2 Specification (Compatibility Profile) (State and 2885bd8deadSopenharmony_ciState Requests) 2895bd8deadSopenharmony_ci 2905bd8deadSopenharmony_ci None. 2915bd8deadSopenharmony_ci 2925bd8deadSopenharmony_ciDependencies on ARB_fragment_shader 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci If ARB_fragment_shader is not supported then references to 2955bd8deadSopenharmony_ci ARB_fragment_shader in section 4.1.8 and elsewhere in this document should 2965bd8deadSopenharmony_ci be removed. In this case, there is no way to generate the second color input 2975bd8deadSopenharmony_ci to the blending equation unless a further extension to another shading 2985bd8deadSopenharmony_ci language is defined and used. 2995bd8deadSopenharmony_ci 3005bd8deadSopenharmony_ciDependencies on ARB_draw_buffers 3015bd8deadSopenharmony_ci 3025bd8deadSopenharmony_ci Using dual-source blending functions may consume additional outputs from 3035bd8deadSopenharmony_ci hardware shading units and therefore can reduce the number of draw buffers 3045bd8deadSopenharmony_ci that may be attached to a single frame buffer when dual-source blending 3055bd8deadSopenharmony_ci functions are enabled. In this case, the value of 3065bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS may be less than the value of 3075bd8deadSopenharmony_ci MAX_DRAW_BUFFERS. If ARB_draw_buffers is not supported then the value of 3085bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS will be 1. Furthermore, the discussion 3095bd8deadSopenharmony_ci in the subsection entitled "Dual Source Blending and Multiple Draw Buffers" 3105bd8deadSopenharmony_ci may be discarded. 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ciDependencies on EXT_blend_func_separate 3135bd8deadSopenharmony_ci 3145bd8deadSopenharmony_ci If EXT_blend_func_separate is not supported, remove references to 3155bd8deadSopenharmony_ci BlendFuncSeparate. Also, remove any references to BLEND_SRC_ALPHA and 3165bd8deadSopenharmony_ci BLEND_DST_ALPHA, and replace references to BLEND_SRC_RGB and BLEND_DST_RGB 3175bd8deadSopenharmony_ci with BLEND_SRC and BLEND_DST, respectively. In this case, the new blend 3185bd8deadSopenharmony_ci functions may only be enabled via the BlendFunc procedure. 3195bd8deadSopenharmony_ci 3205bd8deadSopenharmony_ciDependencies on ARB_draw_buffers_blend 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ci If ARB_draw_buffers_blend is not supported, all references to BlendFunci 3235bd8deadSopenharmony_ci and BlendFuncSeparatei should be removed. In this case, the blend 3245bd8deadSopenharmony_ci functions for all attached draw buffers will be the same. 3255bd8deadSopenharmony_ci 3265bd8deadSopenharmony_ciInteractions with NV_gpu_program5 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ci If NV_gpu_program5 is supported, fragment result bindings 3295bd8deadSopenharmony_ci "result.color[n].primary" and "result.color[n].secondary" can be used to 3305bd8deadSopenharmony_ci specify the <n>th color outputs for index 0 and 1, respectively. 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 3335bd8deadSopenharmony_ci 3345bd8deadSopenharmony_ci None. 3355bd8deadSopenharmony_ci 3365bd8deadSopenharmony_ciGLX Protocol 3375bd8deadSopenharmony_ci 3385bd8deadSopenharmony_ci None. 3395bd8deadSopenharmony_ci 3405bd8deadSopenharmony_ciErrors 3415bd8deadSopenharmony_ci 3425bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by Begin or any procedure that 3435bd8deadSopenharmony_ci implicitly calls Begin if any draw buffer has a blend function requiring the 3445bd8deadSopenharmony_ci second color input (SRC1_COLOR, ONE_MINUS_SRC1_COLOR, SRC1_ALPHA or 3455bd8deadSopenharmony_ci ONE_MINUS_SRC1_ALPHA), and a framebuffer is bound that has more than 3465bd8deadSopenharmony_ci the value of MAX_DUAL_SOURCE_DRAW_BUFFERS-1 active color attachments. 3475bd8deadSopenharmony_ci 3485bd8deadSopenharmony_ciNew State 3495bd8deadSopenharmony_ci 3505bd8deadSopenharmony_ci Table 6.21 (p. 286) 3515bd8deadSopenharmony_ci 3525bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Sec Attribute 3535bd8deadSopenharmony_ci ------------------------ ---- ------------ ------------- ------------------- ----- --------- 3545bd8deadSopenharmony_ci BLEND_SRC_RGB Z19 GetIntegerv ONE Blending source RGB 4.1.8 color-buffer 3555bd8deadSopenharmony_ci function 3565bd8deadSopenharmony_ci BLEND_SRC_ALPHA Z19 GetIntegerv ONE Blending source A 4.1.8 color-buffer 3575bd8deadSopenharmony_ci function 3585bd8deadSopenharmony_ci BLEND_DST_RGB Z19 GetIntegerv ZERO Blending dest. RGB 4.1.8 color-buffer 3595bd8deadSopenharmony_ci function 3605bd8deadSopenharmony_ci BLEND_DST_ALPHA Z19 GetIntegerv ZERO Blending dest. A 4.1.8 color-buffer 3615bd8deadSopenharmony_ci function 3625bd8deadSopenharmony_ci 3635bd8deadSopenharmony_ciNOTE: The only change is that Z14 and Z15 change to Z19 for the existing blend 3645bd8deadSopenharmony_cifunction state. No new state is actually added to the OpenGL Specification. 3655bd8deadSopenharmony_ci 3665bd8deadSopenharmony_ciNew Implementation Dependent State 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ci Get Value Type Get Command Minimum Value Description Sec. Attribute 3695bd8deadSopenharmony_ci --------- ---- ----------- ------------- ------------------- ----- --------- 3705bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS Z+ GetIntegerv 1 Maximum number of 4.1.8 - 3715bd8deadSopenharmony_ci active draw buffers 3725bd8deadSopenharmony_ci when using dual-source 3735bd8deadSopenharmony_ci blending 3745bd8deadSopenharmony_ci 3755bd8deadSopenharmony_ciExample Use Cases 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci There are several potential uses for this functionality. A first example 3785bd8deadSopenharmony_ci is in the implementation of sub-pixel accurate font rendering algorithms. 3795bd8deadSopenharmony_ci Given a known layout of pixel elements (red, green and blue components), 3805bd8deadSopenharmony_ci coverage may be calculated independently for each element and passed 3815bd8deadSopenharmony_ci to the blender in the second source color as a per-channel opacity. To use 3825bd8deadSopenharmony_ci this mode, use the following blend functions: 3835bd8deadSopenharmony_ci 3845bd8deadSopenharmony_ci glBlendFunc(GL_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR); 3855bd8deadSopenharmony_ci 3865bd8deadSopenharmony_ci As a second example, consider a partially reflective colored glass window. 3875bd8deadSopenharmony_ci It will attenuate light passing through it, and reflect some of the light 3885bd8deadSopenharmony_ci that strikes it. Using an appropriate combination of functions, this effect 3895bd8deadSopenharmony_ci may be simulated in a single pass using only fixed-function blending 3905bd8deadSopenharmony_ci hardware. In this case, the following blend functions may be used: 3915bd8deadSopenharmony_ci 3925bd8deadSopenharmony_ci glBlendFunc(GL_SRC_ALPHA, GL_SRC1_COLOR); 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ciIssues 3955bd8deadSopenharmony_ci 3965bd8deadSopenharmony_ci 1) Should the new tokens be SRC1_COLOR and SRC2_COLOR (1-based), or 3975bd8deadSopenharmony_ci be SRC0_COLOR and SRC1_COLOR. 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci RESOLVED: Indices in OpenGL are generally zero based. These follow 4005bd8deadSopenharmony_ci suit. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci 2) What happens when rendering using a dual-source blend function using 4035bd8deadSopenharmony_ci fixed-function? 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci RESOLVED: There is no reasonable way to generate the second source color 4065bd8deadSopenharmony_ci for blending using fixed-function fragment processing. However, as it is 4075bd8deadSopenharmony_ci possible to set the blend function and then enable a shader, there isn't 4085bd8deadSopenharmony_ci really a clean way to report an error. Therefore, we allow it, but leave 4095bd8deadSopenharmony_ci the result undefined. 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ci 2a) Can't we use an existing output from fixed function, like back color, 4125bd8deadSopenharmony_ci to make this work? 4135bd8deadSopenharmony_ci 4145bd8deadSopenharmony_ci DISCUSSION: We could relabel things. For example, make the front color 4155bd8deadSopenharmony_ci be the first input to blending and the back color the second input. This 4165bd8deadSopenharmony_ci kind of thing would come at the cost of lost fixed function capability, 4175bd8deadSopenharmony_ci possible ambiguity and added complexity in the fixed function 4185bd8deadSopenharmony_ci specification. The new functionality in this extension is most useful 4195bd8deadSopenharmony_ci when reading data from multiple textures or other complex sources that 4205bd8deadSopenharmony_ci would just be too complex to express with fixed function processing. 4215bd8deadSopenharmony_ci For these reasons, rendering through dual-source blending functions using 4225bd8deadSopenharmony_ci the fixed function pipeline is not supported and will produce undefined 4235bd8deadSopenharmony_ci results. 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci 2b) Then why write this against OpenGL 2.1 which includes fixed-function? 4265bd8deadSopenharmony_ci Why not write against OpenGL 3.x that only supports shaders anyway? 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci DISCUSSION: Because this extension adds functionality to existing 4295bd8deadSopenharmony_ci extensions and those are written against OpenGL 2.1. Furthermore, the 4305bd8deadSopenharmony_ci functionality described here does not rely on any core feature provided 4315bd8deadSopenharmony_ci by OpenGL 3.x and can be easily built upon and used in implementations of 4325bd8deadSopenharmony_ci OpenGL 2.1 or earlier versions of the OpenGL Specification. 4335bd8deadSopenharmony_ci 4345bd8deadSopenharmony_ci RESOLVED: Updated to stand against OpenGL 3.2, but kept the fixed function 4355bd8deadSopenharmony_ci issues in the spec. 4365bd8deadSopenharmony_ci 4375bd8deadSopenharmony_ci 3) Why is this not orthogonal and interoperable with ARB_draw_buffers? 4385bd8deadSopenharmony_ci 4395bd8deadSopenharmony_ci RESOLVED: This is functionality that has existed in hardware for some 4405bd8deadSopenharmony_ci time and been made available via other graphics APIs. In some hardware 4415bd8deadSopenharmony_ci and APIs, the second color input from the shader is actually what would 4425bd8deadSopenharmony_ci have been written to draw buffer 1. This is the functionality that is 4435bd8deadSopenharmony_ci guaranteed to be universally supported. This extension does not preclude 4445bd8deadSopenharmony_ci use with multiple draw buffers except exclusion through implementation 4455bd8deadSopenharmony_ci defined limits. If future hardware supports multiple color outputs 4465bd8deadSopenharmony_ci simultaneously to multiple draw buffers, it can simply advertise higher 4475bd8deadSopenharmony_ci limits. 4485bd8deadSopenharmony_ci 4495bd8deadSopenharmony_ci 4) Can we not add an implementation state query to find out if it's 4505bd8deadSopenharmony_ci available with multiple draw buffers? 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci RESOLVED: Done. Query MAX_DUAL_SOURCE_DRAW_BUFFERS. If this returns 4535bd8deadSopenharmony_ci the same value as MAX_DRAW_BUFFERS then the functions are orthogonal. 4545bd8deadSopenharmony_ci If this returns 1, then they cannot be used together. If it returns some 4555bd8deadSopenharmony_ci value between 1 and MAX_DRAW_BUFFERS, then dual-source blending 4565bd8deadSopenharmony_ci may consume some additional hardware routing resources, but can be used 4575bd8deadSopenharmony_ci with multiple draw buffers provided the MAX_DUAL_SOURCE_DRAW_BUFFERS 4585bd8deadSopenharmony_ci limit is not exceeded. 4595bd8deadSopenharmony_ci 4605bd8deadSopenharmony_ci 5) Should there also be a Link error if the fragment shader uses both an 4615bd8deadSopenharmony_ci index=1 output below MAX and an index=0 output greater than or equal to 4625bd8deadSopenharmony_ci MAX? The quoted begin-time error leaves open the possibility of an app 4635bd8deadSopenharmony_ci doing something like BindFragDataLocationIndexed(colorNumber=0, index=0) 4645bd8deadSopenharmony_ci + (colorNumber=0, index=1) + (colorNumber=1, index=0), then rendering 4655bd8deadSopenharmony_ci without using the src1 blend functions. If an implementation aliases 4665bd8deadSopenharmony_ci index=1 onto other index=0 outputs, then it wouldn't be able to handle 4675bd8deadSopenharmony_ci that case. 4685bd8deadSopenharmony_ci 4695bd8deadSopenharmony_ci DISCUSSION: The begin time error language states '... if any draw buffer 4705bd8deadSopenharmony_ci has a blend function requiring the second color input ...'. This means 4715bd8deadSopenharmony_ci that the outputs can be bound to non-zero indices, but if the blend 4725bd8deadSopenharmony_ci function does not consume that output, no error will be generated. In 4735bd8deadSopenharmony_ci theory, an implementation could ignore output bound to color=0, index=1 4745bd8deadSopenharmony_ci in this case and operate as if it were not there. However, it makes no 4755bd8deadSopenharmony_ci sense for the linker to accept such a configuration of outputs because 4765bd8deadSopenharmony_ci the underlying hardware may not be able to support it. Therefore, we can 4775bd8deadSopenharmony_ci generate a link time error, thus eliminating this begin-time check and 4785bd8deadSopenharmony_ci potentially improving run-time performance. 4795bd8deadSopenharmony_ci 4805bd8deadSopenharmony_ciRevision History 4815bd8deadSopenharmony_ci 4825bd8deadSopenharmony_ci Rev. Date Author Changes 4835bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 4845bd8deadSopenharmony_ci 13 05/22/2015 mjk Fix misspellings 4855bd8deadSopenharmony_ci 12 02/05/2010 istewart Add interactions with NV_gpu_program5. 4865bd8deadSopenharmony_ci 11 01/26/2010 pbrown Assign enum values. 4875bd8deadSopenharmony_ci 10 01/14/2010 pbrown Add spec language allowing for a link error if 4885bd8deadSopenharmony_ci explicit output bindings don't leave enough 4895bd8deadSopenharmony_ci space for array outputs. Clarify that any 4905bd8deadSopenharmony_ci automatic assignments for fragment outputs 4915bd8deadSopenharmony_ci will use color index zero. 4925bd8deadSopenharmony_ci 9 12/10/2009 Jon Leech Fix typos in blending equation table, remove 4935bd8deadSopenharmony_ci ARB suffixes for core 3.3 inclusion, clean 4945bd8deadSopenharmony_ci up "GL_TOKEN" vs. "the value of GL_TOKEN". 4955bd8deadSopenharmony_ci 8 11/19/2009 gsellers Remove SRC0_COLOR etc. enums, use old ones 4965bd8deadSopenharmony_ci instead. Use previously defined value for 4975bd8deadSopenharmony_ci SRC1_ALPHA. Update text to match. 4985bd8deadSopenharmony_ci 7 10/26/2009 gsellers Change BindFragDataLocationIndexedARB to take a 4995bd8deadSopenharmony_ci numerical index instead of an enum. Clarify 5005bd8deadSopenharmony_ci behavior in several places. Add issue 5. 5015bd8deadSopenharmony_ci 6 10/20/2009 gsellers Update to diff to OpenGL 3.2 (Compatibility) spec. 5025bd8deadSopenharmony_ci Add BindFragDataLocationIndexedARB and 5035bd8deadSopenharmony_ci GetFragDataIndexARB. Remove idea of making shader 5045bd8deadSopenharmony_ci outputs arrays. Define Begin time error when 5055bd8deadSopenharmony_ci blend func is SRC1_* for FBO with >= 5065bd8deadSopenharmony_ci MAX_DUAL_SOURCE_DRAW_BUFFERS draw buffers. 5075bd8deadSopenharmony_ci 5 05/21/2009 gsellers Clarify meaning of MAX_DUAL_SOURCE_BUFFERS_ARB. 5085bd8deadSopenharmony_ci Clarify the (lack of) interaction with fixed 5095bd8deadSopenharmony_ci function fragment processing and further 5105bd8deadSopenharmony_ci justify lack of support (Issues 2a and 2b). 5115bd8deadSopenharmony_ci Clarify modification to state. 5125bd8deadSopenharmony_ci 4 05/19/2009 gsellers Allow simultaneous use of ARB_draw_buffers with 5135bd8deadSopenharmony_ci this extension; 5145bd8deadSopenharmony_ci add MAX_DUAL_SOURCE_DRAW_BUFFERS_ARB. 5155bd8deadSopenharmony_ci Document interaction with ARB_draw_buffers_blend. 5165bd8deadSopenharmony_ci 3 05/19/2009 gsellers Remove access via gl_FragData, replace with user 5175bd8deadSopenharmony_ci defined output varyings. 5185bd8deadSopenharmony_ci 2 05/15/2009 gsellers Minor cleanup. Add usage examples. 5195bd8deadSopenharmony_ci 1 05/14/2009 gsellers Initial draft 520