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

Added ability to override VK_LOADER_LAYERS_DISABLE env var. #4588

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions src/dxvk/dxvk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ namespace dxvk {

m_options = DxvkOptions(m_config);

std::string vkLoaderLayersDisableEnv = env::getEnvVar("VK_LOADER_LAYERS_DISABLE");
if (!vkLoaderLayersDisableEnv.empty())
Logger::info(str::format("VK_LOADER_LAYERS_DISABLE: ", vkLoaderLayersDisableEnv));

// Optionally override VK_LOADER_LAYERS_DISABLE with specified DXVK_LOADER_LAYERS_DISABLE
// Or set DXVK_OVERRIDE_VK_LOADER_LAYERS_DISABLE=1 alone, to clear VK_LOADER_LAYERS_DISABLE
std::string dxvkLoaderLayersDisableEnv = env::getEnvVar("DXVK_LOADER_LAYERS_DISABLE");
if (!dxvkLoaderLayersDisableEnv.empty() || env::getEnvVar("DXVK_OVERRIDE_VK_LOADER_LAYERS_DISABLE") == "1")
{
Logger::info(str::format("DXVK_LOADER_LAYERS_DISABLE: ", dxvkLoaderLayersDisableEnv));
env::setEnvVar("VK_LOADER_LAYERS_DISABLE", dxvkLoaderLayersDisableEnv.c_str());
}

// Load Vulkan library
createLibraryLoader(args);

Expand Down
7 changes: 7 additions & 0 deletions src/util/util_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ namespace dxvk::env {
#endif
}

void setEnvVar(const char* name, const char* value) {
#ifdef _WIN32
::SetEnvironmentVariableA(name, value);
#else
std::setenv(name, value);
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't exist in the std namespace and has an extra parameter.

I'd be fine with printing a warning and not supporting this in native builds at all for the time being; apps using dxvk-native shouldn't be messing around with the Vulkan environment in the first place and we can still add it later if it does turn out to be needed.

Otherwise, we'd need to explicitly include posix headers here and also make sure it behaves the same as the Windows path (mostly relevant for handling the value == nullptr case, but also unicode considerations).

#endif
}

size_t matchFileExtension(const std::string& name, const char* ext) {
auto pos = name.find_last_of('.');
Expand Down
7 changes: 7 additions & 0 deletions src/util/util_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ namespace dxvk::env {
* \returns Value of the variable
*/
std::string getEnvVar(const char* name);

/**
* \brief Sets environment variable
* \param [in] name Name of the variable
* \param [in] value New value to set
*/
void setEnvVar(const char* name, const char* value);

/**
* \brief Checks whether a file name has a given extension
Expand Down
Loading