0 Replies Latest reply on Jun 27, 2013 7:35 PM by dutta

    OpenGL Compute shaders stops rendering

    dutta

      This seems a bit odd, but when I upgraded to the 13.4 driver to be able to utilize compute shaders, I noticed a weird thing. The following code will perform the computation as it should, however the rendering that comes after doesn't.

      
      
      
      
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      ...
      // enable compute shader program and set variables
      ...
      glDispatchCompute(1, 1, 1);
      glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
      
      ...
      // enable vertex-tessellation-geometry shader and set variables
      // bind buffers
      ...
      
      glDrawElements(GL_PATCHES, 36, GL_UNSIGNED_INT, (GLvoid*)0);
      
      SwapBuffers(this->hdc);
      
      
      
      
      
      
      

       

      If I decide to put the glClear after I run glDispatchCompute, the rending and computation works fine. Also, If I completely remove the glDispatchCompute, the rendering also works fine, which must mean that no state switch, texture bind or the like is what's causing the problem. I know that the computation is running even though the rendering isn't, since the compute shader updates a texture which the rendering uses, so I can see that the texture is being updated (which is just what the compute shader is doing).

       

      I'm using an HD5970, on Windows 7 with Catalyst version 13.4.

       

      Thanks in advance.

       

      Edit: Just got myself a new rig with a brand new HD7970 and the bug is there for this model aswell. There is a slight difference however, since if I call glFinish() after my glDispatchCompute(), everything works just fine. The glMemoryBarrier() however doesn't seem to do its thing properly. I think this might be the same thing which caused yours3lf's graphics card driver to crash. So just for clarification:

       

      This works:

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glDispatchCompute(512/16,512/16, 1);
      glFinish(); // glFlush() has the same effect
      
      glBindBuffer(GL_ARRAY_BUFFER, this->cubeVBuffer);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->cubeIBuffer);
      glDrawElements(GL_PATCHES, 36, GL_UNSIGNED_INT, (GLvoid*)0);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      

      And this works too:

      glDispatchCompute(512/16,512/16, 1);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      
      glBindBuffer(GL_ARRAY_BUFFER, this->cubeVBuffer);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->cubeIBuffer);
      glDrawElements(GL_PATCHES, 36, GL_UNSIGNED_INT, (GLvoid*)0);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      

      But this doesn't:

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glDispatchCompute(512/16,512/16, 1);
      glMemoryBarrier(GL_ALL_BARRIER_BITS);
      
      glBindBuffer(GL_ARRAY_BUFFER, this->cubeVBuffer);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->cubeIBuffer);
      glDrawElements(GL_PATCHES, 36, GL_UNSIGNED_INT, (GLvoid*)0);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      


      So it looks like I've either misunderstood the meaning of glMemoryBarrier(), or glMemoryBarrier() doesn't behave as expected.