[Mesa-dev] SandyBridge not handling GL_TRIANGLE_STRIP_ADJACENCY with repeating vertex indices correctly

Iago Toral Quiroga itoral at igalia.com
Tue Jul 29 01:12:23 PDT 2014


Hi,

running the piglit tests on my implementation of geometry shaders for
Sandy Bridge produces a GPU hang for the following test:

./glsl-1.50-geometry-primitive-id-restart GL_TRIANGLE_STRIP_ADJACENCY
ffs

That test checks primitive restarts but the hang seems to be unrelated
to that, since it happens also when primitive restart is not enabled.
The problem, which only affects GL_TRIANGLE_STRIP_ADJACENCY and no other
primitive type -with our without adjacency-, is in this loop that the
test uses to setup the indices for the vertices:

elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_WRITE);
num_elements = 0;
for (i = 1; i <= LONGEST_INPUT_SEQUENCE; i++) {
   for (j = 0; j < i; j++) {
      /* Every element that isn't the primitive
       * restart index can just be element 0, since
       * we don't care about the actual vertex data.
       */
      elements[num_elements++] = 0;
   }
   elements[num_elements++] = prim_restart_index;
}
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);

Setting all elements to the same index (0 in this case) is the one thing
that causes the hang for GL_TRIANGLE_STRIP_ADJACENCY. A simple change
like this removes the hang:
-      elements[num_elements++] = 0;
+      elements[num_elements++] = j != prim_restart_index ? j : j + 1;

Skimming through the docs I have not seen any references to this being a
known problem. In fact, I don't see any references to
GL_TRIANGLE_STRIP_ADJACENCY being special in any way and it seems that
this is not a problem in IvyBridge, since the test runs correctly there.

Does this sound like a hardware bug specific to SandyBridge's handling
of GL_TRIANGLE_STRIP_ADJACENCY or is there something else I should check
before arriving to that conclusion?

If it is a hardware bug I guess we want a workaround for it , at least
to prevent the hang or something but I am not sure what would be the
best option here, I think the only option for the driver would be to
explore the list of indices provided when this primitive type is used
and when we hit this scenario (I'd have to test how many repeating
indices we need for it to hang), error out and do not execute the
drawing command or something... any other suggestions? 

Iago



More information about the mesa-dev mailing list