Fixing conflicts between WineD3D and WGL

Ken Thomases ken at codeweavers.com
Sun Mar 23 23:13:01 CDT 2014


I have an implementation of WGL_WINE_surface for the Mac driver and modified wined3d to use it.  I still have to implement it for the X11 driver.  I'm sending it along here to let folks see where it's going and review/critique my approach.

I also need to update my description from my original proposal, since things didn't quite work how I planned.  See below.

The attached patches apply on top of the patches I just sent to wine-patches (patches 103407 through 103414).

On Jan 28, 2014, at 6:47 PM, Ken Thomases wrote:

> WGL exposes various pieces of state to the application.  Ideally, WineD3D would not alter any of that state since such alterations are visible to the app and Direct3D doesn't do that on Windows.  …
> 
> * The DC pixel format.  …
> * The current GL context for the thread.  …
> * The DC for the current GL context. …

I realized that another piece of WGL state is the swap interval.  That is set on the window of the current context, not on the context as such.  So, when the context is targeting a surface, the swap interval will instead be set on that surface rather than the window.


> Extension WGL_WINE_surface:
> 
> HANDLE wglCreateSurfaceWINE(HDC hdc, int pixel_format);

This no longer takes a pixel format argument.  Wined3d doesn't have a pixel format chosen at the point where a surface should be created.  Instead, one just calls SetPixelFormat() or wglSetPixelFormatWINE() on a surface DC as is currently done for window DCs.  Similarly, GetPixelFormat() works on a surface DC.  (It shouldn't end up that wglSetPixelFormatWINE() is ever actually called on a surface DC since we won't need to change it after it's first set, but it works.)

Also, instead of using the generic HANDLE type, the extension defines the HSURFACEWINE type.


> Destroying a surface while it still has extant surface DCs results in undefined behavior.

This was untenable given the constraints that wined3d operates under.  The surface is destroyed when the swapchain's window is changed, but there may still be contexts targeting the surface DC.  Those may be current on another thread, so there's no way to clear them and release the DC synchronously.  So, I've made the internal object underlying a surface handle reference counted.  The handle itself holds one reference, which is released when the handle is destroyed.  Each DC obtained by wglGetSurfaceDCWINE() holds an additional reference, which is released during wglReleaseSurfaceDCWINE().

-Ken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-opengl32-Define-custom-WGL-extension-WGL_WINE_surfac.patch
Type: application/octet-stream
Size: 6087 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0011.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-DONTSEND-opengl32-Define-custom-WGL-extension-WGL_WI.patch
Type: application/octet-stream
Size: 8963 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0012.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-user32-Track-the-number-of-GL-surfaces-for-a-window-.patch
Type: application/octet-stream
Size: 6933 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0013.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-DONTSEND-user32-Track-the-number-of-GL-surfaces-for-.patch
Type: application/octet-stream
Size: 895 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0014.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-wined3d-Pass-the-context-not-its-window-into-surface.patch
Type: application/octet-stream
Size: 4753 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0015.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-wined3d-Make-use-of-the-WGL_WINE_surface-extension-t.patch
Type: application/octet-stream
Size: 16952 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0016.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-winemac-Allow-passing-a-NULL-window-to-send_mouse_in.patch
Type: application/octet-stream
Size: 931 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0017.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-winemac-Add-support-for-the-WGL_WINE_surface-extensi.patch
Type: application/octet-stream
Size: 35687 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0018.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-d3d8-tests-Remove-todo_wine-from-tests-that-now-pass.patch
Type: application/octet-stream
Size: 1960 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0019.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0010-d3d9-tests-Remove-todo_wine-from-tests-that-now-pass.patch
Type: application/octet-stream
Size: 1960 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0020.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0011-ddraw-tests-Remove-todo_wine-from-tests-that-now-pas.patch
Type: application/octet-stream
Size: 3419 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20140323/885aa7a3/attachment-0021.obj>


More information about the wine-devel mailing list