Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58846
Wine D3D resets the window pixel format to its original value when an internal pixel format was requested and the context done being used, and requests the internal pixel format again before it is used again. When internal pixel format and window pixel format don't match this causes any previously created OpenGL surface with a different format to be released (and destroyed as no context is current with it), creating a new one with the new format, back and forth.
What we actually need here, is to keep the wined3d OpenGL client surface, with the internal pixel format, alive as long as it is being referenced by wined3d, as well as any OpenGL client surface that may have been created, with the window pixel format, by the application itself.
It's not possible to rely on DCs for application-created OpenGL surfaces, as the application is free to release its DC and retrieve another one later on for the same window while still expecting it to use the same OpenGL surface. However with wined3d, we know that the DCs are being kept referenced until the context is being destroyed so we can safely use them to store the wined3d OpenGL surface.
-- v3: wined3d: Remove now unnecessary pixel format restoration. win32u: Get rid of window internal pixel format. win32u: Keep internal pixel format and surfaces on the DCs. wined3d: Call wglSetPixelFormatWINE before releasing context DC.