Distinguish NGX Params and FG mods by API and allow Vulkan FG only for Nukem's

This commit is contained in:
FakeMichau
2026-07-31 16:14:37 +02:00
parent 5819406666
commit cafefdf4e0
12 changed files with 163 additions and 146 deletions
+11 -10
View File
@@ -75,7 +75,7 @@ std::optional<float> GetQualityOverrideRatio(const NVSDK_NGX_PerfQuality_Value i
return output;
}
NVNGX_Parameters::NVNGX_Parameters(std::string_view name, bool isPersistent) : Name(name)
NVNGX_Parameters::NVNGX_Parameters(API api, bool isPersistent) : Api(api)
{
// Old flag used to indicate custom table. Obsolete?
Set("OptiScaler", 1);
@@ -349,7 +349,8 @@ void NVNGX_Parameters::Reset()
LOG_DEBUG("Start");
InitNGXParameters(this);
// As fallback using api during params creation
InitNGXParameters(this, Api);
LOG_DEBUG("End");
}
@@ -701,7 +702,7 @@ NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetStatsCallback(NVSDK_NGX_Parameter*
return NVSDK_NGX_Result_Success;
}
void InitNGXParameters(NVSDK_NGX_Parameter* InParams)
void InitNGXParameters(NVSDK_NGX_Parameter* InParams, API api)
{
InParams->Set(NVSDK_NGX_Parameter_SuperSampling_Available, 1);
@@ -798,9 +799,9 @@ void InitNGXParameters(NVSDK_NGX_Parameter* InParams)
InParams->Set("SuperSamplingDenoising.FeatureInitResult", 0);
}
// not ideal as it doesn't take different APIs into account
if (State::Instance().activeFgInput == FGInput::NvngxFG || State::Instance().activeFgInput == FGInput::DLSSG ||
State::Instance().activeFgOutput == FGOutput::DLSSGWithNvngx)
if ((api == API::DX12 || api == API::Vulkan) &&
(State::Instance().activeFgInput == FGInput::NvngxFG || State::Instance().activeFgInput == FGInput::DLSSG ||
State::Instance().activeFgOutput == FGOutput::DLSSGWithNvngx))
{
InParams->Set("FrameGeneration.Available", 1);
InParams->Set("FrameGeneration.NeedsUpdatedDriver", 0);
@@ -810,7 +811,7 @@ void InitNGXParameters(NVSDK_NGX_Parameter* InParams)
InParams->Set(NVSDK_NGX_Parameter_FrameInterpolation_FeatureInitResult, 1);
// Streamline handle the max interpolated frame count
InParams->Set("DLSSG.MultiFrameCountMax", Nvngx_FG::isMFG() ? 5 : 1);
InParams->Set("DLSSG.MultiFrameCountMax", Nvngx_FG::getMaxFakeFramesCount(api));
if (State::Instance().NVNGX_Engine == NVSDK_NGX_ENGINE_TYPE_UNREAL ||
State::Instance().gameEngine == GameEngineType::Unreal ||
@@ -827,10 +828,10 @@ void InitNGXParameters(NVSDK_NGX_Parameter* InParams)
}
}
NVNGX_Parameters* GetNGXParameters(std::string_view name, bool isPersistent)
NVNGX_Parameters* GetNGXParameters(API api, bool isPersistent)
{
auto params = new NVNGX_Parameters(name, isPersistent);
InitNGXParameters(params);
auto params = new NVNGX_Parameters(api, isPersistent);
InitNGXParameters(params, api);
return params;
}
+4 -4
View File
@@ -49,7 +49,7 @@ static NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetStatsCallback(NVSDK_NGX_Par
/// @brief Initializes an NGX parameter object with supported feature flags (DLSS, FrameGen), version info, and default
/// values.
void InitNGXParameters(NVSDK_NGX_Parameter* InParams);
void InitNGXParameters(NVSDK_NGX_Parameter* InParams, API api);
/// @brief Internal variant structure holding the value of a single NGX parameter.
struct Parameter
@@ -190,13 +190,13 @@ struct Parameter
/// parameters.
struct NVNGX_Parameters : public NVSDK_NGX_Parameter
{
std::string Name;
API Api;
#ifdef ENABLE_ENCAPSULATED_PARAMS
NVSDK_NGX_Parameter* OriginalParam = nullptr;
#endif // ENABLE_ENCAPSULATED_PARAMS
NVNGX_Parameters(std::string_view name, bool isPersistent);
NVNGX_Parameters(API api, bool isPersistent);
void Set(const char* key, unsigned long long value) override;
void Set(const char* key, float value) override;
@@ -240,7 +240,7 @@ struct NVNGX_Parameters : public NVSDK_NGX_Parameter
* @brief Allocates and populates a new custom NGX param map. The persistence flag indicates
* whether the table should be destroyed when NGX DestroyParameters() is used.
*/
NVNGX_Parameters* GetNGXParameters(std::string_view name, bool isPersistent);
NVNGX_Parameters* GetNGXParameters(API api, bool isPersistent);
/**
* @brief Sets a custom tracking tag to indicate the memory management strategy required by
+86 -80
View File
@@ -30,7 +30,7 @@ static BOOL WINAPI hkGetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LE
void Nvngx_FG::setSetting(const wchar_t* setting, const wchar_t* value)
{
if (is120orNewer() && !_mfg)
if (is120orNewer())
{
SetEnvironmentVariable(setting, value);
_refreshGlobalConfiguration();
@@ -40,7 +40,7 @@ void Nvngx_FG::setSetting(const wchar_t* setting, const wchar_t* value)
HMODULE Nvngx_FG::TryInitMFG()
{
// set early so the hooks know
_mfg = true;
_mfgDx12 = true;
HMODULE dll = nullptr;
if (o_GetFileAttributesExW)
@@ -69,7 +69,7 @@ HMODULE Nvngx_FG::TryInitMFG()
}
if (!dll)
_mfg = false;
_mfgDx12 = false;
return dll;
}
@@ -84,26 +84,26 @@ void Nvngx_FG::InitDLSSGMod_Dx12()
return;
}
_dll = TryInitMFG();
_dllDx12 = TryInitMFG();
if (_dll != nullptr)
if (_dllDx12 != nullptr)
{
_DLSSG_D3D12_Init = (PFN_D3D12_Init) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_Init");
_DLSSG_D3D12_Init_Ext = (PFN_D3D12_Init_Ext) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_Init_Ext");
_DLSSG_D3D12_Shutdown = (PFN_D3D12_Shutdown) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_Shutdown");
_DLSSG_D3D12_Shutdown1 = (PFN_D3D12_Shutdown1) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_Shutdown1");
_DLSSG_D3D12_Init = (PFN_D3D12_Init) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_Init");
_DLSSG_D3D12_Init_Ext = (PFN_D3D12_Init_Ext) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_Init_Ext");
_DLSSG_D3D12_Shutdown = (PFN_D3D12_Shutdown) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_Shutdown");
_DLSSG_D3D12_Shutdown1 = (PFN_D3D12_Shutdown1) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_Shutdown1");
_DLSSG_D3D12_GetScratchBufferSize =
(PFN_D3D12_GetScratchBufferSize) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_GetScratchBufferSize");
(PFN_D3D12_GetScratchBufferSize) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_GetScratchBufferSize");
_DLSSG_D3D12_CreateFeature =
(PFN_D3D12_CreateFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_CreateFeature");
(PFN_D3D12_CreateFeature) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_CreateFeature");
_DLSSG_D3D12_ReleaseFeature =
(PFN_D3D12_ReleaseFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_ReleaseFeature");
(PFN_D3D12_ReleaseFeature) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_ReleaseFeature");
_DLSSG_D3D12_GetFeatureRequirements =
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_GetFeatureRequirements");
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_GetFeatureRequirements");
_DLSSG_D3D12_EvaluateFeature =
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_EvaluateFeature");
_DLSSG_D3D12_PopulateParameters_Impl =
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_D3D12_PopulateParameters_Impl");
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dllDx12, "DLSSG_NVSDK_NGX_D3D12_EvaluateFeature");
_DLSSG_D3D12_PopulateParameters_Impl = (PFN_D3D12_PopulateParameters_Impl) GetProcAddress(
_dllDx12, "DLSSG_NVSDK_NGX_D3D12_PopulateParameters_Impl");
_dx12_inited = _DLSSG_D3D12_Init != nullptr;
@@ -114,32 +114,34 @@ void Nvngx_FG::InitDLSSGMod_Dx12()
else
{
HMODULE memModule = nullptr;
auto optiPath = Config::Instance()->MainDllPath.value();
Util::LoadProxyLibrary(L"dlssg_to_fsr3_amd_is_better.dll", L"", optiPath, &memModule, &_dll);
auto& optiPath = Config::Instance()->MainDllPath.value();
Util::LoadProxyLibrary(L"dlssg_to_fsr3_amd_is_better.dll", L"", optiPath, &memModule, &_dllDx12);
if (_dll == nullptr && memModule != nullptr)
_dll = memModule;
if (_dllDx12 == nullptr && memModule != nullptr)
_dllDx12 = memModule;
}
if (_dll != nullptr)
if (_dllDx12 != nullptr)
{
_DLSSG_D3D12_Init = (PFN_D3D12_Init) GetProcAddress(_dll, "NVSDK_NGX_D3D12_Init");
_DLSSG_D3D12_Init_Ext = (PFN_D3D12_Init_Ext) GetProcAddress(_dll, "NVSDK_NGX_D3D12_Init_Ext");
_DLSSG_D3D12_Shutdown = (PFN_D3D12_Shutdown) GetProcAddress(_dll, "NVSDK_NGX_D3D12_Shutdown");
_DLSSG_D3D12_Shutdown1 = (PFN_D3D12_Shutdown1) GetProcAddress(_dll, "NVSDK_NGX_D3D12_Shutdown1");
_DLSSG_D3D12_Init = (PFN_D3D12_Init) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_Init");
_DLSSG_D3D12_Init_Ext = (PFN_D3D12_Init_Ext) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_Init_Ext");
_DLSSG_D3D12_Shutdown = (PFN_D3D12_Shutdown) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_Shutdown");
_DLSSG_D3D12_Shutdown1 = (PFN_D3D12_Shutdown1) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_Shutdown1");
_DLSSG_D3D12_GetScratchBufferSize =
(PFN_D3D12_GetScratchBufferSize) GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetScratchBufferSize");
_DLSSG_D3D12_CreateFeature = (PFN_D3D12_CreateFeature) GetProcAddress(_dll, "NVSDK_NGX_D3D12_CreateFeature");
_DLSSG_D3D12_ReleaseFeature = (PFN_D3D12_ReleaseFeature) GetProcAddress(_dll, "NVSDK_NGX_D3D12_ReleaseFeature");
(PFN_D3D12_GetScratchBufferSize) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_GetScratchBufferSize");
_DLSSG_D3D12_CreateFeature =
(PFN_D3D12_CreateFeature) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_CreateFeature");
_DLSSG_D3D12_ReleaseFeature =
(PFN_D3D12_ReleaseFeature) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_ReleaseFeature");
_DLSSG_D3D12_GetFeatureRequirements =
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetFeatureRequirements");
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_GetFeatureRequirements");
_DLSSG_D3D12_EvaluateFeature =
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_D3D12_EvaluateFeature");
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_EvaluateFeature");
_DLSSG_D3D12_PopulateParameters_Impl =
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(_dll, "NVSDK_NGX_D3D12_PopulateParameters_Impl");
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(_dllDx12, "NVSDK_NGX_D3D12_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dllDx12, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dllDx12, "FSRDebugView");
_dx12_inited = true;
LOG_INFO("DLSSG Mod initialized for DX12");
@@ -157,70 +159,74 @@ void Nvngx_FG::InitDLSSGMod_Vulkan()
if (_vulkan_inited || Config::Instance()->FGInput.value_or_default() != FGInput::NvngxFG)
return;
// Avoid using Enabler for Vulkan
// Vulkan support was removed in 4.4; in <=4.3 only the original Nukem's 2x mode is supported
_dll = TryInitMFG();
//_dllVulkan = TryInitMFG();
if (_dll != nullptr)
{
_DLSSG_VULKAN_Init = (PFN_VULKAN_Init) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_Init");
_DLSSG_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_Init_Ext");
_DLSSG_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_Init_Ext2");
_DLSSG_VULKAN_Shutdown = (PFN_VULKAN_Shutdown) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_Shutdown");
_DLSSG_VULKAN_Shutdown1 = (PFN_VULKAN_Shutdown1) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_Shutdown1");
_DLSSG_VULKAN_GetScratchBufferSize =
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_GetScratchBufferSize");
_DLSSG_VULKAN_CreateFeature =
(PFN_VULKAN_CreateFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature");
_DLSSG_VULKAN_CreateFeature1 =
(PFN_VULKAN_CreateFeature1) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature1");
_DLSSG_VULKAN_ReleaseFeature =
(PFN_VULKAN_ReleaseFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_ReleaseFeature");
_DLSSG_VULKAN_GetFeatureRequirements =
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_GetFeatureRequirements");
_DLSSG_VULKAN_EvaluateFeature =
(PFN_VULKAN_EvaluateFeature) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_EvaluateFeature");
_DLSSG_VULKAN_PopulateParameters_Impl =
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(_dll, "DLSSG_NVSDK_NGX_VULKAN_PopulateParameters_Impl");
// if (_dllVulkan != nullptr)
//{
// _DLSSG_VULKAN_Init = (PFN_VULKAN_Init) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_Init");
// _DLSSG_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_Init_Ext");
// _DLSSG_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2) GetProcAddress(_dllVulkan,
// "DLSSG_NVSDK_NGX_VULKAN_Init_Ext2"); _DLSSG_VULKAN_Shutdown = (PFN_VULKAN_Shutdown)
// GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_Shutdown"); _DLSSG_VULKAN_Shutdown1 =
// (PFN_VULKAN_Shutdown1) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_Shutdown1");
// _DLSSG_VULKAN_GetScratchBufferSize =
// (PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dllVulkan,
// "DLSSG_NVSDK_NGX_VULKAN_GetScratchBufferSize");
// _DLSSG_VULKAN_CreateFeature =
// (PFN_VULKAN_CreateFeature) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature");
// _DLSSG_VULKAN_CreateFeature1 =
// (PFN_VULKAN_CreateFeature1) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_CreateFeature1");
// _DLSSG_VULKAN_ReleaseFeature =
// (PFN_VULKAN_ReleaseFeature) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_ReleaseFeature");
// _DLSSG_VULKAN_GetFeatureRequirements = (PFN_VULKAN_GetFeatureRequirements) GetProcAddress(
// _dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_GetFeatureRequirements");
// _DLSSG_VULKAN_EvaluateFeature =
// (PFN_VULKAN_EvaluateFeature) GetProcAddress(_dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_EvaluateFeature");
// _DLSSG_VULKAN_PopulateParameters_Impl = (PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(
// _dllVulkan, "DLSSG_NVSDK_NGX_VULKAN_PopulateParameters_Impl");
_vulkan_inited = _DLSSG_VULKAN_Init != nullptr;
// _vulkan_inited = _DLSSG_VULKAN_Init != nullptr;
LOG_INFO("DLSSG MFG Mod initialized for Vulkan");
// LOG_INFO("DLSSG MFG Mod initialized for Vulkan");
return;
}
else
// return;
//}
// else
{
HMODULE memModule = nullptr;
auto optiPath = Config::Instance()->MainDllPath.value();
Util::LoadProxyLibrary(L"dlssg_to_fsr3_amd_is_better.dll", L"", optiPath, &memModule, &_dll);
auto& optiPath = Config::Instance()->MainDllPath.value();
Util::LoadProxyLibrary(L"dlssg_to_fsr3_amd_is_better.dll", L"", optiPath, &memModule, &_dllVulkan);
if (_dll == nullptr && memModule != nullptr)
_dll = memModule;
if (_dllVulkan == nullptr && memModule != nullptr)
_dllVulkan = memModule;
}
if (_dll != nullptr)
if (_dllVulkan != nullptr)
{
_DLSSG_VULKAN_Init = (PFN_VULKAN_Init) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init");
_DLSSG_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_Ext");
_DLSSG_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_Ext2");
_DLSSG_VULKAN_Shutdown = (PFN_VULKAN_Shutdown) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Shutdown");
_DLSSG_VULKAN_Shutdown1 = (PFN_VULKAN_Shutdown1) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Shutdown1");
_DLSSG_VULKAN_Init = (PFN_VULKAN_Init) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_Init");
_DLSSG_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_Init_Ext");
_DLSSG_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_Init_Ext2");
_DLSSG_VULKAN_Shutdown = (PFN_VULKAN_Shutdown) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_Shutdown");
_DLSSG_VULKAN_Shutdown1 = (PFN_VULKAN_Shutdown1) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_Shutdown1");
_DLSSG_VULKAN_GetScratchBufferSize =
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetScratchBufferSize");
_DLSSG_VULKAN_CreateFeature = (PFN_VULKAN_CreateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature");
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_GetScratchBufferSize");
_DLSSG_VULKAN_CreateFeature =
(PFN_VULKAN_CreateFeature) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_CreateFeature");
_DLSSG_VULKAN_CreateFeature1 =
(PFN_VULKAN_CreateFeature1) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature1");
(PFN_VULKAN_CreateFeature1) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_CreateFeature1");
_DLSSG_VULKAN_ReleaseFeature =
(PFN_VULKAN_ReleaseFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_ReleaseFeature");
(PFN_VULKAN_ReleaseFeature) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_ReleaseFeature");
_DLSSG_VULKAN_GetFeatureRequirements =
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureRequirements");
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_GetFeatureRequirements");
_DLSSG_VULKAN_EvaluateFeature =
(PFN_VULKAN_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_EvaluateFeature");
(PFN_VULKAN_EvaluateFeature) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_EvaluateFeature");
_DLSSG_VULKAN_PopulateParameters_Impl =
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_PopulateParameters_Impl");
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(_dllVulkan, "NVSDK_NGX_VULKAN_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dllVulkan, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dllVulkan, "FSRDebugView");
_vulkan_inited = true;
LOG_INFO("DLSSG Mod initialized for Vulkan");
@@ -408,7 +414,7 @@ NVSDK_NGX_Result Nvngx_FG::D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCm
}
bool applyHudCutoff = Config::Instance()->FGHudCutoff.value_or_default() > 0.0f ||
(State::Instance().gameQuirks & GameQuirk::FSRFGHudlessMismatchFixup && !_mfg);
(State::Instance().gameQuirks & GameQuirk::FSRFGHudlessMismatchFixup && !_mfgDx12);
uint32_t frameIndex = 1;
InParameters->Get("DLSSG.MultiFrameIndex", &frameIndex);
+23 -6
View File
@@ -14,7 +14,8 @@ typedef void (*PFN_EnableDebugView)(bool enable);
class Nvngx_FG
{
private:
inline static HMODULE _dll = nullptr;
inline static HMODULE _dllDx12 = nullptr;
inline static HMODULE _dllVulkan = nullptr;
inline static PFN_RefreshGlobalConfiguration _refreshGlobalConfiguration = nullptr;
inline static PFN_EnableDebugView _fsrDebugView = nullptr; // for now keep compatibility with the patched 0.110
@@ -46,7 +47,7 @@ class Nvngx_FG
inline static bool _dx12_inited = false;
inline static bool _vulkan_inited = false;
inline static bool _mfg = false;
inline static bool _mfgDx12 = false;
inline static std::unique_ptr<HudCopy_Dx12> _hudCopy;
@@ -62,10 +63,26 @@ class Nvngx_FG
static void InitDLSSGMod_Vulkan();
static inline bool isLoaded() { return _dll != nullptr; }
static inline bool isLoaded(API api)
{
if (api == API::DX12)
return _dllDx12 != nullptr;
else if (api == API::Vulkan)
return _dllVulkan != nullptr;
return false;
}
// Essentially a check to see if we are using Artur's mod for nvngx fg
static inline bool isMFG() { return _mfg; }
static inline int getMaxFakeFramesCount(API api)
{
if (api == API::Vulkan || api == API::DX12 && !_mfgDx12)
return 1;
else if (api == API::DX12 && _mfgDx12)
return 5;
return 0;
}
static void setDebugView(bool enabled);
@@ -75,7 +92,7 @@ class Nvngx_FG
static inline PFN_EnableDebugView FSRDebugView() { return _fsrDebugView; }
static inline bool isDx12Available() { return isLoaded() && _dx12_inited; }
static inline bool isDx12Available() { return isLoaded(API::DX12) && _dx12_inited; }
static NVSDK_NGX_Result D3D12_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo,
@@ -109,7 +126,7 @@ class Nvngx_FG
static NVSDK_NGX_Result D3D12_PopulateParameters_Impl(NVSDK_NGX_Parameter* InParameters);
// Vulkan
static inline bool isVulkanAvailable() { return isLoaded() && _vulkan_inited; }
static inline bool isVulkanAvailable() { return isLoaded(API::Vulkan) && _vulkan_inited; }
static NVSDK_NGX_Result VULKAN_Init(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath,
VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice,
+5 -2
View File
@@ -271,7 +271,9 @@ sl::Result StreamlineHooks::hkslSetTag(const sl::ViewportHandle& viewport, const
LOG_TRACE("Tagging resource of type: {}", magic_enum::enum_name(typeEnum));
// Workaround a bug in the FSR 3 MFG mod where it composits the UI incorrectly
if (tags[i].type == sl::kBufferTypeUIColorAndAlpha && tags[i].resource->native && Nvngx_FG::isMFG())
auto nvngxFgApi = renderApi == sl::RenderAPI::eD3D12 ? API::DX12 : API::NotSelected;
if (tags[i].type == sl::kBufferTypeUIColorAndAlpha && tags[i].resource->native &&
Nvngx_FG::getMaxFakeFramesCount(nvngxFgApi) > 1)
{
tags[i].resource->native = nullptr;
}
@@ -327,8 +329,9 @@ sl::Result StreamlineHooks::hkslSetTagForFrame(const sl::FrameToken& frame, cons
LOG_TRACE("Tagging resource of type: {}", magic_enum::enum_name(typeEnum));
// Workaround a bug in the FSR 3 MFG mod where it composits the UI incorrectly
auto nvngxFgApi = renderApi == sl::RenderAPI::eD3D12 ? API::DX12 : API::NotSelected;
if (resources[i].type == sl::kBufferTypeUIColorAndAlpha && resources[i].resource->native &&
Nvngx_FG::isMFG())
Nvngx_FG::getMaxFakeFramesCount(nvngxFgApi) > 1)
{
resources[i].resource->native = nullptr;
}
+8 -8
View File
@@ -400,16 +400,16 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_GetParameters(NVSDK_NGX_Parameter
if (result == NVSDK_NGX_Result_Success)
{
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX11);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVPersistent);
return result;
}
}
// Get custom parameters if using custom backend
static NVNGX_Parameters oldParams = NVNGX_Parameters("OptiDx11", true);
static NVNGX_Parameters oldParams = NVNGX_Parameters(API::DX11, true);
*OutParameters = &oldParams;
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX11);
LOG_DEBUG("Returning custom Opti parameters");
@@ -439,14 +439,14 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_GetCapabilityParameters(NVSDK_NGX
if (result == NVSDK_NGX_Result_Success)
{
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX11);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVDynamic);
return result;
}
}
*OutParameters = new NVNGX_Parameters("OptiDx11", false);
InitNGXParameters(*OutParameters);
*OutParameters = new NVNGX_Parameters(API::DX11, false);
InitNGXParameters(*OutParameters, API::DX11);
LOG_DEBUG("Returning custom Opti parameters");
@@ -477,7 +477,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_AllocateParameters(NVSDK_NGX_Para
}
}
*OutParameters = new NVNGX_Parameters("OptiDx11", false);
*OutParameters = new NVNGX_Parameters(API::DX11, false);
return NVSDK_NGX_Result_Success;
}
@@ -489,7 +489,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_PopulateParameters_Impl(NVSDK_NGX
if (InParameters == nullptr)
return NVSDK_NGX_Result_FAIL_InvalidParameter;
InitNGXParameters(InParameters);
InitNGXParameters(InParameters, API::DX11);
return NVSDK_NGX_Result_Success;
}
+8 -18
View File
@@ -448,16 +448,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown1(ID3D12Device* InDevice)
#pragma region DLSS Parameter Calls
/**
* @brief Allocates and populates a preexisting NGX param map.
*/
static void GetNGXParameters(std::string InName, NVNGX_Parameters& params)
{
params.Name = InName;
InitNGXParameters(&params);
params.Set("OptiScaler", 1);
}
/**
* @brief [Deprecated NGX API] Superceeded by NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters.
*
@@ -483,16 +473,16 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetParameters(NVSDK_NGX_Parameter
// Copy OptiScaler config to real NGX param table
if (result == NVSDK_NGX_Result_Success)
{
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX12);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVPersistent);
return NVSDK_NGX_Result_Success;
}
}
// Get custom parameters if using custom backend
static NVNGX_Parameters oldParams = NVNGX_Parameters("OptiDx12", true);
static NVNGX_Parameters oldParams = NVNGX_Parameters(API::DX12, true);
*OutParameters = &oldParams;
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX12);
LOG_DEBUG("Returning custom Opti parameters");
@@ -523,15 +513,15 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetCapabilityParameters(NVSDK_NGX
if (result == NVSDK_NGX_Result_Success)
{
// Init external NGX table with current configuration and mark as dynamic+external
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::DX12);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVDynamic);
return NVSDK_NGX_Result_Success;
}
}
// Get custom parameters if using custom backend
auto& params = *(new NVNGX_Parameters("OptiDx12", false));
InitNGXParameters(&params);
auto& params = *(new NVNGX_Parameters(API::DX12, false));
InitNGXParameters(&params, API::DX12);
*OutParameters = &params;
LOG_DEBUG("Returning custom Opti parameters");
@@ -562,7 +552,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_AllocateParameters(NVSDK_NGX_Para
}
}
auto* params = new NVNGX_Parameters("OptiDx12", false);
auto* params = new NVNGX_Parameters(API::DX12, false);
*OutParameters = params;
return NVSDK_NGX_Result_Success;
@@ -575,7 +565,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_PopulateParameters_Impl(NVSDK_NGX
if (InParameters == nullptr)
return NVSDK_NGX_Result_Fail;
InitNGXParameters(InParameters);
InitNGXParameters(InParameters, API::DX12);
if (State::Instance().activeFgInput == FGInput::NvngxFG ||
State::Instance().activeFgOutput == FGOutput::DLSSGWithNvngx)
+8 -8
View File
@@ -459,16 +459,16 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_GetParameters(NVSDK_NGX_Paramete
if (result == NVSDK_NGX_Result_Success)
{
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::Vulkan);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVPersistent);
return result;
}
}
// Get custom parameters if using custom backend
static NVNGX_Parameters oldParams = NVNGX_Parameters("OptiVk", true);
static NVNGX_Parameters oldParams = NVNGX_Parameters(API::Vulkan, true);
*OutParameters = &oldParams;
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::Vulkan);
LOG_DEBUG("Returning custom Opti parameters");
@@ -682,7 +682,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_AllocateParameters(NVSDK_NGX_Par
}
}
auto* params = new NVNGX_Parameters("OptiVk", false);
auto* params = new NVNGX_Parameters(API::Vulkan, false);
*OutParameters = params;
return NVSDK_NGX_Result_Success;
@@ -758,15 +758,15 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_GetCapabilityParameters(NVSDK_NG
if (result == NVSDK_NGX_Result_Success)
{
// Init external NGX table with current configuration and mark as dynamic+external
InitNGXParameters(*OutParameters);
InitNGXParameters(*OutParameters, API::Vulkan);
SetNGXParamAllocType(*(*OutParameters), NGX_AllocTypes::NVDynamic);
return result;
}
}
// Get custom parameters if using custom backend
auto& params = *(new NVNGX_Parameters("OptiVk", false));
InitNGXParameters(&params);
auto& params = *(new NVNGX_Parameters(API::Vulkan, false));
InitNGXParameters(&params, API::Vulkan);
*OutParameters = &params;
return NVSDK_NGX_Result_Success;
@@ -779,7 +779,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_PopulateParameters_Impl(NVSDK_NG
if (InParameters == nullptr)
return NVSDK_NGX_Result_Fail;
InitNGXParameters(InParameters);
InitNGXParameters(InParameters, API::Vulkan);
Nvngx_FG::VULKAN_PopulateParameters_Impl(InParameters);
+7 -7
View File
@@ -1759,7 +1759,7 @@ void MenuCommon::RenderPerformanceOverlay(RenderMenuContext& ctx)
if (state.activeFgOutput == FGOutput::NvngxFG || state.activeFgOutput == FGOutput::DLSSGWithNvngx)
{
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
{
if (state.dlssgDetectedInterpolationCount == 0)
fgText = " (Enabler off)";
@@ -2980,7 +2980,7 @@ void MenuCommon::RenderFrameGenerationSelection(RenderMenuContext& ctx)
auto constexpr nvngxInputIndex = (uint32_t) FGInput::NvngxFG;
if (state.activeFgInput == FGInput::NvngxFG)
{
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
inputOptions[nvngxInputIndex].label = "Artur's DLSSG";
else
inputOptions[nvngxInputIndex].label = "Nukem's DLSSG";
@@ -3052,7 +3052,7 @@ void MenuCommon::RenderFrameGenerationSelection(RenderMenuContext& ctx)
auto constexpr nvngxOutputIndex = (uint32_t) FGOutput::NvngxFG;
if (state.activeFgOutput == FGOutput::NvngxFG)
{
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
outputOptions[nvngxOutputIndex].label = "FSR3-MFG via DLSS Enabler";
else
outputOptions[nvngxOutputIndex].label = "FSR3-FG via Nukem's";
@@ -4327,7 +4327,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
if ((state.activeFgInput == FGInput::NvngxFG && state.activeFgOutput == FGOutput::NvngxFG) ||
state.activeFgOutput == FGOutput::DLSSGWithNvngx)
{
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
{
SeparatorWithHelpMarker("Frame Generation (FSR3-MFG via DLSS Enabler)",
"DLSS Enabler as dlss-enabler-headless.dll\n"
@@ -4347,7 +4347,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
"dlss-enabler-headless.dll next to OptiScaler");
}
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
{
ImGui::TextColored(toneMapColor(ImVec4(1.f, 0.8f, 0.f, 1.f)),
"Using a subset of features from DLSS Enabler");
@@ -4407,7 +4407,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
}
}
if (Nvngx_FG::isLoaded())
if (Nvngx_FG::isLoaded(state.swapchainApi))
{
if (bool disableHudless = config->FGDLSSGDisableHudless.value_or_default();
ImGui::Checkbox("Disable Hudless", &disableHudless))
@@ -4416,7 +4416,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
}
ShowHelpMarker("Might be required for some sets of DispatchFlags");
if (Nvngx_FG::isMFG())
if (Nvngx_FG::getMaxFakeFramesCount(state.swapchainApi) > 1)
{
if (bool showDebug = config->FGDLSSGShowDebug.value_or_default();
ImGui::Checkbox("Show Debug", &showDebug))
@@ -137,7 +137,7 @@ bool FeatureProvider_Dx11::ChangeFeature(Upscaler upscaler, ID3D11Device* device
// Use given params if using DLSS passthrough
const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS;
contextData->createParams = isPassthrough ? parameters : GetNGXParameters("OptiDx11", false);
contextData->createParams = isPassthrough ? parameters : GetNGXParameters(API::DX11, false);
contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags());
contextData->createParams->Set(NVSDK_NGX_Parameter_Width, dc->RenderWidth());
contextData->createParams->Set(NVSDK_NGX_Parameter_Height, dc->RenderHeight());
@@ -128,7 +128,7 @@ bool FeatureProvider_Dx12::ChangeFeature(Upscaler upscaler, ID3D12Device* device
// Use given params if using DLSS passthrough
const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS;
contextData->createParams = isPassthrough ? parameters : GetNGXParameters("OptiDx12", false);
contextData->createParams = isPassthrough ? parameters : GetNGXParameters(API::DX12, false);
contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags());
contextData->createParams->Set(NVSDK_NGX_Parameter_Width, dc->RenderWidth());
contextData->createParams->Set(NVSDK_NGX_Parameter_Height, dc->RenderHeight());
+1 -1
View File
@@ -128,7 +128,7 @@ bool FeatureProvider_Vk::ChangeFeature(Upscaler upscaler, VkInstance instance, V
// Use given params if using DLSS passthrough
const bool isPassthrough = state.newBackend == Upscaler::DLSSD || state.newBackend == Upscaler::DLSS;
contextData->createParams = isPassthrough ? parameters : GetNGXParameters("OptiVk", false);
contextData->createParams = isPassthrough ? parameters : GetNGXParameters(API::Vulkan, false);
contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags());
contextData->createParams->Set(NVSDK_NGX_Parameter_Width, dc->RenderWidth());
contextData->createParams->Set(NVSDK_NGX_Parameter_Height, dc->RenderHeight());