Skip to content

Commit 7b58b52

Browse files
committed
nvngx: add OverrideAlphaUpscaling setting for DLSS 3.6+
more info at #132
1 parent bbee374 commit 7b58b52

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

ConfigTool/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NOTE: this code is pretty much freshly microwaved spaghetti
22
// It does the job it needs to, but probably could have been handled much better if I'd known where I was going with it from the start
33
//
4-
// So far this code has had several stages:
4+
// So far this code has been through several stages:
55
// going from a quick test project to write out an INI ->
66
// something that can also read our INI settings ->
77
// reading INI settings & tracking a default INI file alongside it, copying over comments/missing settings as needed ->
@@ -92,7 +92,7 @@ struct IniChange
9292

9393
static string[] BooleanKeys = new[] { "GlobalForceDLAA", "ForceDLAA", "DisableDevWatermark", "VerboseLogging", "Enable", "DisableIniMonitoring", "OverrideAppId", "EnableNvidiaSigOverride", "DynamicResolutionOverride" };
9494

95-
static string[] OverrideKeys = new[] { "OverrideAutoExposure", "OverrideDlssHud" };
95+
static string[] OverrideKeys = new[] { "OverrideAutoExposure", "OverrideAlphaUpscaling", "OverrideDlssHud" };
9696
static string[] OverrideValues = new[] { "Default", "Force disable", "Force enable" }; // 0, -1, 1
9797

9898
string DlssTweaksDll = "";

dlsstweaks.ini

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ ForceDLAA = false
4141
; Set to 0 to leave it at default, 1 to force enable, or -1 to force disable
4242
OverrideAutoExposure = 0
4343

44+
; OverrideAlphaUpscaling: allows forcing DLSS 3.6+ alpha-upscaling to be enabled/disabled/left at default
45+
; DLSS documentation describes this as:
46+
; By default, DLSS is intended for 3-channel RGB images, only. Experimental support for upscaling 4-
47+
; channel RGBA images can be enabled by setting the NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling
48+
; flag at creation time. For best results, the RGB color should be premultiplied by alpha in the color input.
49+
; Note: performance will be impacted by enabling this feature. Expect the overall execution time of DLSS
50+
; to increase by 15-25% when alpha blending is enabled.
51+
; It'll likely depend on the game whether alpha upscaling will work properly or not.
52+
; Set to 0 to leave it at default, 1 to force enable, or -1 to force disable
53+
OverrideAlphaUpscaling = 0
54+
4455
; OverrideSharpening: allows overriding the DLSS sharpening applied to the image
4556
; This only affects pre-2.5.1 DLSS versions, v2.5.1 and later versions removed sharpening from DLSS (use sharpening available in NV control panel instead)
4657
;
@@ -110,12 +121,10 @@ Quality = 0.66666667
110121

