OpenGL: wrong texture sampled after FBO texture deletion (transparency layers)

In nested transparency layers, bindTexture samples the wrong texture.

A layer’s FBO texture (name 6) is bound → cached. glDeleteTextures resets its GL binding to 0 without updating the ActiveTextures shadow cache. glGenTextures recycles name 6 for the next layer. bindTexture(6) sees currentTextureID[unit] == 6, skips the real glBindTexture, and samples the zero texture:

DESYNC unit=0 requested=6 actualBinding=0 glIsTexture(requested)=1 cache=[6,0,0]

Correctness bug, not just a debug assert (release composites the wrong texture).

Local fix: state->activeTextures.clear() in endTransparencyLayer before compositing.

Proper fix: invalidate the ActiveTextures cache whenever a texture name is deleted, since GL silently unbinds it.

Thanks !

FWIW, this creates glitch as soon as we enable the OpenGL renderer in Falcon.

Like for example the weird dark shadow in this screenshot:

I’ve tried to reproduce the issue, but without any luck so far.

Just to check, are you testing with the develop branch, or at least a branch that contains this change?

If you’re seeing the issue on the develop branch, it would be helpful if you could supply a paint() implementation that demonstrates the issue, since I haven’t been able to come up with an example that looks different between the d2d renderer and the OpenGL renderer on Windows.

using develop from last week. I try to find a simple exemple to reproduce

GLTransparencyLayerRecycleRepro.h (4.5 KB)

same issue with regular image

GLTransparencyLayerRecycleRepro.h (4.9 KB)

Thanks for the minimal repro, that made it much quicker for me to track down the problem. Hopefully that’s fixed here:

1 Like