1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 19:24:11 +01:00

Use std::string for util::getEnvVar input

This allows cleaner code when implementing DXVK as a native library
This commit is contained in:
Derek Lesho 2018-11-15 17:12:09 -05:00 committed by Philip Rebohle
parent 037f2038f0
commit 66bcc4b3d8
10 changed files with 23 additions and 17 deletions

View File

@ -24,7 +24,7 @@ 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 = env::getEnvVar(L"DXVK_SHADER_DUMP_PATH");
const std::string dumpPath = env::getEnvVar("DXVK_SHADER_DUMP_PATH");
if (dumpPath.size() != 0) {
reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxbc"),

View File

@ -3,7 +3,7 @@
namespace dxvk {
DxvkDeviceFilter::DxvkDeviceFilter() {
m_matchDeviceName = env::getEnvVar(L"DXVK_FILTER_DEVICE_NAME");
m_matchDeviceName = env::getEnvVar("DXVK_FILTER_DEVICE_NAME");
if (m_matchDeviceName.size() != 0)
m_flags.set(DxvkDeviceFilterFlag::MatchDeviceName);

View File

@ -115,7 +115,7 @@ namespace dxvk {
vr::IVRCompositor* VrInstance::getCompositor() {
// Skip OpenVR initialization if requested
if (env::getEnvVar(L"DXVK_NO_VR") == "1")
if (env::getEnvVar("DXVK_NO_VR") == "1")
return nullptr;
// Locate the OpenVR DLL if loaded by the process. Some

View File

@ -44,7 +44,7 @@ namespace dxvk {
DxvkRenderPassPool* passManager)
: m_device (device),
m_cache (new DxvkPipelineCache(device->vkd())) {
std::string useStateCache = env::getEnvVar(L"DXVK_STATE_CACHE");
std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE");
if (useStateCache != "0")
m_stateCache = new DxvkStateCache(device, this, passManager);

View File

@ -418,7 +418,7 @@ namespace dxvk {
std::string DxvkStateCache::getCacheFileName() const {
std::string path = env::getEnvVar(L"DXVK_STATE_CACHE_PATH");
std::string path = env::getEnvVar("DXVK_STATE_CACHE_PATH");
if (!path.empty() && *path.rbegin() != '/')
path += '/';

View File

@ -62,7 +62,7 @@ namespace dxvk::hud {
Rc<Hud> Hud::createHud(const Rc<DxvkDevice>& device) {
HudConfig config(env::getEnvVar(L"DXVK_HUD"));
HudConfig config(env::getEnvVar("DXVK_HUD"));
return !config.elements.isClear()
? new Hud(device, config)

View File

@ -244,7 +244,7 @@ namespace dxvk {
Config config;
// Load either $DXVK_CONFIG_FILE or $PWD/dxvk.conf
std::string filePath = env::getEnvVar(L"DXVK_CONFIG_FILE");
std::string filePath = env::getEnvVar("DXVK_CONFIG_FILE");
if (filePath == "")
filePath = "dxvk.conf";

View File

@ -68,7 +68,7 @@ namespace dxvk {
{ "none", LogLevel::None },
}};
const std::string logLevelStr = env::getEnvVar(L"DXVK_LOG_LEVEL");
const std::string logLevelStr = env::getEnvVar("DXVK_LOG_LEVEL");
for (const auto& pair : logLevels) {
if (logLevelStr == pair.first)
@ -80,7 +80,7 @@ namespace dxvk {
std::string Logger::getFileName(const std::string& base) {
std::string path = env::getEnvVar(L"DXVK_LOG_PATH");
std::string path = env::getEnvVar("DXVK_LOG_PATH");
if (!path.empty() && *path.rbegin() != '/')
path += '/';

View File

@ -5,15 +5,21 @@
namespace dxvk::env {
std::string getEnvVar(const wchar_t* name) {
DWORD len = ::GetEnvironmentVariableW(name, nullptr, 0);
std::string getEnvVar(const std::string& name) {
int nameLen = ::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.length() + 1, nullptr, 0);
std::vector<WCHAR> wideName(nameLen);
::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.length() + 1, wideName.data(), nameLen);
DWORD len = ::GetEnvironmentVariableW(wideName.data(), nullptr, 0);
std::vector<WCHAR> result;
while (len > result.size()) {
result.resize(len);
len = ::GetEnvironmentVariableW(
name, result.data(), result.size());
wideName.data(), result.data(), result.size());
}
result.resize(len);

View File

@ -13,7 +13,7 @@ namespace dxvk::env {
* \param [in] name Name of the variable
* \returns Value of the variable
*/
std::string getEnvVar(const wchar_t* name);
std::string getEnvVar(const std::string& name);
/**
* \brief Gets the executable name