Driver issue with bindless textures pixels are flickering on the window

Hi! I use 3 shaders, the goal is the check the most opaque fragment over the refractable objects, and then hide refraction if there is an opaque fragment before.

The code worked well until I use bindless texturing.
I think it’s a driver issue but I post here to be sure it’s it.

In this shader the texture is ok :

const std::string fragmentShader = R"(#version 460
                                                  #extension GL_ARB_bindless_texture : enable
                                                  struct NodeType {
                                                      vec4 color;
                                                      float depth;
                                                      uint next;
                                                  layout(binding = 0, offset = 0) uniform atomic_uint nextNodeCounter;
                                                  layout(binding = 0, r32ui) uniform uimage2D headPointers;
                                                  layout(binding = 0, std430) buffer linkedLists {
                                                      NodeType nodes[];
                                                  layout(std140, binding=0) uniform ALL_TEXTURES {
                                                      sampler2D textures[200];
                                                  uniform uint maxNodes;
                                                  uniform float haveTexture;
                                                  uniform sampler2D texture;
                                                  in vec4 frontColor;
                                                  in vec2 fTexCoords;
                                                  in flat uint texIndex;
                                                  layout (location = 0) out vec4 fcolor;
                                                  void main() {
                                                       uint nodeIdx = atomicCounterIncrement(nextNodeCounter);
                                                       vec4 texel = (texIndex != 0) ? frontColor * texture2D(textures[texIndex-1], fTexCoords.xy) : frontColor;
                                                       if (nodeIdx < maxNodes) {
                                                            uint prevHead = imageAtomicExchange(headPointers, ivec2(gl_FragCoord.xy), nodeIdx);
                                                            nodes[nodeIdx].color = texel;
                                                            nodes[nodeIdx].depth = gl_FragCoord.z;
                                                            nodes[nodeIdx].next = prevHead;
                                                       fcolor = vec4(0, 0, 0, 0);

But in this shader, no textures, alpha is always 0.

const std::string buildAlphaBufferFragmentShader = R"(#version 460
                                                                  #extension GL_ARB_bindless_texture : enable
                                                                  layout(std140, binding=0) uniform ALL_TEXTURES {
                                                                    sampler2D textures[200];
                                                                  layout(binding = 0, rgba32f) uniform image2D alphaBuffer;
                                                                  layout (location = 0) out vec4 fColor;
                                                                  uniform sampler2D texture;
                                                                  uniform sampler2D depthBuffer;
                                                                  uniform float haveTexture;
                                                                  uniform float layer;
                                                                  uniform float nbLayers;
                                                                  uniform vec3 resolution;
                                                                  in vec4 frontColor;
                                                                  in vec2 fTexCoords;
                                                                  in flat uint texIndex;
                                                                  void main() {
                                                                      vec4 texel = (texIndex != 0) ? frontColor * texture2D(textures[texIndex-1], fTexCoords.xy) : frontColor;
                                                                      float current_alpha = texel.a;
                                                                      vec2 position = (gl_FragCoord.xy / resolution.xy);
                                                                      vec4 depth = texture2D (depthBuffer, position);
                                                                      vec4 alpha = imageLoad(alphaBuffer,ivec2(gl_FragCoord.xy));
                                                                      float l = layer / nbLayers;
                                                                      float z = gl_FragCoord.z;
                                                                      if ((l > depth.y || l == depth.y && z > depth.z) && current_alpha > alpha.a) {
                                                                          fColor = vec4(0, l, z, current_alpha);
                                                                          imageStore(alphaBuffer,ivec2(gl_FragCoord.xy),vec4(0, l, z, current_alpha));
                                                                      } else {
                                                                          fColor = alpha;

This is really strange because I use the same UBO for the two shaders and the same code to bind to UBOs to all my shaders :

std::vector<Texture*> allTextures = Texture::getAllTextures();
        Samplers allSamplers{};
        std::vector<math::Matrix4f> textureMatrices;
        for (unsigned int i = 0; i < allTextures.size(); i++) {
            GLuint64 handle_texture = glGetTextureHandleARB(allTextures[i]->getNativeHandle());
            allSamplers.tex[i].handle = handle_texture;
            //std::cout<<"add texture i : "<<i<<" id : "<<allTextures[i]->getNativeHandle()<<std::endl;
        sBuildDepthBuffer.setParameter("textureMatrix", textureMatrices);
        sBuildDepthBufferNormal.setParameter("textureMatrix", textureMatrices);
        sBuildAlphaBuffer.setParameter("textureMatrix", textureMatrices);
        sBuildAlphaBufferNormal.setParameter("textureMatrix", textureMatrices);
        sLinkedList.setParameter("textureMatrix", textureMatrices);
        sLinkedListNormal.setParameter("textureMatrix", textureMatrices);
        glCheck(glGenBuffers(1, &ubo));
        unsigned int ubid;
        glCheck(ubid = glGetUniformBlockIndex(sLinkedList.getHandle(), "ALL_TEXTURES"));
        glCheck(glUniformBlockBinding(sLinkedList.getHandle(),    ubid, 0));
        glCheck(ubid = glGetUniformBlockIndex(sLinkedListNormal.getHandle(), "ALL_TEXTURES"));
        //std::cout<<"shader handle : "<<sLinkedListNormal.getHandle()<<std::endl;
        glCheck(glUniformBlockBinding(sLinkedListNormal.getHandle(),    ubid, 0));
        glCheck(ubid = glGetUniformBlockIndex(sBuildDepthBuffer.getHandle(), "ALL_TEXTURES"));
        glCheck(glUniformBlockBinding(sBuildDepthBuffer.getHandle(),    ubid, 0));
        glCheck(ubid = glGetUniformBlockIndex(sBuildDepthBufferNormal.getHandle(), "ALL_TEXTURES"));
        glCheck(glUniformBlockBinding(sBuildDepthBufferNormal.getHandle(),    ubid, 0));
        glCheck(ubid = glGetUniformBlockIndex(sBuildAlphaBuffer.getHandle(), "ALL_TEXTURES"));
        glCheck(glUniformBlockBinding(sBuildAlphaBuffer.getHandle(),    ubid, 0));
        //std::cout<<"shader handle : "<<sBuildAlphaBufferNormal.getHandle()<<std::endl;
        glCheck(ubid = glGetUniformBlockIndex(sBuildAlphaBufferNormal.getHandle(), "ALL_TEXTURES"));
        glCheck(glUniformBlockBinding(sBuildAlphaBufferNormal.getHandle(),    ubid, 0));

        //std::cout<<"ubid : "<<ubid<<std::endl;
        backgroundColor = sf::Color::Transparent;
        glCheck(glBindBuffer(GL_UNIFORM_BUFFER, ubo));
        glCheck(glBufferData(GL_UNIFORM_BUFFER, sizeof(Samplers),allSamplers.tex, GL_STATIC_DRAW));
        //std::cout<<"size : "<<sizeof(Samplers)<<" "<<alignof (alignas(16) uint64_t[200])<<std::endl;
        glCheck(glBindBuffer(GL_UNIFORM_BUFFER, 0));
        glCheck(glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo));
        glCheck(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicBuffer));
        glCheck(glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, linkedListBuffer));

        for (unsigned int i = 0; i < Batcher::nbPrimitiveTypes; i++) {

I printed values of texIndex and fTexCoords into the textures to see if they are correct and they are correctly affected.
I also passed a color the the colour output of the shader, to see if my draw functions are correct and they are correct.

So I really don’t know what’s wrong, I tested everything, event to calculate size of all uniforms to set them to a multiple of 16 but nothing seems to solve this problem.

So I think it’s a driver issue, everything is ok, excepts the UBO of sampler2D which is empty excepts in my per pixel linked list fragment shader so the UBO is not binbed to all my shaders.

Ok it seems I had to bind/unbind buffers with glBindBufferBase because I use different buffers with different rederer but now I’ve this problem. (some pixels are flickering)

I solved the problem by using one context by FBO, UBO are not shared between context so that was the initial problem but when I use only one context pixels are flickering I thing, it’s a driver issue.