[PATCH] Prevent unneeded context switches.

Roderick Colenbrander thunderbird2k at gmx.net
Fri Nov 9 09:38:50 CST 2007


---
 dlls/wined3d/context.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 8311ab5..7aa8629 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -860,10 +860,17 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
     /* Activate the opengl context */
     if(context != This->activeContext) {
         BOOL ret;
-        TRACE("Switching gl ctx to %p, hdc=%p ctx=%p\n", context, context->hdc, context->glCtx);
-        ret = pwglMakeCurrent(context->hdc, context->glCtx);
-        if(ret == FALSE) {
-            ERR("Failed to activate the new context\n");
+
+        /* Prevent an unneeded context switch as those are expensive */
+        if(context->glCtx && (context->glCtx == pwglGetCurrentContext())) {
+            ERR("Already using gl context %p\n", context->glCtx);
+        }
+        else {
+            TRACE("Switching gl ctx to %p, hdc=%p ctx=%p\n", context, context->hdc, context->glCtx);
+            ret = pwglMakeCurrent(context->hdc, context->glCtx);
+            if(ret == FALSE) {
+                ERR("Failed to activate the new context\n");
+            }
         }
         This->activeContext = context;
     }
-- 
1.5.2.4


--========GMX303841194622691130013--



More information about the wine-patches mailing list