Using TexStorage correctly or is this a bug?

I’m trying to compress a texture to BPTC using this code but I am getting a corrupted image.

glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);

On the other had, if I use this it works.

glTextureImage2DEXT(texture, GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);

Also, if I do this:

glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_SRGB8_ALPHA8, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);

My texture appears overexposed, but if I do this:

glTextureImage2DEXT(texture, GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);

It appears correctly.

For the record, glGetError and KHR_debug report no errors and nothing changes if I used the non-direct_state_access versions of these functions. Can somebody please tell me if I am using these functions incorrectly or if this is a driver bug.

Have you tried with the non-DSA version of TexStorage? Since the DSA version is not in the GL core, it is likely less tested.

It’s not a DSA related issue. It effects glTexStorage2D just as much as glTextureStorage2DEXT.

I decided to use glGetTexLevelParameteriv to actually check the internal format of the texture after creation. When I create the texture with glTexImage2D and GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, glGetTexLevelParameteriv comes back with a format of GL_SRGB_ALPHA. If I create the texture with glTexStorage2D and GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, glGetTexLevelParameteriv comes back with a format of GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, but of course if I use glTexSubImage2D on it, it ends up corrupted (colorful noise). I tried GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT. glTexImage2D seems to work fine. It says the texture is actually S3TC. glTexStorage2D is also able to handle it, without corrupting the image, but as with GL_SRGB8_ALPHA8 the image comes out looking overexposed, as if it is being treated as linear data.