Stefan Majewsky
Stefan Majewsky

Reputation: 5555

Why does glEnableVertexAttribArray crash on some systems depending on call order?

Yesterday, I investigated a weird crash in the setup of my Vertex Buffer Object. I just switched from plain colors to textures, so my Vertex Buffer Object now contains an array of

struct VertexData { glm::vec4 pos; glm::vec2 texCoord; }

instead of

struct VertexData { glm::vec4 pos, color; }

On my system (Intel chip), everything went smoothly, but another system with a Radeon card using the proprietary Linux driver (fglrx) crashed in the VBO setup. We eventually tracked it down to the glEnableVertexAttribArray call, and found that

glEnableVertexAttribArray(1); //attribute location for texcoord
glEnableVertexAttribArray(0); //attribute location for position

works while

glEnableVertexAttribArray(0); //attribute location for position
glEnableVertexAttribArray(1); //attribute location for texcoord

crashes in the first call. (Note that the attribute locations are swapped in the second snippet.) How come? The only explanation I was able to come up with was a driver error, but that seems unlikely to me because all other OpenGL apps work. Or is there anything which I forgot to do?

For reference, I'm attaching the relevant part of my apitrace. At this point, I have set up my context, enabled GL_DEPTH_TEST, GL_CULL_FACE and GL_TEXTURE_2D, uploaded some textures, and prepared my shader program (without calling glBindAttribLocation explicitly).

glGetAttribLocation(3, in_Position) = 0
glGetAttribLocation(3, in_TexCoord) = 1

glGenVertexArrays(1, [1])
glBindVertexArray(1)

glGenBuffers(1, [1])
glBindBuffer(GL_ARRAY_BUFFER, 1)
glVertexAttribPointer(0, 4, GL_FLOAT, false, 0x18, NULL)
glVertexAttribPointer(1, 2, GL_FLOAT, false, 0x18, 0x10)
glEnableVertexAttribArray(0) <-- this crashes with AMD/ATI fglrx driver
glEnableVertexAttribArray(1)

(glBufferData is called later during the first frame.)

Upvotes: 0

Views: 1278

Answers (1)

datenwolf
datenwolf

Reputation: 162164

This is not supposed to crash. You most likely discovered a driver bug. Please report it to AMD so that they can fix it.

Upvotes: 1

Related Questions