Skip to content

Commit

Permalink
INI: add ResolutionOffset setting, helps games that don't like full…
Browse files Browse the repository at this point in the history
…-res DLAA
  • Loading branch information
emoose committed Mar 16, 2023
1 parent 42a95a8 commit b44d9ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
10 changes: 10 additions & 0 deletions dlsstweaks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,13 @@ Quality = Default
Balanced = Default
Performance = Default
UltraPerformance = Default

[Compatibility]
; ResolutionOffset: offsets both resolution axes by this value when DLAA is being applied
; Some games might not function well with full-resolution DLAA for whatever reason
; Subtracting a tiny amount from the resolution first may help with them though
; This offset is only applied to DLAA modes (either from ForceDLAA, DLSSQualityLevels 1.00, or the game setting DLAA itself)
; Titles known to require this for DLAA to work:
; - RE Engine titles (set to -1)
; - Crysis 3 Remastered (set to -1)
ResolutionOffset = 0
1 change: 1 addition & 0 deletions src/DLSSTweaks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct UserSettings
unsigned int presetBalanced = NVSDK_NGX_DLSS_Hint_Render_Preset_Default;
unsigned int presetPerformance = NVSDK_NGX_DLSS_Hint_Render_Preset_Default;
unsigned int presetUltraPerformance = NVSDK_NGX_DLSS_Hint_Render_Preset_Default;
int resolutionOffset = 0; // user-defined offset to apply to DLAA / full-res rendering (some titles don't like DLAA rendering at full res, so small offset is needed)

void print_to_log();
};
Expand Down
3 changes: 3 additions & 0 deletions src/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ bool INIReadSettings()
settings.presetPerformance = DLSS_ReadPresetFromIni(ini, "DLSSPresets", "Performance");
settings.presetUltraPerformance = DLSS_ReadPresetFromIni(ini, "DLSSPresets", "UltraPerformance");

// [Compatibility]
settings.resolutionOffset = ini.Get<int>("Compatibility", "ResolutionOffset", std::move(settings.resolutionOffset));

if (!settings.overrideDlssDll.empty() && !std::filesystem::exists(settings.overrideDlssDll))
{
spdlog::warn("Disabling OverrideDlssDll as override DLL wasn't found (path: {})", settings.overrideDlssDll.string());
Expand Down
16 changes: 12 additions & 4 deletions src/HooksNvngx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,15 @@ uint64_t __cdecl NVSDK_NGX_Parameter_GetUI(void* InParameter, const char* InName
if (overrideWidth || overrideHeight)
{
if (overrideWidth && *OutValue != 0)
{
NVSDK_NGX_Parameter_GetUI_Hook.call(InParameter, NVSDK_NGX_Parameter_Width, OutValue);
*OutValue += settings.resolutionOffset;
}
if (overrideHeight && *OutValue != 0)
{
NVSDK_NGX_Parameter_GetUI_Hook.call(InParameter, NVSDK_NGX_Parameter_Height, OutValue);
*OutValue += settings.resolutionOffset;
}
}

// Override with DLSSQualityLevels value if user set it
Expand All @@ -213,15 +219,17 @@ uint64_t __cdecl NVSDK_NGX_Parameter_GetUI(void* InParameter, const char* InName
{
unsigned int targetWidth = 0;
NVSDK_NGX_Parameter_GetUI_Hook.call(InParameter, NVSDK_NGX_Parameter_Width, &targetWidth); // fetch full screen width
targetWidth = unsigned int(roundf(float(targetWidth) * qualityLevelRatios[prevQualityValue])); // calculate new width from custom ratio
*OutValue = targetWidth;
*OutValue = unsigned int(roundf(float(targetWidth) * qualityLevelRatios[prevQualityValue])); // calculate new width from custom ratio
if (*OutValue == targetWidth) // apply resolutionOffset compatibility hack if it matches the target screen res
*OutValue += settings.resolutionOffset;
}
if (isOutHeight)
{
unsigned int targetHeight = 0;
NVSDK_NGX_Parameter_GetUI_Hook.call(InParameter, NVSDK_NGX_Parameter_Height, &targetHeight); // fetch full screen height
targetHeight = unsigned int(roundf(float(targetHeight) * qualityLevelRatios[prevQualityValue])); // calculate new height from custom ratio
*OutValue = targetHeight;
*OutValue = unsigned int(roundf(float(targetHeight) * qualityLevelRatios[prevQualityValue])); // calculate new height from custom ratio
if (*OutValue == targetHeight) // apply resolutionOffset compatibility hack if it matches the target screen res
*OutValue += settings.resolutionOffset;
}
}

Expand Down

0 comments on commit b44d9ff

Please sign in to comment.