15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_multi_draw_indirect 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_multi_draw_indirect 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Graham Sellers, AMD (graham.sellers 'at' amd.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Graham Sellers 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciNotice 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Copyright (c) 2012-2013 The Khronos Group Inc. Copyright terms at 205bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciSpecification Update Policy 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 255bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 265bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 275bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 285bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 295bd8deadSopenharmony_ci described in more detail at 305bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciStatus 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci Complete. 355bd8deadSopenharmony_ci Approved by the ARB on 2012/06/12. 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciVersion 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci Last Modified Date: June 9, 2014 405bd8deadSopenharmony_ci Revision: 4 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciNumber 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci ARB Extension #133 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ciDependencies 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci OpenGL 4.0 or ARB_draw_indirect is required. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci The extension is written against the OpenGL 4.1 Specification, Core Profile, 515bd8deadSopenharmony_ci July 25, 2010 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ciOverview 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci The ARB_draw_indirect extension (included in OpenGL 4.0) introduced 565bd8deadSopenharmony_ci mechanisms whereby the parameters for a draw function may be provided in 575bd8deadSopenharmony_ci a structure contained in a buffer object rather than as parameters to the 585bd8deadSopenharmony_ci drawing procedure. This is known as an indirect draw and is exposed as two 595bd8deadSopenharmony_ci new functions, glDrawArraysIndirect and glDrawElementsIndirect. Each of 605bd8deadSopenharmony_ci these functions generates a single batch of primitives. 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci This extension builds on this functionality by providing procedures to 635bd8deadSopenharmony_ci invoke multiple draws from a single procedure call. This allows large 645bd8deadSopenharmony_ci batches of drawing commands to be assembled in server memory (via a buffer 655bd8deadSopenharmony_ci object) which may then be dispatched through a single function call. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ciNew Procedures and Functions 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ci void MultiDrawArraysIndirect(enum mode, 705bd8deadSopenharmony_ci const void *indirect, 715bd8deadSopenharmony_ci sizei primcount, 725bd8deadSopenharmony_ci sizei stride); 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci void MultiDrawElementsIndirect(enum mode, 755bd8deadSopenharmony_ci enum type, 765bd8deadSopenharmony_ci const void *indirect, 775bd8deadSopenharmony_ci sizei primcount, 785bd8deadSopenharmony_ci sizei stride); 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciNew Tokens 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci None. 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 4.1 (Core) Specification (OpenGL Operation) 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci Additions to Section 2.8.3, "Drawing Commands" 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci After the description of MultiDrawArrays and before the introduction of 895bd8deadSopenharmony_ci DrawElementsInstanced, insert the following on p.36: 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci The command 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci void MultiDrawArraysIndirect(enum mode, 945bd8deadSopenharmony_ci const void *indirect, 955bd8deadSopenharmony_ci sizei primcount, 965bd8deadSopenharmony_ci sizei stride); 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci behaves identically to DrawArraysIndirect, except that <indirect> is 995bd8deadSopenharmony_ci treated as an array of <primcount> DrawArraysIndirectCommand structures. 1005bd8deadSopenharmony_ci <indirect> contains the offset of the first element of the array within the 1015bd8deadSopenharmony_ci buffer currently bound to the DRAW_INDIRECT buffer binding.<stride> 1025bd8deadSopenharmony_ci specifies the distance, in basic machine units, between the elements of the 1035bd8deadSopenharmony_ci array. If <stride> is zero, the array elements are treated as tightly 1045bd8deadSopenharmony_ci packed. <stride> must be a multiple of four, otherwise an INVALID_VALUE 1055bd8deadSopenharmony_ci error is generated. 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci It has the same effect as (assuming no errors are generated): 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci if (<mode> is invalid) 1105bd8deadSopenharmony_ci generate appropriate error 1115bd8deadSopenharmony_ci else { 1125bd8deadSopenharmony_ci const ubyte * ptr = (const ubyte *)indirect; 1135bd8deadSopenharmony_ci for (i = 0; i < primcount; i++) { 1145bd8deadSopenharmony_ci DrawArraysIndirect(mode, 1155bd8deadSopenharmony_ci (DrawArraysIndirectCommand*)ptr); 1165bd8deadSopenharmony_ci if (stride == 0) 1175bd8deadSopenharmony_ci { 1185bd8deadSopenharmony_ci ptr += sizeof(DrawArraysIndirectCommand); 1195bd8deadSopenharmony_ci } else 1205bd8deadSopenharmony_ci { 1215bd8deadSopenharmony_ci ptr += stride; 1225bd8deadSopenharmony_ci } 1235bd8deadSopenharmony_ci } 1245bd8deadSopenharmony_ci } 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci <primcount> must be positive, otherwise an INVALID_VALUE error will be 1275bd8deadSopenharmony_ci generated. 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci After the description of DrawElementsIndirect and before the introduction 1305bd8deadSopenharmony_ci of MultiDrawElementsBaseVertex, insert the following on p.39: 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci The command 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci void MultiDrawElementsIndirect(enum mode, 1355bd8deadSopenharmony_ci enum type, 1365bd8deadSopenharmony_ci const void *indirect, 1375bd8deadSopenharmony_ci sizei primcount, 1385bd8deadSopenharmony_ci sizei stride); 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci behaves identically to DrawElementsIndirect, except that <indirect> is 1415bd8deadSopenharmony_ci treated as an array of <primcount> DrawElementsIndirectCommand structures. 1425bd8deadSopenharmony_ci <indirect> contains the offset of the first element of the array within the 1435bd8deadSopenharmony_ci buffer currently bound to the DRAW_INDIRECT buffer binding. <stride> 1445bd8deadSopenharmony_ci specifies the distance, in basic machine units, between the elements of the 1455bd8deadSopenharmony_ci array. If <stride> is zero, the array elements are treated as tightly 1465bd8deadSopenharmony_ci packed. <stride> must be a multiple of four, otherwise an INVALID_VALUE 1475bd8deadSopenharmony_ci error is generated. 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci It has the same effect as (assuming no errors are generated): 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci if (<mode> or <type> is invalid) 1525bd8deadSopenharmony_ci generate appropriate error 1535bd8deadSopenharmony_ci else { 1545bd8deadSopenharmony_ci const ubyte * ptr = (const ubyte *)indirect; 1555bd8deadSopenharmony_ci for (i = 0; i < primcount; i++) { 1565bd8deadSopenharmony_ci DrawElementsIndirect(mode, 1575bd8deadSopenharmony_ci type, 1585bd8deadSopenharmony_ci (DrawElementsIndirectCommand*)ptr); 1595bd8deadSopenharmony_ci if (stride == 0) 1605bd8deadSopenharmony_ci { 1615bd8deadSopenharmony_ci ptr += sizeof(DrawElementsIndirectCommand); 1625bd8deadSopenharmony_ci } else 1635bd8deadSopenharmony_ci { 1645bd8deadSopenharmony_ci ptr += stride; 1655bd8deadSopenharmony_ci } 1665bd8deadSopenharmony_ci } 1675bd8deadSopenharmony_ci } 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci Modifications to Section 2.9.8 "Indirect Commands in Buffer Objects" 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci Modify both instances of "DrawArraysIndirect and DrawElementsIndirect" on 1725bd8deadSopenharmony_ci p.51 to read "DrawArraysIndirect, DrawElementsIndirect, 1735bd8deadSopenharmony_ci MultiDrawArraysIndirect and MultiDrawElementsIndirect". 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 4.1 (Core) Specification (Rasterization) 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci None. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 4.1 (Core) Specification (Per-Fragment Operations 1805bd8deadSopenharmony_ciand the Framebuffer) 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci None. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 4.1 (Core) Specification (Special 1855bd8deadSopenharmony_ciFunctions) 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci None. 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 4.1 (Core) Specification (State and 1905bd8deadSopenharmony_ciState Requests) 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci None. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci None. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ciGLX Protocol 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci None. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ciErrors 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci MultiDrawArraysIndirect and MultiDrawElementsIndirect may generate the 2055bd8deadSopenharmony_ci same errors as the corresponding DrawArraysIndirect and 2065bd8deadSopenharmony_ci DrawElementsIndirect commands in the equivalent pseudocode. In addition, 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci INVALID_VALUE is generated by MultiDrawArraysIndirect or 2095bd8deadSopenharmony_ci MultiDrawElementsIndirect if <primcount> is negative. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci INVALID_VALUE is generated by MultiDrawArraysIndirect or 2125bd8deadSopenharmony_ci MultiDrawElementsIndirect if <stride> is not a multipe of four. 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ciNew State 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci None. 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ciNew Implementation Dependent State 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci None. 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ciIssues 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci None, so far. 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ciRevision History 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci Rev. Date Author Changes 2295bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 2305bd8deadSopenharmony_ci 4 06/09/2014 Jon Leech Note that errors can be generated from 2315bd8deadSopenharmony_ci the non-Multi Draw*Indirect commands 2325bd8deadSopenharmony_ci in the equivalent pseudocode (Bug 11946). 2335bd8deadSopenharmony_ci 3 06/14/2012 Jon Leech Change to ARB extension & remove suffixes 2345bd8deadSopenharmony_ci 2 02/14/2011 gsellers Add stride parameters 2355bd8deadSopenharmony_ci 1 01/06/2011 gsellers Initial draft 236