Re: OpenGL driver consumes 100% CPU
- From: David Barrett-Lennard <davidbl@xxxxxxxxxxxx>
- Date: Wed, 3 Dec 2008 18:16:09 -0800 (PST)
On Dec 4, 3:45 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Dec 2, 10:17 am, David Barrett-Lennard <davi...@xxxxxxxxxxxx>
wrote:
You claim there's no point bothering to switch to the idle process.
Of course but so what? How is such a scenario relevant to my case
where there is useful low priority, on going work to be done by the
CPU?
Unfortunately, one most operating systems, priority is too coarse a
tool. The operating system presumes that if a higher-priority thread
is ready-to-run, you would prefer it to run that thread. You've given
your higher priority thread an effectively unlimited amount of work to
do, so it's not surprising that your lower priority threads get
starved.
I agree. But I've only given the higher priority thread an
effectively unlimited amount of work to do because SwapBuffers doesn't
work the way I would like. 16.67 msec is too long to spinlock.
I would have thought the back buffer can be "copied" to the front
buffer independently on the video card, so it would seem that the CPU
could in principle simply signal the card that the back buffer is
ready to be copied at the next vblank. In fact one could consider
this to be a special message in the producer-consumer queue of drawing
commands piped to the video card to indicate "end of frame".
Depending on the buffering available that could potentially allow the
"producer" thread to get many frames ahead of the video card
"consumer", so we typically need to synchronise the "producer" thread
by making it wait before starting the next frame. I could imagine a
HWND receiving a message (call it WM_DRAW_NEXT_FRAME) to indicate that
it should draw the next frame - rather like the way a HWND receives
each WM_MOUSE_MOVE event. Since this approach works with devices
like keyboard and mouse, it should presumably be able to work with a
video card.
As an illustration of the problem: It doesn't appear possible for a
process on my dual core machine to have more than two OpenGL windows
that display at 60fps unless I disable the sync to vblank (and put up
with tearing).
Presumably if I want to display 10 windows on a single processor
machine, and enable the sync to vblank then the best I can do is to
call SyncBuffers on each window in turn and therefore only update each
window at 6fps.
Note that the usual approach of using WM_PAINT "messages" to draw a
frame causes starvation in some windows because WM_PAINT messages are
implemented as dirty flags rather than queued messaged, and Windows
doesn't implement a "fairness policy" when it issues WM_PAINT messages
if a call to SwapBuffers takes so long that all windows are
invalidated again by the time it returns.
I'm aware that the call to glFinish is not required. I was
interested in whether anyone could say why it causes both processors
to be fully utilised.
Because you've force the rendering engine to tell you when it's done,
so it can't stop running. And you are waiting for it, so you can't
stop running.
Are you double-buffering?
Yes.
.
- Follow-Ups:
- Re: OpenGL driver consumes 100% CPU
- From: David Schwartz
- Re: OpenGL driver consumes 100% CPU
- References:
- Re: OpenGL driver consumes 100% CPU
- From: David Schwartz
- Re: OpenGL driver consumes 100% CPU
- From: David Barrett-Lennard
- Re: OpenGL driver consumes 100% CPU
- From: David Schwartz
- Re: OpenGL driver consumes 100% CPU
- From: David Barrett-Lennard
- Re: OpenGL driver consumes 100% CPU
- From: David Schwartz
- Re: OpenGL driver consumes 100% CPU
- Prev by Date: Re: "Synchronization Algorithms & Concurrent Programming" - great book resource
- Next by Date: Re: Wait-Free Programming for General Purpose Computations on GPU
- Previous by thread: Re: OpenGL driver consumes 100% CPU
- Next by thread: Re: OpenGL driver consumes 100% CPU
- Index(es):
Relevant Pages
|
Loading