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

mangohud: add bitness suffix to layer name #231874

Merged
merged 2 commits into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions pkgs/tools/graphics/mangohud/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
, glfw
, xorg
, gamescopeSupport ? true # build mangoapp and mangohudctl
, lowerBitnessSupport ? stdenv.hostPlatform.is64bit # Support 32 bit on 64bit
, nix-update-script
}:

Expand Down Expand Up @@ -128,7 +129,7 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace bin/mangohud.in \
--subst-var-by libraryPath ${lib.makeSearchPath "lib/mangohud" ([
(placeholder "out")
] ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [
] ++ lib.optionals lowerBitnessSupport [
mangohud32
])} \
--subst-var-by dataDir ${placeholder "out"}/share
Expand Down Expand Up @@ -184,7 +185,7 @@ stdenv.mkDerivation (finalAttrs: {

# Support 32bit Vulkan applications by linking in 32bit Vulkan layers
# This is needed for the same reason the 32bit preload workaround is needed.
postInstall = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
postInstall = lib.optionalString lowerBitnessSupport ''
ln -s ${mangohud32}/share/vulkan/implicit_layer.d/MangoHud.x86.json \
"$out/share/vulkan/implicit_layer.d"
Expand All @@ -194,16 +195,26 @@ stdenv.mkDerivation (finalAttrs: {
''}
'';

postFixup = ''
postFixup = let
archMap = {
"x86_64-linux" = "x86_64";
"i686-linux" = "x86";
};
layerPlatform = archMap."${stdenv.hostPlatform.system}" or null;
# We need to give the different layers separate names or else the loader
# might try the 32-bit one first, fail and not attempt to load the 64-bit
# layer under the same name.
in lib.optionalString (layerPlatform != null) ''
substituteInPlace $out/share/vulkan/implicit_layer.d/MangoHud.${layerPlatform}.json \
--replace "VK_LAYER_MANGOHUD_overlay" "VK_LAYER_MANGOHUD_overlay_${toString stdenv.hostPlatform.parsed.cpu.bits}"
Comment on lines +208 to +209
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the means to test but if MangoApp needs this too, the file should be modified here aswell when support is enabled.

cc @Scrumplex

Copy link
Contributor

@kira-bruneau kira-bruneau May 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this should be done for MangoApp too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait sorry nvm!

Copy link
Contributor

@kira-bruneau kira-bruneau May 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now our current build isn't even supporting mixed 32bit & 64bit mangoapp (and I don't think upstream does either). Since it runs in a separate process, there's no need to have a 32bit build for overlaying 32bit games (on a 64bit system).

'' + ''
# Add OpenGL driver path to RUNPATH to support NVIDIA cards
addOpenGLRunpath "$out/lib/mangohud/libMangoHud.so"
${lib.optionalString gamescopeSupport ''
addOpenGLRunpath "$out/bin/mangoapp"
''}
${lib.optionalString finalAttrs.doCheck ''
# libcmocka.so is only used for tests
rm "$out/lib/libcmocka.so"
''}
'' + lib.optionalString gamescopeSupport ''
addOpenGLRunpath "$out/bin/mangoapp"
'' + lib.optionalString finalAttrs.doCheck ''
# libcmocka.so is only used for tests
rm "$out/lib/libcmocka.so"
'';

passthru.updateScript = nix-update-script { };
Expand Down