15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_multi_draw_indirect 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_multi_draw_indirect 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Daniel Koch, NVIDIA (dkoch 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Dominik Witczak, Mobica 165bd8deadSopenharmony_ci Jonas Gustavsson, Sony Mobile 175bd8deadSopenharmony_ci Slawomir Grajewski, Intel 185bd8deadSopenharmony_ci Contributors to ARB_multi_draw_indirect 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ciNotice 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ci Copyright (c) 2012-2014 The Khronos Group Inc. Copyright terms at 235bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Portions Copyright (c) 2014 NVIDIA Corporation. 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciStatus 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Complete 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciVersion 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci Last Modified Date: October 24, 2014 345bd8deadSopenharmony_ci Revision: 4 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciNumber 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci OpenGL ES Extension #205 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciDependencies 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci OpenGL ES 3.1 is required. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci This specification is written against the OpenGL ES 3.1 (June 4, 2014) 455bd8deadSopenharmony_ci Specification. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci This extension interacts with EXT_base_instance. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci This extension interacts with EXT_geometry_shader. 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ciOverview 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci The ARB_draw_indirect extension (included in OpenGL 4.0 and OpenGL ES 3.1) 545bd8deadSopenharmony_ci introduced mechanisms whereby the parameters for a draw function may be 555bd8deadSopenharmony_ci provided in a structure contained in a buffer object rather than as 565bd8deadSopenharmony_ci parameters to the drawing procedure. This is known as an indirect draw and 575bd8deadSopenharmony_ci is exposed as two new functions, glDrawArraysIndirect and 585bd8deadSopenharmony_ci glDrawElementsIndirect. Each of these functions generates a single batch 595bd8deadSopenharmony_ci of primitives. 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci This extension builds on this functionality by providing procedures to 625bd8deadSopenharmony_ci invoke multiple draws from a single procedure call. This allows large 635bd8deadSopenharmony_ci batches of drawing commands to be assembled in server memory (via a buffer 645bd8deadSopenharmony_ci object) which may then be dispatched through a single function call. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ciNew Procedures and Functions 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ci void MultiDrawArraysIndirectEXT(enum mode, 695bd8deadSopenharmony_ci const void *indirect, 705bd8deadSopenharmony_ci sizei drawcount, 715bd8deadSopenharmony_ci sizei stride); 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ci void MultiDrawElementsIndirectEXT(enum mode, 745bd8deadSopenharmony_ci enum type, 755bd8deadSopenharmony_ci const void *indirect, 765bd8deadSopenharmony_ci sizei drawcount, 775bd8deadSopenharmony_ci sizei stride); 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ciNew Tokens 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci None. 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ciAdditions to Chapter 10 of the OpenGL ES 3.1 Specification (Vertex 845bd8deadSopenharmony_ciSpecification and Drawing Commands) 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci Additions to 10.3.8, "Indirect Commands in Buffer Objects", p. 244 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci Add MultiDrawArraysIndirectEXT and MultiDrawElementsIndirectEXT 895bd8deadSopenharmony_ci to the list of "indirect commands" in the first paragraph of the section. 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci In the second paragraph of the section replace the reference to 925bd8deadSopenharmony_ci "Draw*Indirect" commands with a reference to "*Draw*Indirect" so 935bd8deadSopenharmony_ci that it is clear that this statement applies to the MultiDraw 945bd8deadSopenharmony_ci variants of the commands as well. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci Update Table 10.3 "Indirect commands and corresponding indirect buffer 975bd8deadSopenharmony_ci targets" adding the following two rows: 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci Indirect Command Name | Indirect Buffer <target> 1005bd8deadSopenharmony_ci --------------------------------------------------------- 1015bd8deadSopenharmony_ci MultiDrawArraysIndirectEXT | DRAW_INDIRECT_BUFFER 1025bd8deadSopenharmony_ci MultiDrawElementsIndirectEXT | DRAW_INDIRECT_BUFFER 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Additions to Section 10.5, "Drawing Commands using Vertex Arrays" 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci (After the description of DrawArraysIndirect and before the introduction of 1085bd8deadSopenharmony_ci DrawElementsOneInstance, insert the following on p.249) 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci "The command 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci void MultiDrawArraysIndirectEXT(enum mode, 1135bd8deadSopenharmony_ci const void *indirect, 1145bd8deadSopenharmony_ci sizei drawcount, 1155bd8deadSopenharmony_ci sizei stride); 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci behaves identically to DrawArraysIndirect, except that <indirect> is 1185bd8deadSopenharmony_ci treated as an array of <drawcount> DrawArraysIndirectCommand structures. 1195bd8deadSopenharmony_ci <indirect> contains the offset of the first element of the array within the 1205bd8deadSopenharmony_ci buffer currently bound to the DRAW_INDIRECT buffer binding. <stride> 1215bd8deadSopenharmony_ci specifies the distance, in basic machine units, between the elements of the 1225bd8deadSopenharmony_ci array. If <stride> is zero, the array elements are treated as tightly 1235bd8deadSopenharmony_ci packed. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci It is equivalent to 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci if (<mode> is invalid) 1285bd8deadSopenharmony_ci generate appropriate error 1295bd8deadSopenharmony_ci else { 1305bd8deadSopenharmony_ci const ubyte * ptr = (const ubyte *)<indirect>; 1315bd8deadSopenharmony_ci for (i = 0; i < <drawcount>; i++) { 1325bd8deadSopenharmony_ci DrawArraysIndirect(<mode>, 1335bd8deadSopenharmony_ci (DrawArraysIndirectCommand*)ptr); 1345bd8deadSopenharmony_ci if (<stride> == 0) { 1355bd8deadSopenharmony_ci ptr += sizeof(DrawArraysIndirectCommand); 1365bd8deadSopenharmony_ci } else { 1375bd8deadSopenharmony_ci ptr += <stride>; 1385bd8deadSopenharmony_ci } 1395bd8deadSopenharmony_ci } 1405bd8deadSopenharmony_ci } 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci MultiDrawArraysIndirectEXT requires that all data sourced for the command, 1435bd8deadSopenharmony_ci including the DrawArraysIndirectCommand structure, be in buffer objects, 1445bd8deadSopenharmony_ci and cannot be called when the default vertex array object is bound. 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci Errors 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci An INVALID_VALUE is generated if <stride> is neither zero nor a multiple 1495bd8deadSopenharmony_ci of four. 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <drawcount> is not positive. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if zero is bound to 1545bd8deadSopenharmony_ci VERTEX_ARRAY_BINDING, DRAW_INDIRECT_BUFFER, or to any enabled vertex array. 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the command would source data 1575bd8deadSopenharmony_ci beyond the end of the buffer object. 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <indirect> is not a multiple of 1605bd8deadSopenharmony_ci the size, in basic machine units of uint. 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci [[ If EXT_geometry_shader is not supported. ]] 1635bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if transform feedback is active 1645bd8deadSopenharmony_ci and not paused. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci [[ If EXT_base_instance is not supported. ]] 1675bd8deadSopenharmony_ci Results are undefined if <reservedMustBeZero> is non-zero, but may not 1685bd8deadSopenharmony_ci result in program termination." 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci (After the description of DrawElementsIndirect insert the following on 1725bd8deadSopenharmony_ci p.253) 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci "The command 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci void MultiDrawElementsIndirectEXT(enum mode, 1775bd8deadSopenharmony_ci enum type, 1785bd8deadSopenharmony_ci const void *indirect, 1795bd8deadSopenharmony_ci sizei drawcount, 1805bd8deadSopenharmony_ci sizei stride); 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci behaves identically to DrawElementsIndirect, except that <indirect> is 1835bd8deadSopenharmony_ci treated as an array of <drawcount> DrawElementsIndirectCommand structures. 1845bd8deadSopenharmony_ci <indirect> contains the offset of the first element of the array within the 1855bd8deadSopenharmony_ci buffer currently bound to the DRAW_INDIRECT buffer binding. <stride> 1865bd8deadSopenharmony_ci specifies the distance, in basic machine units, between the elements of the 1875bd8deadSopenharmony_ci array. If <stride> is zero, the array elements are treated as tightly 1885bd8deadSopenharmony_ci packed. 1895bd8deadSopenharmony_ci <stride> must be a multiple of four, otherwise an INVALID_VALUE 1905bd8deadSopenharmony_ci error is generated. 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci It is equivalent to 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci if (<mode> or <type> is invalid) 1955bd8deadSopenharmony_ci generate appropriate error 1965bd8deadSopenharmony_ci else { 1975bd8deadSopenharmony_ci const ubyte * ptr = (const ubyte *)<indirect>; 1985bd8deadSopenharmony_ci for (i = 0; i < <drawcount>; i++) { 1995bd8deadSopenharmony_ci DrawElementsIndirect(<mode>, 2005bd8deadSopenharmony_ci <type>, 2015bd8deadSopenharmony_ci (DrawElementsIndirectCommand*)ptr); 2025bd8deadSopenharmony_ci if (<stride> == 0) { 2035bd8deadSopenharmony_ci ptr += sizeof(DrawElementsIndirectCommand); 2045bd8deadSopenharmony_ci } else { 2055bd8deadSopenharmony_ci ptr += <stride>; 2065bd8deadSopenharmony_ci } 2075bd8deadSopenharmony_ci } 2085bd8deadSopenharmony_ci } 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci MultiDrawElementsIndirectEXT requires that all data sourced for the 2115bd8deadSopenharmony_ci command, including the DrawElementsIndirectCommand structure, be in buffer 2125bd8deadSopenharmony_ci objects, and cannot be called when the default vertex array object is bound. 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci Errors 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci An INVALID_VALUE is generated if <stride> is neither zero nor a multiple 2175bd8deadSopenharmony_ci of four. 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <drawcount> is not positive. 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if zero is bound to 2225bd8deadSopenharmony_ci VERTEX_ARRAY_BINDING, DRAW_INDIRECT_BUFFER, ELEMENT_ARRAY_BUFFER, or to 2235bd8deadSopenharmony_ci any enabled vertex array. 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the command would source data 2265bd8deadSopenharmony_ci beyond the end of the buffer object. 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <indirect> is not a multiple of 2295bd8deadSopenharmony_ci the size, in basic machine units of uint. 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci [[ If EXT_geometry_shader is not supported. ]] 2325bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if transform feedback is active 2335bd8deadSopenharmony_ci and not paused. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci [[ If EXT_base_instance is not supported. ]] 2365bd8deadSopenharmony_ci Results are undefined if <reservedMustBeZero> is non-zero, but may not 2375bd8deadSopenharmony_ci result in program termination." 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ciAdditions to the EGL/AGL/GLX/WGL Specifications 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci None. 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ciDependencies on EXT_base_instance 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ci If EXT_base_instance is not supported, the <baseInstance> 2465bd8deadSopenharmony_ci parameter in the Draw*IndirectCommand structures is not supported. 2475bd8deadSopenharmony_ci 2485bd8deadSopenharmony_ciDependencies on EXT_geometry_shader 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci If EXT_geometry_shader is not supported, transform feedback cannot 2515bd8deadSopenharmony_ci be used with the Multi*DrawIndirect commands. 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ciGLX Protocol 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ci None. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ciNew State 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci None. 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ciNew Implementation Dependent State 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ci None. 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ciIssues 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci Note: These issues apply specifically to the definition of the 2685bd8deadSopenharmony_ci EXT_multi_draw_indirect specification, which is based on the OpenGL 2695bd8deadSopenharmony_ci extension ARB_multi_draw_indirect as updated in OpenGL 4.x. 2705bd8deadSopenharmony_ci ARB_multi_draw_indirect can be found in the OpenGL Registry. 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci (0) This extension is based on ARB_multi_draw_indirect. What are the 2735bd8deadSopenharmony_ci major differences? 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci - Rebased against the ES 3.1 restructured specification 2765bd8deadSopenharmony_ci - renamed the <primcount> parameter to <drawcount> to match 2775bd8deadSopenharmony_ci the GL 4.4 spec (and reflect what the parameter really is). 2785bd8deadSopenharmony_ci - using the new commands with the default vertex array object, 2795bd8deadSopenharmony_ci or client-side memory the draw indirect buffer, vertex arrays 2805bd8deadSopenharmony_ci or index data is not permitted. 2815bd8deadSopenharmony_ci - these commands cannot be used when transform feedback is enabled 2825bd8deadSopenharmony_ci unless EXT_geometry_shader is supported. 2835bd8deadSopenharmony_ci - these commands do not support the baseInstance parameter unless 2845bd8deadSopenharmony_ci EXT_base_instance is supported. 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ci (1) What about the "baseInstance" parameter for indirect draws? 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci It is still listed as reserved in the DrawElementsIndirectCommand 2895bd8deadSopenharmony_ci structure. It is separately added as orthogonal functionality in 2905bd8deadSopenharmony_ci the EXT_base_instance extension, although that should really be 2915bd8deadSopenharmony_ci supported in order to get the full benefit of multi_draw_indirect. 2925bd8deadSopenharmony_ci Since MultiDrawElementsIndirectEXT is defined in terms of 2935bd8deadSopenharmony_ci DrawElementsIndirect the extension that adds support for base instance 2945bd8deadSopenharmony_ci will automatically add support for in via MDI as well. 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci (2) Should the new drawing commands be supported on the default 2975bd8deadSopenharmony_ci vertex array object? 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci RESOLVED: No. This extension follows the precedent of ES 3.1's 3005bd8deadSopenharmony_ci Draw*Indirect capabilities, which disallow the commands with the 3015bd8deadSopenharmony_ci default vertex array object. 3025bd8deadSopenharmony_ci 3035bd8deadSopenharmony_ci (3) Should the new drawing commands be supported with client-side 3045bd8deadSopenharmony_ci memory? 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci RESOLVED. No. Again, this extension follows the precedent of OpenGL ES 3075bd8deadSopenharmony_ci 3.1's Draw*Indirect capabilities, which disallow the commands with 3085bd8deadSopenharmony_ci client-side memory for the vertex arrays, element array, and draw 3095bd8deadSopenharmony_ci indirect buffers. 3105bd8deadSopenharmony_ci 3115bd8deadSopenharmony_ci (4) The resolution of Issues (2) and (3) take the opposite resolution 3125bd8deadSopenharmony_ci to the same questions raised in EXT_base_instance. Isn't that a little 3135bd8deadSopenharmony_ci strange? 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci RESOLVED. Yes, but that's the way we roll. The non-indirect drawing 3165bd8deadSopenharmony_ci commands must support the ES2-level features for compatibility. 3175bd8deadSopenharmony_ci 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ciRevision History 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci Rev. Date Author Changes 3225bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 3235bd8deadSopenharmony_ci 4 10/24/2014 dkoch Mark as complete. 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci 3 06/24/2014 dkoch Fixes from Dominik, dangling primcount refs, 3265bd8deadSopenharmony_ci formatting of pseudocode. 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ci 2 06/20/2014 dkoch Require VAO and client-side memory for 3295bd8deadSopenharmony_ci the MultiDraw*Indirect commands. 3305bd8deadSopenharmony_ci List the full set of errors for the new cmds. 3315bd8deadSopenharmony_ci Rebase to Jun 4 ES 3.1 spec. 3325bd8deadSopenharmony_ci Add interactions with EXT_base_instance. 3335bd8deadSopenharmony_ci Add interactions with EXT_geometry_shader. 3345bd8deadSopenharmony_ci 3355bd8deadSopenharmony_ci 1 03/18/2014 dkoch EXT version based on ARB_multi_draw_indirect v.3 336