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 10 of 10

Thread: glDrawElements access violation on AMD card, weird behavior

Hybrid View

  1. #1
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251

    Exclamation glDrawElements access violation on AMD card, weird behavior

    hey, yesterday i've finally got my AMD card for test(HD6670) and what a piece of crap it is... i'm talking mostly about drivers. i can't debug. almost everything doesn't work, but no OpenGL errors. best hint i can get - gDebugger catches access violation errors occasionally.

    configuration: win 7 x64, catalyst 13.1, Gigabyte HD 6670, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB.
    my application works flawlessly on my main nVidia card, gDebugger doesn't catch any errors. all deprecated stuff replaced.

    example of code, that doesn't work on AMD:

    //init quad
    Code :
       GLfloat quadVertices[] = {
       -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,         //bottom left corner
       -1.0f,  1.0f, 0.0f, 0.0f, 1.0f,         //top left corner
        1.0f,  1.0f, 0.0f, 1.0f, 1.0f,         //top right corner
        1.0f, -1.0f, 0.0f, 1.0f, 0.0f};      //bottom right corner
     
       GLubyte quadIndices[] = {2,1,0, // first triangle (bottom left - top left - top right)
        3,2,0};                                  // second triangle (bottom left - top right - bottom right)
     
       glGenVertexArrays(1, &quadVertexArrayObjectId);
        glBindVertexArray(quadVertexArrayObjectId);
     
        glGenBuffers(1, &quadVertexBufferId);
        glBindBuffer(GL_ARRAY_BUFFER, quadVertexBufferId); //Bind the vertex buffer
        glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 20, &quadVertices[0], GL_STATIC_DRAW);
     
        glGenBuffers(1, &quadIndexBufferId);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadIndexBufferId); //Bind the vertex buffer
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte) * 6, &quadIndices[0], GL_STATIC_DRAW);
     
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, BUFFER_OFFSET(0)); //vertex
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, BUFFER_OFFSET(12)); //tex coord
        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
     
        glBindVertexArray(0);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    //render sprite for occlusion query:
    Code :
            glBindVertexArray(quadVertexArrayObjectId);
            SShader[3].applyProgram(8);
     
            glBeginQueryARB(GL_SAMPLES_PASSED_ARB, occQueryObject);
            modelViewMatrix = currentViewMatrix * modelMatrix;
            billBoard();
            modelViewMatrix = glm::scale(modelViewMatrix, glm::vec3(occluderScale * 3.0f, occluderScale* 3.0f, 1.0f));
     
            glUniformMatrix4fv(SShader[shaderId].shaderSet[programId].uniform_modelViewMatrix, 1, 0, glm::value_ptr(modelViewMatrix));
            glUniformMatrix4fv(SShader[shaderId].shaderSet[programId].uniform_projectionMatrix, 1, 0, glm::value_ptr(currentProjectionMatrix));
     
            glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0); //access violation with gDebugger
            glEndQueryARB(GL_SAMPLES_PASSED_ARB);

    there are several cases like that in my code. i've checked contents of Framebuffer, this code draws correctly without gDebugger. but conditional rendering doesn't work. neither for these sprites, neither for normal objects, which are not getting any errors on that stage and also draw correctly into occlusion query buffer and gbuffer.

    also, amd doesn't seem to like that:
    Code :
    glBindFramebuffer(GL_FRAMEBUFFER, lightBufferId);
        glBindFramebuffer(GL_READ_FRAMEBUFFER, gBufferId);
        glBlitFramebuffer(0, 0, gBufferWidth, gBufferHeight, 0, 0, screenw, screenh, GL_DEPTH_BUFFER_BIT, GL_NEAREST);

    althrough they don't explain why. just another access violation with gDebugger and nothing working in normal mode;
    maybe i'm doing something embarassing?
    Last edited by Nowhere-01; 02-13-2013 at 04:59 AM.

  2. #2
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    ok, my first auto-answer:

    i guess, you shouldn't use GL_UNSIGNED_BYTE for indices. it looks like a driver bug to me, but now it works.


    second:
    glBlitFrameBuffer works if i change:
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, buffersArray[f].defWidth, buffersArray[f].defHeight);

    to

    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, buffersArray[f].defWidth, buffersArray[f].defHeight);
    in my framebuffer class initialization code for attached depth. is that normal? seems like another buggy behavior to me;

    and spec https://www.khronos.org/opengles/sdk...ferStorage.xml here says:

    internalformatSpecifies the color-renderable, depth-renderable, or
    stencil-renderable format of the renderbuffer. Must be one of the
    following symbolic constants:
    GL_RGBA4,
    GL_RGB565,
    GL_RGB5_A1,
    GL_DEPTH_COMPONENT16, or
    GL_STENCIL_INDEX8.

    what?

    BTW, now it is access-violating my SwapBuffers(hdc); call. trying to find the reason. conditional render still not working, i don't even know what to post. i've already posted example of sprite rendering to occlusion query. and in main rendering passes i just do:

    glBeginConditionalRender(occQueryObject, GL_QUERY_NO_WAIT);
    //draw
    glEndConditionalRender();
    and occlusion query FBO is just a normal FBO with depth attached and glColorMask(0, 0, 0, 0), and rendering to it works fine.
    Last edited by Nowhere-01; 02-13-2013 at 02:54 AM.

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    455
    Have you re-bound the VAO before drawing? Otherwise the glDrawElements call will be trying to pull indices from client memory, rather than from the quadindexBufferId buffer object.

  4. #4
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    i already fixed glDrawElements issues(presumably). yes i do include call to glBindVertexArray(quadVertexArrayObjectId); but i shouldn't use bytes for indices.

    fixed the 1st post.

    but 2 problems remain: conditional rendering not working; SwapBuffer call fails(detected only with gDebugger, GetLastError() says "0").

  5. #5

  6. #6
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    yeah, i've just noticed i've looked at the wrong spec. but google gives it 1st position if you search for glRenderbufferStorage and title just says "glRenderbufferStorage - Khronos Group", no signs of OpenGL ES, except for a link.

    could SwapBuffer access violation just a gDebugger malfunctioning? it doesn't show any problems if i test application normally.
    and as for conditional rendering - i've created topic in a drivers section.

Posting Permissions

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