Name OES_draw_buffers_indexed Name Strings GL_OES_draw_buffers_indexed Contact Daniel Koch, NVIDIA Corporation (dkoch 'at' nvidia.com) Contributors Graham Connor, Imagination Ben Bowman, Imagination Jonathan Putsman, Imagination Contributors to EXT_draw_buffers2 Contributors to ARB_draw_buffers_blend Notice Copyright (c) 2014 The Khronos Group Inc. Copyright terms at http://www.khronos.org/registry/speccopyright.html Specification Update Policy Khronos-approved extension specifications are updated in response to issues and bugs prioritized by the Khronos OpenGL ES Working Group. For extensions which have been promoted to a core Specification, fixes will first appear in the latest version of that core Specification, and will eventually be backported to the extension document. This policy is described in more detail at https://www.khronos.org/registry/OpenGL/docs/update_policy.php Status Approved by the OpenGL ES Working Group Ratified by the Khronos Board of Promoters on November 7, 2014 Version Last Modified Date: July 14, 2014 Revision: 2 Number OpenGL ES Extension #209 Dependencies OpenGL ES 3.0 or EXT_draw_buffers is required. This extension is written against the OpenGL ES 3.0 specification. Overview This extension builds upon the EXT_draw_buffers extension. In EXT_draw_buffers (part of OpenGL ES 3.0), separate values could be written to each color buffer, but the blend enable, blend functions, blend equations and color write masks are global and apply to all color outputs. This extension provides the ability to independently * enable or disable blending, * set the blend equations, * set the blend functions, and * set the color write masks per color output. This extension introduces indexed versions of the enable, blend equation, blend function, and color mask commands, as well as associated indexed queries in order to control and query these states independently on a per-color output basis. New Procedures and Functions void EnableiOES(enum target, uint index); void DisableiOES(enum target, uint index); void BlendEquationiOES(uint buf, enum mode); void BlendEquationSeparateiOES(uint buf, enum modeRGB, enum modeAlpha); void BlendFunciOES(uint buf, enum src, enum dst); void BlendFuncSeparateiOES(uint buf, enum srcRGB, enum dstRGB, enum srcAlpha, enum dstAlpha); void ColorMaskiOES(uint buf, boolean r, boolean g, boolean b, boolean a); boolean IsEnablediOES(enum target, uint index); New Tokens Accepted by the parameter of GetBooleani_v, GetIntegeri_v, and GetInteger64i_v: BLEND_EQUATION_RGB BLEND_EQUATION_ALPHA BLEND_SRC_RGB BLEND_SRC_ALPHA BLEND_DST_RGB BLEND_DST_ALPHA COLOR_WRITEMASK Accepted by the parameter of EnableiOES, DisableiOES, and IsEnablediOES: BLEND Accepted by the parameter of BlendEquationiOES and by the and parameters of BlendEquationSeparateiOES: FUNC_ADD FUNC_SUBTRACT FUNC_REVERSE_SUBTRACT MIN MAX Accepted by the and parameters of BlendFunciOES and by the , , , and parameters of BlendFuncSeparateiOES: ZERO ONE SRC_COLOR ONE_MINUS_SRC_COLOR DST_COLOR ONE_MINUS_DST_COLOR SRC_ALPHA ONE_MINUS_SRC_ALPHA DST_ALPHA ONE_MINUS_DST_ALPHA CONSTANT_COLOR ONE_MINUS_CONSTANT_COLOR CONSTANT_ALPHA ONE_MINUS_CONSTANT_ALPHA SRC_ALPHA_SATURATE (Note all of the above tokens are already defined in OpenGL ES 3.0.) Additions to Chapter 2 of the OpenGL ES 3.0 Specification (OpenGL ES Operation) None. Additions to Chapter 3 of the OpenGL ES 3.0 Specification (Rasterization) None. Additions to Chapter 4 of the OpenGL ES 3.0 Specification (Per-Fragment Operations and the Framebuffer) Modify the fifth paragraph of section 4.1.7 (Blending), p. 179, to read as follows: "Blending is enabled or disabled for an individual draw buffer with the commands: void EnableiOES(enum target, uint index); void DisableiOES(enum target, uint index); is the symbolic constant BLEND and is an integer specifying the draw buffer associated with the symbolic constant DRAW_BUFFER. Blending can be enabled or disabled for all draw buffers using Enable or Disable with the symbolic constant BLEND. If blending is disabled for a particular draw buffer, proceed to the next operation." Modify section "Blend Equation" replacing the first paragraph beginning on p. 179, with the following: "Blending is controlled by the blend equation. This equation can be simultaneously set to the same value for all draw buffers using the commands: void BlendEquation(enum mode); void BlendEquationSeparate(enum modeRGB, enum modeAlpha); or for an individual draw buffer using the indexed commands: void BlendEquationiOES(uint buf, enum mode); void BlendEquationSeparateiOES(uint buf enum modeRGB, enum modeAlpha); BlendEquationSeparate and BlendEquationSeparateiOES argument determines the RGB blend equation while determines the alpha blend equation. BlendEquation and BlendEquationiOES argument determines both the RGB and alpha blend equations. , , and must be one of FUNC_ADD, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MIN, MAX. BlendEquation and BlendEquationSeparate modify the blend equations for all draw buffers. BlendEquationiOES and BlendEquationSeparateiOES modify the blend equations associated with an individual draw buffer. The argument is an integer that indicates that the blend equations should be modified for DRAW_BUFFER." Modify section "Blend Functions" on p. 181, replacing the last sentence of the first paragraph and the second paragraph with the following: "Blend functions are simultaneously specified for all draw buffers using the commands: void BlendFunc(enum src, enum dst); void BlendFuncSeparate(enum srcRGB, enum dstRGB, enum srcAlpha, enum dstAlpha); or for an individual draw buffer using the indexed commands: void BlendFunciOES(uint buf, enum src, enum dst); void BlendFuncSeparateiOES(uint buf, enum srcRGB, enum dstRGB, enum srcAlpha, enum dstAlpha); BlendFuncSeparate and BlendFuncSeparateiOES arguments and determine the source and destination RGB blend functions, respectively, while and determine the source and destination alpha blend functions. BlendFunc and BlendFunciOES argument determines both RGB and alpha source functions, while determines both RGB and alpha destination functions. BlendFuncSeparate and BlendFunc modify the blend functions for all draw buffers. BlendFuncSeparateiOES and BlendFunciOES modify the blend functions associated with an individual draw buffer. The argument is an integer that indicates that the blend equations should be modified for DRAW_BUFFER." Modify section "Blending State" on p. 183, replacing the first two paragraphs with the following: "The state required for blending, for each draw buffer, is two integers for the RGB and alpha blend equations, four integers indicating the source and destination RGB and alpha blending functions, and a bit indicating whether blending is enabled or disabled. Additionally, four floating-point values to store the RGBA constant blend color are required. For all draw buffers, the initial blend equations for RGB and alpha are both FUNC_ADD, and the initial blending functions are ONE for the source RGB and alpha functions, and ZERO for the destination RGB and alpha functions. Initially, blending is disabled for all draw buffers. The initial constant blend color is (R,G,B,A) = (0,0,0,0). The value of the blend enable for draw buffer can be queried by calling IsEnablediOES with BLEND and , and the values of the blend equations and functions can be queried by calling GetIntegeri_v with the corresponding as shown in table 6.11 and . The value of the blend enable, or the blend equations and functions for draw buffer zero may also be queried by calling IsEnabled, or GetInteger, respectively, with the same symbolic constants but no parameter." Modify section 4.2.2 (Fine Control of Buffer Updates) replacing the first two paragraphs as follows: "Writing to bits of each of the logical framebuffers after all per-fragment operations have been performed may be "masked". The commands: void ColorMask(boolean r, boolean g, boolean b, boolean a); void ColorMaskiOES(uint buf, boolean r, boolean g, boolean b, boolean a); control writes to the active draw buffers. ColorMask and ColorMaskiOES are used to mask the writing of R, G, B and A values to the draw buffer or buffers. ColorMaskiOES sets the mask for a particular draw buffer. The mask for DRAW_BUFFER is modified by passing as the parameter . , , , and indicate whether R, G, B, or A values, respectively, are written or not (a value of TRUE means that the corresponding value is written). The mask specified by , , , and is applied to the color buffer associated with DRAW_BUFFER. ColorMask sets the mask for all draw buffers to the same values as specified by , , , and . In the initial state, all color values are enabled for writing for all draw buffers. The value of the color writemask for draw buffer can be queried by calling GetBooleani_v with COLOR_WRITEMASK and . The value of the color writemask for draw buffer zero may also be queried by calling GetBooleanv with the symbolic constant COLOR_WRITEMASK." Additions to Chapter 5 of the OpenGL ES 3.0 Specification (Special Functions) None. Additions to Chapter 6 of the OpenGL ES 3.0 Specification (State and State Requests) Modify section 6.1.1 (Simple Queries) p. 226. Replace the 3rd paragraph with the following: "Finally, boolean IsEnabled(enum cap); can be used to determine if is currently enabled (as with Enable) or disabled, and boolean IsEnablediOES(enum target, uint index); can be used to determine if the index state corresponding to and is enabled or disabled. Additions to Appendix A of the OpenGL ES 3.0 Specification (Invariance) None. Additions to the EGL/AGL/GLX/WGL Specifications None. Errors The error INVALID_VALUE is generated by BlendEquationiOES, BlendEquationSeparateiOES, BlendFuncSeparateiOES, and BlendFunciOES if the parameter is outside the range [0, MAX_DRAW_BUFFERS-1]. The error INVALID_VALUE is generated by GetIntegeri_v if is BLEND_EQUATION_RGB, BLEND_EQUATION_ALPHA, BLEND_SRC_RGB, BLEND_SRC_ALPHA, BLEND_DST_RGB, BLEND_DST_ALPHA, and is outside the range [0, MAX_DRAW_BUFFERS-1]. The error INVALID_ENUM is generated by BlendFunciOES if either , or is not an accepted value. The error INVALID_ENUM is generated by BlendFuncSeparateiOES if either , , , or is not an accepted value. The error INVALID_ENUM is generated if the parameter of BlendEquationiOES is not one of FUNC_ADD, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MAX, or MIN. The error INVALID_ENUM is generated if either the or parameter of BlendEquationSeparateiOES is not one of FUNC_ADD, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MAX, or MIN. The error INVALID_ENUM is generated by EnableiOES and DisableiOES if the parameter is not BLEND. The error INVALID_VALUE is generated by EnableiOES and DisableiOES if the parameter is BLEND and the parameter is outside the range [0, MAX_DRAW_BUFFERS-1]. The error INVALID_ENUM is generated by IsEnablediOES if the parameter is not BLEND. The error INVALID_VALUE is generated by IsEnablediOES if the parameter is BLEND and the parameter is outside the range [0, MAX_DRAW_BUFFERS-1]. The error INVALID_VALUE is generated by ColorMaskiOES if the parameter is outside the range[0, MAX_DRAW_BUFFERS-1]. The error INVALID_VALUE is generated by GetBooleani_v if the parameter is COLOR_WRITEMASK and the parameter is outside the range [0, MAX_DRAW_BUFFERS-1]. New State Modify Table 6.11 (Pixel Operations) p. 254, modifying the entries for BLEND enable, the blend functions and blend equations, adding indexed versions: Initial Get Value Type Get Command Value Description Section -------------------- --------- ------------- -------- ------------------------------------ ------- BLEND B IsEnablediOES False Blending enabled for draw buffer 4.1.7 where is specified as BLEND_SRC_RGB 4* x Z_19 GetIntegeri_v ONE Blending source RGB 4.1.7 function for draw buffer where is specified as BLEND_SRC_ALPHA 4* x Z_19 GetIntegeri_v ONE Blending source A 4.1.7 function for draw buffer where is specified as BLEND_DST_RGB 4* x Z_19 GetIntegeri_v ZERO Blending destination RGB 4.1.7 function for draw buffer where is specified as BLEND_DST_ALPHA 4* x Z_19 GetIntegeri_v ZERO Blending destination A 4.1.7 function for draw buffer where is specified as BLEND_EQUATION_RGB 4* x Z_5 GetIntegeri_v FUNC_ADD RGB blending equation 4.1.7 for draw buffer where is specified as BLEND_EQUATION_ALPHA 4* x Z_5 GetIntegeri_v FUNC_ADD Alpha blending equation 4.1.7 for draw buffer where is specified as Modify Table 6.12 (Framebuffer Control) p. 255, modifying the entry for COLOR_WRITEMASK: Get Value Type Get Command Value Description Section --------------- -------- ------------- ------ ---------------------------------- ------- COLOR_WRITEMASK 4* x 4xB GetBooleani_v 4xTrue Color write enables (R, G, B, A) 4.2.2 for draw buffer where is specified as Issues Note: these issues apply specifically to the definition of OES_draw_buffers_indexed, which is based on the OpenGL EXT_draw_buffers2 and ARB_draw_buffers_blend extensions as updated in OpenGL 4.x. Resolved issues from EXT_draw_buffers2 and ARB_draw_buffers_blend have been removed but remain largely applicable to this extension. These extensions can be found in the OpenGL Registry. (1) What functionality was removed from EXT_draw_buffers2 and ARB_draw_buffers_blend? - removed mention of multiple buffers being associated with DRAW_BUFFER - removed mention of logical operation on color values - removed mention of the IndexMask command - removed errors related to glBegin/End (2) What functionality was changed or added relative to EXT_draw_buffers2 and ARB_draw_buffers_blend? - use EnableiOES/DisableiOES instead of Enable/DisableIndexedEXT - use ColorMaskiOES instead of ColorMaskIndexedEXT - use IsEnablediOES instead of IsEnabledIndexedEXT - GetIntegeri_v is already in ES 3.0 and is re-used instead of adding GetIntegerIndexedvEXT. - GetBooleani_v is already in ES 3.1 and is re-used instead of adding GetBooleanIndexedvEXT - change the errors to be consistent and match GL 4.4. (3) Issue removed. Not applicable to this extension. (4) Why doesn't this extension include GetBooleani_vOES? RESOLVED: GetBooleani_v was added in OpenGL ES 3.1 per Bug 11326 and thus no longer needs to be added by this extension. This extension does however extend the commands accepted by this core function. (5) What is the correct error for all the commands which take a or parameter which should be in the range [0, MAX_DRAW_BUFFERS-1]? RESOLVED: INVALID_VALUE is the correct error. EXT_draw_buffers2 specified INVALID_OPERATION for the EnableIndexedEXT, DisableIndexedEXT, IsEnabledIndexedEXT, and GetBooleanIndexedvEXT commands. ARB_draw_buffers_blend specified INVALID_ENUM for the Blend{Equation Func}[Separate]iARB commands. OpenGL 4.4 specifies INVALID_VALUE for the core versions of all these commands. This was clarified by Bug 7705, but never propagated back to the ARB_draw_buffers_blend extension. Since we are basing the functionality on the core versions of these commands we will use the GL 4.x error values. (6) What is the correct error for the Blend{Equation Func}[Separate]iOES commands if mode/modeRGB/modeAlpha/srcRGB/srcAlpha/dstRGB/dstAlpha is not a legal value? RESOLVED. INVALID_ENUM. Some versions of the GL 4.4 spec said it should be INVALID_VALUE, but it seems that the more correct error value should INVALID_ENUM since all of these values are specified as 'enum' in the function signatures. This was clarified in Bug 11354. Revision History Rev. Date Author Changes ---- ---------- -------- ----------------------------------------- 2 07/14/2014 dkoch Remove stray tokens from error (bug 12358) 1 06/18/2014 dkoch Initial OES version based on EXT. No functional changes.