3

Okay, so I am trying to write a simple rendering loop to understand glMultiDrawElementsIndirect. But at the moment it freezes up my whole computer(Ubuntu 14.04) and forces me to give it a cold restart.

I define this structure as guidlined by the OpenGL spec:

struct DrawElementsIndirectCommand{
    GLuint count;
    GLuint instanceCount;
    GLuint firstIndex;
    GLuint baseVertex;
    GLuint baseInstance;
};

then at the moment my understanding is this (in pseudo-code):

create vertex array
create vertex buffer
create element buffer
create draw indirect buffer

bind vertex array
bind vertex buffer & allocate some base storage
bind element buffer & allocate some base storage
bind draw indirect buffer & allocate some base storage 

for every mesh in meshes
    load vertices into back of GL_ARRAY_BUFFER
    load elements into back of GL_ELEMENT_ARRAY_BUFFER
    create Draw...Command and put it at the back of GL_DRAW_INDIRECT_BUFFER

then in my drawing loop:

bind vertex array

glMultiDrawElementsIndirect(
    GL_TRIANGLES,
    GL_UNSIGNED_INT,
    nullptr,
    num of commands loaded,
    0
)

And this completely freezes my computer D: I really don't think I understand the correct use of glMultiDrawElementsIndirect, what is the correct way? and how can I do something like I am doing now? I want to load all of my meshes into one block.

RamblingMad
  • 5,332
  • 2
  • 24
  • 48
  • Judging from the pseudo-code you provided, your use of `glMultiDrawElementsIndirect()` seems correct, so the problem might lie in your _real_ code (or data). Also, what GL implementation are you using? Mesa, for example, added support for that extension just quite recently, IIRC. – derhass May 05 '14 at 20:00
  • @derhass I have checked my data so much since posting this question and found out one of the members of `DrawElementsIndirectCommand` was set wrong and I was trying to draw a million or so instances per frame :L so the issue is resolved. It's awesome to hear that mesa has support for this extension :D – RamblingMad May 05 '14 at 22:23

0 Answers0