fix alt tab

This commit is contained in:
cdozdil
2024-10-21 02:44:57 +03:00
parent 5bb3f53e7e
commit a247a2ac01
12 changed files with 161 additions and 812 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ public:
std::optional<int> FGHUDLimit;
bool FGOnlyGenerated = false;
bool FGChanged = false;
bool SCChanged = true;
bool SCChanged = false;
bool SkipHeapCapture = false;
+66 -41
View File
@@ -44,6 +44,7 @@ static int evalCounter = 0;
static std::wstring appDataPath = L".";
static inline bool shutdown = false;
static void FfxFgLogCallback(uint32_t type, const wchar_t* message)
{
std::wstring string(message);
@@ -124,10 +125,14 @@ static void CreateFGObjects()
// Create a command queue for frame generation
D3D12_COMMAND_QUEUE_DESC copyQueueDesc = {};
copyQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
copyQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH;
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(&copyQueueDesc, IID_PPV_ARGS(&ImGuiOverlayDx::fgCopyCommandQueue));
if (result != S_OK)
{
@@ -143,6 +148,24 @@ static void CreateFGObjects()
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;
@@ -177,38 +200,49 @@ static void CreateFGContext(IFeature_Dx12* deviceContext)
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 shutDown)
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.presentCallback = nullptr;
m_FrameGenerationConfig.HUDLessColor = FfxApiResource({});
Config::Instance()->dxgiSkipSpoofing = true;
auto result = _configure(&ImGuiOverlayDx::fgContext, &m_FrameGenerationConfig.header);
ImGuiOverlayDx::fgIsActive = false;
if (!shutDown)
LOG_INFO(" FG _configure result: {0:X}", result);
}
result = _destroyContext(&ImGuiOverlayDx::fgContext, nullptr);
if (destroy && ImGuiOverlayDx::fgContext != nullptr)
{
auto result = _destroyContext(&ImGuiOverlayDx::fgContext, nullptr);
if (!shutDown)
LOG_INFO(" FG _destroyContext result: {0:X}", result);
Config::Instance()->dxgiSkipSpoofing = false;
ImGuiOverlayDx::fgContext = nullptr;
}
Config::Instance()->dxgiSkipSpoofing = false;
if (shutDown)
ReleaseFGObjects();
}
@@ -686,7 +720,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);
StopAndDestroyFGContext(true, true);
shutdown = false;
@@ -1039,7 +1073,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle*
auto handleId = InHandle->Id;
Config::Instance()->FGChanged = true;
StopAndDestroyFGContext(false);
StopAndDestroyFGContext(true, false);
if (!shutdown)
LOG_INFO("releasing feature with id {0}", handleId);
@@ -1245,7 +1279,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
{
if (ImGuiOverlayDx::fgContext != nullptr)
{
StopAndDestroyFGContext(false);
StopAndDestroyFGContext(false, false);
}
if (Dx12Contexts.contains(handleId))
@@ -1459,24 +1493,26 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
if (Config::Instance()->FGUseFGSwapChain.value_or(true) && Config::Instance()->OverlayMenu.value_or(true))
{
if (!Config::Instance()->FGChanged && ImGuiOverlayDx::fgTarget < deviceContext->FrameCount() && Config::Instance()->FGEnabled.value_or(false) &&
_createContext != nullptr && ImGuiOverlayDx::fgContext == nullptr && ImGuiOverlayDx::currentSwapchain != nullptr &&
_createContext != nullptr && !ImGuiOverlayDx::fgIsActive && ImGuiOverlayDx::currentSwapchain != nullptr &&
ImGuiOverlayDx::swapchainFormat != DXGI_FORMAT_UNKNOWN)
{
CreateFGObjects();
CreateFGContext(deviceContext);
}
else if ((!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged) && ImGuiOverlayDx::fgContext != nullptr)
else if ((!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged) && ImGuiOverlayDx::fgIsActive)
{
StopAndDestroyFGContext(false);
StopAndDestroyFGContext(Config::Instance()->SCChanged, false);
}
if (Config::Instance()->FGChanged)
{
LOG_DEBUG(" FG disabled for 10 frames");
ImGuiOverlayDx::fgTarget = deviceContext->FrameCount() + 10;
ImGuiOverlayDx::fgTarget = deviceContext->FrameCount() + 20;
Config::Instance()->FGChanged = false;
}
}
Config::Instance()->SCChanged = false;
// Record the first timestamp (before FSR2 upscaling)
InCmdList->EndQuery(ImGuiOverlayDx::queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0);
@@ -1539,10 +1575,21 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
if (evalResult)
{
// FG Dispatch || Prepare
if (Config::Instance()->FGUseFGSwapChain.value_or(true) && Config::Instance()->OverlayMenu.value_or(true) &&
if (ImGuiOverlayDx::fgIsActive && Config::Instance()->FGUseFGSwapChain.value_or(true) && Config::Instance()->OverlayMenu.value_or(true) &&
Config::Instance()->FGEnabled.value_or(false) && ImGuiOverlayDx::fgTarget < deviceContext->FrameCount() &&
ImGuiOverlayDx::fgContext != nullptr && ImGuiOverlayDx::currentSwapchain != nullptr)
{
float msDelta = 0.0;
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
msDelta = now - fgLastFrameTime;
LOG_DEBUG(" FG msDelta: {0}", msDelta);
}
fgLastFrameTime = now;
ID3D12Resource* output;
InParameters->Get(NVSDK_NGX_Parameter_Output, &output);
@@ -1554,7 +1601,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
auto result = allocator->Reset();
result = ImGuiOverlayDx::fgCopyCommandList->Reset(allocator, nullptr);
if (!Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgTarget + 10 > deviceContext->FrameCount())
if (!Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgTarget > deviceContext->FrameCount())
{
LOG_DEBUG(" FG running, frame: {0}", deviceContext->FrameCount());
@@ -1595,7 +1642,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
auto fIndex = ImGuiOverlayDx::GetFrame();
// check for status
if (!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged || Config::Instance()->CurrentFeature == nullptr ||
if (!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged || Config::Instance()->CurrentFeature == nullptr ||
ImGuiOverlayDx::fgContext == nullptr || ImGuiOverlayDx::fgCopyCommandList == nullptr || ImGuiOverlayDx::fgCopyCommandQueue == nullptr)
{
LOG_WARN("Cancel async dispatch");
@@ -1756,18 +1803,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
dfgPrepare.cameraFovAngleVertical = 1.0471975511966f;
dfgPrepare.viewSpaceToMetersFactor = 1.0;
float msDelta = 0.0;
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
msDelta = now - fgLastFrameTime;
LOG_DEBUG(" FG _dispatch msDelta: {0}", msDelta);
}
fgLastFrameTime = now;
dfgPrepare.frameTimeDelta = msDelta;
Config::Instance()->dxgiSkipSpoofing = true;
@@ -1801,16 +1836,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
InParameters->Get(NVSDK_NGX_Parameter_MV_Scale_X, &ImGuiOverlayDx::mvScaleX);
InParameters->Get(NVSDK_NGX_Parameter_MV_Scale_Y, &ImGuiOverlayDx::mvScaleY);
float msDelta = 0.0;
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
msDelta = now - fgLastFrameTime;
LOG_DEBUG(" FG _dispatch msDelta: {0}", msDelta);
}
fgLastFrameTime = now;
ImGuiOverlayDx::fgFrameTime = msDelta;
ImGuiOverlayDx::upscaleRan = true;
-691
View File
@@ -1,691 +0,0 @@
#pragma once
#include "pch.h"
#include "Util.h"
#include "Config.h"
#include "Logger.h"
#include <vulkan/vulkan.hpp>
inline const char* project_id_override = "24480451-f00d-face-1304-0308dabad187";
constexpr unsigned long long app_id_override = 0x24480451;
typedef NVSDK_NGX_Result(*PFN_CUDA_Init)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
typedef NVSDK_NGX_Result(*PFN_CUDA_Init_ProjectID)(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_CUDA_Shutdown)(void);
typedef NVSDK_NGX_Result(*PFN_CUDA_GetParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_CUDA_AllocateParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_CUDA_GetCapabilityParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_CUDA_DestroyParameters)(NVSDK_NGX_Parameter* InParameters);
typedef NVSDK_NGX_Result(*PFN_CUDA_GetScratchBufferSize)(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes);
typedef NVSDK_NGX_Result(*PFN_CUDA_CreateFeature)(NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle);
typedef NVSDK_NGX_Result(*PFN_CUDA_EvaluateFeature)(const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback);
typedef NVSDK_NGX_Result(*PFN_CUDA_ReleaseFeature)(NVSDK_NGX_Handle* InHandle);
typedef NVSDK_NGX_Result(*PFN_D3D11_Init)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, ID3D11Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
typedef NVSDK_NGX_Result(*PFN_D3D11_Init_ProjectID)(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, ID3D11Device* InDevice, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_D3D11_Init_Ext)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, ID3D11Device* InDevice, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_D3D11_Shutdown)(void);
typedef NVSDK_NGX_Result(*PFN_D3D11_Shutdown1)(ID3D11Device* InDevice);
typedef NVSDK_NGX_Result(*PFN_D3D11_GetParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D11_AllocateParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D11_GetCapabilityParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D11_DestroyParameters)(NVSDK_NGX_Parameter* InParameters);
typedef NVSDK_NGX_Result(*PFN_D3D11_GetScratchBufferSize)(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes);
typedef NVSDK_NGX_Result(*PFN_D3D11_CreateFeature)(ID3D11DeviceContext* InDevCtx, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle);
typedef NVSDK_NGX_Result(*PFN_D3D11_ReleaseFeature)(NVSDK_NGX_Handle* InHandle);
typedef NVSDK_NGX_Result(*PFN_D3D11_GetFeatureRequirements)(IDXGIAdapter* Adapter, const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo, NVSDK_NGX_FeatureRequirement* OutSupported);
typedef NVSDK_NGX_Result(*PFN_D3D11_EvaluateFeature)(ID3D11DeviceContext* InDevCtx, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback);
typedef NVSDK_NGX_Result(*PFN_D3D12_Init)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, ID3D12Device* InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
typedef NVSDK_NGX_Result(*PFN_D3D12_Init_ProjectID)(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, ID3D12Device* InDevice, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_D3D12_Init_Ext)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, ID3D12Device* InDevice, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_D3D12_Shutdown)(void);
typedef NVSDK_NGX_Result(*PFN_D3D12_Shutdown1)(ID3D12Device* InDevice);
typedef NVSDK_NGX_Result(*PFN_D3D12_GetParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D12_AllocateParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D12_GetCapabilityParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_D3D12_DestroyParameters)(NVSDK_NGX_Parameter* InParameters);
typedef NVSDK_NGX_Result(*PFN_D3D12_GetScratchBufferSize)(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes);
typedef NVSDK_NGX_Result(*PFN_D3D12_CreateFeature)(ID3D12GraphicsCommandList* InCmdList, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle);
typedef NVSDK_NGX_Result(*PFN_D3D12_ReleaseFeature)(NVSDK_NGX_Handle* InHandle);
typedef NVSDK_NGX_Result(*PFN_D3D12_GetFeatureRequirements)(IDXGIAdapter* Adapter, const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo, NVSDK_NGX_FeatureRequirement* OutSupported);
typedef NVSDK_NGX_Result(*PFN_D3D12_EvaluateFeature)(ID3D12GraphicsCommandList* InCmdList, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback);
typedef NVSDK_NGX_Result(*PFN_UpdateFeature)(const NVSDK_NGX_Application_Identifier* ApplicationId, const NVSDK_NGX_Feature FeatureID);
typedef NVSDK_NGX_Result(*PFN_VULKAN_RequiredExtensions)(unsigned int* OutInstanceExtCount, const char*** OutInstanceExts, unsigned int* OutDeviceExtCount, const char*** OutDeviceExts);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Init)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Init_Ext)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Init_Ext2)(unsigned long long InApplicationId, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Init_ProjectID_Ext)(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Init_ProjectID)(const char* InProjectId, NVSDK_NGX_EngineType InEngineType, const char* InEngineVersion, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, NVSDK_NGX_Version InSDKVersion, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Shutdown)(void);
typedef NVSDK_NGX_Result(*PFN_VULKAN_Shutdown1)(VkDevice InDevice);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_VULKAN_AllocateParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetCapabilityParameters)(NVSDK_NGX_Parameter** OutParameters);
typedef NVSDK_NGX_Result(*PFN_VULKAN_DestroyParameters)(NVSDK_NGX_Parameter* InParameters);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetScratchBufferSize)(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter* InParameters, size_t* OutSizeInBytes);
typedef NVSDK_NGX_Result(*PFN_VULKAN_CreateFeature)(VkCommandBuffer InCmdBuffer, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle);
typedef NVSDK_NGX_Result(*PFN_VULKAN_CreateFeature1)(VkDevice InDevice, VkCommandBuffer InCmdList, NVSDK_NGX_Feature InFeatureID, NVSDK_NGX_Parameter* InParameters, NVSDK_NGX_Handle** OutHandle);
typedef NVSDK_NGX_Result(*PFN_VULKAN_ReleaseFeature)(NVSDK_NGX_Handle* InHandle);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetFeatureRequirements)(const VkInstance Instance, const VkPhysicalDevice PhysicalDevice, const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo, NVSDK_NGX_FeatureRequirement* OutSupported);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetFeatureInstanceExtensionRequirements)(const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo, uint32_t* OutExtensionCount, VkExtensionProperties** OutExtensionProperties);
typedef NVSDK_NGX_Result(*PFN_VULKAN_GetFeatureDeviceExtensionRequirements)(VkInstance Instance, VkPhysicalDevice PhysicalDevice, const NVSDK_NGX_FeatureDiscoveryInfo* FeatureDiscoveryInfo, uint32_t* OutExtensionCount, VkExtensionProperties** OutExtensionProperties);
typedef NVSDK_NGX_Result(*PFN_VULKAN_EvaluateFeature)(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle* InFeatureHandle, const NVSDK_NGX_Parameter* InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback);
class NVNGXProxy
{
private:
inline static HMODULE _dll = nullptr;
inline static bool _cudaInited = false;
inline static bool _dx11Inited = false;
inline static bool _dx12Inited = false;
inline static bool _vulkanInited = false;
inline static PFN_CUDA_Init _CUDA_Init = nullptr;
inline static PFN_CUDA_Init_ProjectID _CUDA_Init_ProjectID = nullptr;
inline static PFN_CUDA_Shutdown _CUDA_Shutdown = nullptr;
inline static PFN_CUDA_GetParameters _CUDA_GetParameters = nullptr;
inline static PFN_CUDA_AllocateParameters _CUDA_AllocateParameters = nullptr;
inline static PFN_CUDA_GetCapabilityParameters _CUDA_GetCapabilityParameters = nullptr;
inline static PFN_CUDA_DestroyParameters _CUDA_DestroyParameters = nullptr;
inline static PFN_CUDA_GetScratchBufferSize _CUDA_GetScratchBufferSize = nullptr;
inline static PFN_CUDA_CreateFeature _CUDA_CreateFeature = nullptr;
inline static PFN_CUDA_EvaluateFeature _CUDA_EvaluateFeature = nullptr;
inline static PFN_CUDA_ReleaseFeature _CUDA_ReleaseFeature = nullptr;
inline static PFN_D3D11_Init _D3D11_Init = nullptr;
inline static PFN_D3D11_Init_ProjectID _D3D11_Init_ProjectID = nullptr;
inline static PFN_D3D11_Init_Ext _D3D11_Init_Ext = nullptr;
inline static PFN_D3D11_Shutdown _D3D11_Shutdown = nullptr;
inline static PFN_D3D11_Shutdown1 _D3D11_Shutdown1 = nullptr;
inline static PFN_D3D11_GetParameters _D3D11_GetParameters = nullptr;
inline static PFN_D3D11_AllocateParameters _D3D11_AllocateParameters = nullptr;
inline static PFN_D3D11_GetCapabilityParameters _D3D11_GetCapabilityParameters = nullptr;
inline static PFN_D3D11_DestroyParameters _D3D11_DestroyParameters = nullptr;
inline static PFN_D3D11_GetScratchBufferSize _D3D11_GetScratchBufferSize = nullptr;
inline static PFN_D3D11_CreateFeature _D3D11_CreateFeature = nullptr;
inline static PFN_D3D11_ReleaseFeature _D3D11_ReleaseFeature = nullptr;
inline static PFN_D3D11_GetFeatureRequirements _D3D11_GetFeatureRequirements = nullptr;
inline static PFN_D3D11_EvaluateFeature _D3D11_EvaluateFeature = nullptr;
inline static PFN_D3D12_Init _D3D12_Init = nullptr;
inline static PFN_D3D12_Init_ProjectID _D3D12_Init_ProjectID = nullptr;
inline static PFN_D3D12_Init_Ext _D3D12_Init_Ext = nullptr;
inline static PFN_D3D12_Shutdown _D3D12_Shutdown = nullptr;
inline static PFN_D3D12_Shutdown1 _D3D12_Shutdown1 = nullptr;
inline static PFN_D3D12_GetParameters _D3D12_GetParameters = nullptr;
inline static PFN_D3D12_AllocateParameters _D3D12_AllocateParameters = nullptr;
inline static PFN_D3D12_GetCapabilityParameters _D3D12_GetCapabilityParameters = nullptr;
inline static PFN_D3D12_DestroyParameters _D3D12_DestroyParameters = nullptr;
inline static PFN_D3D12_GetScratchBufferSize _D3D12_GetScratchBufferSize = nullptr;
inline static PFN_D3D12_CreateFeature _D3D12_CreateFeature = nullptr;
inline static PFN_D3D12_ReleaseFeature _D3D12_ReleaseFeature = nullptr;
inline static PFN_D3D12_GetFeatureRequirements _D3D12_GetFeatureRequirements = nullptr;
inline static PFN_D3D12_EvaluateFeature _D3D12_EvaluateFeature = nullptr;
inline static PFN_VULKAN_RequiredExtensions _VULKAN_RequiredExtensions = nullptr;
inline static PFN_VULKAN_Init _VULKAN_Init = nullptr;
inline static PFN_VULKAN_Init_ProjectID _VULKAN_Init_ProjectID = nullptr;
inline static PFN_VULKAN_Init_Ext _VULKAN_Init_Ext = nullptr;
inline static PFN_VULKAN_Init_Ext2 _VULKAN_Init_Ext2 = nullptr;
inline static PFN_VULKAN_Init_ProjectID_Ext _VULKAN_Init_ProjectID_Ext = nullptr;
inline static PFN_VULKAN_Shutdown _VULKAN_Shutdown = nullptr;
inline static PFN_VULKAN_Shutdown1 _VULKAN_Shutdown1 = nullptr;
inline static PFN_VULKAN_GetParameters _VULKAN_GetParameters = nullptr;
inline static PFN_VULKAN_AllocateParameters _VULKAN_AllocateParameters = nullptr;
inline static PFN_VULKAN_GetCapabilityParameters _VULKAN_GetCapabilityParameters = nullptr;
inline static PFN_VULKAN_DestroyParameters _VULKAN_DestroyParameters = nullptr;
inline static PFN_VULKAN_GetScratchBufferSize _VULKAN_GetScratchBufferSize = nullptr;
inline static PFN_VULKAN_CreateFeature _VULKAN_CreateFeature = nullptr;
inline static PFN_VULKAN_CreateFeature1 _VULKAN_CreateFeature1 = nullptr;
inline static PFN_VULKAN_ReleaseFeature _VULKAN_ReleaseFeature = nullptr;
inline static PFN_VULKAN_GetFeatureRequirements _VULKAN_GetFeatureRequirements = nullptr;
inline static PFN_VULKAN_GetFeatureInstanceExtensionRequirements _VULKAN_GetFeatureInstanceExtensionRequirements = nullptr;
inline static PFN_VULKAN_GetFeatureDeviceExtensionRequirements _VULKAN_GetFeatureDeviceExtensionRequirements = nullptr;
inline static PFN_VULKAN_EvaluateFeature _VULKAN_EvaluateFeature = nullptr;
inline static PFN_UpdateFeature _UpdateFeature = nullptr;
public:
static void InitNVNGX()
{
// if dll already loaded
if (_dll != nullptr)
return;
LOG_FUNC();
Config::Instance()->dlssDisableHook = true;
_dll = dllModule;
LOG_INFO("getting nvngx method addresses");
_D3D11_Init = (PFN_D3D11_Init)GetProcAddress(_dll, "NVSDK_NGX_D3D11_Init");
_D3D11_Init_ProjectID = (PFN_D3D11_Init_ProjectID)GetProcAddress(_dll, "NVSDK_NGX_D3D11_Init_ProjectID");
_D3D11_Init_Ext = (PFN_D3D11_Init_Ext)GetProcAddress(_dll, "NVSDK_NGX_D3D11_Init_Ext");
_D3D11_Shutdown = (PFN_D3D11_Shutdown)GetProcAddress(_dll, "NVSDK_NGX_D3D11_Shutdown");
_D3D11_Shutdown1 = (PFN_D3D11_Shutdown1)GetProcAddress(_dll, "NVSDK_NGX_D3D11_Shutdown1");
_D3D11_GetParameters = (PFN_D3D11_GetParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D11_GetParameters");
_D3D11_AllocateParameters = (PFN_D3D11_AllocateParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D11_AllocateParameters");
_D3D11_GetCapabilityParameters = (PFN_D3D11_GetCapabilityParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D11_GetCapabilityParameters");
_D3D11_DestroyParameters = (PFN_D3D11_DestroyParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D11_DestroyParameters");
_D3D11_GetScratchBufferSize = (PFN_D3D11_GetScratchBufferSize)GetProcAddress(_dll, "NVSDK_NGX_D3D11_GetScratchBufferSize");
_D3D11_CreateFeature = (PFN_D3D11_CreateFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D11_CreateFeature");
_D3D11_ReleaseFeature = (PFN_D3D11_ReleaseFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D11_ReleaseFeature");
_D3D11_GetFeatureRequirements = (PFN_D3D11_GetFeatureRequirements)GetProcAddress(_dll, "NVSDK_NGX_D3D11_GetFeatureRequirements");
_D3D11_EvaluateFeature = (PFN_D3D11_EvaluateFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D11_EvaluateFeature");
_D3D12_Init = (PFN_D3D12_Init)GetProcAddress(_dll, "NVSDK_NGX_D3D12_Init");
_D3D12_Init_ProjectID = (PFN_D3D12_Init_ProjectID)GetProcAddress(_dll, "NVSDK_NGX_D3D12_Init_ProjectID");
_D3D12_Init_Ext = (PFN_D3D12_Init_Ext)GetProcAddress(_dll, "NVSDK_NGX_D3D12_Init_Ext");
_D3D12_Shutdown = (PFN_D3D12_Shutdown)GetProcAddress(_dll, "NVSDK_NGX_D3D12_Shutdown");
_D3D12_Shutdown1 = (PFN_D3D12_Shutdown1)GetProcAddress(_dll, "NVSDK_NGX_D3D12_Shutdown1");
_D3D12_GetParameters = (PFN_D3D12_GetParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetParameters");
_D3D12_AllocateParameters = (PFN_D3D12_AllocateParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D12_AllocateParameters");
_D3D12_GetCapabilityParameters = (PFN_D3D12_GetCapabilityParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetCapabilityParameters");
_D3D12_DestroyParameters = (PFN_D3D12_DestroyParameters)GetProcAddress(_dll, "NVSDK_NGX_D3D12_DestroyParameters");
_D3D12_GetScratchBufferSize = (PFN_D3D12_GetScratchBufferSize)GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetScratchBufferSize");
_D3D12_CreateFeature = (PFN_D3D12_CreateFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D12_CreateFeature");
_D3D12_ReleaseFeature = (PFN_D3D12_ReleaseFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D12_ReleaseFeature");
_D3D12_GetFeatureRequirements = (PFN_D3D12_GetFeatureRequirements)GetProcAddress(_dll, "NVSDK_NGX_D3D12_GetFeatureRequirements");
_D3D12_EvaluateFeature = (PFN_D3D12_EvaluateFeature)GetProcAddress(_dll, "NVSDK_NGX_D3D12_EvaluateFeature");
_VULKAN_RequiredExtensions = (PFN_VULKAN_RequiredExtensions)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_RequiredExtensions");
_VULKAN_Init = (PFN_VULKAN_Init)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init");
_VULKAN_Init_Ext = (PFN_VULKAN_Init_Ext)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_Ext");
_VULKAN_Init_Ext2 = (PFN_VULKAN_Init_Ext2)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_Ext2");
_VULKAN_Init_ProjectID_Ext = (PFN_VULKAN_Init_ProjectID_Ext)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_ProjectID_Ext");
_VULKAN_Init_ProjectID = (PFN_VULKAN_Init_ProjectID)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Init_ProjectID");
_VULKAN_Shutdown = (PFN_VULKAN_Shutdown)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Shutdown");
_VULKAN_Shutdown1 = (PFN_VULKAN_Shutdown1)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_Shutdown1");
_VULKAN_GetParameters = (PFN_VULKAN_GetParameters)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetParameters");
_VULKAN_AllocateParameters = (PFN_VULKAN_AllocateParameters)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_AllocateParameters");
_VULKAN_GetCapabilityParameters = (PFN_VULKAN_GetCapabilityParameters)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetCapabilityParameters");
_VULKAN_DestroyParameters = (PFN_VULKAN_DestroyParameters)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_DestroyParameters");
_VULKAN_GetScratchBufferSize = (PFN_VULKAN_GetScratchBufferSize)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetScratchBufferSize");
_VULKAN_CreateFeature = (PFN_VULKAN_CreateFeature)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature");
_VULKAN_CreateFeature1 = (PFN_VULKAN_CreateFeature1)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_CreateFeature1");
_VULKAN_ReleaseFeature = (PFN_VULKAN_ReleaseFeature)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_ReleaseFeature");
_VULKAN_GetFeatureRequirements = (PFN_VULKAN_GetFeatureRequirements)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureRequirements");
_VULKAN_GetFeatureInstanceExtensionRequirements = (PFN_VULKAN_GetFeatureInstanceExtensionRequirements)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureInstanceExtensionRequirements");
_VULKAN_GetFeatureDeviceExtensionRequirements = (PFN_VULKAN_GetFeatureDeviceExtensionRequirements)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_GetFeatureDeviceExtensionRequirements");
_VULKAN_EvaluateFeature = (PFN_VULKAN_EvaluateFeature)GetProcAddress(_dll, "NVSDK_NGX_VULKAN_EvaluateFeature");
_UpdateFeature = (PFN_UpdateFeature)GetProcAddress(_dll, "NVSDK_NGX_UpdateFeature");
}
static void GetFeatureCommonInfo(NVSDK_NGX_FeatureCommonInfo* fcInfo)
{
// Allocate memory for the array of const wchar_t*
wchar_t const** paths = new const wchar_t* [Config::Instance()->NVNGX_FeatureInfo_Paths.size()];
// Copy the strings from the vector to the array
for (size_t i = 0; i < Config::Instance()->NVNGX_FeatureInfo_Paths.size(); ++i)
{
paths[i] = Config::Instance()->NVNGX_FeatureInfo_Paths[i].c_str();
LOG_DEBUG("paths[{0}]: {1}", i, wstring_to_string(Config::Instance()->NVNGX_FeatureInfo_Paths[i]));
}
fcInfo->PathListInfo.Path = paths;
fcInfo->PathListInfo.Length = static_cast<unsigned int>(Config::Instance()->NVNGX_FeatureInfo_Paths.size());
}
static HMODULE NVNGXModule()
{
return _dll;
}
static bool IsNVNGXInited()
{
return _dll != nullptr && (_dx11Inited || _dx12Inited || _vulkanInited) && Config::Instance()->DLSSEnabled.value_or(true);
}
// DirectX11
static bool InitDx11(ID3D11Device* InDevice)
{
if (_dx11Inited)
return true;
InitNVNGX();
if (_dll == nullptr)
return false;
NVSDK_NGX_FeatureCommonInfo fcInfo{};
GetFeatureCommonInfo(&fcInfo);
NVSDK_NGX_Result nvResult = NVSDK_NGX_Result_Fail;
if (Config::Instance()->NVNGX_ProjectId != "" && _D3D11_Init_ProjectID != nullptr)
{
LOG_DEBUG("_D3D11_Init_ProjectID!");
nvResult = _D3D11_Init_ProjectID(Config::Instance()->NVNGX_ProjectId.c_str(), Config::Instance()->NVNGX_Engine, Config::Instance()->NVNGX_EngineVersion.c_str(),
Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InDevice, Config::Instance()->NVNGX_Version, &fcInfo);
}
else if (_D3D11_Init_Ext != nullptr)
{
LOG_DEBUG("_D3D11_Init_Ext!");
nvResult = _D3D11_Init_Ext(Config::Instance()->NVNGX_ApplicationId, Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InDevice, Config::Instance()->NVNGX_Version, &fcInfo);
}
LOG_DEBUG("result: {0:X}", (UINT)nvResult);
_dx11Inited = (nvResult == NVSDK_NGX_Result_Success);
return _dx11Inited;
}
static void SetDx11Inited(bool value)
{
_dx11Inited = value;
}
static bool IsDx11Inited()
{
return _dx11Inited;
}
static PFN_D3D11_Init_ProjectID D3D11_Init_ProjectID()
{
return _D3D11_Init_ProjectID;
}
static PFN_D3D11_Init D3D11_Init()
{
return _D3D11_Init;
}
static PFN_D3D11_Init_Ext D3D11_Init_Ext()
{
return _D3D11_Init_Ext;
}
static PFN_D3D11_GetFeatureRequirements D3D11_GetFeatureRequirements()
{
return _D3D11_GetFeatureRequirements;
}
static PFN_D3D11_GetCapabilityParameters D3D11_GetCapabilityParameters()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_GetCapabilityParameters;
}
static PFN_D3D11_AllocateParameters D3D11_AllocateParameters()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_AllocateParameters;
}
static PFN_D3D11_GetParameters D3D11_GetParameters()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_GetParameters;
}
static PFN_D3D11_DestroyParameters D3D11_DestroyParameters()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_DestroyParameters;
}
static PFN_D3D11_CreateFeature D3D11_CreateFeature()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_CreateFeature;
}
static PFN_D3D11_EvaluateFeature D3D11_EvaluateFeature()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_EvaluateFeature;
}
static PFN_D3D11_ReleaseFeature D3D11_ReleaseFeature()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_ReleaseFeature;
}
static PFN_D3D11_Shutdown D3D11_Shutdown()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_Shutdown;
}
static PFN_D3D11_Shutdown1 D3D11_Shutdown1()
{
if (!_dx11Inited)
return nullptr;
return _D3D11_Shutdown1;
}
// DirectX12
static bool InitDx12(ID3D12Device* InDevice)
{
if (_dx12Inited)
return true;
InitNVNGX();
if (_dll == nullptr)
return false;
NVSDK_NGX_FeatureCommonInfo fcInfo{};
GetFeatureCommonInfo(&fcInfo);
NVSDK_NGX_Result nvResult = NVSDK_NGX_Result_Fail;
if (Config::Instance()->NVNGX_ProjectId != "" && _D3D12_Init_ProjectID != nullptr)
{
LOG_INFO("_D3D12_Init_ProjectID!");
nvResult = _D3D12_Init_ProjectID(Config::Instance()->NVNGX_ProjectId.c_str(), Config::Instance()->NVNGX_Engine, Config::Instance()->NVNGX_EngineVersion.c_str(),
Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InDevice, Config::Instance()->NVNGX_Version, &fcInfo);
}
else if (_D3D12_Init_Ext != nullptr)
{
LOG_INFO("_D3D12_Init_Ext!");
nvResult = _D3D12_Init_Ext(Config::Instance()->NVNGX_ApplicationId, Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InDevice, Config::Instance()->NVNGX_Version, &fcInfo);
}
LOG_INFO("result: {0:X}", (UINT)nvResult);
_dx12Inited = (nvResult == NVSDK_NGX_Result_Success);
return _dx12Inited;
}
static void SetDx12Inited(bool value)
{
_dx12Inited = value;
}
static bool IsDx12Inited()
{
return _dx12Inited;
}
static PFN_D3D12_Init_ProjectID D3D12_Init_ProjectID()
{
return _D3D12_Init_ProjectID;
}
static PFN_D3D12_Init D3D12_Init()
{
return _D3D12_Init;
}
static PFN_D3D12_Init_Ext D3D12_Init_Ext()
{
return _D3D12_Init_Ext;
}
static PFN_D3D12_GetFeatureRequirements D3D12_GetFeatureRequirements()
{
return _D3D12_GetFeatureRequirements;
}
static PFN_D3D12_GetCapabilityParameters D3D12_GetCapabilityParameters()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_GetCapabilityParameters;
}
static PFN_D3D12_AllocateParameters D3D12_AllocateParameters()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_AllocateParameters;
}
static PFN_D3D12_GetParameters D3D12_GetParameters()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_GetParameters;
}
static PFN_D3D12_DestroyParameters D3D12_DestroyParameters()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_DestroyParameters;
}
static PFN_D3D12_CreateFeature D3D12_CreateFeature()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_CreateFeature;
}
static PFN_D3D12_EvaluateFeature D3D12_EvaluateFeature()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_EvaluateFeature;
}
static PFN_D3D12_ReleaseFeature D3D12_ReleaseFeature()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_ReleaseFeature;
}
static PFN_D3D12_Shutdown D3D12_Shutdown()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_Shutdown;
}
static PFN_D3D12_Shutdown1 D3D12_Shutdown1()
{
if (!_dx12Inited)
return nullptr;
return _D3D12_Shutdown1;
}
// Vulkan
static bool InitVulkan(VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA)
{
if (_vulkanInited)
return true;
InitNVNGX();
if (_dll == nullptr)
return false;
NVSDK_NGX_FeatureCommonInfo fcInfo{};
GetFeatureCommonInfo(&fcInfo);
NVSDK_NGX_Result nvResult = NVSDK_NGX_Result_Fail;
if (Config::Instance()->NVNGX_ProjectId != "" && _VULKAN_Init_ProjectID != nullptr)
{
LOG_DEBUG("_VULKAN_Init_ProjectID!");
nvResult = _VULKAN_Init_ProjectID(Config::Instance()->NVNGX_ProjectId.c_str(), Config::Instance()->NVNGX_Engine, Config::Instance()->NVNGX_EngineVersion.c_str(),
Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InInstance, InPD, InDevice, InGIPA, InGDPA, Config::Instance()->NVNGX_Version, &fcInfo);
}
else if (_VULKAN_Init_Ext != nullptr)
{
LOG_DEBUG("_VULKAN_Init_Ext!");
nvResult = _VULKAN_Init_Ext(Config::Instance()->NVNGX_ApplicationId, Config::Instance()->NVNGX_ApplicationDataPath.c_str(), InInstance, InPD, InDevice, Config::Instance()->NVNGX_Version, &fcInfo);
}
LOG_DEBUG("result: {0:X}", (UINT)nvResult);
_vulkanInited = (nvResult == NVSDK_NGX_Result_Success);
return true;
}
static void SetVulkanInited(bool value)
{
_vulkanInited = value;
}
static bool IsVulkanInited()
{
return _vulkanInited;
}
static PFN_VULKAN_Init_ProjectID VULKAN_Init_ProjectID()
{
return _VULKAN_Init_ProjectID;
}
static PFN_VULKAN_Init_ProjectID_Ext VULKAN_Init_ProjectID_Ext()
{
return _VULKAN_Init_ProjectID_Ext;
}
static PFN_VULKAN_Init_Ext VULKAN_Init_Ext()
{
return _VULKAN_Init_Ext;
}
static PFN_VULKAN_Init_Ext2 VULKAN_Init_Ext2()
{
return _VULKAN_Init_Ext2;
}
static PFN_VULKAN_Init VULKAN_Init()
{
return _VULKAN_Init;
}
static PFN_VULKAN_GetFeatureDeviceExtensionRequirements VULKAN_GetFeatureDeviceExtensionRequirements()
{
return _VULKAN_GetFeatureDeviceExtensionRequirements;
}
static PFN_VULKAN_GetFeatureInstanceExtensionRequirements VULKAN_GetFeatureInstanceExtensionRequirements()
{
return _VULKAN_GetFeatureInstanceExtensionRequirements;
}
static PFN_VULKAN_GetFeatureRequirements VULKAN_GetFeatureRequirements()
{
return _VULKAN_GetFeatureRequirements;
}
static PFN_VULKAN_GetCapabilityParameters VULKAN_GetCapabilityParameters()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_GetCapabilityParameters;
}
static PFN_VULKAN_AllocateParameters VULKAN_AllocateParameters()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_AllocateParameters;
}
static PFN_VULKAN_GetParameters VULKAN_GetParameters()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_GetParameters;
}
static PFN_VULKAN_DestroyParameters VULKAN_DestroyParameters()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_DestroyParameters;
}
static PFN_VULKAN_CreateFeature VULKAN_CreateFeature()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_CreateFeature;
}
static PFN_VULKAN_CreateFeature1 VULKAN_CreateFeature1()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_CreateFeature1;
}
static PFN_VULKAN_EvaluateFeature VULKAN_EvaluateFeature()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_EvaluateFeature;
}
static PFN_VULKAN_ReleaseFeature VULKAN_ReleaseFeature()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_ReleaseFeature;
}
static PFN_VULKAN_Shutdown VULKAN_Shutdown()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_Shutdown;
}
static PFN_VULKAN_Shutdown1 VULKAN_Shutdown1()
{
if (!_vulkanInited)
return nullptr;
return _VULKAN_Shutdown1;
}
static PFN_UpdateFeature UpdateFeature()
{
if (_dll == nullptr)
InitNVNGX();
return _UpdateFeature;
}
};
-1
View File
@@ -208,7 +208,6 @@ copy $(SolutionDir)nvngx.ini $(SolutionDir)x64\Release\a\</Command>
<ClInclude Include="bias\precompile\Bias_Shader.h" />
<ClInclude Include="format_transfer\FT_Common.h" />
<ClInclude Include="format_transfer\FT_Dx12.h" />
<ClInclude Include="NVNGX_Local_Proxy.h" />
<ClInclude Include="output_scaling\OS_Common.h" />
<ClInclude Include="output_scaling\OS_Dx12.h" />
<ClInclude Include="output_scaling\precompile\BCDS_Shader.h" />
+15 -15
View File
@@ -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);
+15 -15
View File
@@ -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);
+1 -1
View File
@@ -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);
+42 -40
View File
@@ -480,7 +480,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
{
auto fIndex = fgFrameIndex;
if (This != g_pd3dCommandList && fgCopySource[fIndex] != nullptr && Config::Instance()->CurrentFeature != nullptr &&
fgHudlessFrame != Config::Instance()->CurrentFeature->FrameCount() && ImGuiOverlayDx::fgTarget + 10 <= Config::Instance()->CurrentFeature->FrameCount())
fgHudlessFrame != Config::Instance()->CurrentFeature->FrameCount() && ImGuiOverlayDx::fgTarget <= Config::Instance()->CurrentFeature->FrameCount())
{
LOG_DEBUG("FrameCount: {0}, fgHudlessFrame: {1}, CommandList: {2:X}", Config::Instance()->CurrentFeature->FrameCount(), fgHudlessFrame, (UINT64)This);
@@ -547,7 +547,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
// 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::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
{
LOG_WARN("Cancel async dispatch");
fgDispatchCalled = false;
@@ -572,7 +572,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
// 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::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
{
LOG_WARN("Cancel async dispatch");
fgDispatchCalled = false;
@@ -589,7 +589,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
// 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::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
{
LOG_WARN("Cancel async dispatch");
fgDispatchCalled = false;
@@ -605,7 +605,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
// 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::fgCopyCommandQueue == nullptr || !ImGuiOverlayDx::fgIsActive)
{
LOG_WARN("Cancel async dispatch");
fgDispatchCalled = false;
@@ -685,7 +685,7 @@ static void GetHudless(ID3D12GraphicsCommandList* This, bool SkipCopy) //, D3D12
dfgPrepare.frameTimeDelta = ImGuiOverlayDx::fgFrameTime;
// If somehow context is destroyed before this point
if (Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr)
if (Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr || !ImGuiOverlayDx::fgIsActive)
{
LOG_WARN("!! Config::Instance()->CurrentFeature == nullptr || ImGuiOverlayDx::fgContext == nullptr");
return;
@@ -717,26 +717,25 @@ static bool CheckCapture()
return true;
}
static void CaptureHudless(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
static void CaptureHudless(ID3D12GraphicsCommandList* cmdList, ResourceInfo* resource, D3D12_RESOURCE_STATES state)
{
auto fIndex = fgFrameIndex;
ImGuiOverlayDx::upscaleRan = false;
fgUpscaledFound = false;
fgCopySource[fIndex] = resource;
fgCopySource[fIndex] = resource->buffer;
auto resInfo = resource->GetDesc();
if (resInfo.Format != ImGuiOverlayDx::swapchainFormat && Config::Instance()->FGHUDFixExtended.value_or(false) && ImGuiOverlayDx::fgFormatTransfer != nullptr &&
(resInfo.Format == DXGI_FORMAT_R16G16B16A16_FLOAT || resInfo.Format == DXGI_FORMAT_R11G11B10_FLOAT || resInfo.Format == DXGI_FORMAT_R32G32B32A32_FLOAT || resInfo.Format == DXGI_FORMAT_R32G32B32_FLOAT) &&
if (resource->format != ImGuiOverlayDx::swapchainFormat && Config::Instance()->FGHUDFixExtended.value_or(false) && ImGuiOverlayDx::fgFormatTransfer != nullptr &&
(resource->format == DXGI_FORMAT_R16G16B16A16_FLOAT || resource->format == DXGI_FORMAT_R11G11B10_FLOAT || resource->format == DXGI_FORMAT_R32G32B32A32_FLOAT || resource->format == DXGI_FORMAT_R32G32B32_FLOAT) &&
(ImGuiOverlayDx::swapchainFormat == DXGI_FORMAT_R8G8B8A8_UNORM || ImGuiOverlayDx::swapchainFormat == DXGI_FORMAT_B8G8R8A8_UNORM || ImGuiOverlayDx::swapchainFormat == DXGI_FORMAT_R10G10B10A2_UNORM))
{
if (ImGuiOverlayDx::fgFormatTransfer->CreateBufferResource(g_pd3dDeviceParam, resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) &&
CreateBufferResource(g_pd3dDeviceParam, resource, D3D12_RESOURCE_STATE_COPY_SOURCE, &fgHudlessBuffer[fIndex]))
if (ImGuiOverlayDx::fgFormatTransfer->CreateBufferResource(g_pd3dDeviceParam, resource->buffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) &&
CreateBufferResource(g_pd3dDeviceParam, resource->buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, &fgHudlessBuffer[fIndex]))
{
ResourceBarrier(cmdList, resource, state, D3D12_RESOURCE_STATE_COPY_SOURCE);
ResourceBarrier(cmdList, resource->buffer, state, D3D12_RESOURCE_STATE_COPY_SOURCE);
ResourceBarrier(cmdList, fgHudlessBuffer[fIndex], D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
cmdList->CopyResource(fgHudlessBuffer[fIndex], resource);
cmdList->CopyResource(fgHudlessBuffer[fIndex], resource->buffer);
ResourceBarrier(cmdList, fgHudlessBuffer[fIndex], D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
ResourceBarrier(cmdList, resource, D3D12_RESOURCE_STATE_COPY_SOURCE, state);
ResourceBarrier(cmdList, resource->buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, state);
ImGuiOverlayDx::fgFormatTransfer->SetBufferState(ImGuiOverlayDx::fgCopyCommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
ImGuiOverlayDx::fgFormatTransfer->Dispatch(g_pd3dDeviceParam, ImGuiOverlayDx::fgCopyCommandList, fgHudlessBuffer[fIndex], ImGuiOverlayDx::fgFormatTransfer->Buffer());
@@ -748,12 +747,12 @@ static void CaptureHudless(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* r
}
else
{
ResourceBarrier(cmdList, resource, state, D3D12_RESOURCE_STATE_COPY_SOURCE);
ResourceBarrier(cmdList, resource->buffer, state, D3D12_RESOURCE_STATE_COPY_SOURCE);
if (CreateBufferResource(g_pd3dDeviceParam, resource, D3D12_RESOURCE_STATE_COPY_DEST, &fgHudless[fIndex]))
cmdList->CopyResource(fgHudless[fIndex], resource);
if (CreateBufferResource(g_pd3dDeviceParam, resource->buffer, D3D12_RESOURCE_STATE_COPY_DEST, &fgHudless[fIndex]))
cmdList->CopyResource(fgHudless[fIndex], resource->buffer);
ResourceBarrier(cmdList, resource, D3D12_RESOURCE_STATE_COPY_SOURCE, state);
ResourceBarrier(cmdList, resource->buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, state);
}
GetHudless(cmdList, true);
@@ -764,9 +763,9 @@ static bool CheckForHudless(ResourceInfo* resource, bool checkFormat = true)
if (ImGuiOverlayDx::currentSwapchain == nullptr)
return false;
if (Config::Instance()->SCChanged)
{
LOG_INFO("Config::Instance()->SCChanged");
//if (Config::Instance()->SCChanged)
//{
// LOG_INFO("Config::Instance()->SCChanged");
if (ImGuiOverlayDx::currentSwapchain->GetDesc(&fgScDesc) != S_OK)
{
@@ -774,8 +773,8 @@ static bool CheckForHudless(ResourceInfo* resource, bool checkFormat = true)
return false;
}
Config::Instance()->SCChanged = false;
}
// Config::Instance()->SCChanged = false;
//}
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 &&
@@ -926,7 +925,7 @@ static void hkCopyResource(ID3D12GraphicsCommandList* This, ID3D12Resource* Dest
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -954,11 +953,12 @@ static void hkCopyTextureRegion(ID3D12GraphicsCommandList* This, D3D12_TEXTURE_C
auto fIndex = fgFrameIndex;
if (This == g_pd3dCommandList || ImGuiOverlayDx::fgCopyCommandList == This || ImGuiOverlayDx::fgSkipHudlessChecks || Config::Instance()->CurrentFeature == nullptr || !ImGuiOverlayDx::upscaleRan)
if (This == g_pd3dCommandList || ImGuiOverlayDx::fgCopyCommandList == This || ImGuiOverlayDx::fgSkipHudlessChecks ||
Config::Instance()->CurrentFeature == nullptr || !ImGuiOverlayDx::upscaleRan)
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -975,7 +975,7 @@ static void hkCopyTextureRegion(ID3D12GraphicsCommandList* This, D3D12_TEXTURE_C
if (CheckForHudless(&resInfo) && CheckCapture())
{
LOG_DEBUG("Capture");
CaptureHudless(This, pDst->pResource, D3D12_RESOURCE_STATE_COPY_DEST);
CaptureHudless(This, &resInfo, D3D12_RESOURCE_STATE_COPY_DEST);
}
}
@@ -1034,7 +1034,7 @@ static void hkCopyDescriptors(ID3D12Device* This,
LOG_DEBUG_ONLY("SrcRanges: {}, DestRanges: {}, Type: {}", NumSrcDescriptorRanges, NumDestDescriptorRanges, (UINT)DescriptorHeapsType);
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1097,7 +1097,7 @@ static void hkCopyDescriptorsSimple(ID3D12Device* This, UINT NumDescriptors, D3D
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1133,7 +1133,8 @@ static void hkSetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList* This, UI
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() || fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
auto heap = GetHeapByGpuHandle(BaseDescriptor.ptr);
@@ -1181,7 +1182,7 @@ static void hkOMSetRenderTargets(ID3D12GraphicsCommandList* This, UINT NumRender
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1238,7 +1239,8 @@ static void hkSetComputeRootDescriptorTable(ID3D12GraphicsCommandList* This, UIN
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() || fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
auto heap = GetHeapByGpuHandle(BaseDescriptor.ptr);
@@ -1281,7 +1283,7 @@ static void hkDrawInstanced(ID3D12GraphicsCommandList* This, UINT VertexCountPer
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1311,7 +1313,7 @@ static void hkDrawInstanced(ID3D12GraphicsCommandList* This, UINT VertexCountPer
if (CheckCapture())
{
LOG_DEBUG("Capture");
CaptureHudless(This, key, val.state);
CaptureHudless(This, &val, val.state);
break;
}
}
@@ -1334,7 +1336,7 @@ static void hkDrawIndexedInstanced(ID3D12GraphicsCommandList* This, UINT IndexCo
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1367,7 +1369,7 @@ static void hkDrawIndexedInstanced(ID3D12GraphicsCommandList* This, UINT IndexCo
if (CheckCapture())
{
LOG_DEBUG("Capture");
CaptureHudless(This, key, val.state);
CaptureHudless(This, &val, val.state);
break;
}
}
@@ -1390,7 +1392,7 @@ static void hkDispatch(ID3D12GraphicsCommandList* This, UINT ThreadGroupCountX,
return;
if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || ImGuiOverlayDx::fgContext == nullptr ||
ImGuiOverlayDx::fgTarget + 10 > Config::Instance()->CurrentFeature->FrameCount() ||
ImGuiOverlayDx::fgTarget > Config::Instance()->CurrentFeature->FrameCount() || !ImGuiOverlayDx::fgIsActive ||
fgHudlessFrame == Config::Instance()->CurrentFeature->FrameCount() && fgCopySource[fIndex] != nullptr)
return;
@@ -1423,7 +1425,7 @@ static void hkDispatch(ID3D12GraphicsCommandList* This, UINT ThreadGroupCountX,
if (CheckCapture())
{
LOG_DEBUG("Capture");
CaptureHudless(This, key, val.state);
CaptureHudless(This, &val, val.state);
break;
}
}
+1
View File
@@ -51,6 +51,7 @@ namespace ImGuiOverlayDx
inline UINT64 fgTarget = 10;
inline ID3D12Resource* fgUpscaledImage[FG_BUFFER_SIZE] = { nullptr, nullptr, nullptr, nullptr };
inline FT_Dx12* fgFormatTransfer = nullptr;
inline bool fgIsActive = false;
void UnHookDx();
void HookDx();
+14 -6
View File
@@ -116,6 +116,10 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount, UINT Width, UINT
{
LOG_FUNC();
HRESULT result;
DXGI_SWAP_CHAIN_DESC desc{};
GetDesc(&desc);
std::this_thread::sleep_for(std::chrono::milliseconds(150));
if (ClearTrig != nullptr)
@@ -124,13 +128,16 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount, UINT Width, UINT
if (Config::Instance()->CurrentFeature != nullptr)
Config::Instance()->FGChanged = true;
Config::Instance()->SCChanged = true;
if (BufferCount != 0 || desc.BufferDesc.Width != Width || desc.BufferDesc.Height != Height || desc.BufferDesc.Format != NewFormat)
{
Config::Instance()->SCChanged = true;
}
std::this_thread::sleep_for(std::chrono::milliseconds(150));
LOG_DEBUG("BufferCount: {0}, Width: {1}, Height: {2}, NewFormat: {3}, SwapChainFlags: {4:X}", BufferCount, Width, Height, (UINT)NewFormat, SwapChainFlags);
auto result = m_pReal->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags);
result = m_pReal->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags);
if (result == S_OK && Util::GetProcessWindow() == Handle)
{
Config::Instance()->ScreenWidth = Width;
@@ -172,7 +179,6 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers1(UINT BufferCount, UINT Width, UIN
Config::Instance()->ScreenHeight = Height;
}
LOG_FUNC_RESULT(result);
return result;
}
@@ -181,15 +187,17 @@ HRESULT WrappedIDXGISwapChain4::SetFullscreenState(BOOL Fullscreen, IDXGIOutput*
{
auto result = m_pReal->SetFullscreenState(Fullscreen, pTarget);
LOG_DEBUG("Fullscreen: {}", Fullscreen);
std::this_thread::sleep_for(std::chrono::milliseconds(150));
if (Config::Instance()->CurrentFeature != nullptr)
Config::Instance()->FGChanged = true;
Config::Instance()->SCChanged = true;
std::this_thread::sleep_for(std::chrono::milliseconds(150));
LOG_DEBUG("result: {0:X}", (UINT)result);
return result;
}
+1 -1
View File
@@ -21,7 +21,7 @@
#define VER_MAJOR_VERSION 0
#define VER_MINOR_VERSION 7
#define VER_HOTFIX_VERSION 0
#define VER_BUILD_NUMBER 24
#define VER_BUILD_NUMBER 25
#define VER_PRE_RELEASE
+5
View File
@@ -29,6 +29,11 @@ UseFGSwapChain=auto
; true or false - Default (auto) is false
Enabled=auto
; Creates FG CommandQueue with _PRIORITY_HIGH flag
; Might help or cause issues with pacing
; true or false - Default (auto) is false
HighPriority=auto
; Enables FSR3.1 frame generation debug view
; true or false - Default (auto) is false
DebugView=auto