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

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

vilhalmer
Copy link
Collaborator

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.

@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
Collaborator 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.

@vilhalmer
Copy link
Collaborator 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.

@fire
Copy link

fire commented Sep 23, 2024

What is blocking this from merge?

@vilhalmer
Copy link
Collaborator Author

I haven't been pushing on it because I'm taking my time with the followups to make sure I haven't made any terrible API decisions, but I think this one is ready. I think Bastiaan just has a lot of higher priority projects :)

I'll take a look and see if there are any stray commits I should tack on here in the next day or two.

@BastiaanOlij
Copy link
Member

Having browsed through the changes I don't see anything that stands out to me as wrong. If other can test this and verify it is working as expected, I'm more than happy to merge this in.

@BastiaanOlij
Copy link
Member

Once we do I think we also need to spend some time rejigging the branches. The master branch should probably be renamed to 3.x, while the 2.0-dev branch becomes our master branch.

@fire
Copy link

fire commented Sep 24, 2024

implications of linking the MSVC libc++ statically

If we can avoid the microsoft redistributable it means that game player don't need to install https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

@fire
Copy link

fire commented Oct 2, 2024

How did it go?

@vilhalmer
Copy link
Collaborator Author

I didn't find anything additional that should go in here, it should be good for people to test.

@fire
Copy link

fire commented Oct 3, 2024

In Godot Engine main we tend rebase and squash all commits into one, but not sure about GodotVR/godot_openvr.

I would like squashing.

@vilhalmer
Copy link
Collaborator Author

I've just left it for review purposes since Github offers the option at merge time, but if that's not enabled on this repo I'll definitely squash. Might keep the build work in a separate commit.

@fire
Copy link

fire commented Oct 3, 2024

I had to pull the branch onto my fork to be able to build since all the builds expired. https://github.com/V-Sekai/godot_openvr/tree/2.0-dev-overlays

@fire
Copy link

fire commented Oct 3, 2024

Test plan:

  1. Open godot 4.3 from steam
  2. Load windows test project. Ignoring linux...
  3. If openvr load I'll report back. Not overly concerned about one frame delay or whatever since openvr isn't in godot 4.

@fire
Copy link

fire commented Oct 3, 2024

The github actions only provide openvr_api.dll on Windows which makes testing harder.

@fire
Copy link

fire commented Oct 3, 2024

I had some trouble building for Godot Engine 4.3 so I rewrote the scons script rushed. Did not upgrade the demo project. Did not restore linux. Did not restore mingw.

https://github.com/V-Sekai/godot_openvr/tree/2.0-dev-overlays-4.3-stable

image

Note: took pieces from https://github.com/godotengine/godot-cpp-template

@vilhalmer
Copy link
Collaborator Author

I'll take a look at your changes tomorrow and see if I can figure out what's wrong in my version. I admittedly have never compiled it with a full Visual Studio environment, because I was specifically avoiding setting one up. I had it building with the bare tools installed via winget, but I haven't tried it again since I got it working.

I want to do a lot of scons cleanup, but i was trying to avoid doing any more than I already did here. Maybe it would be better to just drop my build changes here and introduce a new PR for that once I have it reconciled.

@vilhalmer
Copy link
Collaborator Author

Sorry for the delay, Friday ended up being a very different day than I had planned.

I had some trouble building for Godot Engine 4.3 so I rewrote the scons script rushed. Did not upgrade the demo project. Did not restore linux. Did not restore mingw.

Can you share the errors and some info about your build environment? Is it Visual Studio?

@fire
Copy link

fire commented Oct 7, 2024

I won’t be able to check for the next week but my goal is mingw, msvc and linux gcc and linux clang.

@vilhalmer
Copy link
Collaborator Author

vilhalmer commented Oct 7, 2024

Ok, some errors had crept in with my local code that aren't present in this branch, but when I check out this branch I'm able to run scons without any arguments with a local openvr checkout and get a build with the MSVC toolchain (warnings trimmed out):

>> scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc/register_types.obj /c src/register_types.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
cl /Fosrc/xr_interface_openvr.obj /c src/xr_interface_openvr.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
xr_interface_openvr.cpp
cl /Fosrc/open_vr/OpenVROverlay.obj /c src/open_vr/OpenVROverlay.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
cl /Fosrc/open_vr/OpenVRRenderModel.obj /c src/open_vr/OpenVRRenderModel.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
cl /Fosrc/open_vr/OpenVRSkeleton.obj /c src/open_vr/OpenVRSkeleton.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
OpenVRSkeleton.cpp
cl /Fosrc/open_vr/openvr_data.obj /c src/open_vr/openvr_data.cpp /TP -std:c++17 /nologo -W3 -GR -O2 -EHsc -DNDEBUG -MT /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /DTYPED_METHOD_BIND /I. /Isrc /Isrc/open_vr /Igodot-cpp/gdextension /Igodot-cpp/include /Igodot-cpp/gen/include /Iopenvr/headers
link /nologo openvr_api.lib /dll /out:demo/addons/godot-openvr/bin/win64/libgodot_openvr_release.dll /implib:demo/addons/godot-openvr/bin/win64/libgodot_openvr_release.lib /LIBPATH:godot-cpp/bin /LIBPATH:openvr/lib/win64 libgodot-cpp.windows.template_release.x86_64.lib src/register_types.obj src/xr_interface_openvr.obj src/open_vr/OpenVROverlay.obj src/open_vr/OpenVRRenderModel.obj src/open_vr/OpenVRSkeleton.obj src/open_vr/openvr_data.obj
   Creating library demo/addons/godot-openvr/bin/win64/libgodot_openvr_release.lib and object demo/addons/godot-openvr/bin/win64/libgodot_openvr_release.exp
Copy("demo/addons/godot-openvr/bin/win64/openvr_api.dll", "openvr/bin/win64/openvr_api.dll")
scons: done building targets.

I'm using the standalone build tools from here.

I won’t be able to check for the next week but my goal is mingw, msvc and linux gcc and linux clang.

Were you building with scons use_mingw=true? I found a bug with mingw + use_static_cpp just now which I'll push a fix for, it wasn't working unless you also used builtin_openvr=false.

@fire
Copy link

fire commented Oct 8, 2024

That sounds great. I will be traveling soon so I might not able to test.

scons use_mingw=true

Please do.

@fire
Copy link

fire commented Oct 17, 2024

I'm back, what do we need to do?

@vilhalmer
Copy link
Collaborator Author

If you could provide as much detail about your build environment as possible, that would be great. I want to be able to reproduce the issue locally and make sure I have automated builds that check everything works in the future.

@fire
Copy link

fire commented Oct 23, 2024

It's fully compiled for me, but I don't have a test project that operates steamvr.

@vilhalmer
Copy link
Collaborator Author

That doesn't help me though since you compiled it by throwing out the entire build system 😅

@fire
Copy link

fire commented Oct 23, 2024

Perhaps you can get it to build on github actions?

@vilhalmer
Copy link
Collaborator Author

I'm asking for details about your environment because it has a known failure with my code that I am trying to merge in this PR. This seems like a basic debugging step to ensure that others will actually be able to build.

@BastiaanOlij
Copy link
Member

I'm more than happy to follow your lead on this. I don't have the time to give this a proper test myself but if at least two people can confirm the OpenVR plugin is working for them in Godot 4.x I'm happy to merge this if the CI clears.

I also suggest that after that, I do a bit of git-fu and change the current master branch to a 3.x branch for legacy, and change the 2.0-dev branch to become the new master.

@BastiaanOlij
Copy link
Member

Also @fire thanks for the ping! I wouldn't have caught the updates otherwise.

@fire
Copy link

fire commented Oct 24, 2024

My criteria for merging would be for two people to:

  • confirm the OpenVR plugin works on godot stable
  • confirm the OpenVR plugin works on godot master
  • pick a demo any demo and run it with success. Report back.
  • Must be able to display on steamvr
  • Must be able to load gdextension without crash
  • Ignore minor problems.

@fire
Copy link

fire commented Oct 24, 2024

I have an minimal openxr demo from godotengine/godot#97907.

https://github.com/user-attachments/files/17271320/demo-bug.zip we may also modify this if it's easier than modifying xr tools

@vilhalmer
Copy link
Collaborator Author

I also have at least four more PRs worth of work once this first bit is done, so if we want to wait a little longer before converting 2.0-dev to master we can get some feedback on some breaking API changes before calling 2.0 "done".

@fire
Copy link

fire commented Oct 24, 2024

We can do the whole alpha, beta, rc thing if you want. It's not really necessary but we can do it as an aid.

@vilhalmer
Copy link
Collaborator Author

vilhalmer commented Oct 24, 2024

Nah, I don't think we need to go that far. I'll get everything else I have outstanding posted in parallel (as much as possible) after this is in and we can figure out our strategy then.

Your merge criteria seem reasonable to me, now we just need to find one more person :D

@BastiaanOlij
Copy link
Member

You'll always need to tweak a demo a little because OpenXRs action map system is fairly different to OpenVRs one implementation wise. BUt other than that agree with Fires list of tickboxes.

And indeed, I don't think we need to go through a whole alpha/beta/whatever release thing. The audience isn't big enough to make that worth the effort.

After things are merged and we change over the branches, we can look into doing a release and if more issues are found, they will just become patch releases with fixes.

@vilhalmer
Copy link
Collaborator Author