111122
[DLSSPresets]
112123
; DLSS preset overrides for each quality level: set to Default to leave the preset set to whatever game/DLSS decided for it
113-
; Or set to A / B / C / D / F to try forcing that preset instead.
124+
; Or set to A / B / C / D / E / F to try forcing that preset instead.
114125
; Presets were added in DLSS 3.1, these are essentially the different kinds of DLSS 2.x DLL versions, all merged into 3.1 as these presets
115-
; (so eg. instead of picking the best quality DLSS DLL for your game, you'd just find the right preset for it instead)
116126
; For descriptions of each preset see https://www.reddit.com/r/nvidia/comments/10z2ra9/nvidia_publishes_dlss_super_resolution_sdk_31/j81f9te/
117-
; (OverrideAppId should no longer be needed to use this section, any overrides should just work without needing anything else enabled)
118-
; (in case the presets here aren't being applied for you the OverrideAppId tweak can still be enabled in Compatibility section below)
127+
; (in case the presets here aren't being applied for you the OverrideAppId tweak in Compatibility section below might help)
119128

120129
DLAA = Default
121130
UltraPerformance = Default
@@ -154,8 +163,7 @@ DynamicResolutionMinOffset = -1
154163
; Not every setting can be applied during gameplay though, most will require game to be relaunched, depends on the game which settings can be changed
155164
; (DLSSPresets should work on almost every title though - you can use OverrideDlssHud to confirm)
156165
;
157-
; INI monitoring should have almost no cost to performance, but may possibly cause issues with certain games depending how they're installed
158-
; In case game fails to launch with DLSSTweaks in place, you can try disabling the INI update code here
166+
; In case game fails to launch with DLSSTweaks in place, try disabling the INI update code here
159167
DisableIniMonitoring = false
160168

161169
; OverrideAppId: previously this was required to be set in order to override DLSS3.1 presets on certain games

src/DLSSTweaks.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct UserSettings
8181

8282
bool forceDLAA = false;
8383
int overrideAutoExposure = 0;
84+
int overrideAlphaUpscaling = 0;
8485
std::optional<float> overrideSharpening{};
8586
std::string overrideSharpeningString = "ignore";
8687
bool overrideSharpeningForceDisable = false;

src/UserSettings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void UserSettings::print_to_log()
1111
spdlog::info(" - VerboseLogging: {}", verboseLogging ? "true" : "false");
1212
spdlog::info(" - ForceDLAA: {}{}", forceDLAA ? "true" : "false", overrideQualityLevels ? " (overridden by DLSSQualityLevels section)" : "");
1313
spdlog::info(" - OverrideAutoExposure: {}", overrideAutoExposure == 0 ? "default" : (overrideAutoExposure > 0 ? "enable" : "disable"));
14+
spdlog::info(" - OverrideAlphaUpscaling: {}", overrideAlphaUpscaling == 0 ? "default" : (overrideAlphaUpscaling > 0 ? "enable" : "disable"));
1415
if (overrideSharpeningForceDisable)
1516
spdlog::info(" - OverrideSharpening: disable (force disabling sharpness flag)");
1617
else if (overrideSharpening.has_value())
@@ -112,6 +113,7 @@ bool UserSettings::read(const std::filesystem::path& iniPath, int numInisRead)
112113
// [DLSS]
113114
forceDLAA = ini.Get<bool>("DLSS", "ForceDLAA", std::move(forceDLAA));
114115
overrideAutoExposure = ini.Get<int>("DLSS", "OverrideAutoExposure", std::move(overrideAutoExposure));
116+
overrideAlphaUpscaling = ini.Get<int>("DLSS", "OverrideAlphaUpscaling", std::move(overrideAlphaUpscaling));
115117

116118
std::string sharpeningString = utility::ini_get_string_safe(ini, "DLSS", "OverrideSharpening", std::move(overrideSharpeningString));
117119
if (!sharpeningString.length() || !_stricmp(sharpeningString.c_str(), "default") ||

src/module_hooks/nvngx.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ void __cdecl NVSDK_NGX_Parameter_SetI(NVSDK_NGX_Parameter* InParameter, const ch
255255
}
256256
}
257257

258+
if (settings.overrideAlphaUpscaling != 0)
259+
{
260+
if (settings.overrideAlphaUpscaling >= 1) // force alpha-upscaling
261+
{
262+
spdlog::debug("OverrideAlphaUpscaling: force enabling flag NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling");
263+
InValue |= NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling;
264+
}
265+
else if (settings.overrideAlphaUpscaling < 0) // force disable alpha-upscaling
266+
{
267+
spdlog::debug("OverrideAlphaUpscaling: force disabling flag NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling");
268+
InValue = InValue & ~NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling;
269+
}
270+
}
271+
258272
if (settings.overrideSharpeningForceDisable)
259273
{
260274
if (InValue & NVSDK_NGX_DLSS_Feature_Flags_DoSharpening)

src/resource.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#define TWEAKS_VER_MAJOR 0
1717
#define TWEAKS_VER_MINOR 200
18-
#define TWEAKS_VER_BUILD 8
19-
#define TWEAKS_VER_REVISION 2
18+
#define TWEAKS_VER_BUILD 9
19+
#define TWEAKS_VER_REVISION 0
2020

2121
#define STR(value) #value
2222
#define STRINGIZE(value) STR(value)

0 commit comments

Comments
 (0)