Skip to content

Commit 65b9677

Browse files
committed
icd: Disable underlying Vulkan implicit layers by default
1 parent 0fcbda6 commit 65b9677

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

icd/icd_env_helper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "icd_env_helper.h"
99

1010
#include <stdlib.h>
11+
#include <string.h>
1112
#include <sstream>
1213

1314
#ifdef _WIN32
@@ -123,6 +124,13 @@ const std::unordered_map<const char*, std::string> EnvironmentHelper::InitLayere
123124
auto env_var_value = getenv(layered_env_var.c_str());
124125
if (env_var_value != nullptr) {
125126
layered_envs.emplace(loader_env_var, env_var_value);
127+
} else if (strcmp(loader_env_var, "VK_LOADER_LAYERS_DISABLE") == 0) {
128+
// NOTE: We disable Vulkan implicit layers unless otherwise instructed by the environment
129+
// as none of the device select / switchable graphics / optimus layers operate correctly
130+
// in most non-trivial environments, and it is anyway questionable whether we want any
131+
// Vulkan implicit layers to take effect when running Vulkan SC applications against the
132+
// emulation driver stack.
133+
layered_envs.emplace("VK_LOADER_LAYERS_DISABLE", "~implicit~");
126134
}
127135
}
128136
return layered_envs;

tests/icd/test_infrastructure.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ TEST_F(InfrastructureTest, EnvironmentVariables) {
4444
auto value = getenv(env_var_name.c_str());
4545
if (value == nullptr) {
4646
env_vars[env_var_name] = "";
47+
48+
// Expect that the Emulation ICD will disable all Vulkan implicit layers by default
49+
if (env_var_name == "VK_LOADER_LAYERS_DISABLE") {
50+
env_vars[env_var_name] = "~implicit~";
51+
}
4752
} else {
4853
env_vars[env_var_name] = value;
4954
}
@@ -72,7 +77,7 @@ TEST_F(InfrastructureTest, EnvironmentVariables) {
7277
if (value == nullptr) {
7378
value = "";
7479
}
75-
EXPECT_STREQ(env_vars[vksc_emu_env_var_name].c_str(), value) << env_var_name << " has incorrect value";
80+
EXPECT_STREQ(env_vars[env_var_name].c_str(), value) << env_var_name << " has incorrect value";
7681

7782
// Expect VKSC_EMU_VK_* to also have the value of VKSC_EMU_VK_*
7883
const char* vksc_emu_value = getenv(vksc_emu_env_var_name.c_str());

0 commit comments

Comments
 (0)