mbucchia / VirtualDesktop-OpenXR

An implementation of the OpenXR standard for Virtual Desktop
MIT License
209 stars 7 forks source link

How to develop against VirtualDesktop-OpenXR (i.e. connect an IDE launched application to it) #37

Closed oneMillionWorlds closed 3 months ago

oneMillionWorlds commented 3 months ago

When I'm developing against SteamVR my workflow is as follows:

What would be the equivalent of that with VirtualDesktop-OpenXR? In particular how do I get it in a running and waiting state? I think the instructions imply it will be launched along with the application when the OpenXR Runtime is set to VDXR but I don't think that will work when Virtual Desktop is unaware my application exists and I'm going to be launching it separately.

(I don't think it matters but my application is a Java OpenXR application launched from IntelliJ)

mbucchia-msft commented 3 months ago

but I don't think that will work when Virtual Desktop is unaware my application exists

That won't matter actually. If you choose VDXR as OpenXR runtime the Virtual Desktop settings (or using the OpenXR runtime picker of your choice), the runtime will be set system-wide. Any OpenXR application run in any way (even outside of the Virtual Desktop Games tab) will use it.

oneMillionWorlds commented 3 months ago

Hmm, I now realise it does actually behave differently when Virtual Desktop is connected in VDXR mode and not connected at all, so it is trying to talk to VDXR just an error occurs. Thanks!

OpenXR.log

When in VDXR mode the call XR10.xrEndFrame returns a nice super generic XR_ERROR_RUNTIME_FAILURE but the virtual desktop OpenXR logs are slightly more helpful

2024-03-12 17:57:33 +0000: VirtualDesktopXR - v1.0.2 (C:\Program Files\Virtual Desktop Streamer\OpenXR)
2024-03-12 17:57:33 +0000: Application: Tamarin OpenXR Example (java.exe); Engine: 
2024-03-12 17:57:33 +0000: Requested extension: XR_KHR_opengl_enable
2024-03-12 17:57:33 +0000: Requested extension: XR_EXT_hand_tracking
2024-03-12 17:57:33 +0000: Using Virtual Desktop runtime
2024-03-12 17:57:33 +0000: Streamer: 1.30.1
2024-03-12 17:57:33 +0000: OVR: 1.64.0
2024-03-12 17:57:33 +0000: Device is: Oculus Quest2 (20)
2024-03-12 17:57:33 +0000: Using OpenGL on adapter: NVIDIA GeForce RTX 3070 Laptop GPU
2024-03-12 17:57:33 +0000: Recommended resolution: 2016x2112
2024-03-12 17:57:34 +0000: xrEndFrame: OpenGL error: 0x502
    Origin: error == GL_NO_ERROR
    Source: D:\a\VirtualDesktop-OpenXR\VirtualDesktop-OpenXR\virtualdesktop-openxr\utils.h:350
2024-03-12 17:57:34 +0000: xrEndFrame failed with XR_ERROR_RUNTIME_FAILURE

Not really sure what that means although I have had problems before with SteamVR being more permissive of technically wrong things than other runtimes.

This is the call (in the Tamarin library) that upsets it

        checkResponseCode(XR10.xrEndFrame(
                xrSession,
                XrFrameEndInfo.malloc(stack)
                        .type$Default()
                        .next(NULL)
                        .displayTime(continuation.getPredictedDisplayTime())
                        .environmentBlendMode(xrSettings.getXrVrMode().getXrValue())
                        .layers(didRender ? layers : null)
                        .layerCount(didRender ? layers.remaining() : 0)
        ));
mbucchia-msft commented 3 months ago

OpenGL support isn't very well tested. 0x502 is GL_INVALID_OPERATION, which could be a few things. It's probably easier to send me the app (even compiled) to investigate.

mbucchia-msft commented 3 months ago

Actually - could you try using Virtual Desktop Beta (1.30.3)? It has a fix for an OpenGL issue that might be the same you are having. You can find instructions in the Virtual Desktop Discord.

oneMillionWorlds commented 3 months ago

Nice! The 1.30.3 beta boots up correctly! Thank you

oneMillionWorlds commented 3 months ago

Incidentally I really like the lightweightness of VDXR. The way SteamVR would boot into home (which seems to be really resource intensive and revs up my fans to maximum) was really annoying for development. I think VDXR's hands off approach is much better.