-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
steam/fhsenv: reorder and fix VK_ICD_FILENAMES #126435
Conversation
While you’re at it, could you also add |
835dd43
to
446725f
Compare
Thanks! I just thought about it, this makes the nvidia and amd drivers a dependency of steam, so people with only an intel GPU will still need to download them (and both are not exactly tiny). I am a bit surprised that setting On a sidenote, I often set |
Hmm, that's true. Maybe it's possible to conditionally set VK_ICD_FILENAMES depending on the contents of I'm not sure why VK_ICD_FILENAMES is necessary, but I'm assuming it's for the pressure-vessel fixes, in which case I don't want to mess with it too much. EDIT: |
A weird side effect I just noticed when trying to play Hades (one of the only Vulkan-native games i own), it seems to use my nvidia gpu regardless of the nvidia prime environment variables (running on an optimus laptop). |
Yes, that's what I was thinking, and just start from most specific to least specific. Just reording the items may cause issues for other users. I'll try to cook something up after work cc @nh2 |
Result of 3 packages built:
|
This pr fixes the problem I have where for some reason my nvidia icd files aren't present in /usr/share/vulkan/icd.d at all which causes some games to not work at all |
nixos/modules/programs/steam.nix
Outdated
@@ -44,7 +44,14 @@ in { | |||
|
|||
hardware.steam-hardware.enable = true; | |||
|
|||
environment.systemPackages = [ steam steam.run ]; | |||
environment.systemPackages = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just inline this overriding into the derivation for the FHSEnv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because (at least, i think) the config
attributes (like config.hardware.nvidia.package
) can't be referred to from within packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you can't do that, but if the ICD files are similar/identical for all Nvidia driver packages, then you could use a generic one in the FHS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the ICD files are similar enough to do that; my reasoning is a bit anecdotal as im not entirely sure of how this works, but using a different version of the nvidia driver (nvidiaBeta or nvidiaVulkanBeta) caused proton/dxvk to throw errors and not work for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked, and yeah, they look similar but they point to different store paths, so it wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I'm not using Nvidia on my system? Will this then pull in Nvidia drivers even though I don't use them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im actually not sure how the fhsenv gets the ICD files to use. If i knew that, i think i could come up with a better/cleaner solution.
as for pulling in nvidia, i think it will... i'm unsure how else to handle it other than a manual switch to toggle it on, but that then adds another toggle on top of enabling the steam module for nvidia users, or a switch to toggle it off for non-nvidia users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, the icd
files you have are driver-specific, and are currently in /run/opengl-driver/share/...
.
I took a look at this, and in the FHS that is made, we still have access to this folder, so you might be able to just add all the icd
files in /run/opengl-driver/share/vulkan/icd.d/
to VK_ICD_FILENAMES
for Steam. I am also not sure where the current icd
files in /usr/
come from.
In essence, taking the existing VK_ICD_FILENAMES
, and appending to it itself, but with /usr
replaced with /run/opengl-driver
, might make it all work magically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the icd files come from the mesa.drivers
package except for the nvidia files which i have no clue where they're supposed to come from.
pkgs/games/steam/fhsenv.nix
Outdated
@@ -282,7 +283,7 @@ in buildFHSUserEnv rec { | |||
|
|||
export STEAM_RUNTIME=${if nativeOnly then "0" else "/steamrt"} | |||
|
|||
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.d/intel_icd.i686.json:/usr/share/vulkan/icd.d/lvp_icd.x86_64.json:/usr/share/vulkan/icd.d/lvp_icd.i686.json:/usr/share/vulkan/icd.d/nvidia_icd.json:/usr/share/vulkan/icd.d/nvidia_icd32.json:/usr/share/vulkan/icd.d/radeon_icd.x86_64.json:/usr/share/vulkan/icd.d/radeon_icd.i686.json | |||
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json:/usr/share/vulkan/icd.d/nvidia_icd32.json:/usr/share/vulkan/icd.d/radeon_icd.x86_64.json:/usr/share/vulkan/icd.d/radeon_icd.i686.json:${amdvlk}/share/vulkan/icd.d/amd_icd64.json:${driversi686Linux.amdvlk}/share/vulkan/icd.d/amd_icd32.json:/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.d/intel_icd.i686.json:/usr/share/vulkan/icd.d/lvp_icd.x86_64.json:/usr/share/vulkan/icd.d/lvp_icd.i686.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would hard code the driver used, which isn't desirable. You likely want to do the same approach for the other drivers as for the Nvidia one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at doing the same for intel (which might not even need it), but i don't want to change stuff around for AMD given that i can't test it at all. i don't want to make changes that may break an already working system.
also, reordering the ICD files may end up being unnecessary, but i'll test different configurations a bit more to make sure.
Ok, this is really weird, but I'm not getting any issues with vulkan anymore, even with shuffling around the nvidia drivers im using and rebooting. It seems the ICD files in the FHS env are taken from If there are actually no issues with nvidia GPUs, and other people aren't having any issues, I think i'll turn this PR solely into adding in support for amdvlk drivers, though im unsure if ICD files for those drivers also show up in EDIT: just noticed #134556 after doing a cursory search for the term "steam". I think what I can make this PR into is changing the VK_ICD_FILENAMES line in the fhsenv itself to just use /run/opengl-driver directly. Depending on if the amdvlk driver makes its files available through |
For your information, most AMD users do not use AMDVLK. Mesa comes with RADV out of the box and is typically preferred. |
@critbase I just tested my system with an amd gpu and with the amdvlk driver added it does show up in /run/opengl-driver [babbaj@nixos:~]$ ls /run/opengl-driver/share/vulkan/icd.d/
amd_icd64.json lvp_icd.x86_64.json
intel_icd.x86_64.json radeon_icd.x86_64.json
[babbaj@nixos:~]$ cat /run/opengl-driver/share/vulkan/icd.d/amd_icd64.json
{
"file_format_version": "1.0.0",
"ICD": {
"library_path": "/nix/store/vq25p9l8ynlhjag6kzkacypivdwr8svr-amdvlk-2021.Q3.2/lib/amdvlk64.so",
"api_version": "1.2.182"
},
"layer": {
"name": "VK_LAYER_AMD_switchable_graphics_64",
"type": "GLOBAL",
"library_path": "/nix/store/vq25p9l8ynlhjag6kzkacypivdwr8svr-amdvlk-2021.Q3.2/lib/amdvlk64.so",
"api_version": "1.2.182",
"implementation_version": "1",
"description": "AMD switchable graphics layer",
"functions": {
"vkGetInstanceProcAddr": "vk_icdGetInstanceProcAddrSG",
"vkGetDeviceProcAddr": "vk_icdGetDeviceProcAddrSG"
},
"disable_environment": {
"DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1": "1"
}
}
} I think /run/opengl-driver might even be good enough to replace /usr/share/vulkan |
@babbaj nice, thank you. I'll go ahead and change this PR to just changing the line in the FHS env where VK_ICD_FILENAMES is set, which should hopefully be a somewhat elegant solution. to test the change i'll make, it should be enough to just paste the following into environment.systemPackages or similar: (steam.override {
extraProfile = ''
unset VK_ICD_FILENAMES
export VK_ICD_FILENAMES=/run/opengl-driver/share/vulkan/icd.d/intel_icd.x86_64.json:/run/opengl-driver-32/share/vulkan/icd.d/intel_icd.i686.json:\
/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json:/run/opengl-driver-32/share/vulkan/icd.d/radeon_icd.i686.json:\
/run/opengl-driver/share/vulkan/icd.d/amd_icd64.json:/run/opengl-driver-32/share/vulkan/icd.d/amd_icd32.json:\
/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.json:/run/opengl-driver-32/share/vulkan/icd.d/nvidia_icd.json:\
/run/opengl-driver/share/vulkan/icd.d/lvp_icd.x86_64.json:/run/opengl-driver-32/share/vulkan/icd.d/lvp_icd.i686.json
'';
}) |
primarily by using /run/opengl-driver directly to ensure the correct vulkan ICD file is picked up.
446725f
to
ef8553b
Compare
nixpkgs/pkgs/games/steam/fhsenv.nix Line 245 in ef8553b
this code can be removed or reused if it's still useful |
Good catch; I'll try and find out if it's necessary. |
I marked this as stale due to inactivity. → More info |
This has been fixed with use of |
For x-reference #161576 |
Motivation for this change
some of the changes introduced with the pressure-vessel commit have caused some pain when using proton/vulkan-enabled games.
this pr makes the environment variable
VK_ICD_FILENAMES
use the user defined nvidia package (throughconfig.hardware.nvidia.package), in addition to reordering the list to
make it more friendly to setups with multiple GPUs (Optimus hybrid
laptops, mainly). The order now prioritizes discrete GPUs first (nvidia, amd/radeon), and intel GPUs second (since these are all integrated).
This solves some issues as seen in issue #126428 and in a few comments in #108598 (comment)
As i do not have an amd device at all, it would be nice for someone with an optimus amd laptop to test this pr, though it shouldn't change their current experience.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)