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

Thread: Rendering contents of Shader Storage Buffer Object and Invalid Operation Error

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    IL
    Posts
    4

    Unhappy Rendering contents of Shader Storage Buffer Object and Invalid Operation Error

    I'm trying to use the new OpenGL 4.3 compute shader.

    I working with a GL_SHADER_STORAGE_BUFFER which is passed to the compute shader and then I am trying to render the computed results.
    However I am getting hung up on drawing the contents of the Shader Storage Buffer as ARRAY_BUFFER

    In a nutshell here is the buffer

    glGenBuffers(1, &posSSbo);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER, posSSbo);
    glBufferData(GL_SHADER_STORAGE_BUFFER, particles * sizeof(struct pos), NULL, GL_STATIC_DRAW);


    // init vertex position buffer
    GLint bufMask = GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT;


    struct pos *points = (struct pos *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, particles * sizeof(struct pos), bufMask);
    for (auto i=0;i<particles;i++) {
    points[i].x = (0.5f-float(std::rand())/RAND_MAX) * 5.0f + 0.0f;
    points[i].y = (0.5f-float(std::rand())/RAND_MAX) * 5.0f + 20.0f;
    points[i].z = (0.5f-float(std::rand())/RAND_MAX) * 5.0f + 0.0f;
    points[i].w = 1.0f;
    }
    glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);

    .. call compute shader...

    .. try to draw ...
    glMemoryBarrier(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT );
    glBindBuffer( GL_ARRAY_BUFFER, posSSbo );
    glVertexAttribPointer(0,4,GL_FLOAT,GL_FALSE,4*size of(GLfloat),(void *)0 )
    ;
    <-- Get Invalid Operation Here

    I have looked at both Mike Bailey's Sigragph 2012 notes: https://docs.google.com/viewer?url=h...Shader_2pp.pdf
    and the spec for Shader Storage Buffer object http://www.opengl.org/registry/specs...fer_object.txt and they have similar code. In fact the above code is copied from Mike Bailey's notes.

    I have seen comments that you need to have a bound ARRAY_BUFFER (which makes sense) to prevent an Invalid Operation but I am clueless as to why I am getting this error.

    Any ideas or comments would be really appreciated.

    Craig
    Last edited by ceebee; 09-11-2012 at 07:19 PM.

Posting Permissions

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