PDA

View Full Version : Is this a driver bug?



Chris_F
12-05-2013, 10:37 PM
When I try this code, it doesn't work. For some reason only mip level 0 is present and all other mip levels are black.


GLuint texture = 0;
glGenTextures(1, &texture);
glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateTextureMipmapEXT(texture, GL_TEXTURE_2D);

If I try this code however, all mip levels are present and accounted for.


GLuint texture = 0;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexStorage2D(GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateMipmap(GL_TEXTURE_2D);

and strangely enough this works as well.


GLuint texture = 0;
glGenTextures(1, &texture);
glTextureImage2DEXT(texture, GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateTextureMipmapEXT(texture, GL_TEXTURE_2D);

This is using OpenGL 4.3 core profile on a AMD HD 5850 using the latest drivers.

tksuoran
12-06-2013, 02:28 AM
The first code block is missing BindTexture.

I see you are using TextureStorage instead of TexStorage. TextureStorage is DSA version, using the non DSA version might have wider support (including OpenGL ES 3).

Chris_F
12-06-2013, 02:50 AM
The first code block is missing BindTexture.

It's not missing. Example 1 and 3 both use DSA. Therefore no binding.


I see you are using TextureStorage instead of TexStorage. TextureStorage is DSA version, using the non DSA version might have wider support (including OpenGL ES 3).

Compatibility with OpenGL ES is not one of my concerns.

The question still stands.

tksuoran
12-06-2013, 03:24 AM
Your code looks valid to me, after having look at the DSA text. So it may indeed be a driver bug.

Can you see if non-DSA version of TexStorage works?

Chris_F
12-06-2013, 01:45 PM
Can you see if non-DSA version of TexStorage works?

Ordinary TexStorage (second example) works fine. It's only when I try to use the DSA version of TextureStorage that GenerateMipmaps fails.

Chris_F
12-06-2013, 02:52 PM
Oddly enough this works too.



GLuint texture = 0;
glGenTextures(1, &texture);
glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glBindTexture(GL_TEXTURE_2D, texture);
glGenerateMipmap(GL_TEXTURE_2D);


as does this



GLuint texture = 0;
glGenTextures(1, &texture);
glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glBindTexture(GL_TEXTURE_2D, texture); //for some reason
glGenerateTextureMipmapEXT(texture, GL_TEXTURE_2D);

Chris_F
12-06-2013, 09:13 PM
Here is some source code to reproduce the bug.

https://gist.github.com/anonymous/7837036