mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-04-22 02:11:43 +00:00
remove broken environment variables
This commit is contained in:
parent
37e0ffa624
commit
6a86107aba
4 changed files with 2 additions and 66 deletions
|
|
@ -5,9 +5,6 @@
|
|||
#include <filesystem>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace Config {
|
||||
|
|
@ -18,8 +15,6 @@ namespace Config {
|
|||
bool enable{false};
|
||||
/// Path to Lossless.dll.
|
||||
std::string dll;
|
||||
/// Additional environment variables to set.
|
||||
std::vector<std::pair<std::string, std::string>> env;
|
||||
|
||||
/// The frame generation muliplier
|
||||
size_t multiplier{2};
|
||||
|
|
@ -32,8 +27,6 @@ namespace Config {
|
|||
|
||||
/// Experimental flag for overriding the synchronization method.
|
||||
VkPresentModeKHR e_present;
|
||||
/// Experimental flag for limiting the framerate of DXVK games.
|
||||
uint32_t e_fps_limit;
|
||||
|
||||
/// Path to the configuration file.
|
||||
std::filesystem::path config_file;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@
|
|||
const std::string DEFAULT_CONFIG = R"(version = 1
|
||||
[global]
|
||||
# override the location of Lossless Scaling
|
||||
# dll = "/games/Lossless Scaling"
|
||||
# dll = "/games/Lossless Scaling/Lossless.dll"
|
||||
|
||||
# [[game]] # example entry
|
||||
# exe = "Game.exe"
|
||||
# env = "SteamDeck=0"
|
||||
#
|
||||
# multiplier = 3
|
||||
# flow_scale = 0.7
|
||||
|
|
@ -17,7 +16,6 @@ const std::string DEFAULT_CONFIG = R"(version = 1
|
|||
# hdr_mode = false
|
||||
#
|
||||
# experimental_present_mode = "fifo"
|
||||
# experimental_fps_limit = 48
|
||||
|
||||
[[game]] # default vkcube entry
|
||||
exe = "vkcube"
|
||||
|
|
|
|||
|
|
@ -16,10 +16,8 @@
|
|||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <fstream>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace Config;
|
||||
|
|
@ -42,46 +40,6 @@ namespace {
|
|||
return VkPresentModeKHR::VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||
return VkPresentModeKHR::VK_PRESENT_MODE_FIFO_KHR;
|
||||
}
|
||||
|
||||
/// Parse environment variables from a string.
|
||||
std::vector<std::pair<std::string, std::string>> parse_env(const std::string& envs) {
|
||||
std::vector<std::pair<std::string, std::string>> vars{};
|
||||
const std::string env_str = envs + ' ';
|
||||
|
||||
std::string current{};
|
||||
bool escape{false};
|
||||
for (const char c : env_str) {
|
||||
// toggle escape mode
|
||||
if (c == '\'') {
|
||||
escape = !escape;
|
||||
continue;
|
||||
}
|
||||
|
||||
// parse variable
|
||||
if (c == ' ' && !escape) {
|
||||
if (current.empty())
|
||||
continue;
|
||||
|
||||
auto eq_pos = current.find('=');
|
||||
if (eq_pos == std::string::npos)
|
||||
throw std::runtime_error("Invalid environment variable: " + current);
|
||||
|
||||
std::string key = current.substr(0, eq_pos);
|
||||
std::string value = current.substr(eq_pos + 1);
|
||||
if (key.empty() || value.empty())
|
||||
throw std::runtime_error("Invalid environment variable: " + current);
|
||||
|
||||
vars.emplace_back(std::move(key), std::move(value));
|
||||
|
||||
current.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
current += c;
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
}
|
||||
|
||||
void Config::updateConfig(const std::string& file) {
|
||||
|
|
@ -139,13 +97,11 @@ void Config::updateConfig(const std::string& file) {
|
|||
Configuration game{
|
||||
.enable = true,
|
||||
.dll = global.dll,
|
||||
.env = parse_env(toml::find_or(gameTable, "env", std::string())),
|
||||
.multiplier = toml::find_or(gameTable, "multiplier", 2U),
|
||||
.flowScale = toml::find_or(gameTable, "flow_scale", 1.0F),
|
||||
.performance = toml::find_or(gameTable, "performance_mode", false),
|
||||
.hdr = toml::find_or(gameTable, "hdr_mode", false),
|
||||
.e_present = into_present(toml::find_or(gameTable, "experimental_present_mode", "")),
|
||||
.e_fps_limit = toml::find_or(gameTable, "experimental_fps_limit", 0U),
|
||||
.config_file = file,
|
||||
.timestamp = global.timestamp
|
||||
};
|
||||
|
|
@ -185,10 +141,6 @@ Configuration Config::getConfig(const std::pair<std::string, std::string>& name)
|
|||
if (hdr) conf.hdr = std::string(hdr) == "1";
|
||||
const char* e_present = std::getenv("LSFG_EXPERIMENTAL_PRESENT_MODE");
|
||||
if (e_present) conf.e_present = into_present(std::string(e_present));
|
||||
const char* e_fps_limit = std::getenv("LSFG_EXPERIMENTAL_FPS_LIMIT");
|
||||
if (e_fps_limit) conf.e_fps_limit = static_cast<uint32_t>(std::stoul(e_fps_limit));
|
||||
const char* envs = std::getenv("LSFG_ENV");
|
||||
if (envs) conf.env = parse_env(std::string(envs));
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,21 +46,14 @@ namespace {
|
|||
// print config
|
||||
std::cerr << "lsfg-vk: Loaded configuration for " << name.second << ":\n";
|
||||
if (!conf.dll.empty()) std::cerr << " Using DLL from: " << conf.dll << '\n';
|
||||
for (const auto& [key, value] : conf.env)
|
||||
std::cerr << " Environment: " << key << "=" << value << '\n';
|
||||
std::cerr << " Multiplier: " << conf.multiplier << '\n';
|
||||
std::cerr << " Flow Scale: " << conf.flowScale << '\n';
|
||||
std::cerr << " Performance Mode: " << (conf.performance ? "Enabled" : "Disabled") << '\n';
|
||||
std::cerr << " HDR Mode: " << (conf.hdr ? "Enabled" : "Disabled") << '\n';
|
||||
if (conf.e_present != 2) std::cerr << " ! Present Mode: " << conf.e_present << '\n';
|
||||
if (conf.e_fps_limit > 0) std::cerr << " ! FPS Limit: " << conf.e_fps_limit << '\n';
|
||||
|
||||
// update environment variables
|
||||
// remove mesa var in favor of config
|
||||
unsetenv("MESA_VK_WSI_PRESENT_MODE"); // NOLINT
|
||||
for (const auto& [key, value] : conf.env)
|
||||
setenv(key.c_str(), value.c_str(), 1); // NOLINT
|
||||
if (conf.e_fps_limit > 0)
|
||||
setenv("DXVK_FRAME_RATE", std::to_string(conf.e_fps_limit).c_str(), 1); // NOLINT
|
||||
|
||||
// write latest file
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue