From: Paul Gofman Subject: Re: [PATCH] wined3d: Avoid crash in swapchain_gl_present() if context could not be acquired. Message-Id: Date: Thu, 14 Nov 2019 20:34:37 +0300 In-Reply-To: References: <20191113151515.1455279-1-gofmanp@gmail.com> <725e09c0-1bdc-faaa-8eef-2400934fe57c@gmail.com> <217818f9-a056-424d-2bf8-ed187ea9c872@gmail.com> <127d5806-b0a1-6945-1a01-ba55b0568ffb@gmail.com> <9712e0c2-88fb-4cc9-4695-c2d759823513@gmail.com> <15e38ef6-f114-0d16-f06b-bbbeb5912456@gmail.com> On 11/14/19 19:42, Henri Verbeet wrote: > On Thu, 14 Nov 2019 at 20:05, Paul Gofman wrote: >> On 11/14/19 18:23, Henri Verbeet wrote: >>> Somewhat, in the sense that it gives us the option of using e.g. >>> (gdi32) BitBlt() to still get the contents into the target window, if >>> we really needed to. >>> >>> That isn't entirely the point though. Part of the issue is that the >>> behaviour for creating a new context should be consistent with the >>> behaviour for reusing an existing one. Another part is that for better >>> or worse, the model we currently have is that provided OpenGL works at >>> all, context_acquire() isn't supposed to fail. It may make sense to >>> rethink that, but we have a lot more context_acquire() calls besides >>> the one in swapchain_gl_present(). >>> >>> The background is that the target window can go away at any given >>> point, and D3D is supposed to keep working when that happens. Modern >>> versions of OpenGL/GLX can make a context current without a drawable, >>> but originally the drawable was required. Provided FBOs are available >>> current wined3d always renders offscreen and only needs an onscreen >>> context for Present(), but in the past that was not the case either. >>> (I.e., think Opengl 1.x or 2.x and "backbuffer" ORM.) >> Thanks for the explanation, I see now. >> >> So I will make wined3d_context_gl_init() create backup context as well >> if it fails to set pixel format (and maybe as well if wglCreateContext() >> fails?). >> > Right. FWIW, I now figured out what exactly is wrong with that window. The window is created by a different process, and get_win_data() in winex11.drv/windows.c obviously can't find the window data which was set in another process to its own display. The attached patch works that around and SetPixelFormat() succeeds after that. This looks like something to be done in winex11.drv (but I realize that the rendering to other process windows might require much more than this). Yet I suppose it still worth handling the failures in gl context creation in wined3d_context_gl_init() as we discussed before. ko0_qBs!NEjLx IK/Z$ܦMS%?B>~}B6x Cɭv019D;h~hQ`'TFdޢ2b8Ub:Y3cYkuĸic4# @mK>R>@;iκ1ěLt˱ vgԶl߂( 8M$e0&y(x[ϗ-ߡ>,6\Fb_}Mhb c4g_xpsrewBٝ DwBѝPugMb[F !M H[ ݃G004+d>x mOY(LF L,`@rM HfOǐ{{6Q]'9`ILGԇۖxN]4öpjt@MKiM/ n>4'yG[C;r HX'!C\ WC7To"BTYs*t$lkF.8M}M`O[fnhz# AyG]9P{F