5 Replies Latest reply on Apr 8, 2018 7:09 AM by nou

    Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1

    ronniko

      I created context wglCreateContextAttribsARB with:

       

      WGL_SUPPORT_OPENGL_ARB, GL_TRUE,\

                                  WGL_DOUBLE_BUFFER_ARB, GL_TRUE,\

                                  WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,\

                                  WGL_COLOR_BITS_ARB, 32,\

                                  WGL_DEPTH_BITS_ARB, 16 ,\

                                  WGL_SAMPLE_BUFFERS_ARB,GL_TRUE ,\

                                  WGL_SAMPLES_ARB,4

       

      I try with WGL_DEPTH_BITS_ARB, 24 ,WGL_STENCIL_BITS_ARB, 8  but result the same.

       

      I created FBO color and depth textures. And i see 3d model teapot and dirt in depth and color fbo textures. My model teapot rotated.

      I try create FBO depth with flag GL_DEPTH_COMPONENT not help. Try with GL_DEPTH24_STENCIL8 not help.

      I try create glRenderbufferStorageMultisample(GL_RENDERBUFFER, 8, GL_DEPTH_COMPONENT16_ARB, 512,512) not help

      When i do render in FBO i do: glClearColor(1.0f, 0.0f, 1.0f,1.0);

             glClear(GL_DEPTH_BUFFER_BIT+GL_COLOR_BUFFER_BIT+ GL_STENCIL_BUFFER_BIT  );

      I try clear only Depth but not help.

       

      My question is this bug AMD driver ?!

       

      I draw in FBO plane for clearing dirt. Its help for color FBO texture, but not help for depth FBO.

      Its problem will return, when i begin write shadow map technic.

        • Re: Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1
          ronniko

          I found. That's my fault !

          I use bindless textures. In fragment shader i do layout (binding = 0, std140) uniform ALL_TEXTURES { sampler2D texs[4000]; };

          And FBO color texture GL_COLOR_ATTACHMENT0 !

          I removed bindless textures from fragment shader and FBO depth and color textures now cleared.

          And i see correct FBO color texture without dirt !

           

            • Re: Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1
              ronniko

              Its AMD driver bug !

              I tested on NVIDIA GeForce 1050 ti. And FBO depth cleared. I use bindless textures and FBO render.

              Screenshot from GeForce 1050 ti:

              nvidia.jpg

               

              But the same program on AMD not clear FBO depth ! In top left coner FBO depth texture.

              Screenshot from Radeon HD 7950 and Radeon R380:

              rr.jpg

                • Re: Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1
                  ronniko

                  How i do.

                  I create FBO color and depth textures. As simple GL_TEXTURE_2D. Not msaa !

                  Check FBO status. Get FRAMEBUFFER status = 0x8CD5 (8CD5=COMPLETE).

                   

                  Then i do bindless for FBO color and depth textures.

                  glBindTexture(GL_TEXTURE_2D,FBOColorTexture);

                  AdrrInt64 = glGetTextureHandleARB(FBOColorTexture);

                  glMakeTextureHandleResidentARB(AdrrInt64);

                  Set AdrrInt64 to uniform buffer(buffers.BindlesstextureHandle)

                  for bindless shader textures. Offset for one texture addres 16 bytes for uniform buf.

                   

                  glBindTexture(GL_TEXTURE_2D,FBODepthTexture);

                  AdrrDepthInt64 = glGetTextureHandleARB(FBODepthTexture);

                  glMakeTextureHandleResidentARB(AdrrDepthInt64);

                  Set AdrrDepthInt64 to uniform buffer(buffers.BindlesstextureHandle+16) for bindless shader textures.

                   

                  And glBindBufferBase(GL_UNIFORM_BUFFER, 9,buffers.BindlesstextureHandle);

                   

                  I use WGL_CONTEXT_FLAGS_ARB,WGL_CONTEXT_DEBUG_BIT_ARB,\

                                           WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB

                   

                  But debugCallBack function not send me any warnings or messages for AMD videocards.

                  For NVIDIA i get many messages in log file.

                    • Re: Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1
                      ronniko

                      When i do screenshot FBO texture i not see dirt in tga file ! I open in photoshop tga screenshot and see two teapots without dirt and bugs !

                      void screendump(int W, int H) {

                      FILE   *out = fopen("screenshot.tga","wb");

                      char   *pixel_data = new char[3*W*H];

                      short  TGAhead[] = { 0, 2, 0, 0, 0, 0, W, H, 32 };

                       

                      glReadBuffer(GL_FRONT);

                      glReadPixels(0, 0, W, H, GL_BGRA, GL_UNSIGNED_BYTE, pixel_data);

                       

                      fwrite(&TGAhead,sizeof(TGAhead),1,out);

                      fwrite(pixel_data, 4*W*H, 1, out);

                      fclose(out);

                       

                      delete[] pixel_data; }

                • Re: Windows 7 OpenGL 4.5 Radeon HD 7950. FBO not clear depth. Crimson 17.12.1
                  nou

                  Don't assume that if it work on nVidia that you program is correct. nVidia OpenGL driver is much more forgiving where AMD is more strict. So check official OpenGL specification if you don't do some invalid or undefined operation.