Skip to content
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

Update 2.0-dev to Godot 4.2 + mingw support #151

Open
wants to merge 26 commits into
base: 2.0-dev
Choose a base branch
from

Conversation

vilhalmer
Copy link

With these changes, OpenVR scene applications work again in Godot 4.2. The demo is functional. Overlays do not yet work, I'll have a followup PR to fix them with some changes for how they're created and rendered as discussed in Discord.

While I was adjusting the build system to work with latest godot-cpp, I also added support for building using mingw. I can attempt to break that into a separate PR if it would be easier to review, though I did most of my testing with a mingw build because I am new to development on Windows in general and keeping my usual toolchain made progress a lot faster. There were no code changes to support this, just some new logic for scons.

I did test MSVC builds from within the Build Tools environment, but I have not tested inside the IDE. There were no significant changes to that part of the SConstruct, but testing from someone more familiar with this whole toolchain would be very welcome. The MSVC build spits out a lot of type conversion warnings which gcc does not, and I intend to continue investigating those before this is merged to make sure they're safe and/or clean them up.

I'm currently without an actual headset to do final testing after getting MSVC working again. I should have it back in a week or two, but I figured I might as well get some other eyeballs on this in the meantime.

Things I'm not sure about

  • There was some type confusion between real_t and the float types used by OpenVR. I wasn't sure which source of truth to use, so I adjusted them to match OpenVR to get things compiling. This should be revisited by someone more familiar with Godot innards.
  • I removed the bundled godot-xr-tools in favor of instructions in the README to install it from the asset library, since it isn't needed for building the extension but just for running the demo. This way we don't have to worry about keeping yet another submodule up to date. If keeping it here is desired though, I can put it back and just bring it up to date.
  • I don't fully understand the implications of linking the MSVC libc++ statically and what this means for distribution, as I'm completely new to that aspect of Windows life. I chose to match the default of godot-cpp, but am unsure why it's the default.
  • I removed Mac support entirely from the build as it was marked untested even before Valve dropped it entirely and I have no way to test it currently. Valve has reintroduced support quietly in OpenVR 2.0, but I figured it can wait until someone needs it.

Other notes

This mingw support is not the cross-compilation support from #99, this is only support for compiling for Windows within a mingw/msys2 environment on Windows. I'll work on getting cross-compilation up to date in a separate PR if everything looks good, as I'd like to be able to build my app for both platforms within a single pipeline.

I can also clean up the commit history a bit if that's desired, I was figuring things out as I went and thought it would be best to preserve my train of thought for review.

I left some TODOs in SConstruct for other things I'd like to fix up to make the build more robust, but didn't want to balloon the changes any further just yet.

This may not actually work yet, but it compiles.
I've only tested building within the msys2 UCRT env for now. Forcing
static linking for builtin_openvr=no isn't ideal but I'm not sure how to
get the DLL path without assuming it's msys2 and not just somewhere that
happens to have pkg-config. Building with an openvr submodule also
works.
Rather than get this up to date in here, just require it to be installed
separately.
Lots of broken code, but the extension loads.
I kind of guessed at these, I couldn't figure out where the old names
were defined.
Viewport is abstract and we can't inherit from it in an extension. I'm
not sure if this is the correct fix, but it was the only obvious path
forward.
This isn't really optimal, because the header name was just made up by
the msys2 project.
This works around godotengine/godot#64975 the same way as the reference
XR and TiltFive extensions.
Messed up columns/rows when making this compile again.
There's no actual openvr connection in the editor, so stop trying to
create the overlay there.
Use res:// paths to find actions within the project, and use the proper
globalizing function depending on whether we're running in the editor.
Didn't run into this earlier because I was forcing it static for all
mingw builds, now both compilers are controlled by a new build
variable. The name of the variable was chosen to match godot-cpp.

As of this commit, building with MSVC appears to be fully working. It
does produce a lot of type mismatch warnings which need to be
investigated, I'm not sure if mingw is actually producing a different
result or if it's just quieter about it.
Document new build flags (and old), remove old context about updates
within the Godot 3.x train and old OpenVR, update example GDScript. I
also added a lot of notes about requirements for successfully building
with mingw/msys2.
Building with mingw while MSVC is installed didn't actually work because
SCons generates the incorrect arguments. The easiest fix was just to do
these TODOs now.
Godot has a debug_crt flag to put this back, but it conflicts with
use_static_cpp so just punting until someone needs it.
@BastiaanOlij
Copy link
Member

There was some type confusion between real_t and the float types used by OpenVR. I wasn't sure which source of truth to use, so I adjusted them to match OpenVR to get things compiling. This should be revisited by someone more familiar with Godot innards.

This is always an annoying part of working with GDExtension. Godot internally can be compiled with double float support. real_t is simply either defined as a normal float, or double float, depending on the compiler settings.
If I'm not mistake GDExtension was written so most data going between Godot and the extension will always be using double float but it's not something I've deeply looked into myself.

Generally speaking, if it works for the downloadable version of Godot, I'm happy :)

I removed the bundled godot-xr-tools in favor of instructions in the README to install it from the asset library, since it isn't needed for building the extension but just for running the demo. This way we don't have to worry about keeping yet another submodule up to date. If keeping it here is desired though, I can put it back and just bring it up to date.

I'm happy for that change, I do have plans to change XR tools in a way that it could be submoduled, but it has some downsides to maintaining it so it's unlikely that will happen soon.

I don't fully understand the implications of linking the MSVC libc++ statically and what this means for distribution, as I'm completely new to that aspect of Windows life. I chose to match the default of godot-cpp, but am unsure why it's the default.

Honestly, don't know either, just copied from the base implementation myself.

I removed Mac support entirely from the build as it was marked untested even before Valve dropped it entirely and I have no way to test it currently. Valve has reintroduced support quietly in OpenVR 2.0, but I figured it can wait until someone needs it.

I'm surprised they re-added it as there is nothing that will be using it.. That said, OpenXR has introduced Mac support so maybe they are following suit?

@BastiaanOlij
Copy link
Member

Note that CI needs to be updated with newer versions so the build checks run through.

@vilhalmer
Copy link
Author

vilhalmer commented Apr 24, 2024

I've updated CI, though I can't guarantee it will work on the first try :)

Edit: realized I can test this out on my fork, so I'll work out any issues on a different branch there.

- Update scons to 4.x
- Bump github action versions to eliminate node 12 deprecation warning.
  v4 of the asset actions contains breaking changes, so I stopped at v3
  for now.
- Combine build steps to be platform-agnostic where possible.
- Remove dead macOS config
- Add TODOs for outstanding tech debt
@vilhalmer
Copy link
Author

There we go: https://github.com/vilhalmer/godot_openvr/actions/runs/8810090117

Apparently the action versions I updated to also throw deprecation warnings, but at least they're not... as deprecated? I'll plan on a second pass to get them to the latest versions soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants