Results 1 to 6 of 6

Thread: glNamedBufferData fires GL_INVALID_OPERATION

  1. #1
    Member Contributor
    Join Date
    Dec 2011
    Posts
    85

    glNamedBufferData fires GL_INVALID_OPERATION

    I get an exception at the very begin of my sample, when I try to allocate geometry for the gound, here and here:

    at this point

    Code :
       gl4.glNamedBufferData(vertexBuffer[0], Vertex.size() * vertices.size(), floatBuffer, GL4.GL_STATIC_DRAW);

    Exception:

    Code :
    Caused by: com.jogamp.opengl.GLException: GL-Error 0x502 while creating mutable storage for buffer 1 of size 512 with data java.nio.DirectFloatBufferU[pos=0 lim=128 cap=128]

    I have the object Vertex that takes 128 floats, I have 4 vertices, this means 512 Byte

    Everything seems right

    Anyway, error 0x502 is GL_INVALID_OPERATION and glNamedBufferData fires that only if:

    - GL_INVALID_OPERATION is generated by glNamedBufferData if buffer is not the name of an existing buffer object.

    - GL_INVALID_OPERATION is generated if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer object is GL_TRUE.

    Since buffer exist (!= 0, 1), it must be the second one

    But I cant query any GL_BUFFER_IMMUTABLE_STORAGE flag, since glGetBufferParameter requires a target which I didnt provide because of glNamedBufferData,
    and looking here, if mutableUsage was false, I would have catched the internal error, which I didnt, so..

    Any idea?

    Ps:
    Code :
    gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, vertexBuffer[0]);
    gl4.glBufferData(GL4.GL_ARRAY_BUFFER, Vertex.size() * vertices.size(), floatBuffer, GL4.GL_STATIC_DRAW);
    gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

    it works like a charm and I am sure I have 4.5 and DSA

    gl4.glGetString(GL4.GL_VERSION) 4.5.0 NVIDIA 347.88
    gl4.isExtensionAvailable("GL_ARB_direct_state_acce ss" true

  2. #2
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    Are you creating the buffer using glGenBuffers or glCreateBuffers? Note that in the former case (i.e with glGenBuffers) the buffer object does not exist; all that glGenBuffers gives you is a name, but it doesn't create an object.

  3. #3
    Member Contributor
    Join Date
    Dec 2011
    Posts
    85
    Quote Originally Posted by mhagain View Post
    Are you creating the buffer using glGenBuffers or glCreateBuffers? Note that in the former case (i.e with glGenBuffers) the buffer object does not exist; all that glGenBuffers gives you is a name, but it doesn't create an object.
    glGenBuffers

    Ok, but then why it works on C? Directly from the Nvidia github https://github.com/NVIDIAGameWorks/O...esh.cpp#L55-77

    Is the driver directly fixing it on the fly?

    Anyway, it seems if you bind the buffer before it doesnt complain

    Code :
    gl4.glNamedBufferData(vertexBuffer[0], Vertex.size() * vertices.size(),
                GLBuffers.newDirectFloatBuffer(verticesFA), GL4.GL_STATIC_DRAW);
     
        // *** INTERESTING ***
        // get the GPU pointer for the vertex buffer and make the vertex buffer
        // resident on the GPU
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, vertexBuffer[0]);
        gl4.glGetBufferParameterui64vNV(GL4.GL_ARRAY_BUFFER, GL4.GL_BUFFER_GPU_ADDRESS_NV,
                vertexBufferGPUPtr, 0);
        gl4.glGetBufferParameteriv(GL4.GL_ARRAY_BUFFER, GL4.GL_BUFFER_SIZE,
                vertexBufferSize, 0);
        gl4.glMakeBufferResidentNV(GL4.GL_ARRAY_BUFFER, GL4.GL_READ_ONLY);
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

    To:

    Code :
    // *** INTERESTING ***
        // get the GPU pointer for the vertex buffer and make the vertex buffer
        // resident on the GPU
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, vertexBuffer[0]);
        gl4.glNamedBufferData(vertexBuffer[0], Vertex.size() * vertices.size(),
                GLBuffers.newDirectFloatBuffer(verticesArray), GL4.GL_STATIC_DRAW);
        gl4.glGetBufferParameterui64vNV(GL4.GL_ARRAY_BUFFER, GL4.GL_BUFFER_GPU_ADDRESS_NV,
                vertexBufferGPUPtr, 0);
        gl4.glGetBufferParameteriv(GL4.GL_ARRAY_BUFFER, GL4.GL_BUFFER_SIZE,
                vertexBufferSize, 0);
        gl4.glMakeBufferResidentNV(GL4.GL_ARRAY_BUFFER, GL4.GL_READ_ONLY);
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

  4. #4
    Member Contributor
    Join Date
    Dec 2011
    Posts
    85
    Quote Originally Posted by mhagain View Post
    Are you creating the buffer using glGenBuffers or glCreateBuffers? Note that in the former case (i.e with glGenBuffers) the buffer object does not exist; all that glGenBuffers gives you is a name, but it doesn't create an object.
    If I switch Gen to Create it works outside the bindings... this anyway doesnt explain why it works with the Nvidia C code

  5. #5
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    Code :
    // Stick the data for the vertices and indices in their respective buffers
    glNamedBufferDataEXT(m_vertexBuffer, sizeof(vertices[0]) * vertices.size(), &vertices[0], GL_STATIC_DRAW);
    glNamedBufferDataEXT(m_indexBuffer, sizeof(indices[0]) * indices.size(), &indices[0], GL_STATIC_DRAW);
    The NVIDIA code isn't using GL 4.5 DSA but rather the old GL_EXT_direct_state_access extension. These are not the same thing. When DSA was brought into core GL it wasn't just a renamed version of the old extension, and the old extension didn't have this requirement.

  6. #6
    Member Contributor
    Join Date
    Dec 2011
    Posts
    85
    Quote Originally Posted by mhagain View Post
    Code :
    // Stick the data for the vertices and indices in their respective buffers
    glNamedBufferDataEXT(m_vertexBuffer, sizeof(vertices[0]) * vertices.size(), &vertices[0], GL_STATIC_DRAW);
    glNamedBufferDataEXT(m_indexBuffer, sizeof(indices[0]) * indices.size(), &indices[0], GL_STATIC_DRAW);
    The NVIDIA code isn't using GL 4.5 DSA but rather the old GL_EXT_direct_state_access extension. These are not the same thing. When DSA was brought into core GL it wasn't just a renamed version of the old extension, and the old extension didn't have this requirement.
    Ah, thanks for the clarification, then I will always use glCreateBuffer together with glNamedBufferData

Similar Threads

  1. glutPassiveMotionFunc continuously fires
    By deadeye in forum OpenGL: General
    Replies: 0
    Last Post: 03-03-2011, 01:50 PM
  2. GL_INVALID_OPERATION in glVertexAttribPointer
    By imported_pjcozzi in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-22-2010, 05:42 PM
  3. GL_INVALID_OPERATION on glGetTexImage
    By Cedrick_ in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-16-2010, 05:11 AM
  4. GL_INVALID_OPERATION
    By MickeyMouse in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-21-2003, 01:02 AM
  5. Will this cause an GL_INVALID_OPERATION??
    By Roach in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-20-2002, 07:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean