View Full Version : context switches extremely slow
07-09-2002, 02:57 AM
in my application I have two rendering contexts. One context is used for rendering to a window, while the other context is used for dynamically creating textures in a pbuffer.
The problem is that switching between these contexts sometimes is extremely slow, which means that the call to glXMakeCurrent() won't return for 100 milliseconds or even longer. It's just about 5 percent of the context switches that take so much time, the normal context switch takes about 1 millisecond.
Does anyone have an idea how to speed up these context switches?
By the way, I have a GeForce4 Ti4600 and I'm using the latest Nvidia drivers under linux.
My guess is that the driver has to wait for something. You can test this by throwing in some glFinish before the calls to glXMakeCurrent. Perhaps can the program be more efficent with some rearrangement of the code and possible some glFlush calls. I do not think it is linux specific, have you tested the program under Windows?
07-10-2002, 04:19 AM
You're right, when I call glFinish() before the call to glXMakeCurrent(), it is indeed glFinish() that takes so much time, not glXMakeCurrent().
So the question is now: Why does glFinish() sometimes take so much time?
I've noticed another crazy thing: When I use texture compression (change the internal format of my textures from GL_RGBA to GL_COMPRESSED_RGBA_S3TC_DXT5_EXT), everything works fine, that means no call to glFinish() takes longer than 1 ms.
I can't test this program under Windows because all that pbuffer stuff uses GLX and therefore is linux specific.
Seems like the driver wants to finish the flush before changing context. The bottleneck is probably the copy from the pbuffer to the texture. It must be really slow if it is faster to compress making the texture smaller. The Windows driver has the render to texture extension but I have heard that it currently is not faster.
Do you still get big differences in execution using glFinish?
I expected it to be more equal since the buffers are periodicaly "washed".
If you have some CPU stuff to do would something like this probably be better:
/* do some calculations or IO or any none graphic stuff */
07-11-2002, 02:58 AM
Only the glFinish and glXMakeCurrent calls get faster when texture compression is enabled, but copying texture (sub)images is much too slow then, so I can't actually use it in my application.
I found out that putting some glFinish calls into my code, especially after copying from the pbuffer to a texture, makes context switches much faster. There are still differences in execution time, but now the maximum execution time is about 10 ms.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.