From 645eb62f709275ac46c2a7ea59bf8bcba34c7edd Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 18 Nov 2019 17:48:12 +0330 Subject: [PATCH] wined3d: Create a backup context if setting the pixel format failed in wined3d_context_gl_create_wgl_ctx(). Signed-off-by: Paul Gofman Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 5b8402bfe4f..c5d2eeaa477 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2033,9 +2033,27 @@ static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context if (!wined3d_context_gl_set_pixel_format(context_gl)) { - ERR("Failed to set pixel format %d on device context %p.\n", context_gl->pixel_format, context_gl->dc); context_release(context); - return FALSE; + + if (context_gl->dc_is_private) + { + ERR("Failed to set pixel format %d on device context %p.\n", context_gl->pixel_format, context_gl->dc); + + return FALSE; + } + + WARN("Failed to set pixel format %d on device context %p, trying backup DC.\n", + context_gl->pixel_format, context_gl->dc); + + wined3d_release_dc(context_gl->window, context_gl->dc); + if (!(context_gl->dc = wined3d_swapchain_gl_get_backup_dc(swapchain_gl))) + { + ERR("Failed to retrieve the backup device context.\n"); + return E_FAIL; + } + context_gl->dc_is_private = TRUE; + + return wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl); } share_ctx = device->context_count ? wined3d_context_gl(device->contexts[0])->gl_ctx : NULL;