(Disclaimer: This is a crosspost from StackOverflow where my question has not been answered yet.)
Dear OpenGL community,
is it possible to use glClearTexImage to clear a packed depth/stencil texture in OpenGL? And if so, how?
I’m using a multisample texture with pixel format GL_FLOAT_32_UNSIGNED_INT_24_8_REV that has been initialized with
glTextureStorage2DMultisample(textureId, numSamples, GL_DEPTH32F_STENCIL8, width, height, false)
.
Attempting to clear the texture with
glClearTexImage(textureId, 0, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, nullptr);
yields the error
GL_INVALID_OPERATION error generated. <format> must be GL_DEPTH_STENCIL for depth-stencil textures.
The fact that depth/stencil textures are considered in this error message lets me believe it should be possible somehow.
If I change the format parameter to GL_DEPTH_STENCIL, I get the error
GL_INVALID_OPERATION error generated. Texture type and format combination is not valid.
Am I mixing up the parameters? Or did I miss that clearing of packed textures was not within specs? Using a simple GL_DEPTH_COMPONENT32F instead of the packed format works flawlessly. I also tried creating a texture view with only the depth component and provide its id as first parameter to glClearTexImage, which however yields the same error.
I am testing this in an OpenGL 4.6 context on an Nvidia Titan RTX in Windows 10.