mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-16 10:43:27 +00:00
6bf27c2cae
The loader now uses XDK_DATA_DIRS to find drivers and layers.
143 lines
5.4 KiB
Diff
143 lines
5.4 KiB
Diff
diff --git a/loader/loader.c b/loader/loader.c
|
|
index a950ea1..9462d05 100644
|
|
--- a/loader/loader.c
|
|
+++ b/loader/loader.c
|
|
@@ -2671,6 +2671,94 @@ static VkResult loader_get_manifest_files(
|
|
}
|
|
}
|
|
|
|
+#if !defined(_WIN32)
|
|
+ if (home_location && override == NULL) {
|
|
+ char *xdgconfdirs = secure_getenv("XDG_CONFIG_DIRS");
|
|
+ char *xdgdatadirs = secure_getenv("XDG_DATA_DIRS");
|
|
+ char *cur, *src = loc;
|
|
+ size_t src_size = strlen(src), rel_size = strlen(home_location);
|
|
+ size_t size = 0;
|
|
+
|
|
+ if (src_size > 0)
|
|
+ size += src_size + 1;
|
|
+
|
|
+ if (xdgconfdirs == NULL)
|
|
+ xdgconfdirs = "/etc/xdg";
|
|
+ if (xdgdatadirs == NULL)
|
|
+ xdgdatadirs = "/usr/local/share:/usr/share";
|
|
+
|
|
+ for (char *x = xdgconfdirs; *x; ++x)
|
|
+ if (*x == PATH_SEPERATOR) size += rel_size;
|
|
+ size += strlen(xdgconfdirs) + rel_size + 1;
|
|
+ for (char *x = xdgdatadirs; *x; ++x)
|
|
+ if (*x == PATH_SEPERATOR) size += rel_size;
|
|
+ size += strlen(xdgdatadirs) + rel_size + 1;
|
|
+
|
|
+#if defined(LOCALPREFIX)
|
|
+ size += strlen(LOCALPREFIX "/" SYSCONFDIR) + rel_size + 1;
|
|
+ size += strlen(LOCALPREFIX "/" DATADIR) + rel_size + 1;
|
|
+#endif
|
|
+
|
|
+ loc = cur = loader_stack_alloc(size);
|
|
+ if (cur == NULL) {
|
|
+ loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
|
|
+ "Out of memory can't get manifest files");
|
|
+ res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ if (src_size > 0) {
|
|
+ memcpy(cur, src, src_size);
|
|
+ cur += src_size;
|
|
+ *cur++ = PATH_SEPERATOR;
|
|
+ }
|
|
+
|
|
+ src = xdgconfdirs;
|
|
+ for (char *x = src;; ++x) {
|
|
+ if (*x == PATH_SEPERATOR || *x == 0) {
|
|
+ size_t s = x - src;
|
|
+ memcpy(cur, src, s); cur += s;
|
|
+ memcpy(cur, home_location, rel_size); cur += rel_size;
|
|
+ *cur++ = PATH_SEPERATOR;
|
|
+ if (*x == 0)
|
|
+ break;
|
|
+ src = ++x;
|
|
+ }
|
|
+ }
|
|
+
|
|
+#if defined(LOCALPREFIX)
|
|
+ strcpy(cur, LOCALPREFIX "/" SYSCONFDIR);
|
|
+ cur += strlen(cur);
|
|
+ memcpy(cur, home_location, rel_size); cur += rel_size;
|
|
+ *cur++ = PATH_SEPERATOR;
|
|
+#endif
|
|
+
|
|
+ src = xdgdatadirs;
|
|
+ for (char *x = src;; ++x) {
|
|
+ if (*x == PATH_SEPERATOR || *x == 0) {
|
|
+ size_t s = x - src;
|
|
+ memcpy(cur, src, s); cur += s;
|
|
+ memcpy(cur, home_location, rel_size); cur += rel_size;
|
|
+ *cur++ = PATH_SEPERATOR;
|
|
+ if (*x == 0)
|
|
+ break;
|
|
+ src = ++x;
|
|
+ }
|
|
+ }
|
|
+
|
|
+#if defined(LOCALPREFIX)
|
|
+ strcpy(cur, LOCALPREFIX "/" DATADIR);
|
|
+ cur += strlen(cur);
|
|
+ memcpy(cur, home_location, rel_size); cur += rel_size;
|
|
+ *cur++ = PATH_SEPERATOR;
|
|
+#endif
|
|
+
|
|
+ loc[size - 1] = 0;
|
|
+ assert(cur == loc + size);
|
|
+ list_is_dirs = true;
|
|
+ }
|
|
+#endif
|
|
+
|
|
// Print out the paths being searched if debugging is enabled
|
|
loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0,
|
|
"Searching the following paths for manifest files: %s\n", loc);
|
|
diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h
|
|
index 3a02640..70a2652 100644
|
|
--- a/loader/vk_loader_platform.h
|
|
+++ b/loader/vk_loader_platform.h
|
|
@@ -57,35 +57,10 @@
|
|
#define VULKAN_ILAYERCONF_DIR "implicit_layer.d"
|
|
#define VULKAN_LAYER_DIR "layer"
|
|
|
|
-#if defined(LOCALPREFIX)
|
|
-#define LOCAL_DRIVERS_INFO \
|
|
- LOCALPREFIX "/" SYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR ":" \
|
|
- LOCALPREFIX "/" DATADIR VULKAN_DIR VULKAN_ICDCONF_DIR ":"
|
|
-#define LOCAL_ELAYERS_INFO \
|
|
- LOCALPREFIX "/" SYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR ":" \
|
|
- LOCALPREFIX "/" DATADIR VULKAN_DIR VULKAN_ELAYERCONF_DIR ":"
|
|
-#define LOCAL_ILAYERS_INFO \
|
|
- LOCALPREFIX "/" SYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR ":" \
|
|
- LOCALPREFIX "/" DATADIR VULKAN_DIR VULKAN_ILAYERCONF_DIR ":"
|
|
-#else
|
|
-#define LOCAL_DRIVERS_INFO
|
|
-#define LOCAL_ELAYERS_INFO
|
|
-#define LOCAL_ILAYERS_INFO
|
|
-#endif
|
|
-
|
|
-#define DEFAULT_VK_DRIVERS_INFO \
|
|
- LOCAL_DRIVERS_INFO \
|
|
- "/" SYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR ":" \
|
|
- "/usr/" DATADIR VULKAN_DIR VULKAN_ICDCONF_DIR
|
|
+#define DEFAULT_VK_DRIVERS_INFO ""
|
|
#define DEFAULT_VK_DRIVERS_PATH ""
|
|
-#define DEFAULT_VK_ELAYERS_INFO \
|
|
- LOCAL_ELAYERS_INFO \
|
|
- "/" SYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR ":" \
|
|
- "/usr/" DATADIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
|
|
-#define DEFAULT_VK_ILAYERS_INFO \
|
|
- LOCAL_ILAYERS_INFO \
|
|
- "/" SYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR ":" \
|
|
- "/usr/" DATADIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
|
|
+#define DEFAULT_VK_ELAYERS_INFO ""
|
|
+#define DEFAULT_VK_ILAYERS_INFO ""
|
|
#define DEFAULT_VK_LAYERS_PATH ""
|
|
#if !defined(LAYERS_SOURCE_PATH)
|
|
#define LAYERS_SOURCE_PATH NULL
|