Our inhouse engine relies on angle to simulate GLES on PC. When running, we get the following warning from glDebugMessageCallback:
Message: Program undefined behavior warning: The current GL state uses a sampler (2) that has depth comparisons disabled, with a texture object (53) with a depth format, by a shader that samples it with a shadow sampler. Using this state to sample would result in undefined behavior.
I try figuring out what happened: At first I logged every texture unit & sampler, but find they seems correct with corresponding shader.
Then I guess maybe some texture unit/sampler are not cleared when not in use. After investigating angle’s StateManagerGL::updateProgramTextureBindings, I added some debug code in the end to force clean up
// test: force bind zero for inactive texture units
for (size_t textureUnitIndex = 0; textureUnitIndex < gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES;
textureUnitIndex++)
{
if (!activeTextures.test(textureUnitIndex))
{
activeTexture(textureUnitIndex);
bindTexture(gl::TextureType::_3D, 0);
bindTexture(gl::TextureType::_2DArray, 0);
bindTexture(gl::TextureType::_2D, 0);
bindSampler(textureUnitIndex, 0);
}
}
Now I get similar warning but texture unit (0) and sampler (0)
Message: Program undefined behavior warning: The current GL state uses a sampler (0) that has depth comparisons disabled, with a texture object (0) with a non-depth format, by a shader that samples it with a shadow sampler. Using this state to sample would result in undefined behavior.
As I only cleanup inactive slots and all warning message changes as above: I guess nvogvl64.dll is checking texture unit&sample not in use?
ps. Also I checked every shadow sampler in our shaders to ensure correct usage :(
Is there any way to fix these warnings?