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

[util] Add DXVK_CONFIG to define additional options #3581

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
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
32 changes: 22 additions & 10 deletions src/util/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,30 +1090,42 @@ namespace dxvk {

// Load either $DXVK_CONFIG_FILE or $PWD/dxvk.conf
std::string filePath = env::getEnvVar("DXVK_CONFIG_FILE");
std::string confLine = env::getEnvVar("DXVK_CONFIG");

if (filePath == "")
filePath = "dxvk.conf";

// Open the file if it exists
std::ifstream stream(str::topath(filePath.c_str()).c_str());

if (!stream)
if (!stream && confLine.empty())
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
ConfigContext ctx;
ctx.active = true;

// Parse the file line by line
std::string line;
if (stream) {
// Inform the user that we loaded a file, might
// help when debugging configuration issues
Logger::info(str::format("Found config file: ", filePath));

// Parse the file line by 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, "#"))
Copy link
Owner

Choose a reason for hiding this comment

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

why '#' specifically? that's such an odd choice when everything else either uses ; or :, and much like ; it hard-requires using quotes on the string as well so i don't really see the benefit here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most standard separators already taken by some options, I saw there was , and maybe ; in upcoming dx8 implementation. : already used by d3d9.forceAspectRatio.

Could be whitespace, but copy-pasting something from dxvk.conf or web will not work, e.g DXVK_CONFIG="dxvk.hud = full" "user friendly" vs DXVK_CONFIG="dxvk.hud=full" with strict (whitespace separator) variant.

Just random choice, to be honest.

Copy link
Owner

Choose a reason for hiding this comment

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

I think ; should be reserved as a separator and not be allowed in option values then. I'd rather change this on the d3d8 side than introduce a weird separator here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fine by me, changed it to ;

Copy link
Contributor

@WinterSnowfall WinterSnowfall Jul 31, 2023

Choose a reason for hiding this comment

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

d8vk only uses , and : AFAIK, so ; should be perfectly safe to use here.

parseUserConfigLine(config, ctx, std::string(l.data(), l.size()));
}

while (std::getline(stream, line))
parseUserConfigLine(config, ctx, line);

return config;
}

Expand Down