Moved DLSSG_Mod.h to inputs/FG

This commit is contained in:
cdozdil
2025-09-05 15:33:41 +03:00
parent 5198c33f0a
commit 39e4f4f71c
6 changed files with 239 additions and 225 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
#pragma once
#include "pch.h"
#include "Config.h"
#include "DLSSG_Mod.h"
// #include "inputs/FG/DLSSG_Mod.h"
#include <ankerl/unordered_dense.h>
@@ -469,7 +471,7 @@ inline static void InitNGXParameters(NVSDK_NGX_Parameter* InParams)
InParams->Set(NVSDK_NGX_Parameter_RTXValue, 0);
// not ideal as it doesn't take different APIs into account
if (DLSSGMod::isLoaded() || Config::Instance()->FGInput == FGInput::DLSSG)
if (State::Instance().activeFgInput == FGInput::Nukems || State::Instance().activeFgInput == FGInput::DLSSG)
{
InParams->Set("FrameGeneration.Available", 1);
InParams->Set("FrameInterpolation.Available", 1);
+1 -1
View File
@@ -377,7 +377,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
<ClInclude Include="upscalers\fsr31\FSR31Feature_Dx11On12.h" />
<ClInclude Include="upscalers\fsr31\FSR31Feature_Dx12.h" />
<ClInclude Include="upscalers\fsr31\FSR31Feature_Vk.h" />
<ClInclude Include="DLSSG_Mod.h" />
<ClInclude Include="inputs\FG\DLSSG_Mod.h" />
<ClInclude Include="inputs\FfxApi_Dx12.h" />
<ClInclude Include="inputs\FSR2_Dx12.h" />
<ClInclude Include="inputs\FSR3_Dx12.h" />
@@ -1,5 +1,7 @@
#pragma once
#include <NVNGX_Parameter.h>
#include "proxies/NVNGX_Proxy.h"
#include "proxies/KernelBase_Proxy.h"
@@ -61,46 +63,43 @@ class DLSSGMod
{
LOG_FUNC();
if (_dx12_inited)
if (_dx12_inited || Config::Instance()->FGInput.value_or_default() != FGInput::Nukems)
return;
if (Config::Instance()->FGInput.value_or_default() == FGInput::Nukems)
if (_dll == nullptr)
{
if (_dll == nullptr)
{
auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll";
_dll = KernelBaseProxy::LoadLibraryExW_()(dllPath.c_str(), NULL, 0);
}
auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll";
_dll = KernelBaseProxy::LoadLibraryExW_()(dllPath.c_str(), NULL, 0);
}
if (_dll != 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_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");
_DLSSG_D3D12_GetFeatureRequirements =
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetFeatureRequirements");
_DLSSG_D3D12_EvaluateFeature =
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_D3D12_EvaluateFeature");
_DLSSG_D3D12_PopulateParameters_Impl =
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(_dll, "NVSDK_NGX_D3D12_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
_dx12_inited = true;
if (_dll != 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_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");
_DLSSG_D3D12_GetFeatureRequirements =
(PFN_D3D12_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetFeatureRequirements");
_DLSSG_D3D12_EvaluateFeature =
(PFN_D3D12_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_D3D12_EvaluateFeature");
_DLSSG_D3D12_PopulateParameters_Impl =
(PFN_D3D12_PopulateParameters_Impl) GetProcAddress(_dll, "NVSDK_NGX_D3D12_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
_dx12_inited = true;
LOG_INFO("DLSSG Mod initialized for DX12");
}
else
{
LOG_INFO("DLSSG Mod enabled but cannot be loaded");
}
LOG_INFO("DLSSG Mod initialized for DX12");
}
else
{
LOG_INFO("DLSSG Mod enabled but cannot be loaded");
}
}
@@ -108,49 +107,46 @@ class DLSSGMod
{
LOG_FUNC();
if (_vulkan_inited)
if (_vulkan_inited || Config::Instance()->FGInput.value_or_default() != FGInput::Nukems)
return;
if (Config::Instance()->FGInput.value_or_default() == FGInput::Nukems)
if (_dll == nullptr)
{
if (_dll == nullptr)
{
auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll";
_dll = KernelBaseProxy::LoadLibraryExW_()(dllPath.c_str(), NULL, 0);
}
auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll";
_dll = KernelBaseProxy::LoadLibraryExW_()(dllPath.c_str(), NULL, 0);
}
if (_dll != 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_GetScratchBufferSize =
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetScratchBufferSize");
_DLSSG_VULKAN_CreateFeature =
(PFN_VULKAN_CreateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature");
_DLSSG_VULKAN_CreateFeature1 =
(PFN_VULKAN_CreateFeature1) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature1");
_DLSSG_VULKAN_ReleaseFeature =
(PFN_VULKAN_ReleaseFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_ReleaseFeature");
_DLSSG_VULKAN_GetFeatureRequirements =
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureRequirements");
_DLSSG_VULKAN_EvaluateFeature =
(PFN_VULKAN_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_EvaluateFeature");
_DLSSG_VULKAN_PopulateParameters_Impl = (PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(
_dll, "NVSDK_NGX_VULKAN_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
_vulkan_inited = true;
if (_dll != 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_GetScratchBufferSize =
(PFN_VULKAN_GetScratchBufferSize) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetScratchBufferSize");
_DLSSG_VULKAN_CreateFeature =
(PFN_VULKAN_CreateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature");
_DLSSG_VULKAN_CreateFeature1 =
(PFN_VULKAN_CreateFeature1) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature1");
_DLSSG_VULKAN_ReleaseFeature =
(PFN_VULKAN_ReleaseFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_ReleaseFeature");
_DLSSG_VULKAN_GetFeatureRequirements =
(PFN_VULKAN_GetFeatureRequirements) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureRequirements");
_DLSSG_VULKAN_EvaluateFeature =
(PFN_VULKAN_EvaluateFeature) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_EvaluateFeature");
_DLSSG_VULKAN_PopulateParameters_Impl =
(PFN_VULKAN_PopulateParameters_Impl) GetProcAddress(_dll, "NVSDK_NGX_VULKAN_PopulateParameters_Impl");
_refreshGlobalConfiguration =
(PFN_RefreshGlobalConfiguration) GetProcAddress(_dll, "RefreshGlobalConfiguration");
_fsrDebugView = (PFN_EnableDebugView) GetProcAddress(_dll, "FSRDebugView");
_vulkan_inited = true;
LOG_INFO("DLSSG Mod initialized for Vulkan");
}
else
{
LOG_INFO("DLSSG Mod enabled but cannot be loaded");
}
LOG_INFO("DLSSG Mod initialized for Vulkan");
}
else
{
LOG_INFO("DLSSG Mod enabled but cannot be loaded");
}
}
@@ -252,14 +248,103 @@ class DLSSGMod
static inline NVSDK_NGX_Result D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCmdList,
const NVSDK_NGX_Handle* InFeatureHandle,
const NVSDK_NGX_Parameter* InParameters,
NVSDK_NGX_Parameter* InParameters,
PFN_NVSDK_NGX_ProgressCallback InCallback)
{
if (isDx12Available() && InFeatureHandle->Id >= DLSSG_MOD_ID_OFFSET)
{
if (!is120orNewer())
{
// Workaround mostly for final fantasy xvi
uint32_t depthInverted = 0;
float cameraNear = 0;
float cameraFar = 0;
InParameters->Get("DLSSG.DepthInverted", &depthInverted);
InParameters->Get("DLSSG.CameraNear", &cameraNear);
InParameters->Get("DLSSG.CameraFar", &cameraFar);
if (cameraNear == 0)
{
if (depthInverted)
cameraNear = 100000.0f;
else
cameraNear = 0.1f;
InParameters->Set("DLSSG.CameraNear", cameraNear);
}
if (cameraFar == 0)
{
if (depthInverted)
cameraFar = 0.1f;
else
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
else if (cameraFar == INFINITY)
{
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
// Workaround for a bug in Nukem's mod
// if (uint32_t LowresMvec = 0; InParameters->Get("DLSSG.run_lowres_mvec_pass", &LowresMvec) ==
// NVSDK_NGX_Result_Success && LowresMvec == 1) {
InParameters->Set("DLSSG.MVecsSubrectWidth", 0U);
InParameters->Set("DLSSG.MVecsSubrectHeight", 0U);
//}
}
// Make a copy of the depth going to the frame generator
// Fixes an issue with the depth being corrupted on AMD under Windows
ID3D12Resource* dlssgDepth = nullptr;
if (Config::Instance()->MakeDepthCopy.value_or_default())
InParameters->Get("DLSSG.Depth", &dlssgDepth);
if (dlssgDepth)
{
D3D12_RESOURCE_DESC desc = dlssgDepth->GetDesc();
D3D12_HEAP_PROPERTIES heapProperties;
D3D12_HEAP_FLAGS heapFlags;
static ID3D12Resource* copiedDlssgDepth = nullptr;
if (copiedDlssgDepth != nullptr)
{
copiedDlssgDepth->Release();
copiedDlssgDepth = nullptr;
}
if (dlssgDepth->GetHeapProperties(&heapProperties, &heapFlags) == S_OK)
{
auto result = State::Instance().currentD3D12Device->CreateCommittedResource(
&heapProperties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS(&copiedDlssgDepth));
if (result == S_OK)
{
InCmdList->CopyResource(copiedDlssgDepth, dlssgDepth);
InParameters->Set(
"DLSSG.Depth",
(void*) copiedDlssgDepth); // cast to make sure it's void*, otherwise dlssg cries
}
else
{
LOG_ERROR("Making a new resource for DLSSG Depth has failed");
}
}
else
{
LOG_ERROR("Getting heap properties has failed");
}
}
NVSDK_NGX_Handle TempHandle = { .Id = InFeatureHandle->Id - DLSSG_MOD_ID_OFFSET };
return _DLSSG_D3D12_EvaluateFeature(InCmdList, &TempHandle, InParameters, InCallback);
}
return NVSDK_NGX_Result_Fail;
}
@@ -380,14 +465,58 @@ class DLSSGMod
static inline NVSDK_NGX_Result VULKAN_EvaluateFeature(VkCommandBuffer InCmdList,
const NVSDK_NGX_Handle* InFeatureHandle,
const NVSDK_NGX_Parameter* InParameters,
NVSDK_NGX_Parameter* InParameters,
PFN_NVSDK_NGX_ProgressCallback InCallback)
{
if (isVulkanAvailable() && InFeatureHandle->Id >= DLSSG_MOD_ID_OFFSET)
{
if (!is120orNewer())
{
// Workaround mostly for final fantasy xvi, keeping it from DX12
uint32_t depthInverted = 0;
float cameraNear = 0;
float cameraFar = 0;
InParameters->Get("DLSSG.DepthInverted", &depthInverted);
InParameters->Get("DLSSG.CameraNear", &cameraNear);
InParameters->Get("DLSSG.CameraFar", &cameraFar);
if (cameraNear == 0)
{
if (depthInverted)
cameraNear = 100000.0f;
else
cameraNear = 0.1f;
InParameters->Set("DLSSG.CameraNear", cameraNear);
}
if (cameraFar == 0)
{
if (depthInverted)
cameraFar = 0.1f;
else
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
else if (cameraFar == INFINITY)
{
cameraFar = 10000;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
// Workaround for a bug in Nukem's mod, keeping it from DX12
// if (uint32_t LowresMvec = 0; InParameters->Get("DLSSG.run_lowres_mvec_pass", &LowresMvec) ==
// NVSDK_NGX_Result_Success && LowresMvec == 1) {
InParameters->Set("DLSSG.MVecsSubrectWidth", 0U);
InParameters->Set("DLSSG.MVecsSubrectHeight", 0U);
//}
}
NVSDK_NGX_Handle TempHandle = { .Id = InFeatureHandle->Id - DLSSG_MOD_ID_OFFSET };
return _DLSSG_VULKAN_EvaluateFeature(InCmdList, &TempHandle, InParameters, InCallback);
}
return NVSDK_NGX_Result_Fail;
}
+25 -99
View File
@@ -1,13 +1,13 @@
#include "Util.h"
#include "Config.h"
#include "DLSSG_Mod.h"
#include "NVNGX_DLSS.h"
#include "NVNGX_Parameter.h"
#include "proxies/NVNGX_Proxy.h"
#include <upscalers/FeatureProvider_Dx12.h>
#include "FG/DLSSG_Mod.h"
#include "FG/Upscaler_Inputs_Dx12.h"
#include "hooks/HooksDx.h"
@@ -182,8 +182,11 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp
}
}
DLSSGMod::InitDLSSGMod_Dx12();
DLSSGMod::D3D12_Init_Ext(InApplicationId, InApplicationDataPath, InDevice, InSDKVersion, InFeatureInfo);
if (State::Instance().activeFgInput == FGInput::Nukems)
{
DLSSGMod::InitDLSSGMod_Dx12();
DLSSGMod::D3D12_Init_Ext(InApplicationId, InApplicationDataPath, InDevice, InSDKVersion, InFeatureInfo);
}
LOG_INFO("AppId: {0}", InApplicationId);
LOG_INFO("SDK: {0:x}", (unsigned int) InSDKVersion);
@@ -305,8 +308,11 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init(unsigned long long InApplica
}
}
DLSSGMod::InitDLSSGMod_Dx12();
DLSSGMod::D3D12_Init(InApplicationId, InApplicationDataPath, InDevice, InFeatureInfo, InSDKVersion);
// if (State::Instance().activeFgInput == FGInput::Nukems)
//{
// DLSSGMod::InitDLSSGMod_Dx12();
// DLSSGMod::D3D12_Init(InApplicationId, InApplicationDataPath, InDevice, InFeatureInfo, InSDKVersion);
// }
auto result =
NVSDK_NGX_D3D12_Init_Ext(InApplicationId, InApplicationDataPath, InDevice, InSDKVersion, InFeatureInfo);
@@ -430,7 +436,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void)
shutdown = false;
DLSSGMod::D3D12_Shutdown();
if (State::Instance().activeFgInput == FGInput::Nukems)
DLSSGMod::D3D12_Shutdown();
State::Instance().NvngxDx12Inited = false;
@@ -442,7 +449,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown1(ID3D12Device* InDevice)
shutdown = true;
State::Instance().NvngxDx12Inited = false;
DLSSGMod::D3D12_Shutdown1(InDevice);
if (State::Instance().activeFgInput == FGInput::Nukems)
DLSSGMod::D3D12_Shutdown1(InDevice);
// Added `&& !State::Instance().isShuttingDown` hack for crash on exit
if (Config::Instance()->DLSSEnabled.value_or_default() && NVNGXProxy::IsDx12Inited() &&
@@ -538,7 +546,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_PopulateParameters_Impl(NVSDK_NGX
InitNGXParameters(InParameters);
DLSSGMod::D3D12_PopulateParameters_Impl(InParameters);
if (State::Instance().activeFgInput == FGInput::Nukems)
DLSSGMod::D3D12_PopulateParameters_Impl(InParameters);
return NVSDK_NGX_Result_Success;
}
@@ -579,7 +588,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsComma
if (InCmdList != nullptr)
HookToCommandList(InCmdList);
if (DLSSGMod::isDx12Available() && InFeatureID == NVSDK_NGX_Feature_FrameGeneration)
if (State::Instance().activeFgInput == FGInput::Nukems && DLSSGMod::isDx12Available() &&
InFeatureID == NVSDK_NGX_Feature_FrameGeneration)
{
auto result = DLSSGMod::D3D12_CreateFeature(InCmdList, InFeatureID, InParameters, OutHandle);
LOG_INFO("Creating new modded DLSSG feature with HandleId: {0}", (*OutHandle)->Id);
@@ -768,7 +778,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle*
return NVSDK_NGX_Result_FAIL_FeatureNotFound;
}
}
else if (handleId >= DLSSG_MOD_ID_OFFSET)
else if (State::Instance().activeFgInput == FGInput::Nukems && handleId >= DLSSG_MOD_ID_OFFSET)
{
LOG_INFO("D3D12_ReleaseFeature modded DLSSG with HandleId: {0}", handleId);
return DLSSGMod::D3D12_ReleaseFeature(InHandle);
@@ -802,7 +812,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetFeatureRequirements(
{
LOG_DEBUG("for ({0})", (int) FeatureDiscoveryInfo->FeatureID);
DLSSGMod::InitDLSSGMod_Dx12();
if (State::Instance().activeFgInput == FGInput::Nukems)
DLSSGMod::InitDLSSGMod_Dx12();
if (FeatureDiscoveryInfo->FeatureID == NVSDK_NGX_Feature_SuperSampling ||
((DLSSGMod::isDx12Available() || Config::Instance()->FGInput == FGInput::DLSSG) &&
@@ -874,94 +885,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
return NVSDK_NGX_Result_FAIL_FeatureNotFound;
}
}
else if (handleId >= DLSSG_MOD_ID_OFFSET)
else if (State::Instance().activeFgInput == FGInput::Nukems && handleId >= DLSSG_MOD_ID_OFFSET)
{
if (!DLSSGMod::is120orNewer())
{
// Workaround mostly for final fantasy xvi
uint32_t depthInverted = 0;
float cameraNear = 0;
float cameraFar = 0;
InParameters->Get("DLSSG.DepthInverted", &depthInverted);
InParameters->Get("DLSSG.CameraNear", &cameraNear);
InParameters->Get("DLSSG.CameraFar", &cameraFar);
if (cameraNear == 0)
{
if (depthInverted)
cameraNear = 100000.0f;
else
cameraNear = 0.1f;
InParameters->Set("DLSSG.CameraNear", cameraNear);
}
if (cameraFar == 0)
{
if (depthInverted)
cameraFar = 0.1f;
else
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
else if (cameraFar == INFINITY)
{
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
// Workaround for a bug in Nukem's mod
// if (uint32_t LowresMvec = 0; InParameters->Get("DLSSG.run_lowres_mvec_pass", &LowresMvec) ==
// NVSDK_NGX_Result_Success && LowresMvec == 1) {
InParameters->Set("DLSSG.MVecsSubrectWidth", 0U);
InParameters->Set("DLSSG.MVecsSubrectHeight", 0U);
//}
}
// Make a copy of the depth going to the frame generator
// Fixes an issue with the depth being corrupted on AMD under Windows
ID3D12Resource* dlssgDepth = nullptr;
if (Config::Instance()->MakeDepthCopy.value_or_default())
InParameters->Get("DLSSG.Depth", &dlssgDepth);
if (dlssgDepth)
{
D3D12_RESOURCE_DESC desc = dlssgDepth->GetDesc();
D3D12_HEAP_PROPERTIES heapProperties;
D3D12_HEAP_FLAGS heapFlags;
static ID3D12Resource* copiedDlssgDepth = nullptr;
if (copiedDlssgDepth != nullptr)
{
copiedDlssgDepth->Release();
copiedDlssgDepth = nullptr;
}
if (dlssgDepth->GetHeapProperties(&heapProperties, &heapFlags) == S_OK)
{
auto result = D3D12Device->CreateCommittedResource(&heapProperties, D3D12_HEAP_FLAG_NONE, &desc,
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS(&copiedDlssgDepth));
if (result == S_OK)
{
InCmdList->CopyResource(copiedDlssgDepth, dlssgDepth);
InParameters->Set("DLSSG.Depth",
(void*) copiedDlssgDepth); // cast to make sure it's void*, otherwise dlssg cries
}
else
{
LOG_ERROR("Making a new resource for DLSSG Depth has failed");
}
}
else
{
LOG_ERROR("Getting heap properties has failed");
}
}
return DLSSGMod::D3D12_EvaluateFeature(InCmdList, InFeatureHandle, InParameters, InCallback);
}
@@ -1103,7 +1028,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_GetScratchBufferSize(NVSDK_NGX_Fe
const NVSDK_NGX_Parameter* InParameters,
size_t* OutSizeInBytes)
{
if (DLSSGMod::isDx12Available() && InFeatureId == NVSDK_NGX_Feature_FrameGeneration)
if (State::Instance().activeFgInput == FGInput::Nukems && DLSSGMod::isDx12Available() &&
InFeatureId == NVSDK_NGX_Feature_FrameGeneration)
{
return DLSSGMod::D3D12_GetScratchBufferSize(InFeatureId, InParameters, OutSizeInBytes);
}
+4 -47
View File
@@ -1,13 +1,13 @@
#include "pch.h"
#include "Util.h"
#include "Config.h"
#include "resource.h"
#include "NVNGX_Parameter.h"
#include "NVNGX_DLSS.h"
#include "FG/DLSSG_Mod.h"
#include "NVNGX_Parameter.h"
#include "proxies/NVNGX_Proxy.h"
#include "DLSSG_Mod.h"
#include "Config.h"
#include "upscalers/fsr2/FSR2Feature_Vk.h"
#include "upscalers/dlss/DLSSFeature_Vk.h"
#include "upscalers/dlssd/DLSSDFeature_Vk.h"
@@ -17,8 +17,8 @@
#include "hooks/HooksVk.h"
#include <ankerl/unordered_dense.h>
#include <vulkan/vulkan.hpp>
#include <ankerl/unordered_dense.h>
VkInstance vkInstance;
VkPhysicalDevice vkPD;
@@ -953,49 +953,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_EvaluateFeature(VkCommandBuffer
}
else if (handleId >= DLSSG_MOD_ID_OFFSET)
{
if (!DLSSGMod::is120orNewer())
{
// Workaround mostly for final fantasy xvi, keeping it from DX12
uint32_t depthInverted = 0;
float cameraNear = 0;
float cameraFar = 0;
InParameters->Get("DLSSG.DepthInverted", &depthInverted);
InParameters->Get("DLSSG.CameraNear", &cameraNear);
InParameters->Get("DLSSG.CameraFar", &cameraFar);
if (cameraNear == 0)
{
if (depthInverted)
cameraNear = 100000.0f;
else
cameraNear = 0.1f;
InParameters->Set("DLSSG.CameraNear", cameraNear);
}
if (cameraFar == 0)
{
if (depthInverted)
cameraFar = 0.1f;
else
cameraFar = 100000.0f;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
else if (cameraFar == INFINITY)
{
cameraFar = 10000;
InParameters->Set("DLSSG.CameraFar", cameraFar);
}
// Workaround for a bug in Nukem's mod, keeping it from DX12
// if (uint32_t LowresMvec = 0; InParameters->Get("DLSSG.run_lowres_mvec_pass", &LowresMvec) ==
// NVSDK_NGX_Result_Success && LowresMvec == 1) {
InParameters->Set("DLSSG.MVecsSubrectWidth", 0U);
InParameters->Set("DLSSG.MVecsSubrectHeight", 0U);
//}
}
return DLSSGMod::VULKAN_EvaluateFeature(InCmdList, InFeatureHandle, InParameters, InCallback);
}
+1 -1
View File
@@ -8,7 +8,7 @@
#include <proxies/XeFG_Proxy.h>
#include <proxies/FfxApi_Proxy.h>
#include "DLSSG_Mod.h"
#include <inputs/FG/DLSSG_Mod.h>
#include <framegen/ffx/FSRFG_Dx12.h>