Is this a driver bug? (Buffer Textures)

Started by
7 comments, last by Mona2000 10 years, 1 month ago

I am messing around with programmable vertex pulling, using buffer textures to store indices and vertex attributes. The problem is that when I try to bind my index containing buffer texture to GL_TEXTURE0, it doesn't work. If I bind it to any other texture unit, it works. Please excuse the mess. http://pastebin.com/tKQSDPN2

Line 254:


glBindMultiTextureEXT(GL_TEXTURE0, GL_TEXTURE_BUFFER, TextureName[TEXTURE_INDEX]);

Change to (for example):


glBindMultiTextureEXT(GL_TEXTURE10, GL_TEXTURE_BUFFER, TextureName[TEXTURE_INDEX]);

Line 287:


glProgramUniform1i(shader_program, 0, 0);

Change to:


glProgramUniform1i(shader_program, 0, 10);

With that change, it suddenly works for me.

Advertisement

I'm going to guess that calling glBindTexture(GL_TEXTURE_BUFFER, 0) each time after pointing each texture to its corresponding buffer is overwriting the state of GL_TEXTURE0, because that is the default glActiveTexture

I'm going to guess that calling glBindTexture(GL_TEXTURE_BUFFER, 0) each time after pointing each texture to its corresponding buffer is overwriting the state of GL_TEXTURE0, because that is the default glActiveTexture

Removing them has made no difference.

When you say removing them made no difference, do you mean you went from not working to not working? If so, that doesn't really rule out anything since you could have broken even more stuff or fixed part of the problem but not all of it.

I'd think setting a different active texture is a better way to test what radioteeth was talking about.

When you say removing them made no difference, do you mean you went from not working to not working? If so, that doesn't really rule out anything since you could have broken even more stuff or fixed part of the problem but not all of it.

I'd think setting a different active texture is a better way to test what radioteeth was talking about.

By made no difference I mean everything I said before is still valid.

Here is the old code with the glBindTexture calls removed: http://pastebin.com/6gF0Q5si

Everything I said before is still valid. It doesn't work, but if you change GL_TEXTURE0 to something else, it does.

However, here is an updated version which replaces some of the non-DSA code with what I believe to be the DSA equivalent: http://pastebin.com/75EvACPe

For some reason this version works with GL_TEXTURE0.

So again, I have no idea if I made some sort of mistake or if I have uncovered some driver bug.

Using glBindTexture affects whatever texture unit is active (default being GL_TEXTURE0)

Calling glBindMultiTextureEXT(GL_TEXTURE0, etc..) and then calling glBindTexture after will be like calling glBindMultiTexture(GL_TEXTURE0, ...) with whatever parameters you are passing glBindTexture.

You are effectively overwriting calls to glBindMultiTextureEXT that pass GL_TEXTURE0 when you follow them with glBindTexture calls without changing the active texture unit.

Either use glActiveTexture before your glBindTexture calls, to specify what texture unit they should be operating on, or do away with them altogether.

Using glBindTexture affects whatever texture unit is active (default being GL_TEXTURE0)

Calling glBindMultiTextureEXT(GL_TEXTURE0, etc..) and then calling glBindTexture after will be like calling glBindMultiTexture(GL_TEXTURE0, ...) with whatever parameters you are passing glBindTexture.

You are effectively overwriting calls to glBindMultiTextureEXT that pass GL_TEXTURE0 when you follow them with glBindTexture calls without changing the active texture unit.

Either use glActiveTexture before your glBindTexture calls, to specify what texture unit they should be operating on, or do away with them altogether.

Ah, of course. This is why I prefer DSA.


Line 287:

glProgramUniform1i(shader_program, 0, 0);

Change to:

glProgramUniform1i(shader_program, 0, 10);

With that change, it suddenly works for me.

A common misstake with loading uniforms is, that you do not determine the proper location of the variables. You hardcode them here (0 and 10), but the locations depends on a lot of factors and you should really use glGetUniformLocation to determine the correct location.

A common misstake with loading uniforms is, that you do not determine the proper location of the variables. You hardcode them here (0 and 10), but the locations depends on a lot of factors and you should really use glGetUniformLocation to determine the correct location.

Nope. This is his shader:


layout(location = 0) uniform isamplerBuffer indexBuffer;

Location is always gonna be 0.

This topic is closed to new replies.

Advertisement