ValveSoftware / Proton

Compatibility tool for Steam Play based on Wine and additional components
Other
24.65k stars 1.07k forks source link

Doom 2016 Vulkan not loading with Vega M hardware (379720) #765

Open rstrube opened 6 years ago

rstrube commented 6 years ago

Hello Everyone, I believe I've discovered a edge case bug that affects laptop users that have both an integrated GPU and a discrete GPU. In my case I have a system with a Vega M.

Current System Info: Kernel: 4.18.5 Mesa: 18.3+ GPU: AMD Vega M

Description of the Problem:

Edit: I appear to have been mistaken. The DRI_PRIME environment variable is being passed into to DOOMx64vk.exe. The issue is that when running DOOM with Vulkan (r_renderapi 1) the game does not load (stuck at 99% and menu never appears).

I'm not 100% sure what's going on, but one possibility is that DOOM is not using the discrete Vega M GPU and instead using the Intel iGPU. I tried to force the use of the Vega M GPU by:

The other possibility is that there is a bug with RADV (Mesa) on Vega M hardware with DOOM. This seems more unlikely though, as I'm able to run other games via Proton + DXVK with no problems.

When setting the following launch options: DRI_PRIME=1 %command% +r_renderapi 0 (OpenGL) The Vega M GPU is used and I have no problems - the game runs flawlessly.

If I try to run the game with the following launch options: DRI_PRIME=1 %command% +r_renderapi 1 (Vulkan) Steam first starts DOOMx64.exe with the DRI_PRIME=1 environment variable set. This exe then shuts down and the immediately starts DOOMx64vk.exe as a separate process (you can actually see this within Steam if you watch closely). When DOOMx64vk.exe is started, the context of the DRI_PRIME=1 environment variable is lost, and the game uses the integrated Intel iGPU.

I've tried creating a symlink from DOOMx64.exe to DOOMx64vk.exe to try to shortcut the execution process - but that doesn't appear to work.

whizse commented 6 years ago

You can rename or move the driver file as a a workaround. (Try moving the intel_icd* files out from /usr/share/vulkan/icd.d)

Upstream bugs: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/2600 https://bugs.freedesktop.org/show_bug.cgi?id=106187

(This is actually bug for bug compatible with the windows version!)

rstrube commented 6 years ago

Hi and thanks for the response!

I did check out those bug reports previously during my sleuthing and I did try to remove the intel_icd* files from the /usr/share/vulkan/icd.d directory. I even tried using the VK_ICD_FILENAMES environment variable to explicitly point to the radeon icd files. I should have put this in my report.

To sanity check, I just tried it again and confirmed that the problem persists. I think in this case it's really because the DRI_PRIME environment variable is not being set when DOOMx64.exe is shut down and DOOMx64vk.exe is executed.

You can observe the behavior by monitoring the processes:

  1. DOOMx64.exe (OpenGL) is started <-- DRI_PRIME=1 is passed in here!
  2. DOOMx64.exe shuts down
  3. DOOMx64vk.exe (Vulkan) is started <-- DRI_PRIME=1 is NOT passed in here!

Unfortunately the Vega M GPU will not be used unless DRI_PRIME is set to 1. I ran into the same problem with Minecraft and built a simple wrapper shell script which executed java with DRI_PRIME=1.

See here: https://www.reddit.com/r/linux_gaming/comments/90w9og/how_i_made_minecraft_work_with_discrete_gpu_prime/

I believe this is a similar problem. If steam would start DOOMx64vk.exe directly then there wouldn't be an issue.

jozefkucia commented 6 years ago

DRI_PRIME=1 is expected to work only for OpenGL. It doesn't have any effect on Vulkan.

whizse commented 6 years ago

@ rstrube You can double check if it is passed down by checking /proc/X/environ for the DOOMx64vk.exe process.

@jozefkucia radv should have support for DRI_PRIME, with a sufficiently recent Mesa release: https://cgit.freedesktop.org/mesa/mesa/commit/?id=f695735ed61ea2f11f0fdf032a8ad2c99b6b064c

rstrube commented 6 years ago

@jozefkucia - hmm that's really interesting. At least in the past when using DXVK with vanilla wine (prior to Proton), I had to set DRI_PRIME=1 in order for the Vega M to be used.

What's strange is that I've tried all the other "official" approaches that Vulkan is supposed to leverage:

But Doom still refuses to use the Vega M and instead tries to run on my Intel iGPU.

@whizse I had no idea you could do that. I'll report back.

rstrube commented 6 years ago

Here's the /proc/xxx/environ when running with OpenGL (DOOMx64.exe) Note: I tructated it because it was so long:

XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0STEAM_RUNTIME=/home/robert/.steam/ubuntu12_32/steam-runtimeUSER=robertDXVK_LOG_LEVEL=noneSteam3Master=127.0.0.1:57343KDE_SESSION_VERSION=5SteamStreamingHardwareEncodingNVIDIA=1XDG_CURRENT_DESKTOP=KDEXDG_SESSION_TYPE=x11LOGNAME=robertXDG_SEAT=seat0STEAM_COMPAT_CONFIG=noneXDG_VTNR=1HOME=/home/robertDRI_PRIME=1

...more...

PATH=/home/robert/Games/SteamLibrary/steamapps/common/Proton 3.7 Beta/dist/bin/:/home/robert/.steam/ubuntu12_32/steam-runtime/amd64/bin:/home/robert/.steam/ubuntu12_32/steam-runtime/amd64/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSTEAM_COMPAT_CLIENT_INSTALL_PATH=/home/robert/.steamSteamStreamingHardwareEncodingIntel=1__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1__GL_SHADER_DISK_CACHE_PATH=/home/robert/Games/SteamLibrary/steamapps/shadercache/379720/nvidiav1SteamClientLaunch=1SYSTEM_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSTEAM_COMPAT_DATA_PATH=/home/robert/Games/SteamLibrary/steamapps/compatdata/379720XDG_SESSION_ID=3DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-xkAKXCBpkf,guid=9feec52cccac190f1caea48c5b8406edSYSTEM_LD_LIBRARY_PATH=DEFAULTS_PATH=/usr/share/gconf/plasma.default.pathSteamAppId=379720PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socketSDL_GAMECONTROLLERCONFIG=03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1DISPLAY=:0LD_PRELOAD=:/home/robert/.steam/ubuntu12_32/gameoverlayrenderer.so:/home/robert/.steam/ubuntu12_64/gameoverlayrenderer.soDBUS_FATAL_WARNINGS=0WINEESYNC=1OLDPWD=/home/robertDXVK_HUD=devinfo,fps__GL_SHADER_DISK_CACHE_READ_ONLY_APP_NAME=steam_shader_cacheXDG_DATA_DIRS=/home/robert/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share/:/usr/share/plasma:/home/robert/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/sharePWD=/home/robert/Games/SteamLibrary/steamapps/common/DOOMTEXTDOMAINDIR=/usr/share/localeMESA_GLSL_CACHE_DIR=/home/robert/Games/SteamLibrary/steamapps/shadercache/379720SteamGameId=379720SteamUser=rds1981WINEDEBUG=-allSDL_VIDEO_X11_DGAMOUSE=0XDG_SESSION_DESKTOP=KDEXDG_CONFIG_DIRS=/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings__GL_SHADER_DISK_CACHE_APP_NAME=steamapp_shader_cacheWINELOADERNOEXEC=1%

Note that DRI_PRIME IS set = 1.

Here's the /proc/xxx/environ when running with Vulkan (DOOMx64vk.exe) Note: I tructated it because it was so long:

XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0STEAM_RUNTIME=/home/robert/.steam/ubuntu12_32/steam-runtimeUSER=robertDXVK_LOG_LEVEL=noneSteam3Master=127.0.0.1:57343KDE_SESSION_VERSION=5SteamStreamingHardwareEncodingNVIDIA=1XDG_CURRENT_DESKTOP=KDEXDG_SESSION_TYPE=x11LOGNAME=robertXDG_SEAT=seat0STEAM_COMPAT_CONFIG=noneXDG_VTNR=1HOME=/home/robertDRI_PRIME=1

...more...

