_eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;
oldCtx = t->CurrentContexts[apiIndex];
- if (ctx == oldCtx)
- return NULL;
+ if (ctx != oldCtx) {
+ if (oldCtx)
+ oldCtx->Binding = NULL;
+ if (ctx)
+ ctx->Binding = t;
- if (oldCtx)
- oldCtx->Binding = NULL;
- if (ctx)
- ctx->Binding = t;
-
- t->CurrentContexts[apiIndex] = ctx;
+ t->CurrentContexts[apiIndex] = ctx;
+ }
return oldCtx;
}
_eglBindContextToSurfaces(newCtx, draw, read);
/* unbind the old context from its binding surfaces */
- if (oldCtx) {
+ if (oldCtx && oldCtx != newCtx) {
/*
* If the new context replaces some old context, the new one should not
* be current before the replacement and it should not be bound to any