Rendering to texture via FBO and then using that texture on a shared context

Hello Developers,


I've just discovered that code I've been using for several years does not work properly on all GPUs. The basic failure case is like this:


1. Offscreen OpenGL context + FBO, with share context of the main context.

2. Clear FBO context with glClear()

3. Render stuff, mostly other textures to the FBO context.

4. Take the resulting texture from the FBO and render it to the main context, on screen.

5. Repeat at step #2.


What I'm seeing is that glClear(), and possibly other functions, start to fail silently on the FBO context with certain GPUs.


I've narrowed it down to these calls. Once these calls are made on the main context (with the texture from the FBO context), the FBO context stops behaving.


glEnable(GL_TEXTURE_RECTANGLE_EXT);
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, fbo.texture);
glBegin(GL_QUADS);
....
glEnd();


My initial findings are that this all works fine on NVIDIA hardware but break with Intel Iris hardware.


I've tried several things to get the FBO context back in working condition but I can't seem to figiure it out. Is this supposed to work or have I found a bug?


Thanks!