Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Radeon MemoryLeak on glBlitFramebufferEXT

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2010
    Location
    Russia
    Posts
    6

    Radeon MemoryLeak on glBlitFramebufferEXT

    Hi! We have strange problem in our MSAA code, it works nice on nVidia, but memory is leaking on Radeon (catalyst 11.6-11.8). We created separate test:
    Code :
    static HDC DC;
     
    static GLuint MSAAColor;
    static GLuint MSAADepth;
    static GLuint MSAABuffer;
     
    static GLuint Buffer;
    static GLuint Texture;
    static GLuint DepthTexture;
     
    const int MSAA_LEVEL = 8;
     
    void initTest(HWND wnd)
    {
    	//INIT OPENGL
    	HDC hDC = GetDC(wnd);
    	PIXELFORMATDESCRIPTOR pfd;
    	ZeroMemory( &pfd, sizeof( pfd ) );
    	pfd.nSize = sizeof( pfd );
    	pfd.nVersion = 1;
    	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
    				  PFD_DOUBLEBUFFER;
    	pfd.iPixelType = PFD_TYPE_RGBA;
    	pfd.cColorBits = 32;
    	pfd.cDepthBits = 24;
    	pfd.cStencilBits = 8;
    	pfd.iLayerType = PFD_MAIN_PLANE;
    	int iFormat = ChoosePixelFormat( hDC, &pfd );
    	SetPixelFormat( hDC, iFormat, &pfd );
    	HGLRC hRC = wglCreateContext(hDC);
    	wglMakeCurrent(hDC, hRC);
     
    	DC = hDC;
     
    	glewInit();
     
    	//INIT MSAA FBO
    	glGenRenderbuffersEXT(1, &MSAAColor);
    	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MSAAColor);
    	glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, MSAA_LEVEL, GL_RGBA, 1024, 1024);
     
    	glGenRenderbuffersEXT(1, &MSAADepth);
    	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MSAADepth);
    	glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, MSAA_LEVEL, GL_DEPTH24_STENCIL8_EXT, 1024, 1024);
     
    	glGenFramebuffersEXT(1, &MSAABuffer);
    	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MSAABuffer);
    	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
    	  GL_RENDERBUFFER_EXT, MSAAColor);
    	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    	  GL_RENDERBUFFER_EXT, MSAADepth);
    	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
    	  GL_RENDERBUFFER_EXT, MSAADepth);
     
    	//INIT FBO
    	glGenFramebuffersEXT(1, &Buffer);
    	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Buffer);
     
    	glGenTextures(1, &Texture);
    	glActiveTextureARB(GL_TEXTURE0_ARB);
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D, Texture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
     
        glGenTextures(1, &DepthTexture);
        glBindTexture(GL_TEXTURE_2D, DepthTexture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, 1024, 1024, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
     
     
    	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
          GL_TEXTURE_2D, Texture, 0);
     
        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    			GL_TEXTURE_2D, DepthTexture, 0);
     
    	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
    			GL_TEXTURE_2D, DepthTexture, 0);
     
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    }
     
    void renderTest()
    {
    	glClear(GL_COLOR_BUFFER_BIT);
     
    	glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, MSAABuffer);
    	glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, Buffer);
    	glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    	glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
    	glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
     
    	SwapBuffers(DC);
    }

    Memory is leaking very fast (Depends on FPS).

    Commenting this:
    Code :
    //glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
    fixes leak, but makes stencil unaccessible.

    Any suggestions? Maybe incorrect code?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    669

    Re: Radeon MemoryLeak on glBlitFramebufferEXT

    I knew that blitting stencil values on ATI breaks the depthbuffer contents, but I didn't know that it also creates a memory leak :-/

    BTW, you can consolidate all 3 blit calls into one - just OR the 'mask' flags together.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2010
    Location
    Russia
    Posts
    6

    Re: Radeon MemoryLeak on glBlitFramebufferEXT

    We splited bliting in three calls in this January because it fixes damaged depth on ATI, but this bug (with depth) in driver was fixed later this year, so after some tests we have:
    Code :
    glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    // Not leaking, not working depth with OLD drivers
    //glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
    // Leaking, working depth with OLD drivers
    glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
    glBlitFramebufferEXT(0, 0, 1024, 1024, 0, 0, 1024, 1024, GL_STENCIL_BUFFER_BIT, GL_NEAREST);

    So for current drivers we can use bliting together...

    Can anybody give me AMD/ATI's contacts to report this leak?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •