diff --git a/README.md b/README.md index b8cfaebfa..b7f7b0d32 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,6 @@ DXVK will create a file `dxgi.log` in the current working directory and may prin ### Environment variables The behaviour of DXVK can be modified with environment variables. -- `DXVK_SHADER_DUMP_PATH=directory` Writes all DXBC and SPIR-V shaders to `directory` \ No newline at end of file +- `DXVK_SHADER_DUMP_PATH=directory` Writes all DXBC and SPIR-V shaders to the given directory +- `DXVK_SHADER_READS_PATH=directory` Reads SPIR-V shaders from the given directory instead of compiling the DXBC shader. +- `DXVK_DEBUG_LAYERS=1` Enables Vulkan debug layers. Highly recommended for troubleshooting and debugging purposes. \ No newline at end of file diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp index 1c9dca614..f5aef5ed4 100644 --- a/src/d3d11/d3d11_shader.cpp +++ b/src/d3d11/d3d11_shader.cpp @@ -3,22 +3,6 @@ namespace dxvk { - static std::string GetEnvVar(LPCWSTR name) { - DWORD len = ::GetEnvironmentVariableW(name, nullptr, 0); - - std::wstring result; - - while (len > result.size()) { - result.resize(len); - len = ::GetEnvironmentVariableW( - name, result.data(), result.size()); - } - - result.resize(len); - return str::fromws(result); - } - - D3D11ShaderModule:: D3D11ShaderModule() { } D3D11ShaderModule::~D3D11ShaderModule() { } @@ -41,8 +25,8 @@ namespace dxvk { // If requested by the user, dump both the raw DXBC // shader and the compiled SPIR-V module to a file. - const std::string dumpPath = GetEnvVar(L"DXVK_SHADER_DUMP_PATH"); - const std::string readPath = GetEnvVar(L"DXVK_SHADER_READ_PATH"); + const std::string dumpPath = env::getEnvVar(L"DXVK_SHADER_DUMP_PATH"); + const std::string readPath = env::getEnvVar(L"DXVK_SHADER_READ_PATH"); if (dumpPath.size() != 0) { const std::string baseName = str::format(dumpPath, "/", diff --git a/src/d3d11/d3d11_shader.h b/src/d3d11/d3d11_shader.h index 6a87ef13a..a9c39e134 100644 --- a/src/d3d11/d3d11_shader.h +++ b/src/d3d11/d3d11_shader.h @@ -5,6 +5,8 @@ #include "../util/sha1/sha1_util.h" +#include "../util/util_env.h" + #include "d3d11_device_child.h" #include "d3d11_interfaces.h" diff --git a/src/dxvk/dxvk_include.h b/src/dxvk/dxvk_include.h index 90ca4ee19..a5247c8af 100644 --- a/src/dxvk/dxvk_include.h +++ b/src/dxvk/dxvk_include.h @@ -3,6 +3,7 @@ #include "../util/log/log.h" #include "../util/log/log_debug.h" +#include "../util/util_env.h" #include "../util/util_error.h" #include "../util/util_flags.h" #include "../util/util_string.h" diff --git a/src/dxvk/dxvk_instance.cpp b/src/dxvk/dxvk_instance.cpp index 66416999f..a87d5d166 100644 --- a/src/dxvk/dxvk_instance.cpp +++ b/src/dxvk/dxvk_instance.cpp @@ -67,9 +67,11 @@ namespace dxvk { vk::NameList DxvkInstance::getLayers() { - std::vector layers = { - "VK_LAYER_LUNARG_standard_validation" - }; + std::vector layers = { }; + + if (env::getEnvVar(L"DXVK_DEBUG_LAYERS") == "1") + layers.push_back("VK_LAYER_LUNARG_standard_validation"); + const vk::NameSet layersAvailable = vk::NameSet::enumerateInstanceLayers(*m_vkl); diff --git a/src/util/meson.build b/src/util/meson.build index d6286062d..ca64f8adb 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -1,4 +1,6 @@ util_src = files([ + 'util_env.cpp', + 'com/com_guid.cpp', 'com/com_private_data.cpp',