ValveSoftware / SteamVR-for-Linux

Issue tracker for the Linux port of SteamVR
930 stars 45 forks source link

Codes4Fun/RBDOOM-3-BFG segfault #65

Closed ChristophHaag closed 7 years ago

ChristophHaag commented 7 years ago

Your system information

Please describe your issue in as much detail as possible:

Code from this repository: https://github.com/Codes4Fun/RBDOOM-3-BFG/ build with cd neo; cmake .; make start ./RBDoom3BFG segfault:

Thread 1 "RBDoom3BFG" received signal SIGSEGV, Segmentation fault.
0x00007f3b36363b41 in GetExtensionsAsVector(char const*, unsigned int, std::vector<std::string, std::allocator<std::string> >&) [clone .constprop.25] ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
(gdb) bt
#0  0x00007f3b36363b41 in GetExtensionsAsVector(char const*, unsigned int, std::vector<std::string, std::allocator<std::string> >&) [clone .constprop.25] ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#1  0x00007f3b3636441e in BInitVulkanInstance(char const*, unsigned int, bool, VkInstance_T**) ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#2  0x00007f3b3634557a in CVRCompositorSharedTextures::GetDevice(vr::Texture_t const*, vr::EVRSubmitFlags, void**) ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#3  0x00007f3b36346bab in CVRCompositorSharedTextures::UpdateTextureSet(CVRCompositorSharedTextures::Params const*, VRCompositorState_TextureSet_t*) ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#4  0x00007f3b3634075d in CVRCompositorClient::Submit(vr::EVREye, vr::Texture_t const*, vr::VRTextureBounds_t const*, vr::EVRSubmitFlags) ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#5  0x00007f3b36302225 in CVRCompositor_017::Submit(vr::EVREye, vr::Texture_t const*, vr::VRTextureBounds_t const*, vr::EVRSubmitFlags) ()
   from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrclient.so
#6  0x0000000000859075 in VR_PreSwap(unsigned int, unsigned int) ()
#7  0x0000000000858414 in RB_StereoRenderExecuteBackEndCommands(emptyCommand_t const*) ()
#8  0x000000000085920f in RB_ExecuteBackEndCommands(emptyCommand_t const*) ()
#9  0x00000000007c4880 in idRenderSystemLocal::RenderCommandBuffers(emptyCommand_t const*) ()
#10 0x000000000069431e in idCommonLocal::RenderSplash() ()
#11 0x000000000069543b in idCommonLocal::Init(int, char const* const*, char const*) ()
#12 0x0000000000da173c in main ()

The same code has worked in earlier SteamVR versions, see https://github.com/Codes4Fun/RBDOOM-3-BFG/issues/83#issuecomment-284226159

ChristophHaag commented 7 years ago

Didn't actually compile with latest gcc, so I used clang: CXX=clang++ cmake .

danginsburg commented 7 years ago

Can you post ~/.steam/steam/logs/vrclient_RBDoom3BFG.txt to a gist?

ChristophHaag commented 7 years ago

It's not so long.

Wed Jul 19 2017 01:23:58.544735 - //=====================================================================================================================
Wed Jul 19 2017 01:23:58.544770 - vrclient startup with PID=13229, type=VRApplication_Scene, config=/home/chris/.local/share/Steam/config/
Wed Jul 19 2017 01:23:58.545325 - [Settings] Load Default Json Settings from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545381 - [Settings] Load Default Json Settings from /home/chris/build/OpenVRCardBoard/VirtualCheap/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545403 - [Settings] Load Default Json Settings from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/drivers/htc/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545419 - [Settings] Load Default Json Settings from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/drivers/lighthouse/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545462 - [Settings] Load Default Json Settings from /usr/lib/openvr/osvr/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545500 - [Settings] Load Default Json Settings from /home/chris/.local/share/Steam/SteamApps/common/SteamVR/drivers/null/resources/settings/default.vrsettings
Wed Jul 19 2017 01:23:58.545734 - [Settings] Load Json Settings from /home/chris/.local/share/Steam/config/steamvr.vrsettings
Wed Jul 19 2017 01:23:58.556890 - CIPCPipe::ConnectPipe(VR_ServerPipe_28295) attempting bind to 32855
Wed Jul 19 2017 01:24:04.058813 - Received success response from vrserver connect
Wed Jul 19 2017 01:24:04.060591 - CIPCPipe::ConnectPipe(VR_CompositorPipe_28295) attempting bind to 42183
Wed Jul 19 2017 01:24:04.060714 - Received success response from vrcompositor connect
Wed Jul 19 2017 01:24:04.072807 - Started /home/chris/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrdashboard with pid 13292
Wed Jul 19 2017 01:24:04.085842 - [Chaperone] Universe changed from 0 to 1498856523.
Wed Jul 19 2017 01:24:05.019806 - Capturing Scene Focus
Wed Jul 19 2017 01:24:05.019891 - No GPU timing Vulkan device in CVRCompositorSharedTextures::StartGPUTimingCommandBuffer!
Wed Jul 19 2017 01:24:05.019903 - No Vulkan command buffer open in CGpuTiming::MarkEvent!
Wed Jul 19 2017 01:24:05.019909 - No command buffer in flight in CVRCompositorSharedTextures::FinishOpenCommandBuffer!
Wed Jul 19 2017 01:24:05.025254 - Disabling advanced image processing of scene textures. Only enabled on latest OSs.
danginsburg commented 7 years ago

