GLMULTIDRAWARRAYSIND(3G)

πŸ“¦ in arch rolling

πŸ’… GLMULTIDRAWARRAYSIND(3G) β€” bestie, it's the 3G manual page

okay so picture this: you got a ton of primitives to draw, right? and you are NOT about to spam the driver with a million subroutine calls like some kind of NPC. this page is your girl. no cap, this is the one that lets the GPU fetch its own draw parameters straight out of memory, and it's giving main character energy ✨


🌸 NAME 🌸

glMultiDrawArraysIndirectCount β€” render multiple sets of primitives from array data, taking parameters and count from memory πŸ’–


✨ C SPECIFICATION ✨

void glMultiDrawArraysIndirectCount(GLenum mode, const void *indirect,
                                    GLintptr drawcount,
                                    GLsizei maxdrawcount,
                                    GLsizei stride);

πŸŽ€ PARAMETERS πŸŽ€

  • mode β€” literally specifies what kind of primitives to render. the following symbolic constants are accepted, and yes you gotta pick one of these exact ones: GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_LINE_STRIP_ADJACENCY, GL_LINES_ADJACENCY, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_TRIANGLE_STRIP_ADJACENCY, GL_TRIANGLES_ADJACENCY, and GL_PATCHES. that's the whole roster 🫢
  • indirect β€” the address of an array of structures holding all the draw parameters. so like, the actual homework. πŸ“š
  • drawcount β€” an offset (in bytes, okurrr) into the buffer object bound to the GL_PARAMETER_BUFFER binding point, where a single sizei typed value lives. must be a multiple of four. don't come in here with your weird byte offsets πŸ™ˆ
  • maxdrawcount β€” the maximum number of draws that are expected to be stored in the buffer. and here's the tea: if the value stored at drawcount into the buffer is greater than maxdrawcount, the implementation just stops processing draws after maxdrawcount parameter sets. it's a hard cutoff, bestie πŸ’€
  • stride β€” the distance in basic machine units between elements of the draw parameter array. basically the gap between your structs. 🧚

πŸ”₯ DESCRIPTION πŸ”₯

glMultiDrawArraysIndirectCount specifies multiple geometric primitives with very few subroutine calls. like, minimal effort, maximum slay. πŸ‘‘

it behaves similarly to glMultiDrawArraysIndirect(), except that the drawcount parameter is stored in the buffer bound to the GL_PARAMETER_BUFFER binding at the offset specified by drawcount. so instead of you passing the count in by hand, it's chillin' in memory. iykyk πŸ’…

the parameters addressed by indirect are packed into an array of structures, and each element takes this exact form (in C):

typedef  struct {
    uint  count;
    uint  instanceCount;
    uint  first;
    uint  baseInstance;
} DrawArraysIndirectCommand;

so if a buffer is bound to the GL_DRAW_INDIRECT_BUFFER binding at the time of a call to glMultiDrawArraysIndirectCount, then indirect is interpreted as an offset, in basic machine units, into that buffer β€” and the parameter data is read from the buffer rather than from client memory. glow-up behavior honestly ✨

and here's a fun little contrast for you: unlike glDrawArraysInstancedBaseInstance(), the first member of the parameter structure is unsigned, and out-of-range indices do not generate an error. wild, i know. 🀯

⚠️ real talk though: vertex attributes that are modified by glMultiDrawArraysIndirectCount have an unspecified value after glMultiDrawArraysIndirectCount returns. attributes that aren't modified remain well defined. so don't go reading the modified ones and acting surprised. 😭

πŸ’€ ERRORS πŸ’€

these are the ways to get yelled at. every single one, no skipping:

  • GL_INVALID_ENUM is generated if mode is not an accepted value. pick a real one bestie πŸ₯²
  • GL_INVALID_VALUE is generated if stride is not a multiple of four.
  • GL_INVALID_VALUE is generated if drawcount is negative. no negative offsets, that's not the vibe.
  • GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or to the GL_DRAW_INDIRECT_BUFFER binding and the buffer object's data store is currently mapped. unmapped = unmapped, periodt.
  • GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program object.
  • GL_INVALID_OPERATION is generated if mode is GL_PATCHES and no tessellation control shader is active. patches need their shader, she's nothing without her πŸ’…
  • GL_INVALID_OPERATION error is generated if no buffer is bound to the GL_PARAMETER_BUFFER binding point.
  • GL_INVALID_OPERATION error is generated if drawcount is not a multiple of four.
  • GL_INVALID_OPERATION error is generated if reading a sizei typed value from the buffer bound to the GL_PARAMETER_BUFFER target at the offset specified by drawcount would result in an out-of-bounds access. πŸ’€ do not do that.

🌈 VERSION SUPPORT 🌈

okay so the original is a big glamorous table β€” rows are Function / Feature Name, columns are OpenGL Version β€” and the only entry is glMultiDrawArraysIndirectCount. here's the whole thing spelled out, every version, every symbol, so you don't miss a crumb πŸ“

  • OpenGL 2.0 β€” -
  • OpenGL 2.1 β€” -
  • OpenGL 3.0 β€” -
  • OpenGL 3.1 β€” -
  • OpenGL 3.2 β€” -
  • OpenGL 3.3 β€” -
  • OpenGL 4.0 β€” -
  • OpenGL 4.1 β€” -
  • OpenGL 4.2 β€” -
  • OpenGL 4.3 β€” -
  • OpenGL 4.4 β€” -
  • OpenGL 4.5 β€” -
  • OpenGL 4.6 β€” βœ”

so yeah. she's a 4.6 exclusive. if you're on anything older, respectfully, this function does not know you. 😌


πŸ¦‹ SEE ALSO πŸ¦‹

go read these too, they're all in the group chat:

  • glDrawArrays()
  • glDrawArraysInstanced()
  • glDrawElements()
  • glDrawRangeElements()
  • glDrawArraysIndirect()
  • glMultiDrawArraysIndirect()
  • glMultiDrawElementsIndirect()
  • glMultiDrawElementsIndirectCount()

Copyright Β© 2012-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. https://opencontent.org/openpub/.

Copyright Β© 2012-2014 Khronos Group.


okay that's the whole page, you ate that 🫢 this came from [FIXME: source] and it's dated 10/07/2026 β€” so yeah, it's a GLMULTIDRAWARRAYSIND(3G) page and we're all caught up. now go draw something iconic πŸ’œβœ¨πŸŒΈ

πŸ“¦ where this page comes from