Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Adept I

glMultiDrawElementsIndirect() system hangs

With the latest beta driver 15.4 on a Radeon 5870 powered laptop I have experienced system hangs consistently when drawing a zero count number of elements.  I have had quite a few system hangs and strange behaviour around related functionality since a few driver versions ago in fact which has made it difficult to track down the different cases - with the zero count elements being the only one I have managed to pin down.  In a few cases I have found I have made mistakes but in others I am not convinced I was in error and of course a full system hang is a pretty awful result regardless in gl debug mode.

Testing the same applications on an IntelHD 4000 seems to have no issues though.  I'm not convinced I haven't done something wrong still though, but I wondered before I dig even deeper, if there were any current known issues around glMultiDrawElementsIndirect() functionality with the latest drivers on the Radeon 5870?


One particular problem I have been seeing now is that missing commands seem to randomly occur.  This goes away if I replace the glMultiDrawElementsIndirect()  with multiple glDrawElementsInstancedBaseVertexBaseInstance() calls....

The problem also seems to go away if I issue a glMultiDrawElementsIndirect() for single elements within the buffer rather than all at once?  There are no errors or warnings from the debug context.

3 Replies
Adept I

I found the cause - it seems it doesn't like a zero count of elements in the indirect draw structs for some reason?  If I remove said null elements its all fine.  But that's a bit worrying if I want to eventually generate those draws on the GPU instead of CPU...

Also if I use:

glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 0, 0);

It draws something not _nothing_ but doesn't hang my system any more.

So I think that's a driver bug?



Just to be clear, it sounds like you're seeing two problems here. First is that if you have a single draw in the indirect buffer with a count of zero indices, then the GPU hangs. The second is that if you call glMultiDrawElementsIndirect with a draw count of zero, then you see corruption or hangs. Is that correct?

The first sounds like a known issue that we resolved many months - actually well over a year ago, so it is surprising if it came back, We'll have to investigate.

The second also sounds like a separate bug.

Do you have an indirect parameter buffer bound, or are you trying to use client memory for this? It looks from your code snippet it looks like you're using a buffer, but I want to confirm that.





Yes it appears that I encountered two problems.  The main one is the indirect draw buffer with a count of zero (but not all elements were zero which I think is ok), and yes the second a glMultiDrawElementsIndirect() with a draw count of zero.  However I had to discover the second (and guard around it to stop the system hang) to discover the indirect draw buffer problem.  I am not sure if they were actually directly related in cause.

I had persistently mapped buffers for the indirect draw and the instance vertex stream (which consisted of 4 GL_INTs - one being used for the instanceID, and connected to vertex attribute 2).  The index and vertex buffers used were allocated with buffer storage and mapped per frame (The vertex format from here had a position and texture coordinates that were a compressed 8 bytes in size, 16 bit indices).

I posted some additional info in the related question top here:

Since then I have moved a few things around as I am transitioning things to more modern OpenGL but I believe the problem is still happening - as all I have changed currently is using a persistent staging buffer to upload index/vertex data which is then copied to GPU only accessible buffers used for rendering (draw indirect and instance data still coming from a persistently mapped CPU accessible buffers).

Also it would be good to know while I am here if it is recommended against to use the same persistent staging buffer for both index and vertex data at the same time?  - I am writing a mix of index and vertex data in the stream together currently that then get copied out to their respective GPU side index/vertex buffers.

Thanks for your response!