Can glVertexAttribDivisor works with glVertexAttribFormat and glVertexAttribBinding?

I am using glVertexAttribDivisor to specify the instancing data storage. All the instance specific data is stored in 2nd vertex buffer at vertex buffer binding index 1 (vertex buffer at binding index 0 stores data used for all instances) used as instance specific data.

This is how I specify vertex format.

    glCreateVertexArrays(1, &mVertexArray);

    for (auto& vertexAttrib : vertexFormat->mVertexAttributeList)
        glVertexAttribFormat(vertexAttrib.mLocation, vertexAttrib.mChannel,
                             vertexAttrib.mNormalized, vertexAttrib.mOffset);
        glVertexAttribBinding(vertexAttrib.mLocation, vertexAttrib.mBindingIndex);

        if (vertexAttrib.mDivision != 0)
            glVertexAttribDivisor(vertexAttrib.mLocation, vertexAttrib.mDivision);



This is how I enable vertex buffer for 2 vertex buffer.

    glBindVertexBuffer(bindingIndex, mBuffer, offset, stride);

The problem is that when I used glVertexAttribDivisor, the glDrawArraysInstanced crashs as memory read violation. Can anyone provide a hint for potential problem for this situation? Thank you.

I checked the specification:

The command

void VertexAttribDivisor( uint index, uint divisor );

is equivalent to (assuming no errors are generated):

VertexAttribBinding(index, index);
VertexBindingDivisor(index, divisor);

I just misread the parameter in VertexAttribDivisor. The first paramter is for vertex buffer binding index, rather than the attribute index.

glVertexBindingDivisor is provided for use with the attrib binding calls.


glVertexBindingDivisor is provided for use with the attrib binding calls.[/QUOTE]

Yeah, Thank you. I just misread the information.