As mentioned in https://gitlab.winehq.org/wine/wine/-/merge_requests/5264, the next step for OpenGL in the Wayland driver is support for WGL_ARB_pixel_format. It seems possible, at least in theory, to move a large part of the logic involved in this extension outside the drivers for common use by all of them (or ones that want to opt-in).
The goal of this RFC MR is, through experimentation and discussion/feedback, evaluate:
1. Whether making such functionality available outside the drivers (likely in an opt-in manner to begin with) is a productive way forward, or the complexity and platform specific decisions favor the current per-driver approach. 2. If we think that (1) is a worthy goal, what's the best mechanism to achieve it.
Note that the focus of this MR is currently on being a proof-of-concept, rather providing ready-for-detailed-review code (although I have done my best to keep the code decent). This MR currently (roughly in commit order):
* Introduces a new wgl driver callback to allow drivers to provide to opengl32/unix a list of formats and many details about them. * Uses the information in that list to implement wglGetPixelFormatAttrib*. * Uses the information in that list plus format sorting rules from WineX11 (effectively GLX rules plus tweaks) to implement wglChoosePixelFormatARB. * Implements the get_pixel_formats callback for the Wayland driver. * Hacks the get_pixel_formats callback for WineX11, and to allow me to run some experiments to compare the output of native WineX11 and get_pixel_formats-WineX11. In the admittedly not too many games I tried the sort order is the same, so at least that's encouraging.
My thoughts and notes so far:
* Using this approach for wglGetPixelFormatAttrib* works well, and we can also implement wglDescribePixelFormat in this way. * It's not at all clear what the "right" sorting rules are for wglChoosePixelFormatARB. * WineX11 uses GLX + tweaks (e.g., changes depth sorting). This means that larger formats tend to be preferred, at least according to the GLX spec. For example, asking for a r5, g6, b5 in the attributes is supposed to give back rgb888 (or even higher if available) as the top format in the list. Interestingly, and to confuse things even more, I haven't been able to make GLX return non-888(8) configs at all to actually test this more, so perhaps that's what saves it here? However, eglChooseConfig works similarly and there I was able to verify this behavior (e.g., got a nice surprise 10-bit format when asking for 5551 :)). * Winemac has its own custom logic. * Mesa's WGL implementation uses a different approach, closer to Wine's normal (wgl)ChoosePixelFormat, where proximity to the target format is strongly rewarded (so it seems asking for r5g6b5 is much more likely to actually get you that). * Of course, the "gold standard" here would be to try to infer and use the rules used by some windows driver.
Looking forward to thoughts/feedback!