Module: wine Branch: master Commit: 817b520c3d5ed88abb959dbbbd85aa53eecb661d URL: http://source.winehq.org/git/wine.git/?a=commit;h=817b520c3d5ed88abb959dbbbd...
Author: Roderick Colenbrander thunderbird2k@gmx.net Date: Fri Nov 9 16:38:50 2007 +0100
wined3d: Prevent unneeded context switches.
---
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..32d75b6 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())) { + TRACE("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; }