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 4 of 4

Thread: Strange GL frame buffer corruption

  1. #1
    Intern Contributor
    Join Date
    Jul 2010
    Posts
    74

    Strange GL frame buffer corruption

    I am working on a new app using GL 4.2 core profile from scratch.

    This is my init code:
    Code :
         HDC hDC = ::GetDC(hWnd);
     
     
        PIXELFORMATDESCRIPTOR pfd;
        ::ZeroMemory(&pfd, sizeof(pfd));
        pfd.nSize = sizeof(pfd);
        pfd.nVersion = 1;
        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL 
            | PFD_GENERIC_ACCELERATED | PFD_DOUBLEBUFFER;
        pfd.iPixelType = PFD_TYPE_RGBA;
        pfd.cColorBits = 32;
        pfd.cAlphaBits = 8;
        pfd.cDepthBits = 24;
        pfd.cStencilBits = 8;
     
     
        int format = ::ChoosePixelFormat(hDC, &pfd);
     
     
        ::SetPixelFormat (hDC, format, &pfd);
     
     
        HGLRC hTempRC = ::wglCreateContext(hDC);
     
     
        ::wglMakeCurrent(hDC, hTempRC);
     
     
        wgl_LoadFunctions(hDC);
     
     
        int attribs[] = 
        {
            WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
            WGL_CONTEXT_MINOR_VERSION_ARB, 2,
            WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
            0
        };
     
     
        HGLRC hRC = ::wglCreateContextAttribsARB(hDC, nullptr, attribs);    
     
     
        ::wglMakeCurrent(nullptr, nullptr);
     
     
        wglDeleteContext(hTempRC);
     
     
        ::wglMakeCurrent(hDC, hRC);
     
     
     
        ogl_LoadFunctions();

    I then clear the framebuffer to red:
    Code :
     
        ::glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        ::glClearDepthf(1.0f);
        ::glClearStencil(0);
     
     
        ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        SwapBuffers(hDC);

    This is the result:


    What am I doing wrong?

    I am on Windows 7 SP1 64-bit, with AMD Catalyst 12.11 drivers.

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    433
    How about without PFD_GENERIC_ACCELERATED specified in pfd.dwFlags?
    From the MSDN PIXELFORMATDESCRIPTOR docs:
    The generic implementation is the Microsoft GDI software implementation of OpenGL.

    Asking for a pixel format that supports a software implementation of OpenGL, and then creating an OpenGL 4.2 context may be the cause of the problem.

  3. #3
    Intern Contributor
    Join Date
    Jul 2010
    Posts
    74
    Quote Originally Posted by Dan Bartlett View Post
    How about without PFD_GENERIC_ACCELERATED specified in pfd.dwFlags?
    Asking for a pixel format that supports a software implementation of OpenGL, and then creating an OpenGL 4.2 context may be the cause of the problem.
    Removing that did not change anything.

    Also the MSDN docs say next to PFD_GENERIC_ACCELERATED:
    The pixel format is supported by a device driver that accelerates the generic implementation. If this flag is clear and the PFD_GENERIC_FORMAT flag is set, the pixel format is supported by the generic implementation only.
    Which indicates that it is the opposite of what you think, it looks for a non-generic implementation.

  4. #4
    Intern Contributor
    Join Date
    Jul 2010
    Posts
    74
    I discovered the problem.

    It looks like it's a bug in AMD's driver.

    I am running this on my HP latop which comes with two GPUs - an integrated one in the CPU/APU, and a dedicated GPU. AMD calls this Radeon Dual Graphics.

    In the AMD driver control panel I can control whether a program runs in power saving mode - which means it only runs on the APU, or high performance mode - which runs it on both GPUs using CrossFire.

    When I run it in high performance I get the corruption, but when I run it in power saving it correctly renders solid red.

    So it must be a bug in the CrossFire driver.

    EDIT: Just checked the current Catalyst driver versions, I was running Catalyst 12.11 Beta 3, which is about 1 month old, the current version 12.11 Beta 7.

    I will test to see if the bug is still in Beta 7 - when it finishes downloading...
    Last edited by Leith Bade; 11-13-2012 at 08:32 AM.

Posting Permissions

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