Skip to content

Commit f52efca

Browse files
authored
fix: add UseGenericAppIdWithDlss to fix OptiScaler's overrides not working on certain games. (#72)
thanks 👍
1 parent e28a385 commit f52efca

9 files changed

+64
-4
lines changed

OptiScaler/Config.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ bool Config::Reload(std::filesystem::path iniPath)
276276

277277
UsePrecompiledShaders = readBool("Hotfix", "UsePrecompiledShaders");
278278

279+
UseGenericAppIdWithDlss = readBool("Hotfix", "UseGenericAppIdWithDlss");
280+
279281
ColorResourceBarrier = readInt("Hotfix", "ColorResourceBarrier");
280282
MVResourceBarrier = readInt("Hotfix", "MotionVectorResourceBarrier");
281283
DepthResourceBarrier = readInt("Hotfix", "DepthResourceBarrier");
@@ -566,6 +568,8 @@ bool Config::SaveIni()
566568

567569
ini.SetValue("Hotfix", "UsePrecompiledShaders", GetBoolValue(Instance()->UsePrecompiledShaders).c_str());
568570

571+
ini.SetValue("Hotfix", "UseGenericAppIdWithDlss", GetBoolValue(Instance()->UseGenericAppIdWithDlss).c_str());
572+
569573
ini.SetValue("Hotfix", "ColorResourceBarrier", GetIntValue(Instance()->ColorResourceBarrier).c_str());
570574
ini.SetValue("Hotfix", "MotionVectorResourceBarrier", GetIntValue(Instance()->MVResourceBarrier).c_str());
571575
ini.SetValue("Hotfix", "DepthResourceBarrier", GetIntValue(Instance()->DepthResourceBarrier).c_str());

OptiScaler/Config.h

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class Config
106106

107107
std::optional<bool> UsePrecompiledShaders;
108108

109+
std::optional<bool> UseGenericAppIdWithDlss;
110+
109111
std::optional<int32_t> ColorResourceBarrier;
110112
std::optional<int32_t> MVResourceBarrier;
111113
std::optional<int32_t> DepthResourceBarrier;