PATH=/home/robert/Games/SteamLibrary/steamapps/common/Proton 3.7 Beta/dist/bin/:/home/robert/.steam/ubuntu12_32/steam-runtime/amd64/bin:/home/robert/.steam/ubuntu12_32/steam-runtime/amd64/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSTEAM_COMPAT_CLIENT_INSTALL_PATH=/home/robert/.steamSteamStreamingHardwareEncodingIntel=1__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1__GL_SHADER_DISK_CACHE_PATH=/home/robert/Games/SteamLibrary/steamapps/shadercache/379720/nvidiav1SteamClientLaunch=1SYSTEM_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSTEAM_COMPAT_DATA_PATH=/home/robert/Games/SteamLibrary/steamapps/compatdata/379720XDG_SESSION_ID=3DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-xkAKXCBpkf,guid=9feec52cccac190f1caea48c5b8406edSYSTEM_LD_LIBRARY_PATH=DEFAULTS_PATH=/usr/share/gconf/plasma.default.pathSteamAppId=379720PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socketSDL_GAMECONTROLLERCONFIG=03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,
030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1DISPLAY=:0LD_PRELOAD=:/home/robert/.steam/ubuntu12_32/gameoverlayrenderer.so:/home/robert/.steam/ubuntu12_64/gameoverlayrenderer.soDBUS_FATAL_WARNINGS=0WINEESYNC=1OLDPWD=/home/robertDXVK_HUD=devinfo,fps__GL_SHADER_DISK_CACHE_READ_ONLY_APP_NAME=steam_shader_cacheXDG_DATA_DIRS=/home/robert/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share/:/usr/share/plasma:/home/robert/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/sharePWD=/home/robert/Games/SteamLibrary/steamapps/common/DOOMTEXTDOMAINDIR=/usr/share/localeMESA_GLSL_CACHE_DIR=/home/robert/Games/SteamLibrary/steamapps/shadercache/379720SteamGameId=379720SteamUser=rds1981WINEDEBUG=-allSDL_VIDEO_X11_DGAMOUSE=0XDG_SESSION_DESKTOP=KDEXDG_CONFIG_DIRS=/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings__GL_SHADER_DISK_CACHE_APP_NAME=steamapp_shader_cacheWINELOADERNOEXEC=1WINEPRELOADRESERVE=140000000-153fe8000WINESERVERSOCKET=239%

Note that DRI_PRIME IS ALSO set = 1.

So at this point I'm at a loss as to why DOOM appears to be using the Intel iGPU!

rstrube commented 6 years ago

@whizse one thing to note there is that I'm not 100% positive DOOM using the Intel iGPU. I'm making an assumption because the game doesn't fully load (it gets to 99%) and other have reported this behavior when attempting to run DOOM using Mesa + Intel Vulkan.

As mentioned earlier, the game also runs great using Mesa + RadeonSI (OpenGL) on my Vega M.

Is there any way to confirm which GPU DOOM is using? I tried checking on the log files but nothing stuck out at me.

jozefkucia commented 6 years ago

Yes, RADV has prime support which means that it can present to a different GPU, but the DRI_PRIME variable doesn't have any effect on Vulkan.

The only reliable way to force Vulkan loader to load only RADV Vulkan driver is to set VK_ICD_FILENAMES. You may try to verify if VK_ICD_FILENAMES is set correctly using vulkaninfo. Also, VK_LOADER_DEBUG=all should show which ICD is loaded.

rstrube commented 6 years ago

@jozefkucia thanks for your response. I did some more testing by running: VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json vulkaninfo And I do indeed see that the only surface is the VEGA M

===========
VULKAN INFO
===========

Vulkan Instance Version: 1.1.70

Instance Extensions:
====================
Instance Extensions     count = 16
        VK_KHR_device_group_creation        : extension revision  1
        VK_KHR_external_fence_capabilities  : extension revision  1
        VK_KHR_external_memory_capabilities : extension revision  1
        VK_KHR_external_semaphore_capabilities: extension revision  1
        VK_KHR_get_physical_device_properties2: extension revision  1
        VK_KHR_get_surface_capabilities2    : extension revision  1
        VK_KHR_surface                      : extension revision 25
        VK_KHR_wayland_surface              : extension revision  6
        VK_KHR_xcb_surface                  : extension revision  6
        VK_KHR_xlib_surface                 : extension revision  6
        VK_KHR_display                      : extension revision 23
        VK_EXT_direct_mode_display          : extension revision  1
        VK_EXT_acquire_xlib_display         : extension revision  1
        VK_EXT_display_surface_counter      : extension revision  1
        VK_EXT_debug_report                 : extension revision  9
        VK_EXT_debug_utils                  : extension revision  1
