[util] Use regular expressions on full exe path to match app profiles

This allows us to detect applications with non-unique executable names
or with variable executable names more reliably, and also allows us to
merge profiles for games that have multiple known exe names.

The matching is also no longer case-sensitive.
This commit is contained in:
Philip Rebohle 2019-08-17 11:46:56 +02:00
parent c934333a5c
commit 54ca5900e1
2 changed files with 40 additions and 54 deletions

View File

@ -12,7 +12,7 @@ namespace dxvk {
Logger::info(str::format("DXVK: ", DXVK_VERSION)); Logger::info(str::format("DXVK: ", DXVK_VERSION));
m_config = Config::getUserConfig(); m_config = Config::getUserConfig();
m_config.merge(Config::getAppConfig(env::getExeName())); m_config.merge(Config::getAppConfig(env::getExePath()));
m_config.logOptions(); m_config.logOptions();
g_vrInstance.initInstanceExtensions(); g_vrInstance.initInstanceExtensions();

View File

@ -1,6 +1,7 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <regex>
#include "config.h" #include "config.h"
@ -10,152 +11,133 @@
namespace dxvk { namespace dxvk {
const static std::unordered_map<std::string, Config> g_appDefaults = {{ const static std::vector<std::pair<const char*, Config>> g_appDefaults = {{
/* Anno 1800 */ /* Anno 1800 */
{ "Anno1800.exe", {{ { "\\\\Anno1800\\.exe$", {{
{ "d3d11.allowMapFlagNoWait", "True" } { "d3d11.allowMapFlagNoWait", "True" }
}} }, }} },
/* Assassin's Creed Syndicate: amdags issues */ /* Assassin's Creed Syndicate: amdags issues */
{ "ACS.exe", {{ { "\\\\ACS\\.exe$", {{
{ "dxgi.customVendorId", "10de" }, { "dxgi.customVendorId", "10de" },
}} }, }} },
/* Dishonored 2 */ /* Dishonored 2 */
{ "Dishonored2.exe", {{ { "\\\\Dishonored2\\.exe$", {{
{ "d3d11.allowMapFlagNoWait", "True" } { "d3d11.allowMapFlagNoWait", "True" }
}} }, }} },
/* Dissidia Final Fantasy NT Free Edition */ /* Dissidia Final Fantasy NT Free Edition */
{ "dffnt.exe", {{ { "\\\\dffnt\\.exe$", {{
{ "dxgi.deferSurfaceCreation", "True" }, { "dxgi.deferSurfaceCreation", "True" },
}} }, }} },
/* Elite Dangerous: Compiles weird shaders * /* Elite Dangerous: Compiles weird shaders *
* when running on AMD hardware */ * when running on AMD hardware */
{ "EliteDangerous64.exe", {{ { "\\\\EliteDangerous64\\.exe$", {{
{ "dxgi.customVendorId", "10de" }, { "dxgi.customVendorId", "10de" },
}} }, }} },
/* The Vanishing of Ethan Carter Redux */ /* The Vanishing of Ethan Carter Redux */
{ "EthanCarter-Win64-Shipping.exe", {{ { "\\\\EthanCarter-Win64-Shipping\\.exe$", {{
{ "dxgi.customVendorId", "10de" }, { "dxgi.customVendorId", "10de" },
}} }, }} },
/* The Evil Within: Submits command lists * /* The Evil Within: Submits command lists *
* multiple times */ * multiple times */
{ "EvilWithin.exe", {{ { "\\\\EvilWithin(Demo)?\\.exe$", {{
{ "d3d11.dcSingleUseMode", "False" },
}} },
/* The Evil Within Demo */
{ "EvilWithinDemo.exe", {{
{ "d3d11.dcSingleUseMode", "False" }, { "d3d11.dcSingleUseMode", "False" },
}} }, }} },
/* Far Cry 3: Assumes clear(0.5) on an UNORM * /* Far Cry 3: Assumes clear(0.5) on an UNORM *
* format to result in 128 on AMD and 127 on * * format to result in 128 on AMD and 127 on *
* Nvidia. We assume that the Vulkan drivers * * Nvidia. We assume that the Vulkan drivers *
* match the clear behaviour of D3D11. */ * match the clear behaviour of D3D11. */
{ "farcry3_d3d11.exe", {{ { "\\\\(farcry3|fc3_blooddragon)_d3d11\\.exe$", {{
{ "dxgi.nvapiHack", "False" },
}} },
{ "fc3_blooddragon_d3d11.exe", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Far Cry 4: Same as Far Cry 3 */ /* Far Cry 4: Same as Far Cry 3 */
{ "FarCry4.exe", {{ { "\\\\FarCry4\\.exe$", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Far Cry 5: Avoid CPU <-> GPU sync */ /* Far Cry 5: Avoid CPU <-> GPU sync */
{ "FarCry5.exe", {{ { "\\\\FarCry5\\.exe$", {{
{ "d3d11.allowMapFlagNoWait", "True" } { "d3d11.allowMapFlagNoWait", "True" }
}} }, }} },
/* Far Cry Primal: Nvidia performance */ /* Far Cry Primal: Nvidia performance */
{ "FCPrimal.exe", {{ { "\\\\FCPrimal\\.exe$", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
} }}, } }},
/* Frostpunk: Renders one frame with D3D9 * /* Frostpunk: Renders one frame with D3D9 *
* after creating the DXGI swap chain */ * after creating the DXGI swap chain */
{ "Frostpunk.exe", {{ { "\\\\Frostpunk\\.exe$", {{
{ "dxgi.deferSurfaceCreation", "True" }, { "dxgi.deferSurfaceCreation", "True" },
}} }, }} },
/* Nioh: See Frostpunk, apparently? */ /* Nioh: See Frostpunk, apparently? */
{ "nioh.exe", {{ { "\\\\nioh\\.exe$", {{
{ "dxgi.deferSurfaceCreation", "True" }, { "dxgi.deferSurfaceCreation", "True" },
}} }, }} },
/* Quantum Break: Mever initializes shared * /* Quantum Break: Mever initializes shared *
* memory in one of its compute shaders */ * memory in one of its compute shaders */
{ "QuantumBreak.exe", {{ { "\\\\QuantumBreak\\.exe$", {{
{ "d3d11.zeroInitWorkgroupMemory", "True" }, { "d3d11.zeroInitWorkgroupMemory", "True" },
}} }, }} },
/* Anno 2205: Random crashes with state cache */ /* Anno 2205: Random crashes with state cache */
{ "anno2205.exe", {{ { "\\\\anno2205\\.exe$", {{
{ "dxvk.enableStateCache", "False" }, { "dxvk.enableStateCache", "False" },
}} }, }} },
/* Fifa '19: Binds typed buffer SRV to shader * /* Fifa '19: Binds typed buffer SRV to shader *
* that expects raw/structured buffer SRV */ * that expects raw/structured buffer SRV */
{ "FIFA19.exe", {{ { "\\\\FIFA19(_demo)?\\.exe$", {{
{ "dxvk.useRawSsbo", "True" }, { "dxvk.useRawSsbo", "True" },
}} }, }} },
/* Final Fantasy XIV: Fix random black blocks */ /* Final Fantasy XIV: Fix random black blocks */
{ "ffxiv_dx11.exe", {{ { "\\\\ffxiv_dx11\\.exe$", {{
{ "d3d11.strictDivision", "True" }, { "d3d11.strictDivision", "True" },
}} }, }} },
/* Fifa '19 Demo */
{ "FIFA19_demo.exe", {{
{ "dxvk.useRawSsbo", "True" },
}} },
/* Resident Evil 2: Improve GPU performance */ /* Resident Evil 2: Improve GPU performance */
{ "re2.exe", {{ { "\\\\re2\\.exe$", {{
{ "d3d11.relaxedBarriers", "True" }, { "d3d11.relaxedBarriers", "True" },
}} }, }} },
/* Resident Evil 7 */ /* Resident Evil 7 */
{ "re7.exe", {{ { "\\\\re7\\.exe$", {{
{ "d3d11.relaxedBarriers", "True" }, { "d3d11.relaxedBarriers", "True" },
}} }, }} },
/* Devil May Cry 5 */ /* Devil May Cry 5 */
{ "DevilMayCry5.exe", {{ { "\\\\DevilMayCry5\\.exe$", {{
{ "d3d11.relaxedBarriers", "True" }, { "d3d11.relaxedBarriers", "True" },
}} }, }} },
/* Call of Duty WW2 */ /* Call of Duty WW2 */
{ "s2_sp64_ship.exe", {{ { "\\\\s2_sp64_ship\\.exe$", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Need for Speed 2015 */ /* Need for Speed 2015 */
{ "NFS16.exe", {{ { "\\\\NFS16\\.exe$", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Mass Effect Andromeda */ /* Mass Effect Andromeda */
{ "MassEffectAndromeda.exe", {{ { "\\\\MassEffectAndromeda\\.exe$", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Mirror`s Edge Catalyst: Crashes on AMD */ /* Mirror`s Edge Catalyst: Crashes on AMD */
{ "MirrorsEdgeCatalyst.exe", {{ { "\\\\MirrorsEdgeCatalyst(Trial)?\\.exe$", {{
{ "dxgi.customVendorId", "10de" },
}} },
/* Mirror`s Edge Catalyst Trial */
{ "MirrorsEdgeCatalystTrial.exe", {{
{ "dxgi.customVendorId", "10de" }, { "dxgi.customVendorId", "10de" },
}} }, }} },
/* Star Wars Battlefront (2015) */ /* Star Wars Battlefront (2015) */
{ "starwarsbattlefront.exe", {{ { "\\\\starwarsbattlefront(trial)?\\.exe$", {{
{ "dxgi.nvapiHack", "False" },
}} },
/* Star Wars Battlefront (2015) Trial */
{ "starwarsbattlefronttrial.exe", {{
{ "dxgi.nvapiHack", "False" }, { "dxgi.nvapiHack", "False" },
}} }, }} },
/* Dark Souls Remastered */ /* Dark Souls Remastered */
{ "DarkSoulsRemastered.exe", {{ { "\\\\DarkSoulsRemastered\\.exe$", {{
{ "d3d11.constantBufferRangeCheck", "True" }, { "d3d11.constantBufferRangeCheck", "True" },
}} }, }} },
/* Grim Dawn */ /* Grim Dawn */
{ "Grim Dawn.exe", {{ { "\\\\Grim Dawn\\.exe$", {{
{ "d3d11.constantBufferRangeCheck", "True" }, { "d3d11.constantBufferRangeCheck", "True" },
}} }, }} },
/* NieR:Automata */ /* NieR:Automata */
{ "NieRAutomata.exe", {{ { "\\\\NieRAutomata\\.exe$", {{
{ "d3d11.constantBufferRangeCheck", "True" }, { "d3d11.constantBufferRangeCheck", "True" },
}} }, }} },
/* The Surge */ /* The Surge */
{ "TheSurge.exe", {{ { "\\\\TheSurge\\.exe$", {{
{ "d3d11.allowMapFlagNoWait", "True" }, { "d3d11.allowMapFlagNoWait", "True" },
}} }, }} },
/* SteamVR performance test */ /* SteamVR performance test */
{ "vr.exe", {{ { "\\\\vr\\.exe$", {{
{ "d3d11.dcSingleUseMode", "False" }, { "d3d11.dcSingleUseMode", "False" },
}} }, }} },
}}; }};
@ -325,11 +307,15 @@ namespace dxvk {
Config Config::getAppConfig(const std::string& appName) { Config Config::getAppConfig(const std::string& appName) {
auto appConfig = g_appDefaults.find(appName); auto appConfig = std::find_if(g_appDefaults.begin(), g_appDefaults.end(),
[&appName] (const std::pair<const char*, Config>& pair) {
std::regex expr(pair.first, std::regex::extended | std::regex::icase);
return std::regex_search(appName, expr);
});
if (appConfig != g_appDefaults.end()) { if (appConfig != g_appDefaults.end()) {
// Inform the user that we loaded a default config // Inform the user that we loaded a default config
Logger::info(str::format("Found built-in config: ", appName)); Logger::info(str::format("Found built-in config:"));
return appConfig->second; return appConfig->second;
} }