I tried this with lostgoat's wip-mem-obj-v4, but the vrcompositor fails to start. The problem is that we switched SteamVR to require the KHR external memory extensions, specifically: VK_KHR_external_memory, VK_KHR_external_memory_fd, VK_KHR_dedicated_allocation, VK_KHR_get_memory_requirements2 which are not on the wip-mem-obj-v4 branch. Can you test with https://github.com/airlied/mesa/tree/radv-wip-steamvr-master and at least confirm that is working for you? That branch has those extensions.

Unfortunately, the radv-wip-steamvr-master branch does not have the OpenGL interop extensions which it looks like is what you are wanting to test. What you need is the radv-wip-steamvr-master branch + lostgoat's OpenGL interop extensions.

danginsburg commented 7 years ago

Also, for the record, I know you are not on NVIDIA but 381.26.08 is required on NVIDIA to get the new KHR extensions + GL interop.

ChristophHaag commented 7 years ago

I have those two branches merged (https://github.com/ChristophHaag/mesa-mesa/commits/master).

SteamVR home etc. works. Vivecraft is actually playbable now.

danginsburg commented 7 years ago

OK, so OpenGL interop is working for you in general, but not RBDoom3BFG? I'll need to get that to try to repro.

ChristophHaag commented 7 years ago

It's not directly related to this bug report, but maybe still useful for testing:

ChimeraX is a closed source OpenGL application. It works, but runs at like 5 fps, though that might be the application's fault. https://www.rbvi.ucsf.edu/chimerax/download.html / https://www.rbvi.ucsf.edu/chimerax/docs/user/vr.html

JanusVR is a closed source OpenGL application. It renders garbage in the right eye, but the left eye works with good performance. In the past it has rendered both eyes correctly, but back then of course very slow. www.janusvr.com/download.php

Vivecraft seems to fully work and runs relatively smoothly, but still slightly stutters.

danginsburg commented 7 years ago

I'm still trying to understand the problem and what RBDoom3BFG is doing to trigger it, but I do have a workaround. What is happening is that inside of steamvr when we call vkEnumerateInstanceExtensionProperties to determine the list of instance extensions supported by the Vulkan driver, for some reason the libvulkan.so.1 in the steam-runtime is not returning all of the extensions. This is odd, because it seems to work fine on other applications I've tried, so I'm not sure what about Doom 3 is triggering the problem yet.

However, one thing you can do is download https://vulkan.lunarg.com/sdk/home#sdk/downloadConfirm/1.0.54.0/linux/vulkansdk-linux-x86_64-1.0.54.0.run

Unzip it to a directory, then put at the front of your LD_LIBRARY_PATH something like:

LD_LIBRARY_PATH=/path/to/VulkanSDK/1.0.54.0/x86_64/lib:

This gets me further, although I'm getting a bunch of errors during startup about GLSL 1.50 not being supported so it's just rendering black, but it avoids the crash.

ChristophHaag commented 7 years ago

I think it was working with MESA_GL_VERSION_OVERRIDE=4.5COMPAT MESA_GLSL_VERSION_OVERRIDE=450 ./RBDoom3BFG

danginsburg commented 7 years ago

Actually, digging into this more, I think I have a handle on the problem. The issues are:

  1. We need to update the vulkan loader in the steam-runtime to v1.0.54.0 in order for VK_KHR_external_memory_capabilities and VK_KHR_external_semaphore_capabilities to be exposed. This can be demonstrated by running:
  LD_LIBRARY_PATH=~/.steam/steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/ vulkaninfo

which you will notice does not end up including VK_KHR_external_memory_capabilities and VK_KHR_external_semaphore_capabilities in the list of "Instance Extensions".

  1. All OpenGL applications are actually hitting this bug, but it crashes in BFGDoom3 due to a nullptr access that other applications were just getting lucky about. This is a steamvr bug I have a fix for.

In the meantime, both problems can be worked around by the aforementioned use of the 1.0.54.0 vulkan loader in your LD_LIBRARY_PATH, but I'll work on getting these two issues fixed and pushed out.

Unfortunately I missed this because when I was testing vrclient with validation I had been using the v1.0.54.0 SDK so the extensions were getting exposed for me.

danginsburg commented 7 years ago

Using MESA_GL_VERSION_OVERRIDE=4.5COMPAT MESA_GLSL_VERSION_OVERRIDE=450 I do see a brief loading screen in the HMD but then black.

ChristophHaag commented 7 years ago

It actually works. while the menu is shown in the preview window, nothing is displayed in the hmd. you have to navigate witha combination of mouse input and the hmd orientation to the menu in the preview window and start a game. Then it works.

danginsburg commented 7 years ago

Yeah, OK, I figured that out. I was able to navigate the menu and start a new campaign but didn't actually get into the game. Seemed to be working well up until that point.

(Edit: nevermind, had to click on the window...running now)

ChristophHaag commented 7 years ago

Started with MESA_GL_VERSION_OVERRIDE=4.5COMPAT MESA_GLSL_VERSION_OVERRIDE=450 LD_LIBRARY_PATH=/home/chris/VulkanSDK/1.0.54.0/x86_64/lib ./RBDoom3BFG the game works for me.

Performance is not great though. screenshot_20170719_152839

danginsburg commented 7 years ago

OK, you can file a separate issue on perf if you think there's an issue there. On RX 480 I've found I've needed to do this to get performance with VR otherwise it downclocks:

sudo echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level

I'll note that mesa is currently missing the GL interop semaphore extensions which should help performance some by avoiding a glFinish() during the Submit() call. The support is there in SteamVR and works on NVIDIA, the extensions are still being worked on for mesa.

ChristophHaag commented 7 years ago

Yes, I'm running with dpm on high and also the cpu governor on performance.

There's already https://github.com/ValveSoftware/SteamVR-for-Linux/issues/23 but let's wait until everything is implemented. Afaik only the kernel patch and libdrm patch are on the mailing lists and the radv integration hasn't been written yet.

danginsburg commented 7 years ago

@ChristophHaag I was trying to look into the right eye corruption in JanusVR, but can't figure out how to launch it to use the Vive. Can you post repro instructions?

danginsburg commented 7 years ago

Regarding ChimeraX, the application is GPU limited. If you do "lighting simple" prior to "vr on" it runs at 90hz.

ChristophHaag commented 7 years ago

You're right, ChimeraX runs perfect with "lighting simple". Thanks for checking.

JanusVR uses steamvr when I just run it as ./janusvr with nothing else. Possibly ./janusvr -render vive does the trick. It comes with its own libopenvr_api.so and all, so I don't see an obvious reason why it wouldn't work.

danginsburg commented 7 years ago

The issue with janusvr was that I couldn't run it from the steam-runtime and vrclient.so depends on libudev.so.0 which was not on my system. Installing that corrected it, I've repro'd the right eye bug.

beniwtv commented 7 years ago

I noticed some jerkyines on OpenGL applications still as well - also have an RX480. Might be because of that lostgoat's wip-mem-obj-v4 branch I'm missing here.

Vulkan does work fine as of semi-latest (need to update, my build is a few days old) Mesa-Master Git (no special branches or merges) and latest SteamVR, without any perf overrides, at least on Serious Sam: First encounter HD and on SteamVR Home.

ChristophHaag commented 7 years ago

Without the wip-mem-obj-v4 branch, OpenGL applications should not be just a bit jerky, but really, really bad.

Anyway, if you have at least 4.13-rc1 and the latest libdrm, you can use https://github.com/airlied/mesa/commits/radv-wip-shared-sem to get a proper implementation of VK_KHR_external_semaphore.

The default summit pavillion in SteamVR Home is working okay, but is very gpu intensive, reprojection is always on and just rotation the head left and right for a while shows short freezes every couple of seconds, I'm guessing this is because the gpu load is so high, so I'm hoping once we have high priority rendering this will be much better.

Speaking of high load, wow, Vivecraft is much more cpu and gpu intensive than I thought it should be. screenshot_20170721_103122

danginsburg commented 7 years ago

This bug has morphed into a bunch of issues, but the next SteamVR Beta update will have the following fixes from this bug:

If you guys have other issues with other apps, please open a new issue so they can be tracked separately. Thanks @ChristophHaag for the great bug reporting. I'll keep this one open until the next SteamVR beta update ships.

danginsburg commented 7 years ago

The fixes for the issues here are in the latest SteamVR Beta update: http://steamcommunity.com/games/250820/announcements/detail/1423552564379225564

ChristophHaag commented 7 years ago

It does. It also fixes some corruption in Vivecraft, the dialog box over the left controller "look around etc." was corrupted before, now it's fine. Thanks.