diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 73dd02901f67a0a65f190b22821003f0b3a070bf..d5cd0f88b743fb5b9f9cdef7c19f013298c7e277 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -29,6 +29,8 @@ #include "libglnx/libglnx.h" #include <steam-runtime-tools/steam-runtime-tools.h> + +#include "steam-runtime-tools/graphics-internal.h" #include "steam-runtime-tools/resolve-in-sysroot-internal.h" #include "steam-runtime-tools/utils-internal.h" @@ -3954,6 +3956,48 @@ pv_runtime_bind (PvRuntime *self, self->adverb_in_container = "/run/pressure-vessel/pv-from-host/bin/pressure-vessel-adverb"; } + if ((self->flags & PV_RUNTIME_FLAGS_IMPORT_VULKAN_LAYERS) + && exports != NULL) + { + /* We have added our imported Vulkan layers to the search path, + * but we can't just remove ~/.local/share, etc. from the search + * path without breaking unrelated users of the XDG basedirs spec, + * such as .desktop files and icons. Mask any remaining Vulkan + * layers by mounting empty directories over the top. */ + static const char * const layer_suffixes[] = + { + _SRT_GRAPHICS_EXPLICIT_VULKAN_LAYER_SUFFIX, + _SRT_GRAPHICS_IMPLICIT_VULKAN_LAYER_SUFFIX, + }; + gsize i; + + for (i = 0; i < G_N_ELEMENTS (layer_suffixes); i++) + { + g_auto(GStrv) search_path = NULL; + const char *suffix = layer_suffixes[i]; + gsize j; + + search_path = _srt_graphics_get_vulkan_search_paths ("/", + self->original_environ, + multiarch_tuples, + suffix); + + for (j = 0; search_path != NULL && search_path[j] != NULL; j++) + { + const char *dir = search_path[j]; + + /* We are mounting our own runtime over /usr anyway, so + * ignore those */ + if (flatpak_has_path_prefix (dir, "/usr")) + continue; + + /* Otherwise, if the directory exists, mask it */ + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) + flatpak_exports_add_path_tmpfs (exports, dir); + } + } + } + /* Some games detect that they have been run outside the Steam Runtime * and try to re-run themselves via Steam. Trick them into thinking * they are in the LD_LIBRARY_PATH Steam Runtime.