0
votes

I've had some very strange behavior after I've changed my graphics card from to AMD. I had two separate vertex attribute layouts used among my shader programs. For one I had:

layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec3 inNormal;
layout (location = 2) in vec2 inTexCoords;

And I set the attrib pointer as:

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)nullptr);
glEnableVertexAttribArray(0);

glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);

glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
glEnableVertexAttribArray(2);

Then I had another vertex attribute layout that looks like this in the shader:

layout (location = 0) in vec4 inPosAndCoords;
layout (location = 1) in int inColour;

And I set the attribute pointer as:

glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)nullptr);
glEnableVertexAttribArray(0);

glVertexAttribIPointer(1, 1, GL_INT, 5 * sizeof(float), (void*) (4 * sizeof(float)));
glEnableVertexAttribArray(1);

So the issue is that on my nVidia GTX 980 and Intel integrated graphics I would switch from the 3-attribute layout to the 2-attribute one just as above, and things would work fine. However since I installed a Radeon RX570 I get an exception thrown at atio6axx.dll, access violation reading location...

There are a couple of way I can fix this. I can either do:

glDisableVertexAttribArray(2);

Or set the VertexAttribPointer for index 2 (the third attribute) with values that don't seem to matter anyway, such as:

glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));

Since when switching from the 3-attribute layout to the 2-attribute layout seemed to work with nVidia and Intel, and not with this Radeon card, I'm thinking that this behavior is a quirk of this card.

I am using the same VAO, and I am binding a different VBO, then I set the glVertexAttribPointer and glEnableVertexAttribArray.

A similar question was asked on here, "Is it important to call glDisableVertexAttribArray()?" , but in my case it works if I don't disable the third attribute (index 2), as long as I call glVertexAttribPointer for index 2. I'm confused about what the correct process is.

1
If these objects are using such distinct vertex formats, then they should be using distinct VAOs.Nicol Bolas

1 Answers

0
votes

Since when switching from the 3-attribute layout to the 2-attribute layout seemed to work with nVidia and Intel, and not with this Radeon card, I'm thinking that this behavior is a quirk of this card.

That conclusion is not backed up by the OpenGL spec. If you access the i-th vertex index, the GL might access the i-th element of every enabled vertex array. And if that isn't pointing to valid locations, you'll get undefined behavior. That it happends to work on Nvidia and Intel doesn't change any of that. Just disable the vertex attribute arrays for attributes you don't provide valid data.