Is this a driver bug?

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.

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).

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

Compatibility with OpenGL ES is not one of my concerns.

The question still stands.

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?

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

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);

Here is some source code to reproduce the bug.