Layers: count = 3
=======
VK_LAYER_VALVE_steam_overlay_32 (Steam Overlay Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 1
                GPU id       : 0 (AMD RADV VEGA M (LLVM 8.0.0))
                Layer-Device Extensions count = 0

VK_LAYER_VALVE_steam_overlay_64 (Steam Overlay Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 1
                GPU id       : 0 (AMD RADV VEGA M (LLVM 8.0.0))
                Layer-Device Extensions count = 0

VK_LAYER_LUNARG_standard_validation (LunarG Standard Validation Layer) Vulkan version 1.0.70, layer version 1
        Layer Extensions        count = 0
        Devices         count = 1
                GPU id       : 0 (AMD RADV VEGA M (LLVM 8.0.0))
                Layer-Device Extensions count = 0

Presentable Surfaces:
=====================
GPU id       : 0 (AMD RADV VEGA M (LLVM 8.0.0))
Surface type : VK_KHR_xcb_surface
Formats:                count = 2
        B8G8R8A8_SRGB
        B8G8R8A8_UNORM
Present Modes:          count = 3
        IMMEDIATE_KHR
        MAILBOX_KHR
        FIFO_KHR

VkSurfaceCapabilitiesKHR:
=========================
        minImageCount       = 2
        maxImageCount       = 0
        currentExtent:
                width       = 256
                height      = 256
        minImageExtent:
                width       = 256
                height      = 256
        maxImageExtent:
                width       = 256
                height      = 256
        maxImageArrayLayers = 1
        supportedTransform:
                VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
        currentTransform:
                VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
        supportedCompositeAlpha:
                VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR
                VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
        supportedUsageFlags:
                VK_IMAGE_USAGE_TRANSFER_SRC_BIT
                VK_IMAGE_USAGE_TRANSFER_DST_BIT
                VK_IMAGE_USAGE_SAMPLED_BIT
                VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT

VkSurfaceCapabilities2EXT:
==========================

        supportedSurfaceCounters:
                None

Device Properties and Extensions :
==================================
GPU0
VkPhysicalDeviceProperties:
===========================
        apiVersion     = 0x401046  (1.1.70)
        driverVersion  = 75505763 (0x4802063)
        vendorID       = 0x1002
        deviceID       = 0x694e
        deviceType     = DISCRETE_GPU
        deviceName     = AMD RADV VEGA M (LLVM 8.0.0)
        VkPhysicalDeviceLimits:
        -----------------------

I've also confirmed using /proc/xxx/environ that VK_ICD_FILENAMES has been passed into DOOMx64vk.exe. At this point perhaps we're looking at a bug specifically with Vega M hardware with RADV?

If I set the VK_LOADER_DEBUG=all environment variable - where is the log data outputted? Ideally I'd love to confirm which GPU DOOM is using - my hunch is that it's using the Intel iGPU, despite being very explicit with the VK_ICD_FILENAMES environment variable.

rstrube commented 6 years ago

@jozefkucia I've tried again using the latest beta version of Proton and I'm still having issues with Doom 2016 with Vulkan. OpenGL continues to work great.

I've done some more research and it appears that other users have also reported similar issues with Doom 2016 on Windows - for whatever reason when running Doom with Vulkan, it appears to use the Intel iGPU instead of the discrete GPU. The solution that is generally recommended is to switch back to OpenGL as the render API.

Do you have any other suggestions? I've tried using the VK_ICD_FILENAMES environment variable to no avail.

Thanks!

EDIT: here are some links related to others having problems with Doom 2016 selecting the wrong GPU when running using Vulkan.

https://steamcommunity.com/app/379720/discussions/0/1368380934274760808/ https://steamcommunity.com/app/379720/discussions/0/353915309338272544/

It almost seems like the bug is with Doom, picking the GPU in the reverse order (ID 1 instead of ID 0). Is there any way I can change the IDs of the GPUs?

jozefkucia commented 6 years ago

If VK_ICD_FILENAMES is set correctly, then VEGA M should be used. In order to confirm which Vulkan implementation is used you can try to run the game with VK_LAYER_LUNARG_api_dump: https://vulkan.lunarg.com/doc/sdk/1.1.82.1/linux/api_dump_layer.html

rstrube commented 6 years ago

@jozefkucia thanks for the information. I've actually confirmed that Doom IS using the Vega M hardware. I confirmed this by setting the VK_ICD_FILENAMES to the intel_xxx.json and running the game. Doom DOES actually run using the Intel iGPU with Vulkan, albeit at a very low framerate. Setting the VK_ICD_FILENAMES to radeon_xxx.json causes the crash to occur.

So at this point I think it's actually a bug specifically with RADV and Vega M. Perhaps I should open up an upstream bug with Mesa? Any advice on how to continue? Apologies I'm a bit out of my element here.

jozefkucia commented 6 years ago

Yes, please file a Mesa bug: https://www.mesa3d.org/bugs.html

A +vulkan log could also be useful. In order to get a +vulkan log, please add +vulkan to WINEDEBUG in user_settings.py. See https://github.com/ValveSoftware/Proton#runtime-config-options

GloriousEggroll commented 5 years ago

I just wanted to leave an update for people with this issue. I also have an amd laptop with both a vega igpu and rx 560x. There IS work currently in progress regarding this, including a PR from David Arlie:

https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1766

additionally, a quick solution exists from Feral's Alex Smith:

https://github.com/aejsmith/vkdevicechooser

Alex Smith's solutions works for me, and should work for others until Arlie's work is finished!