mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-07-08 08:22:05 +00:00
stash
This commit is contained in:
@@ -51,202 +51,6 @@ static void FfxFgLogCallback(uint32_t type, const wchar_t* message)
|
||||
LOG_DEBUG(" FG Log: {0}", wstring_to_string(string));
|
||||
}
|
||||
|
||||
static void ReleaseFGObjects()
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
if (ImGuiOverlayDx::fgCopyCommandAllocators[i] != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i]->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i] = nullptr;
|
||||
}
|
||||
|
||||
//if (ImGuiOverlayDx::fgFence[i] != nullptr)
|
||||
//{
|
||||
// ImGuiOverlayDx::fgFence[i]->Release();
|
||||
// ImGuiOverlayDx::fgFence[i] = nullptr;
|
||||
//}
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgCopyCommandList != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandList->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandList = nullptr;
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgCopyCommandQueue != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandQueue->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandQueue = nullptr;
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgFormatTransfer != nullptr)
|
||||
{
|
||||
delete ImGuiOverlayDx::fgFormatTransfer;
|
||||
ImGuiOverlayDx::fgFormatTransfer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateFGObjects()
|
||||
{
|
||||
if (ImGuiOverlayDx::fgCopyCommandQueue != nullptr)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
result = D3D12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandAllocators[i]));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandAllocators[{0}]: {1:X}", i, (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i]->SetName(L"fgCopyCommandAllocator");
|
||||
}
|
||||
|
||||
result = D3D12Device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, ImGuiOverlayDx::fgCopyCommandAllocators[0], NULL, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandList));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandList: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandList->SetName(L"fgCopyCommandList");
|
||||
|
||||
result = ImGuiOverlayDx::fgCopyCommandList->Close();
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("ImGuiOverlayDx::fgCopyCommandList->Close: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
|
||||
// Create a command queue for frame generation
|
||||
D3D12_COMMAND_QUEUE_DESC copyQueueDesc = {};
|
||||
copyQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
copyQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
copyQueueDesc.NodeMask = 0;
|
||||
|
||||
if (Config::Instance()->FGHighPriority.value_or(false))
|
||||
copyQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH;
|
||||
else
|
||||
copyQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
|
||||
HRESULT hr = D3D12Device->CreateCommandQueue(©QueueDesc, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandQueue));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandQueue: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandQueue->SetName(L"fgCopyCommandQueue");
|
||||
|
||||
ImGuiOverlayDx::fgFormatTransfer = new FT_Dx12("FormatTransfer", D3D12Device, ImGuiOverlayDx::swapchainFormat);
|
||||
|
||||
} while (false);
|
||||
}
|
||||
|
||||
static void CreateFGContext(IFeature_Dx12* deviceContext)
|
||||
{
|
||||
if (ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
ffxConfigureDescFrameGeneration m_FrameGenerationConfig = {};
|
||||
m_FrameGenerationConfig.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
|
||||
m_FrameGenerationConfig.frameGenerationEnabled = true;
|
||||
m_FrameGenerationConfig.swapChain = ImGuiOverlayDx::currentSwapchain;
|
||||
//m_FrameGenerationConfig.presentCallback = nullptr;
|
||||
m_FrameGenerationConfig.HUDLessColor = FfxApiResource({});
|
||||
|
||||
auto result = _configure(&ImGuiOverlayDx::fgContext, &m_FrameGenerationConfig.header);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = (result == FFX_API_RETURN_OK);
|
||||
|
||||
LOG_DEBUG("Reactivate");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ffxCreateBackendDX12Desc backendDesc{};
|
||||
backendDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_DX12;
|
||||
backendDesc.device = D3D12Device;
|
||||
|
||||
ffxCreateContextDescFrameGeneration createFg{};
|
||||
createFg.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION;
|
||||
createFg.displaySize = { deviceContext->DisplayWidth(), deviceContext->DisplayHeight() };
|
||||
createFg.maxRenderSize = { deviceContext->DisplayWidth(), deviceContext->DisplayHeight() };
|
||||
createFg.flags = 0;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_IsHDR)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_HIGH_DYNAMIC_RANGE;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_DepthInverted)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_DEPTH_INVERTED;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_MVJittered)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION;
|
||||
|
||||
if ((deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes) == 0)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS;
|
||||
|
||||
if (Config::Instance()->FGAsync.value_or(false))
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_ASYNC_WORKLOAD_SUPPORT;
|
||||
|
||||
createFg.backBufferFormat = ffxApiGetSurfaceFormatDX12(ImGuiOverlayDx::swapchainFormat);
|
||||
createFg.header.pNext = &backendDesc.header;
|
||||
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
Config::Instance()->SkipHeapCapture = true;
|
||||
ffxReturnCode_t retCode = _createContext(&ImGuiOverlayDx::fgContext, &createFg.header, nullptr);
|
||||
Config::Instance()->SkipHeapCapture = false;
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
LOG_INFO(" FG _createContext result: {0:X}", retCode);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = (retCode == FFX_API_RETURN_OK);
|
||||
|
||||
LOG_DEBUG("Create");
|
||||
}
|
||||
|
||||
|
||||
static void StopAndDestroyFGContext(bool destroy, bool shutDown)
|
||||
{
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
|
||||
if (ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||
|
||||
ffxConfigureDescFrameGeneration m_FrameGenerationConfig = {};
|
||||
m_FrameGenerationConfig.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
|
||||
m_FrameGenerationConfig.frameGenerationEnabled = false;
|
||||
m_FrameGenerationConfig.swapChain = ImGuiOverlayDx::currentSwapchain;
|
||||
//m_FrameGenerationConfig.presentCallback = nullptr;
|
||||
m_FrameGenerationConfig.HUDLessColor = FfxApiResource({});
|
||||
|
||||
auto result = _configure(&ImGuiOverlayDx::fgContext, &m_FrameGenerationConfig.header);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = false;
|
||||
|
||||
if (!shutDown)
|
||||
LOG_INFO(" FG _configure result: {0:X}", result);
|
||||
}
|
||||
|
||||
if (destroy && ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
auto result = _destroyContext(&ImGuiOverlayDx::fgContext, nullptr);
|
||||
|
||||
if (!shutDown)
|
||||
LOG_INFO(" FG _destroyContext result: {0:X}", result);
|
||||
|
||||
ImGuiOverlayDx::fgContext = nullptr;
|
||||
}
|
||||
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
|
||||
if (shutDown)
|
||||
ReleaseFGObjects();
|
||||
}
|
||||
|
||||
static void ResourceBarrier(ID3D12GraphicsCommandList* InCommandList, ID3D12Resource* InResource, D3D12_RESOURCE_STATES InBeforeState, D3D12_RESOURCE_STATES InAfterState)
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER barrier = {};
|
||||
@@ -720,7 +524,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void)
|
||||
// Disabled for now to check if it cause any issues
|
||||
//ImGuiOverlayDx::UnHookDx();
|
||||
|
||||
StopAndDestroyFGContext(true, true);
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(true, true);
|
||||
|
||||
shutdown = false;
|
||||
|
||||
@@ -1073,7 +877,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle*
|
||||
auto handleId = InHandle->Id;
|
||||
|
||||
Config::Instance()->FGChanged = true;
|
||||
StopAndDestroyFGContext(true, false);
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(true, false);
|
||||
|
||||
if (!shutdown)
|
||||
LOG_INFO("releasing feature with id {0}", handleId);
|
||||
@@ -1279,7 +1083,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
{
|
||||
if (ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
StopAndDestroyFGContext(false, false);
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(false, false);
|
||||
}
|
||||
|
||||
if (Dx12Contexts.contains(handleId))
|
||||
@@ -1496,12 +1300,12 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
|
||||
_createContext != nullptr && !ImGuiOverlayDx::fgIsActive && ImGuiOverlayDx::currentSwapchain != nullptr &&
|
||||
ImGuiOverlayDx::swapchainFormat != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
CreateFGObjects();
|
||||
CreateFGContext(deviceContext);
|
||||
ImGuiOverlayDx::CreateFGObjects(D3D12Device);
|
||||
ImGuiOverlayDx::CreateFGContext(D3D12Device, deviceContext);
|
||||
}
|
||||
else if ((!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged) && ImGuiOverlayDx::fgIsActive)
|
||||
{
|
||||
StopAndDestroyFGContext(Config::Instance()->SCChanged, false);
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(Config::Instance()->SCChanged, false);
|
||||
}
|
||||
|
||||
if (Config::Instance()->FGChanged)
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<IncludePath>$(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\FidelityFX-SDK\ffx-api\include\ffx_api;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)fsr2\lib;$(ProjectDir)fsr2_212\lib;$(ProjectDir)fsr31\lib;$(ProjectDir)vulkan;$(ProjectDir)d3dx;$(ProjectDir)detours;$(SolutionDir)external\xess\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>dxgi</TargetName>
|
||||
<OutDir>D:\Folders\Games\Banishers Ghosts of New Eden\NWD\Binaries\Win64\</OutDir>
|
||||
<OutDir>D:\Folders\Games\Kena - Bridge of Spirits\Kena\Binaries\Win64\</OutDir>
|
||||
<IntDir>.\x64\Debug</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
DWORD handle = 0;
|
||||
DWORD versionSize = GetFileVersionInfoSizeW(dllPath.c_str(), &handle);
|
||||
|
||||
if (versionSize == 0 || handle == 0)
|
||||
if (versionSize == 0)
|
||||
{
|
||||
LOG_ERROR("Failed to get version info size: {0:X}", GetLastError());
|
||||
return;
|
||||
|
||||
@@ -190,8 +190,8 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, &RenderPresetDLAA) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.DLAA", &RenderPresetDLAA);
|
||||
|
||||
//if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, &RenderPresetUltraQuality) != NVSDK_NGX_Result_Success)
|
||||
// InParameters->Get("RayReconstruction.Hint.Render.Preset.UltraQuality", &RenderPresetUltraQuality);
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, &RenderPresetUltraQuality) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.UltraQuality", &RenderPresetUltraQuality);
|
||||
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Quality, &RenderPresetQuality) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.Quality", &RenderPresetQuality);
|
||||
@@ -212,11 +212,11 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
signedEnum = true;
|
||||
}
|
||||
|
||||
//if (RenderPresetUltraQuality >= 2147483648)
|
||||
//{
|
||||
// RenderPresetUltraQuality -= 2147483648;
|
||||
// signedEnum = true;
|
||||
//}
|
||||
if (RenderPresetUltraQuality >= 2147483648)
|
||||
{
|
||||
RenderPresetUltraQuality -= 2147483648;
|
||||
signedEnum = true;
|
||||
}
|
||||
|
||||
if (RenderPresetQuality >= 2147483648)
|
||||
{
|
||||
@@ -246,14 +246,14 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
LOG_DEBUG("Preset override active, config overrides:");
|
||||
LOG_DEBUG("Preset_DLAA {}", Config::Instance()->RenderPresetDLAA.value_or(RenderPresetDLAA));
|
||||
//LOG_DEBUG("Preset_UltraQuality {}", Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality));
|
||||
LOG_DEBUG("Preset_UltraQuality {}", Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality));
|
||||
LOG_DEBUG("Preset_Quality {}", Config::Instance()->RenderPresetQuality.value_or(RenderPresetQuality));
|
||||
LOG_DEBUG("Preset_Balanced {}", Config::Instance()->RenderPresetBalanced.value_or(RenderPresetBalanced));
|
||||
LOG_DEBUG("Preset_Performance {}", Config::Instance()->RenderPresetPerformance.value_or(RenderPresetPerformance));
|
||||
LOG_DEBUG("Preset_UltraPerformance {}", Config::Instance()->RenderPresetUltraPerformance.value_or(RenderPresetUltraPerformance));
|
||||
|
||||
RenderPresetDLAA = Config::Instance()->RenderPresetDLAA.value_or(RenderPresetDLAA);
|
||||
//RenderPresetUltraQuality = Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality);
|
||||
RenderPresetUltraQuality = Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality);
|
||||
RenderPresetQuality = Config::Instance()->RenderPresetQuality.value_or(RenderPresetQuality);
|
||||
RenderPresetBalanced = Config::Instance()->RenderPresetBalanced.value_or(RenderPresetBalanced);
|
||||
RenderPresetPerformance = Config::Instance()->RenderPresetPerformance.value_or(RenderPresetPerformance);
|
||||
@@ -263,8 +263,8 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (RenderPresetDLAA < 0 || RenderPresetDLAA > 7)
|
||||
RenderPresetDLAA = 0;
|
||||
|
||||
//if (RenderPresetUltraQuality < 0 || RenderPresetUltraQuality > 7)
|
||||
// RenderPresetUltraQuality = 0;
|
||||
if (RenderPresetUltraQuality < 0 || RenderPresetUltraQuality > 7)
|
||||
RenderPresetUltraQuality = 0;
|
||||
|
||||
if (RenderPresetQuality < 0 || RenderPresetQuality > 7)
|
||||
RenderPresetQuality = 0;
|
||||
@@ -282,7 +282,7 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (signedEnum)
|
||||
{
|
||||
RenderPresetDLAA += 2147483648;
|
||||
//RenderPresetUltraQuality += 2147483648;
|
||||
RenderPresetUltraQuality += 2147483648;
|
||||
RenderPresetQuality += 2147483648;
|
||||
RenderPresetBalanced += 2147483648;
|
||||
RenderPresetPerformance += 2147483648;
|
||||
@@ -292,8 +292,8 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
LOG_DEBUG("Final Presets:");
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, RenderPresetDLAA);
|
||||
LOG_DEBUG("Preset_DLAA {}", RenderPresetDLAA);
|
||||
//InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, RenderPresetUltraQuality);
|
||||
//LOG_DEBUG("Preset_UltraQuality {}", RenderPresetUltraQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, RenderPresetUltraQuality);
|
||||
LOG_DEBUG("Preset_UltraQuality {}", RenderPresetUltraQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Quality, RenderPresetQuality);
|
||||
LOG_DEBUG("Preset_Quality {}", RenderPresetQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Balanced, RenderPresetBalanced);
|
||||
@@ -303,7 +303,7 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraPerformance, RenderPresetUltraPerformance);
|
||||
LOG_DEBUG("Preset_UltraPerformance {}", RenderPresetUltraPerformance);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.DLAA", RenderPresetDLAA);
|
||||
//InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraQuality", RenderPresetUltraQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraQuality", RenderPresetUltraQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Quality", RenderPresetQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Balanced", RenderPresetBalanced);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Performance", RenderPresetPerformance);
|
||||
|
||||
@@ -181,8 +181,8 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, &RenderPresetDLAA) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.DLAA", &RenderPresetDLAA);
|
||||
|
||||
//if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, &RenderPresetUltraQuality) != NVSDK_NGX_Result_Success)
|
||||
// InParameters->Get("RayReconstruction.Hint.Render.Preset.UltraQuality", &RenderPresetUltraQuality);
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, &RenderPresetUltraQuality) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.UltraQuality", &RenderPresetUltraQuality);
|
||||
|
||||
if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Quality, &RenderPresetQuality) != NVSDK_NGX_Result_Success)
|
||||
InParameters->Get("RayReconstruction.Hint.Render.Preset.Quality", &RenderPresetQuality);
|
||||
@@ -203,11 +203,11 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
signedEnum = true;
|
||||
}
|
||||
|
||||
//if (RenderPresetUltraQuality >= 2147483648)
|
||||
//{
|
||||
// RenderPresetUltraQuality -= 2147483648;
|
||||
// signedEnum = true;
|
||||
//}
|
||||
if (RenderPresetUltraQuality >= 2147483648)
|
||||
{
|
||||
RenderPresetUltraQuality -= 2147483648;
|
||||
signedEnum = true;
|
||||
}
|
||||
|
||||
if (RenderPresetQuality >= 2147483648)
|
||||
{
|
||||
@@ -237,14 +237,14 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
LOG_DEBUG("Preset override active, config overrides:");
|
||||
LOG_DEBUG("Preset_DLAA {}", Config::Instance()->RenderPresetDLAA.value_or(RenderPresetDLAA));
|
||||
//LOG_DEBUG("Preset_UltraQuality {}", Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality));
|
||||
LOG_DEBUG("Preset_UltraQuality {}", Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality));
|
||||
LOG_DEBUG("Preset_Quality {}", Config::Instance()->RenderPresetQuality.value_or(RenderPresetQuality));
|
||||
LOG_DEBUG("Preset_Balanced {}", Config::Instance()->RenderPresetBalanced.value_or(RenderPresetBalanced));
|
||||
LOG_DEBUG("Preset_Performance {}", Config::Instance()->RenderPresetPerformance.value_or(RenderPresetPerformance));
|
||||
LOG_DEBUG("Preset_UltraPerformance {}", Config::Instance()->RenderPresetUltraPerformance.value_or(RenderPresetUltraPerformance));
|
||||
|
||||
RenderPresetDLAA = Config::Instance()->RenderPresetDLAA.value_or(RenderPresetDLAA);
|
||||
//RenderPresetUltraQuality = Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality);
|
||||
RenderPresetUltraQuality = Config::Instance()->RenderPresetUltraQuality.value_or(RenderPresetUltraQuality);
|
||||
RenderPresetQuality = Config::Instance()->RenderPresetQuality.value_or(RenderPresetQuality);
|
||||
RenderPresetBalanced = Config::Instance()->RenderPresetBalanced.value_or(RenderPresetBalanced);
|
||||
RenderPresetPerformance = Config::Instance()->RenderPresetPerformance.value_or(RenderPresetPerformance);
|
||||
@@ -254,8 +254,8 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (RenderPresetDLAA < 0 || RenderPresetDLAA > 7)
|
||||
RenderPresetDLAA = 0;
|
||||
|
||||
//if (RenderPresetUltraQuality < 0 || RenderPresetUltraQuality > 7)
|
||||
// RenderPresetUltraQuality = 0;
|
||||
if (RenderPresetUltraQuality < 0 || RenderPresetUltraQuality > 7)
|
||||
RenderPresetUltraQuality = 0;
|
||||
|
||||
if (RenderPresetQuality < 0 || RenderPresetQuality > 7)
|
||||
RenderPresetQuality = 0;
|
||||
@@ -273,7 +273,7 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
if (signedEnum)
|
||||
{
|
||||
RenderPresetDLAA += 2147483648;
|
||||
//RenderPresetUltraQuality += 2147483648;
|
||||
RenderPresetUltraQuality += 2147483648;
|
||||
RenderPresetQuality += 2147483648;
|
||||
RenderPresetBalanced += 2147483648;
|
||||
RenderPresetPerformance += 2147483648;
|
||||
@@ -283,8 +283,8 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
LOG_DEBUG("Final Presets:");
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, RenderPresetDLAA);
|
||||
LOG_DEBUG("Preset_DLAA {}", RenderPresetDLAA);
|
||||
//InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, RenderPresetUltraQuality);
|
||||
//LOG_DEBUG("Preset_UltraQuality {}", RenderPresetUltraQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraQuality, RenderPresetUltraQuality);
|
||||
LOG_DEBUG("Preset_UltraQuality {}", RenderPresetUltraQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Quality, RenderPresetQuality);
|
||||
LOG_DEBUG("Preset_Quality {}", RenderPresetQuality);
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_Balanced, RenderPresetBalanced);
|
||||
@@ -294,7 +294,7 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters)
|
||||
InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraPerformance, RenderPresetUltraPerformance);
|
||||
LOG_DEBUG("Preset_UltraPerformance {}", RenderPresetUltraPerformance);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.DLAA", RenderPresetDLAA);
|
||||
//InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraQuality", RenderPresetUltraQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraQuality", RenderPresetUltraQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Quality", RenderPresetQuality);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Balanced", RenderPresetBalanced);
|
||||
InParameters->Set("RayReconstruction.Hint.Render.Preset.Performance", RenderPresetPerformance);
|
||||
|
||||
@@ -1229,7 +1229,7 @@ void ImGuiCommon::RenderMenu()
|
||||
}
|
||||
|
||||
AddRenderPreset("DLAA Preset", &Config::Instance()->RenderPresetDLAA);
|
||||
//AddRenderPreset("UltraQ Preset", &Config::Instance()->RenderPresetUltraQuality);
|
||||
AddRenderPreset("UltraQ Preset", &Config::Instance()->RenderPresetUltraQuality);
|
||||
AddRenderPreset("Quality Preset", &Config::Instance()->RenderPresetQuality);
|
||||
AddRenderPreset("Balanced Preset", &Config::Instance()->RenderPresetBalanced);
|
||||
AddRenderPreset("Perf Preset", &Config::Instance()->RenderPresetPerformance);
|
||||
|
||||
@@ -200,6 +200,7 @@ static bool fgPresentRunning = false;
|
||||
static double fgLastFrameTime = 0.0;
|
||||
static double fgLastDeltaTime = 0.0;
|
||||
static bool fgDispatchCalled = false;
|
||||
static bool fgStopAfterNextPresent = false;
|
||||
|
||||
// Swapchain frame counter
|
||||
static UINT64 frameCounter = 0;
|
||||
@@ -542,11 +543,12 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
|
||||
m_FrameGenerationConfig.frameGenerationCallback = [](ffxDispatchDescFrameGeneration* params, void* pUserCtx) -> ffxReturnCode_t
|
||||
{
|
||||
HRESULT result;
|
||||
ffxReturnCode_t dispatchResult;
|
||||
auto fIndex = fgFrameIndex;
|
||||
|
||||
// check for status
|
||||
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || Config::Instance()->FGChanged ||
|
||||
Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr ||
|
||||
ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr ||
|
||||
ImGuiOverlayDx::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
|
||||
{
|
||||
LOG_WARN("Cancel async dispatch");
|
||||
@@ -556,73 +558,30 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
|
||||
}
|
||||
|
||||
// If fg is active but upscaling paused
|
||||
if (!fgDispatchCalled || fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount())
|
||||
if (!fgDispatchCalled || Config::Instance()->CurrentFeature == nullptr || fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount())
|
||||
{
|
||||
LOG_WARN("Callback without hudless!");
|
||||
|
||||
auto allocator = ImGuiOverlayDx::fgCopyCommandAllocators[fIndex];
|
||||
result = allocator->Reset();
|
||||
result = ImGuiOverlayDx::fgCopyCommandList->Reset(allocator, nullptr);
|
||||
LOG_WARN("Callback without hudless!");
|
||||
|
||||
params->reset = true;
|
||||
}
|
||||
|
||||
if (Config::Instance()->CurrentFeature != nullptr)
|
||||
fgLastFGFrame = Config::Instance()->CurrentFeature->FrameCount();
|
||||
|
||||
// check for status
|
||||
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || Config::Instance()->FGChanged ||
|
||||
Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr ||
|
||||
ImGuiOverlayDx::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
|
||||
{
|
||||
LOG_WARN("Cancel async dispatch");
|
||||
fgDispatchCalled = false;
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = _dispatch(reinterpret_cast<ffxContext*>(pUserCtx), ¶ms->header);
|
||||
}
|
||||
|
||||
dispatchResult = _dispatch(reinterpret_cast<ffxContext*>(pUserCtx), ¶ms->header);
|
||||
ID3D12CommandList* cl[1] = { nullptr };
|
||||
result = ImGuiOverlayDx::fgCopyCommandList->Close();
|
||||
cl[0] = ImGuiOverlayDx::fgCopyCommandList;
|
||||
ImGuiOverlayDx::gameCommandQueue->ExecuteCommandLists(1, cl);
|
||||
|
||||
// check for status
|
||||
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || Config::Instance()->FGChanged ||
|
||||
Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr ||
|
||||
ImGuiOverlayDx::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
|
||||
{
|
||||
LOG_WARN("Cancel async dispatch");
|
||||
fgDispatchCalled = false;
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ImGuiOverlayDx::fgCopyCommandList->Close();
|
||||
cl[0] = ImGuiOverlayDx::fgCopyCommandList;
|
||||
}
|
||||
|
||||
// check for status
|
||||
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || Config::Instance()->FGChanged ||
|
||||
Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr ||
|
||||
ImGuiOverlayDx::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
|
||||
{
|
||||
LOG_WARN("Cancel async dispatch");
|
||||
fgDispatchCalled = false;
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGuiOverlayDx::gameCommandQueue->ExecuteCommandLists(1, cl);
|
||||
}
|
||||
|
||||
LOG_DEBUG("Callback _dispatch result: {0}", (UINT)result);
|
||||
LOG_DEBUG("_dispatch result: {0}", (UINT)result);
|
||||
|
||||
fgDispatchCalled = false;
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
|
||||
return result;
|
||||
return dispatchResult;
|
||||
};
|
||||
|
||||
m_FrameGenerationConfig.frameGenerationCallbackUserContext = &ImGuiOverlayDx::fgContext;
|
||||
@@ -763,18 +722,23 @@ static bool CheckForHudless(ResourceInfo* resource, bool checkFormat = true)
|
||||
if (ImGuiOverlayDx::currentSwapchain == nullptr)
|
||||
return false;
|
||||
|
||||
//if (Config::Instance()->SCChanged)
|
||||
//{
|
||||
// LOG_INFO("Config::Instance()->SCChanged");
|
||||
DXGI_SWAP_CHAIN_DESC scDesc{};
|
||||
if (ImGuiOverlayDx::currentSwapchain->GetDesc(&scDesc) != S_OK)
|
||||
{
|
||||
LOG_WARN("Can't get swapchain desc!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::currentSwapchain->GetDesc(&fgScDesc) != S_OK)
|
||||
{
|
||||
LOG_WARN("Can't get swapchain desc!");
|
||||
return false;
|
||||
}
|
||||
if (scDesc.BufferDesc.Height != fgScDesc.BufferDesc.Height || scDesc.BufferDesc.Width != fgScDesc.BufferDesc.Width || scDesc.BufferDesc.Format != fgScDesc.BufferDesc.Format)
|
||||
{
|
||||
|
||||
// Config::Instance()->SCChanged = false;
|
||||
//}
|
||||
delete ImGuiOverlayDx::fgFormatTransfer;
|
||||
ImGuiOverlayDx::fgFormatTransfer = nullptr;
|
||||
ImGuiOverlayDx::fgFormatTransfer = new FT_Dx12("FormatTransfer", g_pd3dDeviceParam, scDesc.BufferDesc.Format);
|
||||
|
||||
ImGuiOverlayDx::swapchainFormat = scDesc.BufferDesc.Format;
|
||||
fgScDesc = scDesc;
|
||||
}
|
||||
|
||||
if (resource->height == fgScDesc.BufferDesc.Height && resource->width == fgScDesc.BufferDesc.Width && (!checkFormat || resource->format == fgScDesc.BufferDesc.Format ||
|
||||
(Config::Instance()->FGHUDFixExtended.value_or(false) && ImGuiOverlayDx::fgFormatTransfer != nullptr &&
|
||||
@@ -848,7 +812,7 @@ static void hkCreateRenderTargetView(ID3D12Device* This, ID3D12Resource* pResour
|
||||
auto heap = GetHeapByCpuHandle(DestDescriptor.ptr);
|
||||
if (heap != nullptr)
|
||||
heap->SetByCpuHandle(DestDescriptor.ptr, resInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void hkCreateShaderResourceView(ID3D12Device* This, ID3D12Resource* pResource, D3D12_SHADER_RESOURCE_VIEW_DESC* pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
|
||||
{
|
||||
@@ -953,7 +917,7 @@ static void hkCopyTextureRegion(ID3D12GraphicsCommandList* This, D3D12_TEXTURE_C
|
||||
|
||||
auto fIndex = fgFrameIndex;
|
||||
|
||||
if (This == g_pd3dCommandList || ImGuiOverlayDx::fgCopyCommandList == This || ImGuiOverlayDx::fgSkipHudlessChecks ||
|
||||
if (This == g_pd3dCommandList || ImGuiOverlayDx::fgCopyCommandList == This || ImGuiOverlayDx::fgSkipHudlessChecks ||
|
||||
Config::Instance()->CurrentFeature == nullptr || !ImGuiOverlayDx::upscaleRan)
|
||||
return;
|
||||
|
||||
@@ -1731,6 +1695,12 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags
|
||||
if (Config::Instance()->CurrentFeature != nullptr)
|
||||
fgPresentedFrame = Config::Instance()->CurrentFeature->FrameCount();
|
||||
|
||||
if (fgStopAfterNextPresent)
|
||||
{
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(false, false);
|
||||
fgStopAfterNextPresent = false;
|
||||
}
|
||||
|
||||
auto now = Util::MillisecondsNow();
|
||||
|
||||
if (fgLastFrameTime != 0)
|
||||
@@ -1934,6 +1904,12 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags
|
||||
|
||||
fgLastFrameTime = now;
|
||||
|
||||
if (fgStopAfterNextPresent)
|
||||
{
|
||||
ImGuiOverlayDx::StopAndDestroyFGContext(false, false);
|
||||
fgStopAfterNextPresent = false;
|
||||
}
|
||||
|
||||
return presentResult;
|
||||
}
|
||||
|
||||
@@ -2072,7 +2048,7 @@ static HRESULT hkCreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI
|
||||
createSwapChainDesc.gameQueue = (ID3D12CommandQueue*)pDevice;
|
||||
createSwapChainDesc.desc = pDesc;
|
||||
createSwapChainDesc.swapchain = (IDXGISwapChain4**)ppSwapChain;
|
||||
|
||||
|
||||
|
||||
fgSkipSCWrapping = true;
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
@@ -3302,3 +3278,192 @@ void ImGuiOverlayDx::UnHookDx()
|
||||
|
||||
_isInited = false;
|
||||
}
|
||||
|
||||
void ImGuiOverlayDx::ReleaseFGObjects()
|
||||
{
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
if (ImGuiOverlayDx::fgCopyCommandAllocators[i] != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i]->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgCopyCommandList != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandList->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandList = nullptr;
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgCopyCommandQueue != nullptr)
|
||||
{
|
||||
ImGuiOverlayDx::fgCopyCommandQueue->Release();
|
||||
ImGuiOverlayDx::fgCopyCommandQueue = nullptr;
|
||||
}
|
||||
|
||||
if (ImGuiOverlayDx::fgFormatTransfer != nullptr)
|
||||
{
|
||||
delete ImGuiOverlayDx::fgFormatTransfer;
|
||||
ImGuiOverlayDx::fgFormatTransfer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiOverlayDx::CreateFGObjects(ID3D12Device* InDevice)
|
||||
{
|
||||
if (ImGuiOverlayDx::fgCopyCommandQueue != nullptr)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
result = InDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandAllocators[i]));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandAllocators[{0}]: {1:X}", i, (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandAllocators[i]->SetName(L"fgCopyCommandAllocator");
|
||||
}
|
||||
|
||||
result = InDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, ImGuiOverlayDx::fgCopyCommandAllocators[0], NULL, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandList));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandList: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandList->SetName(L"fgCopyCommandList");
|
||||
|
||||
result = ImGuiOverlayDx::fgCopyCommandList->Close();
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("ImGuiOverlayDx::fgCopyCommandList->Close: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
|
||||
// Create a command queue for frame generation
|
||||
D3D12_COMMAND_QUEUE_DESC copyQueueDesc = {};
|
||||
copyQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
copyQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
copyQueueDesc.NodeMask = 0;
|
||||
|
||||
if (Config::Instance()->FGHighPriority.value_or(false))
|
||||
copyQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH;
|
||||
else
|
||||
copyQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
|
||||
HRESULT hr = InDevice->CreateCommandQueue(©QueueDesc, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandQueue));
|
||||
if (result != S_OK)
|
||||
{
|
||||
LOG_ERROR("CreateCommandQueue: {0:X}", (unsigned long)result);
|
||||
break;
|
||||
}
|
||||
ImGuiOverlayDx::fgCopyCommandQueue->SetName(L"fgCopyCommandQueue");
|
||||
|
||||
ImGuiOverlayDx::fgFormatTransfer = new FT_Dx12("FormatTransfer", InDevice, ImGuiOverlayDx::swapchainFormat);
|
||||
|
||||
} while (false);
|
||||
}
|
||||
|
||||
void ImGuiOverlayDx::CreateFGContext(ID3D12Device* InDevice, IFeature* deviceContext)
|
||||
{
|
||||
if (ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
ffxConfigureDescFrameGeneration m_FrameGenerationConfig = {};
|
||||
m_FrameGenerationConfig.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
|
||||
m_FrameGenerationConfig.frameGenerationEnabled = true;
|
||||
m_FrameGenerationConfig.swapChain = ImGuiOverlayDx::currentSwapchain;
|
||||
//m_FrameGenerationConfig.presentCallback = nullptr;
|
||||
m_FrameGenerationConfig.HUDLessColor = FfxApiResource({});
|
||||
|
||||
auto result = _configure(&ImGuiOverlayDx::fgContext, &m_FrameGenerationConfig.header);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = (result == FFX_API_RETURN_OK);
|
||||
|
||||
LOG_DEBUG("Reactivate");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ffxCreateBackendDX12Desc backendDesc{};
|
||||
backendDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_DX12;
|
||||
backendDesc.device = InDevice;
|
||||
|
||||
ffxCreateContextDescFrameGeneration createFg{};
|
||||
createFg.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION;
|
||||
createFg.displaySize = { deviceContext->DisplayWidth(), deviceContext->DisplayHeight() };
|
||||
createFg.maxRenderSize = { deviceContext->DisplayWidth(), deviceContext->DisplayHeight() };
|
||||
createFg.flags = 0;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_IsHDR)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_HIGH_DYNAMIC_RANGE;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_DepthInverted)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_DEPTH_INVERTED;
|
||||
|
||||
if (deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_MVJittered)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION;
|
||||
|
||||
if ((deviceContext->GetFeatureFlags() & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes) == 0)
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS;
|
||||
|
||||
if (Config::Instance()->FGAsync.value_or(false))
|
||||
createFg.flags |= FFX_FRAMEGENERATION_ENABLE_ASYNC_WORKLOAD_SUPPORT;
|
||||
|
||||
createFg.backBufferFormat = ffxApiGetSurfaceFormatDX12(ImGuiOverlayDx::swapchainFormat);
|
||||
createFg.header.pNext = &backendDesc.header;
|
||||
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
Config::Instance()->SkipHeapCapture = true;
|
||||
ffxReturnCode_t retCode = _createContext(&ImGuiOverlayDx::fgContext, &createFg.header, nullptr);
|
||||
Config::Instance()->SkipHeapCapture = false;
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
LOG_INFO("_createContext result: {0:X}", retCode);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = (retCode == FFX_API_RETURN_OK);
|
||||
|
||||
LOG_DEBUG("Create");
|
||||
}
|
||||
|
||||
void ImGuiOverlayDx::StopAndDestroyFGContext(bool destroy, bool shutDown)
|
||||
{
|
||||
ImGuiOverlayDx::fgSkipHudlessChecks = false;
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
|
||||
if (ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||
|
||||
ffxConfigureDescFrameGeneration m_FrameGenerationConfig = {};
|
||||
m_FrameGenerationConfig.header.type = FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION;
|
||||
m_FrameGenerationConfig.frameGenerationEnabled = false;
|
||||
m_FrameGenerationConfig.swapChain = ImGuiOverlayDx::currentSwapchain;
|
||||
m_FrameGenerationConfig.presentCallback = nullptr;
|
||||
m_FrameGenerationConfig.HUDLessColor = FfxApiResource({});
|
||||
|
||||
auto result = _configure(&ImGuiOverlayDx::fgContext, &m_FrameGenerationConfig.header);
|
||||
|
||||
ImGuiOverlayDx::fgIsActive = false;
|
||||
|
||||
if (!shutDown)
|
||||
LOG_INFO(" FG _configure result: {0:X}", result);
|
||||
}
|
||||
|
||||
if (destroy && ImGuiOverlayDx::fgContext != nullptr)
|
||||
{
|
||||
auto result = _destroyContext(&ImGuiOverlayDx::fgContext, nullptr);
|
||||
|
||||
if (!shutDown)
|
||||
LOG_INFO(" FG _destroyContext result: {0:X}", result);
|
||||
|
||||
ImGuiOverlayDx::fgContext = nullptr;
|
||||
}
|
||||
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
|
||||
if (shutDown)
|
||||
ReleaseFGObjects();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <dx12/ffx_api_dx12.h>
|
||||
#include <ffx_framegeneration.h>
|
||||
#include "../format_transfer/FT_Dx12.h"
|
||||
#include "../backends/IFeature.h"
|
||||
|
||||
namespace ImGuiOverlayDx
|
||||
{
|
||||
@@ -58,4 +59,8 @@ namespace ImGuiOverlayDx
|
||||
UINT ClearFrameResources();
|
||||
UINT GetFrame();
|
||||
void NewFrame();
|
||||
void ReleaseFGObjects();
|
||||
void CreateFGObjects(ID3D12Device* InDevice);
|
||||
void CreateFGContext(ID3D12Device* InDevice, IFeature* deviceContext);
|
||||
void StopAndDestroyFGContext(bool destroy, bool shutDown);
|
||||
}
|
||||
|
||||
@@ -122,14 +122,15 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount, UINT Width, UINT
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
||||
|
||||
if (ClearTrig != nullptr)
|
||||
ClearTrig(true, Handle);
|
||||
|
||||
if (Config::Instance()->CurrentFeature != nullptr)
|
||||
Config::Instance()->FGChanged = true;
|
||||
|
||||
if (BufferCount != 0 || desc.BufferDesc.Width != Width || desc.BufferDesc.Height != Height || desc.BufferDesc.Format != NewFormat)
|
||||
// recreate buffers only when needed
|
||||
if (desc.BufferDesc.Width != Width || desc.BufferDesc.Height != Height || desc.BufferDesc.Format != NewFormat)
|
||||
{
|
||||
if (ClearTrig != nullptr)
|
||||
ClearTrig(true, Handle);
|
||||
|
||||
Config::Instance()->SCChanged = true;
|
||||
}
|
||||
|
||||
@@ -157,16 +158,22 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers1(UINT BufferCount, UINT Width, UIN
|
||||
const UINT* pCreationNodeMask, IUnknown* const* ppPresentQueue)
|
||||
{
|
||||
LOG_FUNC();
|
||||
DXGI_SWAP_CHAIN_DESC desc{};
|
||||
GetDesc(&desc);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
||||
|
||||
if (ClearTrig != nullptr)
|
||||
ClearTrig(true, Handle);
|
||||
|
||||
if (Config::Instance()->CurrentFeature != nullptr)
|
||||
Config::Instance()->FGChanged = true;
|
||||
|
||||
Config::Instance()->SCChanged = true;
|
||||
// recreate buffers only when needed
|
||||
if (desc.BufferDesc.Width != Width || desc.BufferDesc.Height != Height || desc.BufferDesc.Format != Format)
|
||||
{
|
||||
if (ClearTrig != nullptr)
|
||||
ClearTrig(true, Handle);
|
||||
|
||||
Config::Instance()->SCChanged = true;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define VER_MAJOR_VERSION 0
|
||||
#define VER_MINOR_VERSION 7
|
||||
#define VER_HOTFIX_VERSION 0
|
||||
#define VER_BUILD_NUMBER 25
|
||||
#define VER_BUILD_NUMBER 26
|
||||
|
||||
#define VER_PRE_RELEASE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user