@BastiaanOlij do you want me to manually squash this, or does this repo have the automatic squash on merge enabled?

@fire
Copy link

fire commented Oct 24, 2024

The general godot policy is the pull request maker squashes.

@fire
Copy link

fire commented Nov 5, 2024

Can you squash?

@vilhalmer
Copy link
Collaborator Author

I could, but we still want another person to test it and there will be at least one more change to fix the issue you pointed out with github actions. Every change to this branch is a bunch of work on my end to keep downstream branches updated, is it really needed to do it right this second? I promise I'm not going to forget to do it before we merge.

(Sorry for the delay, last week was chaotic.)

@fire
Copy link

fire commented Nov 11, 2024

sorry! haven't been able to test. is there a ready to use example to send to my friends for testing

@vilhalmer
Copy link
Collaborator Author

vilhalmer commented Nov 11, 2024

I'll try to get actions packaging up the extension correctly, then the demo project in this repo should be runnable by replacing demo/addons/godot-openvr with the downloaded artifacts.

(But if your friends don't mind compiling code, it should Just Work™ after a build because the results go into the demo project by default.)

@fire
Copy link

fire commented Nov 11, 2024

I couldn't package the extension correctly, and the demo wasn't set up. Sorry!

@vilhalmer
Copy link
Collaborator Author

Ok, I think CI is producing the whole addon correctly now. Here's a run where I hacked it to produce the final zip file for non-master: https://github.com/vilhalmer/godot_openvr/actions/runs/11785210944
And here's the resulting "release": https://github.com/vilhalmer/godot_openvr/releases/tag/8f082d6

And the results of the code that's actually committed, skipping the release artifact correctly but still producing the intermediate platform-specific artifacts: https://github.com/vilhalmer/godot_openvr/actions/runs/11785458499

the demo wasn't set up

As noted in the readme I removed the xr tools from the repo so they need to be installed from the asset library. I'll flesh out that section a bit more to explain where to download the built addon.

@fire
Copy link

fire commented Nov 11, 2024

I'm a bit delayed, but I'll check as soon as I can.

@fire
Copy link

fire commented Nov 13, 2024

Can you package xr tools by downloading an exact version https://github.com/GodotVR/godot-xr-tools by commit zip?

image

@vilhalmer
Copy link
Collaborator Author

I guess we could do that, I removed it because it's not actually needed for anything but the demo and most people will care about the demo once at most. @BastiaanOlij do you have an opinion about this? I'd almost be tempted to rework the demo to just not use it, simpler seems better so people don't get the components mixed up when they're new to all this.

@BastiaanOlij
Copy link
Member

I guess we could do that, I removed it because it's not actually needed for anything but the demo and most people will care about the demo once at most. @BastiaanOlij do you have an opinion about this? I'd almost be tempted to rework the demo to just not use it, simpler seems better so people don't get the components mixed up when they're new to all this.

I'd say the simpler we keep it, the better. We can always refer to XR tools in the documentation as a suggestion.

@fire
Copy link

fire commented Nov 15, 2024

It was work, but I could assemble the package and test it.

  1. Download the cicd zip.
  2. .gdextension must reference release on windows debug
  3. had to copy the executable and combine it with the source code zip demo folder
  4. had to copy xr tools
  5. xr tools must be on
  6. doubles build is missing
  7. must start the editor twice due to 4.3 stable bug with gdextension

https://github.com/V-Sekai/godot_openvr/releases/download/v2.0-dev-godot4.2/demo.zip

image

@BastiaanOlij
Copy link
Member

I think all those things can be addressed separately. I'm happy to merge this.

- Update godot-cpp to track 4.2
- Update openvr to 2.0.10
- Remove bundled godot-xr-tools
- Remove support for MacOS, never tested and long broken
- Update gdextension interface for changes in godot 4.1
- Support finding system-installed libopenvr on platforms with
  pkg-config
- Support for mingw in build using tunabrain-patched openvr header
- Add autoload singleton to register XR interface with server
  - This works around godotengine/godot#64975 the same way as the
    reference XR and TiltFive extensions.
- Default to static libc++ to match godot-cpp
- Remove CRT debug flag to match godot and godot-cpp
- Update CI to publish gdextension artifacts correctly
@vilhalmer
Copy link
Collaborator Author

Squashed!

@fire
Copy link

fire commented Nov 18, 2024

@BastiaanOlij let's do it.

@BastiaanOlij BastiaanOlij merged commit 838f8ff into GodotVR:2.0-dev Nov 18, 2024
4 checks passed
@BastiaanOlij
Copy link
Member

Merged, and I renamed the branches so you'll have to do a full reset of your local master branch and do a forced push to your fork.

@vilhalmer
Copy link
Collaborator Author

Thank you! More to come very 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.

3 participants