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:
parent
037f2038f0
commit
66bcc4b3d8
@ -24,7 +24,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
// If requested by the user, dump both the raw DXBC
|
// If requested by the user, dump both the raw DXBC
|
||||||
// shader and the compiled SPIR-V module to a file.
|
// 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) {
|
if (dumpPath.size() != 0) {
|
||||||
reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxbc"),
|
reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxbc"),
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxvkDeviceFilter::DxvkDeviceFilter() {
|
DxvkDeviceFilter::DxvkDeviceFilter() {
|
||||||
m_matchDeviceName = env::getEnvVar(L"DXVK_FILTER_DEVICE_NAME");
|
m_matchDeviceName = env::getEnvVar("DXVK_FILTER_DEVICE_NAME");
|
||||||
|
|
||||||
if (m_matchDeviceName.size() != 0)
|
if (m_matchDeviceName.size() != 0)
|
||||||
m_flags.set(DxvkDeviceFilterFlag::MatchDeviceName);
|
m_flags.set(DxvkDeviceFilterFlag::MatchDeviceName);
|
||||||
|
@ -115,7 +115,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
vr::IVRCompositor* VrInstance::getCompositor() {
|
vr::IVRCompositor* VrInstance::getCompositor() {
|
||||||
// Skip OpenVR initialization if requested
|
// Skip OpenVR initialization if requested
|
||||||
if (env::getEnvVar(L"DXVK_NO_VR") == "1")
|
if (env::getEnvVar("DXVK_NO_VR") == "1")
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Locate the OpenVR DLL if loaded by the process. Some
|
// Locate the OpenVR DLL if loaded by the process. Some
|
||||||
|
@ -44,7 +44,7 @@ namespace dxvk {
|
|||||||
DxvkRenderPassPool* passManager)
|
DxvkRenderPassPool* passManager)
|
||||||
: m_device (device),
|
: m_device (device),
|
||||||
m_cache (new DxvkPipelineCache(device->vkd())) {
|
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")
|
if (useStateCache != "0")
|
||||||
m_stateCache = new DxvkStateCache(device, this, passManager);
|
m_stateCache = new DxvkStateCache(device, this, passManager);
|
||||||
|
@ -418,7 +418,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
std::string DxvkStateCache::getCacheFileName() const {
|
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() != '/')
|
if (!path.empty() && *path.rbegin() != '/')
|
||||||
path += '/';
|
path += '/';
|
||||||
|
@ -62,7 +62,7 @@ namespace dxvk::hud {
|
|||||||
|
|
||||||
|
|
||||||
Rc<Hud> Hud::createHud(const Rc<DxvkDevice>& device) {
|
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()
|
return !config.elements.isClear()
|
||||||
? new Hud(device, config)
|
? new Hud(device, config)
|
||||||
|
@ -244,7 +244,7 @@ namespace dxvk {
|
|||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
// Load either $DXVK_CONFIG_FILE or $PWD/dxvk.conf
|
// 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 == "")
|
if (filePath == "")
|
||||||
filePath = "dxvk.conf";
|
filePath = "dxvk.conf";
|
||||||
|
@ -68,7 +68,7 @@ namespace dxvk {
|
|||||||
{ "none", LogLevel::None },
|
{ "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) {
|
for (const auto& pair : logLevels) {
|
||||||
if (logLevelStr == pair.first)
|
if (logLevelStr == pair.first)
|
||||||
@ -80,7 +80,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
std::string Logger::getFileName(const std::string& base) {
|
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() != '/')
|
if (!path.empty() && *path.rbegin() != '/')
|
||||||
path += '/';
|
path += '/';
|
||||||
|
@ -5,15 +5,21 @@
|
|||||||
|
|
||||||
namespace dxvk::env {
|
namespace dxvk::env {
|
||||||
|
|
||||||
std::string getEnvVar(const wchar_t* name) {
|
std::string getEnvVar(const std::string& name) {
|
||||||
DWORD len = ::GetEnvironmentVariableW(name, nullptr, 0);
|
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;
|
std::vector<WCHAR> result;
|
||||||
|
|
||||||
while (len > result.size()) {
|
while (len > result.size()) {
|
||||||
result.resize(len);
|
result.resize(len);
|
||||||
len = ::GetEnvironmentVariableW(
|
len = ::GetEnvironmentVariableW(
|
||||||
name, result.data(), result.size());
|
wideName.data(), result.data(), result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
result.resize(len);
|
result.resize(len);
|
||||||
|
@ -13,7 +13,7 @@ namespace dxvk::env {
|
|||||||
* \param [in] name Name of the variable
|
* \param [in] name Name of the variable
|
||||||
* \returns Value 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
|
* \brief Gets the executable name
|
||||||
|
Loading…
Reference in New Issue
Block a user