Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

Adept II
Adept II

glMultiDrawArrays(GL_TRIANGLE_STRIP) is broken

I have encountered a particularly strange bug on AMD using both crimson 17.7.2 and 17.9.1 (AMD R9 270). A consecutive range of first-count pairs is provided where every end of one range is the start of the next, but the primitive type (GL_TRIANGLE_STRIP) does not allow the draw to be collapsed. Using glMultiDrawArrays gives artifacts but emulating the call using glDrawArrays in a loop using the data in the first-count arrays works fine.

The snippet is as follows:

if (branch cond)


     std::vector<GLint> firsts;

     std::vector<GLsizei> counts;


     ..[fill first-count pairs]

     glMultiDrawArrays(GL_TRIANGLE_STRIP,,, draw_count);


replacing the glMultiDrawArrays call with:

for (int i = 0; i < draw_count; ++i)

     glDrawArrays(GL_TRIANGLE_STRIP, firsts, counts);

gives correct results.

The man page for glMultiDrawArrays does not mandate that first/count data is kept 'alive' after use so I assume the driver stores the information locally. I've tried moving the storage outside to global storage and the error is still visible. It is worth noting similar setup elsewhere works consistently with GL_POINTS. The same setup also works fine on radeonsi and the other hw vendors.

It is also worth noting that gl_VertexID is used to generate vertex shader output. I have attached expected vs actual output on AMD drivers below, while emulating the game resident evil 4 (rpcs3)

EDIT: I retried with a 128 megabyte ring buffer just to ensure I was not overwriting anything the driver might be using and the result is the same. Output is also very stable with no flickering making a race condition in the program less likely.

Tags (2)
0 Kudos
1 Reply
Adept II
Adept II

Re: glMultiDrawArrays(GL_TRIANGLE_STRIP) is broken

After speaking to others with the same issue - it seems gl_VertexID is broken with multidraw. It does not increment with the first argument of a set as the base index. Manually passing vertex ID or using multiDrawElements with an identity index buffer seems to work okay.

0 Kudos