static void context_update_window(struct wined3d_context *context)
{
+ if (context->win_handle == context->swapchain->win_handle)
+ return;
+
TRACE("Updating context %p window from %p to %p.\n",
context, context->win_handle, context->swapchain->win_handle);
context->valid = 0;
}
-/* Do not call while under the GL lock. */
-static void context_validate(struct wined3d_context *context)
-{
- HWND wnd = WindowFromDC(context->hdc);
-
- if (wnd != context->win_handle)
- {
- WARN("DC %p belongs to window %p instead of %p.\n",
- context->hdc, wnd, context->win_handle);
- context->valid = 0;
- }
-
- if (context->win_handle != context->swapchain->win_handle)
- context_update_window(context);
-}
-
/* Do not call while under the GL lock. */
static void context_destroy_gl_resources(struct wined3d_context *context)
{
restore_ctx = pwglGetCurrentContext();
restore_dc = pwglGetCurrentDC();
- context_validate(context);
- if (context->valid && restore_ctx != context->glCtx) pwglMakeCurrent(context->hdc, context->glCtx);
+ context_update_window(context);
+ if (context->valid && restore_ctx != context->glCtx)
+ context->valid = !!pwglMakeCurrent(context->hdc, context->glCtx);
else restore_ctx = NULL;
ENTER_GL();
if (current_context && current_context->current_rt == target)
{
- context_validate(current_context);
+ context_update_window(current_context);
return current_context;
}
context = swapchain_get_context(This->swapchains[0]);
}
- context_validate(context);
+ context_update_window(context);
return context;
}
if(!This->d3d_initialized) return WINED3DERR_INVALIDCALL;
+ /* Force making the context current again, to verify it is still valid
+ * (workaround for broken drivers) */
+ context_set_current(NULL);
/* I don't think that the interface guarantees that the device is destroyed from the same thread
* it was created. Thus make sure a context is active for the glDelete* calls
*/