Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: glVertexAttrib* ignored on AMD

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    4

    glVertexAttrib* ignored on AMD

    In programs I write using strictly forward compatible, core profiles (and typically 4.2), I have noticed that per-vertex attributes specified using glVertexAttrib* seem to be ignored on devices with an AMD card, while they work exactly as expected on NVIDIA devices. On both, I disable the corresponding per-vertex attribute array and then specify the fixed attribute I want with glVertexAttrib*. But on AMD, it seems to just use the last attribute specified with a real per-vertex attribute array and ignores the one set with glvertexAttrib. Is this a known problem? Is there a workaround or planned fix?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Are you talking about the glVertexAttrib{1,2,3,4}* family of functions or the glVertexAttribPointer* family of functions?

    Edit: Duh, should have read it better.

    So you basically do something like

    Code :
    // assuming a vec4 attrib here
    glDisableVertexAttribArray(index);
    glVertexAttrib4f(index, x, y, z, 1.0);

    and you expect the shader variable associated with index to assume the fixed value. Is that correct?
    Last edited by thokra; 12-07-2012 at 09:52 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    4
    Yes, that is correct. I re-read the OpenGL spec, and it suggests that that is exactly how should work. And it does on NVIDIA.

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    450
    This behaviour is only guaranteed on recent OpenGL versions. Prior to OpenGL 4.1 implementors were free to leave the current value of an attribute corresponding to an enabled attribute array at any value after a draw call, so after this code:
    Code :
    glVertexAttrib4f(index, ...);
    glEnableVertexAttribArray(index, ...);
    glVertexAttribPointer(index, ...);
    glDrawElements(...);

    the vertex attrib could be any value, so you would need to reset it:
    Code :
    glDisableVertexAttribArray(index);
    glVertexAttrib4f(index, ...);
    glDrawElements(...);

    From OpenGL 4.1 onwards the draw call can't affect it, so you can just use:

    Code :
    glVertexAttrib4f(index, ...);
    glEnableVertexAttribArray(index, ...);
    glVertexAttribPointer(index, ...);
    glDrawElements(...);
     
    // note: no glVertexAttrib4f required here
    glDisableVertexAttribArray(index);
    glDrawElements(...);

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    4
    Thank you both for your quick replies. Unfortunately I think I am doing it as you suggest. I am running using OpenGL 4.2. So for example if I have a large number of vertices for a triangle strip, all of which are in the same plane, I want to specify the plane normal once and render as:
    glDisableVertexAttribArray(normalVectorIndex);
    glVertexAttrib3f(normalVectorIndex, fixedNormalDx, fixedNormalDy, fixedNormalDz);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, numPoints);

    I get exactly the results I expect on NVIDIA platforms; on AMD platforms, the glVertexAttrib3f call seems to have no effect.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Well it may always be a driver bug. If you'r 100% sure you're doing it right, file a bug with AMD.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •