Talk About Network

Google


Giganews Newsgroups




Programming > Programming Threads > OpenGL driver c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 4166 of 4207
Post > Topic >>

OpenGL driver consumes 100% CPU

by David Barrett-Lennard <davidbl@[EMAIL PROTECTED] > Nov 27, 2008 at 12:47 AM

Consider a simple win32 application that creates a single OpenGL frame
window using the following windows procedure

LRESULT CALLBACK WndProc(
    HWND hWnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
    HGLRC hRC;
    PIXELFORMATDESCRIPTOR pfd =
    {
        sizeof(PIXELFORMATDESCRIPTOR), 1,
        PFD_DRAW_TO_WINDOW | PFD_SUP****T_OPENGL |
        PFD_DOUBLEBUFFER, PFD_TYPE_RGBA,
        24, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0,
        32, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
    };
    switch (message)
    {
    case WM_CREATE :
        hdc = GetDC(hWnd);
        SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
        hRC = wglCreateContext(hdc);
        wglMakeCurrent(hdc,hRC);
        SetTimer(hWnd,1,15,NULL);
        break;

    case WM_TIMER :
        InvalidateRect(hWnd,NULL,FALSE);
        break;

    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        glFinish();
        SwapBuffers(hdc);
        EndPaint(hWnd, &ps);
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

According to the windows task manager on my dual core machine both
processors are 100% utilised while this window is displayed

When I comment out the call to glFinish the CPU usage drops from 100%
to exactly 50% suggesting that at any given time one processor is
fully occupied within SwapBuffers().  Does this suggest the OpenGL
driver is using a spin lock?

If the timer period is increased from 15 msec to 17 msec the total
processor activity drops from 100% down to about 3%.  Presumably this
has something to do with the synchronisation with the screen refresh.

Is it reasonable for the OpenGL driver to consume the CPU like that?
 




 8 Posts in Topic:
OpenGL driver consumes 100% CPU
David Barrett-Lennard <  2008-11-27 00:47:23 
Re: OpenGL driver consumes 100% CPU
David Schwartz <davids  2008-12-01 09:52:19 
Re: OpenGL driver consumes 100% CPU
David Barrett-Lennard <  2008-12-02 01:02:45 
Re: OpenGL driver consumes 100% CPU
David Schwartz <davids  2008-12-02 06:26:01 
Re: OpenGL driver consumes 100% CPU
David Barrett-Lennard <  2008-12-02 10:17:46 
Re: OpenGL driver consumes 100% CPU
David Schwartz <davids  2008-12-03 10:45:18 
Re: OpenGL driver consumes 100% CPU
David Barrett-Lennard <  2008-12-03 18:16:09 
Re: OpenGL driver consumes 100% CPU
David Schwartz <davids  2008-12-03 22:21:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Sat Jul 4 13:51:27 PDT 2009.