OptiScaler/NVNGX.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,19 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_UpdateFeature(const NVSDK_NGX_Applicati
107107
{
108108
if (ApplicationId->IdentifierType == NVSDK_NGX_Application_Identifier_Type_Application_Id)
109109
{
110-
LOG_INFO("Update ApplicationId: {0:X}", ApplicationId->v.ApplicationId);
111-
Config::Instance()->NVNGX_ApplicationId = ApplicationId->v.ApplicationId;
110+
auto appId = Config::Instance()->UseGenericAppIdWithDlss.value_or(false) ? app_id_override : ApplicationId->v.ApplicationId;
111+
LOG_INFO("Update ApplicationId: {0:X}", appId);
112+
Config::Instance()->NVNGX_ApplicationId = appId;
112113
}
113114
else if (ApplicationId->IdentifierType == NVSDK_NGX_Application_Identifier_Type_Project_Id)
114115
{
115-
Config::Instance()->NVNGX_ProjectId = std::string(ApplicationId->v.ProjectDesc.ProjectId);
116+
auto projectId = Config::Instance()->UseGenericAppIdWithDlss.value_or(false) ? project_id_override :
117+
std::string(ApplicationId->v.ProjectDesc.ProjectId);
118+
Config::Instance()->NVNGX_ProjectId = projectId;
116119
Config::Instance()->NVNGX_Engine = ApplicationId->v.ProjectDesc.EngineType;
117120
Config::Instance()->NVNGX_EngineVersion = std::string(ApplicationId->v.ProjectDesc.EngineVersion);
118121

119-
LOG_INFO("Update InProjectId: {0}", Config::Instance()->NVNGX_ProjectId);
122+
LOG_INFO("Update InProjectId: {0}", projectId);
120123
LOG_INFO("Update InEngineType: {0}", (int)Config::Instance()->NVNGX_Engine);
121124
LOG_INFO("Update InEngineVersion: {0}", Config::Instance()->NVNGX_EngineVersion);
122125
}

OptiScaler/NVNGX_DLSS_Dx11.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init_Ext(unsigned long long InApp
3434
{
3535
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsDx11Inited())
3636
{
37+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
38+
InApplicationId = app_id_override;
39+
3740
if (NVNGXProxy::NVNGXModule() == nullptr)
3841
NVNGXProxy::InitNVNGX();
3942

@@ -106,6 +109,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init(unsigned long long InApplica
106109
{
107110
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsDx11Inited())
108111
{
112+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
113+
InApplicationId = app_id_override;
114+
109115
if (NVNGXProxy::NVNGXModule() == nullptr)
110116
NVNGXProxy::InitNVNGX();
111117

@@ -131,6 +137,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init_ProjectID(const char* InProj
131137
{
132138
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsDx11Inited())
133139
{
140+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
141+
InProjectId = project_id_override;
142+
134143
if (NVNGXProxy::NVNGXModule() == nullptr)
135144
NVNGXProxy::InitNVNGX();
136145

OptiScaler/NVNGX_DLSS_Dx12.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp
209209
{
210210
LOG_FUNC();
211211

212+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
213+
InApplicationId = app_id_override;
214+
212215
Config::Instance()->NVNGX_ApplicationId = InApplicationId;
213216
Config::Instance()->NVNGX_ApplicationDataPath = std::wstring(InApplicationDataPath);
214217
Config::Instance()->NVNGX_Version = InSDKVersion;
@@ -291,6 +294,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init(unsigned long long InApplica
291294

292295
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsDx12Inited())
293296
{
297+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
298+
InApplicationId = app_id_override;
299+
294300
if (NVNGXProxy::NVNGXModule() == nullptr)
295301
NVNGXProxy::InitNVNGX();
296302

@@ -319,6 +325,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_ProjectID(const char* InProj
319325

320326
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsDx12Inited())
321327
{
328+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
329+
InProjectId = project_id_override;
330+
322331
if (NVNGXProxy::NVNGXModule() == nullptr)
323332
NVNGXProxy::InitNVNGX();
324333

OptiScaler/NVNGX_DLSS_Vk.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_Ext(unsigned long long InAp
3636

3737
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsVulkanInited())
3838
{
39+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
40+
InApplicationId = app_id_override;
41+
3942
if (NVNGXProxy::NVNGXModule() == nullptr)
4043
NVNGXProxy::InitNVNGX();
4144

@@ -59,6 +62,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_Ext2(unsigned long long InA
5962

6063
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsVulkanInited())
6164
{
65+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
66+
InApplicationId = app_id_override;
67+
6268
if (NVNGXProxy::NVNGXModule() == nullptr)
6369
NVNGXProxy::InitNVNGX();
6470

@@ -206,6 +212,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init(unsigned long long InApplic
206212

207213
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsVulkanInited())
208214
{
215+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
216+
InApplicationId = app_id_override;
217+
209218
if (NVNGXProxy::NVNGXModule() == nullptr)
210219
NVNGXProxy::InitNVNGX();
211220

@@ -230,6 +239,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_ProjectID(const char* InPro
230239

231240
if (Config::Instance()->DLSSEnabled.value_or(true) && !NVNGXProxy::IsVulkanInited())
232241
{
242+
if (Config::Instance()->UseGenericAppIdWithDlss.value_or(false))
243+
InProjectId = project_id_override;
244+
233245
if (NVNGXProxy::NVNGXModule() == nullptr)
234246
NVNGXProxy::InitNVNGX();
235247

OptiScaler/NVNGX_Proxy.h

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <filesystem>
1212
#include "detours/detours.h"
1313

14+
inline const char* project_id_override = "24480451-f00d-face-1304-0308dabad187";
15+
constexpr unsigned long long app_id_override = 0x24480451;
16+
1417
#pragma region spoofing hooks for 16xx
1518

1619
// NvAPI_GPU_GetArchInfo hooking based on Nukem's spoofing code here

OptiScaler/imgui/imgui_common.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,20 @@ void ImGuiCommon::RenderMenu()
17441744
Config::Instance()->changeBackend = true;
17451745
}
17461746
}
1747+
1748+
if (Config::Instance()->AdvancedSettings.value_or(false) && currentBackend == "dlss")
1749+
{
1750+
bool appIdOverride = Config::Instance()->UseGenericAppIdWithDlss.value_or(false);
1751+
1752+
if (ImGui::Checkbox("Use Generic App Id with DLSS", &appIdOverride))
1753+
{
1754+
Config::Instance()->UseGenericAppIdWithDlss = appIdOverride;
1755+
}
1756+
1757+
ShowHelpMarker("Use generic appid with NGX\n"
1758+
"Fixes OptiScaler preset override not working with certain games\n"
1759+
"Requires a game restart.");
1760+
}
17471761
}
17481762
}
17491763

nvngx.ini

+4
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ ExposureResourceBarrier=auto
502502
; Default (auto) is state correction disabled
503503
OutputResourceBarrier=auto
504504

505+
; Use generic appid with NGX, fixes OptiScaler preset override not working with certain games
506+
; true or false - Default (auto) is false
507+
UseGenericAppIdWithDlss=auto
508+
505509
; These settings defines each resources initial resource
506510
; state and add resource barrier for correct state
507511
;

0 commit comments

Comments
 (0)