1Name 2 3 AMD_multi_draw_indirect 4 5Name Strings 6 7 GL_AMD_multi_draw_indirect 8 9Contact 10 11 Graham Sellers, AMD (graham.sellers 'at' amd.com) 12 13Contributors 14 15 Graham Sellers 16 17Status 18 19 Complete, shipping. 20 21Version 22 23 Last Modified Date: Febuary 14, 2011 24 Revision: 2 25 26Number 27 28 408 29 30Dependencies 31 32 OpenGL 4.0 or ARB_draw_indirect is required. 33 34 The extension is written against the OpenGL 4.1 Specification, Core Profile, 35 July 25, 2010 36 37Overview 38 39 The ARB_draw_indirect extension (included in OpenGL 4.0) introduced 40 mechanisms whereby the parameters for a draw function may be provided in 41 a structure contained in a buffer object rather than as parameters to the 42 drawing procedure. This is known as an indirect draw and is exposed as two 43 new functions, glDrawArraysIndirect and glDrawElementsIndirect. Each of 44 these functions generates a single batch of primitives. 45 46 This extension builds on this functionality by providing procedures to 47 invoke multiple draws from a single procedure call. This allows large 48 batches of drawing commands to be assembled in server memory (via a buffer 49 object) which may then be dispatched through a single function call. 50 51New Procedures and Functions 52 53 void MultiDrawArraysIndirectAMD(enum mode, 54 const void *indirect, 55 sizei primcount, 56 sizei stride); 57 58 void MultiDrawElementsIndirectAMD(enum mode, 59 enum type, 60 const void *indirect, 61 sizei primcount, 62 sizei stride); 63 64New Tokens 65 66 None. 67 68Additions to Chapter 2 of the OpenGL 4.1 (Core) Specification (OpenGL Operation) 69 70 Additions to Section 2.8.3, "Drawing Commands" 71 72 After the description of MultiDrawArrays and before the introduction of 73 DrawElementsInstanced, insert the following on p.36: 74 75 The command 76 77 void MultiDrawArraysIndirectAMD(enum mode, 78 const void *indirect, 79 sizei primcount, 80 sizei stride); 81 82 behaves identically to DrawArraysIndirect, except that <indirect> is 83 treated as an array of <primcount> DrawArraysIndirectCommand structures. 84 <indirect> contains the offset of the first element of the array within the 85 buffer currently bound to the DRAW_INDIRECT buffer binding.<stride> 86 specifies the distance, in basic machine units, between the elements of the 87 array. If <stride> is zero, the array elements are treated as tightly 88 packed. <stride> must be a multiple of four, otherwise an INVALID_VALUE 89 error is generated. 90 91 It has the same effect as: 92 93 if (<mode> is invalid) 94 generate appropriate error 95 else { 96 const ubyte * ptr = (const ubyte *)indirect; 97 for (i = 0; i < primcount; i++) { 98 DrawArraysIndirect(mode, 99 (DrawArraysIndirectCommand*)ptr); 100 if (stride == 0) 101 { 102 ptr += sizeof(DrawArraysIndirectCommand); 103 } else 104 { 105 ptr += stride; 106 } 107 } 108 } 109 110 <primcount> must be positive, otherwise an INVALID_VALUE error will be 111 generated. 112 113 After the description of DrawElementsIndirect and before the introduction 114 of MultiDrawElementsBaseVertex, insert the following on p.39: 115 116 The command 117 118 void MultiDrawElementsIndirectAMD(enum mode, 119 enum type, 120 const void *indirect, 121 sizei primcount, 122 sizei stride); 123 124 behaves identically to DrawElementsIndirect, except that <indirect> is 125 treated as an array of <primcount> DrawElementsIndirectCommand structures. 126 <indirect> contains the offset of the first element of the array within the 127 buffer currently bound to the DRAW_INDIRECT buffer binding. <stride> 128 specifies the distance, in basic machine units, between the elements of the 129 array. If <stride> is zero, the array elements are treated as tightly 130 packed. <stride> must be a multiple of four, otherwise an INVALID_VALUE 131 error is generated. 132 133 It has the same effect as: 134 135 if (<mode> or <type> is invalid) 136 generate appropriate error 137 else { 138 const ubyte * ptr = (const ubyte *)indirect; 139 for (i = 0; i < primcount; i++) { 140 DrawElementsIndirect(mode, 141 type, 142 (DrawElementsIndirectCommand*)ptr); 143 if (stride == 0) 144 { 145 ptr += sizeof(DrawElementsIndirectCommand); 146 } else 147 { 148 ptr += stride; 149 } 150 } 151 } 152 153 Modifications to Section 2.9.8 "Indirect Commands in Buffer Objects" 154 155 Modify both instances of "DrawArraysIndirect and DrawElementsIndirect" on 156 p.51 to read "DrawArraysIndirect, DrawElementsIndirect, 157 MultiDrawArraysIndirect and MultiDrawElementsIndirect". 158 159Additions to Chapter 3 of the OpenGL 4.1 (Core) Specification (Rasterization) 160 161 None. 162 163Additions to Chapter 4 of the OpenGL 4.1 (Core) Specification (Per-Fragment Operations 164and the Framebuffer) 165 166 None. 167 168Additions to Chapter 5 of the OpenGL 4.1 (Core) Specification (Special 169Functions) 170 171 None. 172 173Additions to Chapter 6 of the OpenGL 4.1 (Core) Specification (State and 174State Requests) 175 176 None. 177 178Additions to the AGL/GLX/WGL Specifications 179 180 None. 181 182GLX Protocol 183 184 None. 185 186Errors 187 188 INVALID_VALUE is generated by MultiDrawArraysIndirect or 189 MultiDrawElementsIndirect if <primcount> is negative. 190 191 INVALID_VALUE is generated by MultiDrawArraysIndirect or 192 MultiDrawElementsIndirect if <stride> is not a multipe of four. 193 194New State 195 196 None. 197 198New Implementation Dependent State 199 200 None. 201 202Issues 203 204 None, so far. 205 206Revision History 207 208 Rev. Date Author Changes 209 ---- -------- -------- ----------------------------------------- 210 211 2 02/14/2011 gsellers Add stride parameters 212 1 01/06/2011 gsellers Initial draft 213