Expand root state tracking to Graphics Root

This commit is contained in:
FakeMichau
2026-06-02 19:13:46 +02:00
parent 7cc38c8e87
commit 363a08ef6e
3 changed files with 671 additions and 273 deletions
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -11,7 +11,7 @@ class D3D12Hooks
static bool RestoreDescriptorHeaps(ID3D12GraphicsCommandList* cmdList);
static bool RestorePipelineState(ID3D12GraphicsCommandList* cmdList);
static bool RestoreComputeRootState(ID3D12GraphicsCommandList* cmdList);
static void RestoreComputeRootSignature(ID3D12GraphicsCommandList* cmdList);
static bool RestoreGraphicsRootState(ID3D12GraphicsCommandList* cmdList);
public:
static void Hook();
@@ -19,9 +19,7 @@ class D3D12Hooks
static void HookDevice(ID3D12Device* device);
static void Unhook();
static void SetRootSignatureTracking(bool enable);
static bool CanRestoreComputeRootSignature(ID3D12GraphicsCommandList* cmdList);
static bool CanRestoreGraphicsRootSignature(ID3D12GraphicsCommandList* cmdList);
static bool CanRestoreRootSignature(ID3D12GraphicsCommandList* cmdList);
static void HookToCommandListLate(ID3D12GraphicsCommandList* commandList);
static void RestoreComputeRoot(ID3D12GraphicsCommandList* cmdList);
static void RestoreGraphicsRootSignature(ID3D12GraphicsCommandList* cmdList);
static void RestoreRoot(ID3D12GraphicsCommandList* cmdList);
};
+7 -22
View File
@@ -691,12 +691,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsComma
State::Instance().changeBackend[handleId] = true;
}
if (Config::Instance()->RestoreComputeSignature.value_or_default())
D3D12Hooks::RestoreComputeRoot(InCmdList);
if (Config::Instance()->RestoreGraphicSignature.value_or_default())
D3D12Hooks::RestoreGraphicsRootSignature(InCmdList);
// Root signature restore
D3D12Hooks::RestoreRoot(InCmdList);
D3D12Hooks::SetRootSignatureTracking(true);
State::Instance().FGchanged = true;
@@ -882,17 +878,11 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
if (Config::Instance()->SkipFirstFrames.has_value() && evalCounter < Config::Instance()->SkipFirstFrames.value())
return NVSDK_NGX_Result_Success;
if (Config::Instance()->RestoreComputeSignature.value_or_default() &&
!D3D12Hooks::CanRestoreComputeRootSignature(InCmdList))
if ((Config::Instance()->RestoreComputeSignature.value_or_default() ||
Config::Instance()->RestoreGraphicSignature.value_or_default()) &&
!D3D12Hooks::CanRestoreRootSignature(InCmdList))
{
LOG_DEBUG("Skipping upscaling because can't restore compute signature");
return NVSDK_NGX_Result_Success;
}
if (Config::Instance()->RestoreGraphicSignature.value_or_default() &&
!D3D12Hooks::CanRestoreGraphicsRootSignature(InCmdList))
{
LOG_DEBUG("Skipping upscaling because can't restore graphics signature");
LOG_DEBUG("Skipping upscaling because can't restore root signature");
return NVSDK_NGX_Result_Success;
}
@@ -970,12 +960,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
NVSDK_NGX_Result methodResult = evalResult ? NVSDK_NGX_Result_Success : NVSDK_NGX_Result_Fail;
// Root signature restore
if (Config::Instance()->RestoreComputeSignature.value_or_default())
D3D12Hooks::RestoreComputeRoot(InCmdList);
if (Config::Instance()->RestoreGraphicSignature.value_or_default())
D3D12Hooks::RestoreGraphicsRootSignature(InCmdList);
D3D12Hooks::RestoreRoot(InCmdList);
D3D12Hooks::SetRootSignatureTracking(true);
LOG_DEBUG("Upscaling done: {}", evalResult);