-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library Forwarding: Add support for 32-bit OpenGL #3630
Conversation
@@ -405,6 +405,12 @@ struct host_to_guest_convertible { | |||
{ | |||
return {static_cast<uint32_t>(from.data)}; | |||
} | |||
|
|||
// libGL also needs to allow long->int conversions for return values... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to double-check if this is still required. The other changes in Host.h may have obsoleted it.
Did some light testing.
32-bit OpenGL Linux games now crash:
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
Backtrace
32-bit Linux games that work:
|
3364954
to
ab82141
Compare
I added a patch to fix this: The |
32-Bit OpenGL Linux games: Works:
Crashes:
Misc:
Games that previously worked and still work:
Looking pretty interesting. |
bf8dff3
to
70a38e8
Compare
More 32-bit games tested:
I couldn't reproduce the Psychonauts crash on either X11 or XWayland, so I'm inclined to merge the PR as-is and debug that crash another time. (For future reference, the intro sequences can be skipped by renaming some of the files in the game's movies folder) All main TODOs have been addressed then. I'll tidy up the commit history after approval since it's clean enough for review. |
70a38e8
to
7a703e1
Compare
Overview
This PR adds support for forwarding the overwhelming majority of the OpenGL API to the host driver for 32-bit applications. Previously, this was exclusively possible for 64-bit titles.
This work is enabled by #3584, thanks to which forwarding OpenGL calls to the host does not require forwarding libX11 calls anymore. We can now tick off the last critical box in the Library Forwarding Roadmap:
That leaves only 32-bit Vulkan applications and OpenGL-on-Wayland unsupported. The former is barely used in the wild, and the latter is also still uncommon in practice. (Note that due to putting #3487 on hold, the phase numbering is off)
Implementation
thunkgen
has caught all APIs that are problematic with regards to 32-bit support:size_t
/intptr_t
(only in-parameters)char**
(only in-parameters)void**
(only out-parameters)The first two cases are handled by relocating the data element-by-element (onto the stack). The last case only occurs in APIs that write a single pointer to a user-provided destination and is easily handled without overhead.
Other errors raised by
thunkgen
refer to unannotatedvoid*
pointers. Since these are very common in the OpenGL API but always refer to data of consistent layout, an escape hatch is added to ignore errors fromvoid*
specifically.Limitations
A small number of vendor-specific functions is currently not implemented on 32-bit, simply because exhaustively doing so is tedious busy-work that I couldn't verify the results of for lack of corresponding hardware. If individual functions are considered critical, adding support for them should be easy though.
Testing
I only have few 32-bit OpenGL applications in my library, so further testing will be needed in addition to these
Testing round 2:
Testing round 3:
TODO
alloca
is suitable in all instances (should be fine, since thecount
parameters should never be huge)