Commit 1b30d153 authored by Kyle Brenneman's avatar Kyle Brenneman
Browse files

GLdispatch: Don't unpatch entrypoints in __glDispatchLoseCurrent.



In __glDispatchLoseCurrent, don't try to restore the default entrypoints.
Instead, __glDispatchMakeCurrent will check if it's using a different vendor
library, and if so, it will unpatch and repatch the entrypoints then. If it's
using the same vendor library (which will usually be the case), then it can
leave them patched and skip the patch overhead.

Some applications will call glXMakeCurrent to release and bind the same context
every frame, sometimes multiples times. Each patch and unpatch sequnce can chew
up 1-2 milliseconds. That's enough to significantly reduce the framerate of
some applications.

Reviewed-by: James Jones's avatarJames Jones <jajones@nvidia.com>
parent d0ced9a2
......@@ -573,6 +573,17 @@ static int PatchEntrypoints(
if (stubCurrentPatchCb->releasePatch != NULL) {
stubCurrentPatchCb->releasePatch();
}
// Restore the stubs to the default implementation.
glvnd_list_for_each_entry(stub, &dispatchStubList, entry) {
if (stub->isPatched) {
stub->callbacks.restoreFuncs();
stub->isPatched = GL_FALSE;
}
}
stubCurrentPatchCb = NULL;
stubOwnerVendorID = 0;
}
if (patchCb) {
......@@ -609,17 +620,6 @@ static int PatchEntrypoints(
stubCurrentPatchCb = NULL;
stubOwnerVendorID = 0;
}
} else {
// Restore the stubs to the default implementation
glvnd_list_for_each_entry(stub, &dispatchStubList, entry) {
if (stub->isPatched) {
stub->callbacks.restoreFuncs();
stub->isPatched = GL_FALSE;
}
}
stubCurrentPatchCb = NULL;
stubOwnerVendorID = 0;
}
return 1;
......@@ -695,8 +695,10 @@ static void LoseCurrentInternal(__GLdispatchThreadState *curThreadState,
GLboolean threadDestroyed)
{
LockDispatch();
// Try to restore the libglvnd default stubs, if possible.
PatchEntrypoints(NULL, 0);
// Note that we don't try to restore the default stubs here. Chances are,
// the next MakeCurrent will be from the same vendor, and if we leave them
// patched, then we won't have to go through the overhead of patching them
// again.
if (curThreadState) {
numCurrentContexts--;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment