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

[util] Add DXVK_CONFIG to define additional options

This commit is contained in:
pchome 2023-08-01 23:09:29 +03:00 committed by GitHub
parent 09857dcaa9
commit e598dcd77e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1090,6 +1090,7 @@ namespace dxvk {
// Load either $DXVK_CONFIG_FILE or $PWD/dxvk.conf // Load either $DXVK_CONFIG_FILE or $PWD/dxvk.conf
std::string filePath = env::getEnvVar("DXVK_CONFIG_FILE"); std::string filePath = env::getEnvVar("DXVK_CONFIG_FILE");
std::string confLine = env::getEnvVar("DXVK_CONFIG");
if (filePath == "") if (filePath == "")
filePath = "dxvk.conf"; filePath = "dxvk.conf";
@ -1097,22 +1098,33 @@ namespace dxvk {
// Open the file if it exists // Open the file if it exists
std::ifstream stream(str::topath(filePath.c_str()).c_str()); std::ifstream stream(str::topath(filePath.c_str()).c_str());
if (!stream) if (!stream && confLine.empty())
return config; return config;
// Inform the user that we loaded a file, might
// help when debugging configuration issues
Logger::info(str::format("Found config file: ", filePath));
// Initialize parser context // Initialize parser context
ConfigContext ctx; ConfigContext ctx;
ctx.active = true; ctx.active = true;
// Parse the file line by line if (stream) {
std::string line; // Inform the user that we loaded a file, might
// help when debugging configuration issues
Logger::info(str::format("Found config file: ", filePath));
while (std::getline(stream, line)) // Parse the file line by line
parseUserConfigLine(config, ctx, line); std::string line;
while (std::getline(stream, line))
parseUserConfigLine(config, ctx, line);
}
if (!confLine.empty()) {
// Inform the user that we parsing config from environment, might
// help when debugging configuration issues
Logger::info(str::format("Found config env: ", confLine));
for(auto l : str::split(confLine, ";"))
parseUserConfigLine(config, ctx, std::string(l.data(), l.size()));
}
return config; return config;
} }