diff --git a/CyberXeSS/FSR3Feature.cpp b/CyberXeSS/FSR3Feature.cpp new file mode 100644 index 00000000..d7c0bdde --- /dev/null +++ b/CyberXeSS/FSR3Feature.cpp @@ -0,0 +1,233 @@ +#include "pch.h" +#include "FSR3Feature.h" +#include "Config.h" + +inline void logCallback(FfxMsgType type, const wchar_t* message) +{ + std::wstring string(message); + std::string str(string.begin(), string.end()); + + if (type == FFX_MESSAGE_TYPE_ERROR) + spdlog::error("FSR3Feature::LogCallback FSR Runtime: {0}", str); + else if (type == FFX_MESSAGE_TYPE_WARNING) + spdlog::warn("FSR3Feature::LogCallback FSR Runtime: {0}", str); + else + spdlog::debug("FSR3Feature::LogCallback FSR Runtime: {0}", str); +} + +void FSR3Feature::SetInit(bool value) +{ + _isInited = value; +} + +double FSR3Feature::GetDeltaTime() +{ + double currentTime = MillisecondsNow(); + double deltaTime = (currentTime - _lastFrameTime); + _lastFrameTime = currentTime; + return deltaTime; +} + +bool FSR3Feature::IsDepthInverted() const +{ + return _depthInverted; +} + +bool FSR3Feature::IsInited() +{ + return _isInited; +} + +bool FSR3Feature::InitFSR3(ID3D12Device* device, const NVSDK_NGX_Parameter* InParameters) +{ + if (IsInited()) + return true; + + if (device == nullptr) + { + spdlog::error("FSR3Feature::InitFSR3 D3D12Device is null!"); + return false; + } + + const size_t scratchBufferSize = ffxGetScratchMemorySizeDX12(FFX_FSR3UPSCALER_CONTEXT_COUNT); + void* scratchBuffer = calloc(scratchBufferSize, 1); + + auto errorCode = ffxGetInterfaceDX12(&_contextDesc.backendInterface, device, scratchBuffer, scratchBufferSize, FFX_FSR3UPSCALER_CONTEXT_COUNT); + + if (errorCode != FFX_OK) + { + spdlog::error("FSR3Feature::InitFSR3 ffxGetInterfaceDX12 error: {0:x}", errorCode); + free(scratchBuffer); + return false; + } + + _contextDesc.maxRenderSize.width = RenderWidth(); + _contextDesc.maxRenderSize.height = RenderHeight(); + _contextDesc.displaySize.width = DisplayWidth(); + _contextDesc.displaySize.height = DisplayHeight(); + + _contextDesc.flags = 0; + + int featureFlags; + InParameters->Get(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, &featureFlags); + + bool Hdr = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_IsHDR; + bool EnableSharpening = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_DoSharpening; + bool DepthInverted = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_DepthInverted; + bool JitterMotion = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_MVJittered; + bool LowRes = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes; + bool AutoExposure = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_AutoExposure; + + if (Config::Instance()->DepthInverted.value_or(DepthInverted)) + { + Config::Instance()->DepthInverted = true; + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_DEPTH_INVERTED; + _depthInverted = true; + spdlog::info("FSR3Feature::InitFSR3 contextDesc.initFlags (DepthInverted) {0:b}", _contextDesc.flags); + } + + if (Config::Instance()->AutoExposure.value_or(AutoExposure)) + { + Config::Instance()->AutoExposure = true; + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_AUTO_EXPOSURE; + spdlog::info("FSR3Feature::InitFSR3 contextDesc.initFlags (AutoExposure) {0:b}", _contextDesc.flags); + } + else + { + Config::Instance()->AutoExposure = false; + spdlog::info("FSR3Feature::InitFSR3 contextDesc.initFlags (!AutoExposure) {0:b}", _contextDesc.flags); + } + + if (Config::Instance()->HDR.value_or(Hdr)) + { + Config::Instance()->HDR = false; + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_HIGH_DYNAMIC_RANGE; + spdlog::info("FSR3Feature::InitFSR3 xessParams.initFlags (HDR) {0:b}", _contextDesc.flags); + } + else + { + Config::Instance()->HDR = true; + spdlog::info("FSR3Feature::InitFSR3 xessParams.initFlags (!HDR) {0:b}", _contextDesc.flags); + } + + if (Config::Instance()->JitterCancellation.value_or(JitterMotion)) + { + Config::Instance()->JitterCancellation = true; + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION; + spdlog::info("FSR3Feature::InitFSR3 xessParams.initFlags (JitterCancellation) {0:b}", _contextDesc.flags); + } + + if (Config::Instance()->DisplayResolution.value_or(!LowRes)) + { + Config::Instance()->DisplayResolution = true; + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS; + spdlog::info("FSR3Feature::InitFSR3 xessParams.initFlags (!LowResMV) {0:b}", _contextDesc.flags); + } + else + { + Config::Instance()->DisplayResolution = false; + spdlog::info("FSR3Feature::InitFSR3 xessParams.initFlags (LowResMV) {0:b}", _contextDesc.flags); + } + + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_DEPTH_INFINITE; + +#if _DEBUG + _contextDesc.flags |= FFX_FSR3UPSCALER_ENABLE_DEBUG_CHECKING; + _contextDesc.fpMessage = logCallback; +#endif + + spdlog::debug("FSR3Feature::InitFSR3 ffxFsr3UpscalerContextCreate!"); + + auto ret = ffxFsr3UpscalerContextCreate(&_context, &_contextDesc); + + if (ret != FFX_OK) + { + spdlog::error("FSR3Feature::InitFSR3 ffxFsr3UpscalerContextCreate error: {0:x}", ret); + return false; + } + + _isInited = true; + + return true; +} + +FSR3Feature::~FSR3Feature() +{ + spdlog::debug("FSR3Feature::~FSR3Feature"); + + if (!IsInited()) + return; + + auto errorCode = ffxFsr3UpscalerContextDestroy(&_context); + + if (errorCode != FFX_OK) + spdlog::error("FSR3Feature::~FSR3Feature ffxFsr3UpscalerContextDestroy error: {0:x}", errorCode); + + free(_contextDesc.backendInterface.scratchBuffer); + + SetInit(false); +} + +void FSR3Feature::SetRenderResolution(const NVSDK_NGX_Parameter* InParameters, FfxFsr3UpscalerDispatchDescription* params) const +{ + if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width, ¶ms->renderSize.width) != NVSDK_NGX_Result_Success || + InParameters->Get(NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, ¶ms->renderSize.height) != NVSDK_NGX_Result_Success) + { + unsigned int width, height, outWidth, outHeight; + + if (InParameters->Get(NVSDK_NGX_Parameter_Width, &width) == NVSDK_NGX_Result_Success && + InParameters->Get(NVSDK_NGX_Parameter_Height, &height) == NVSDK_NGX_Result_Success) + { + if (InParameters->Get(NVSDK_NGX_Parameter_OutWidth, &outWidth) == NVSDK_NGX_Result_Success && + InParameters->Get(NVSDK_NGX_Parameter_OutHeight, &outHeight) == NVSDK_NGX_Result_Success) + { + if (width < outWidth) + { + params->renderSize.width = width; + params->renderSize.height = height; + return; + } + + params->renderSize.width = outWidth; + params->renderSize.height = outHeight; + } + else + { + if (width < RenderWidth()) + { + params->renderSize.width = width; + params->renderSize.height = height; + return; + } + + params->renderSize.width = RenderWidth(); + params->renderSize.height = RenderHeight(); + return; + } + } + + params->renderSize.width = RenderWidth(); + params->renderSize.height = RenderHeight(); + } +} + +double FSR3Feature::MillisecondsNow() +{ + static LARGE_INTEGER s_frequency; + static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency); + double milliseconds = 0; + + if (s_use_qpc) + { + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + milliseconds = double(1000.0 * now.QuadPart) / s_frequency.QuadPart; + } + else + { + milliseconds = double(GetTickCount()); + } + + return milliseconds; +} + diff --git a/CyberXeSS/FSR3Feature.h b/CyberXeSS/FSR3Feature.h new file mode 100644 index 00000000..ea2d1206 --- /dev/null +++ b/CyberXeSS/FSR3Feature.h @@ -0,0 +1,37 @@ +#pragma once +#include "IFeature.h" +#include "FidelityFX/host/backends/dx12/ffx_dx12.h" +#include "FidelityFX/host/ffx_fsr3upscaler.h" + + +class FSR3Feature : public IFeature +{ +private: + bool _isInited = false; + double _lastFrameTime; + bool _depthInverted = false; + +protected: + + FfxFsr3UpscalerContext _context = {}; + FfxFsr3UpscalerContextDescription _contextDesc = {}; + + bool InitFSR3(ID3D12Device* device, const NVSDK_NGX_Parameter* InParameters); + void SetRenderResolution(const NVSDK_NGX_Parameter* InParameters, FfxFsr3UpscalerDispatchDescription* params) const; + double MillisecondsNow(); + + void SetInit(bool value) override; + double GetDeltaTime(); + bool IsDepthInverted() const; + +public: + + FSR3Feature(unsigned int handleId, const NVSDK_NGX_Parameter* InParameters) : IFeature(handleId, InParameters) + { + _lastFrameTime = MillisecondsNow(); + } + + bool IsInited() override; + + ~FSR3Feature(); +}; \ No newline at end of file diff --git a/CyberXeSS/FSR3Feature_Dx12.cpp b/CyberXeSS/FSR3Feature_Dx12.cpp new file mode 100644 index 00000000..46240f6b --- /dev/null +++ b/CyberXeSS/FSR3Feature_Dx12.cpp @@ -0,0 +1,272 @@ +#include "pch.h" +#include "FSR3Feature_Dx12.h" +#include "Config.h" + +bool FSR3FeatureDx12::Init(ID3D12Device* device, const NVSDK_NGX_Parameter* InParameters) +{ + if (IsInited()) + return true; + + Device = device; + + return InitFSR3(device, InParameters); +} + +bool FSR3FeatureDx12::Evaluate(ID3D12GraphicsCommandList* commandList, const NVSDK_NGX_Parameter* InParameters) +{ + if (!IsInited()) + return false; + + FfxFsr3UpscalerDispatchDescription params{}; + + InParameters->Get(NVSDK_NGX_Parameter_Jitter_Offset_X, ¶ms.jitterOffset.x); + InParameters->Get(NVSDK_NGX_Parameter_Jitter_Offset_Y, ¶ms.jitterOffset.y); + + unsigned int reset; + InParameters->Get(NVSDK_NGX_Parameter_Reset, &reset); + params.reset = reset == 1; + + FSR3Feature::SetRenderResolution(InParameters, ¶ms); + + spdlog::debug("FSR3FeatureDx12::Evaluate Input Resolution: {0}x{1}", params.renderSize.width, params.renderSize.height); + + params.commandList = ffxGetCommandListDX12(commandList); + + ID3D12Resource* paramColor; + if (InParameters->Get(NVSDK_NGX_Parameter_Color, ¶mColor) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_Color, (void**)¶mColor); + + if (paramColor) + { + spdlog::debug("FSR3FeatureDx12::Evaluate Color exist.."); + + if (Config::Instance()->ColorResourceBarrier.has_value()) + ResourceBarrier(commandList, paramColor, + (D3D12_RESOURCE_STATES)Config::Instance()->ColorResourceBarrier.value(), + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + + params.color = ffxGetResourceDX12(paramColor, GetFfxResourceDescriptionDX12(paramColor), (wchar_t*)L"FSR3Upscale_Color", FFX_RESOURCE_STATE_COMPUTE_READ); + } + else + { + spdlog::error("FSR3FeatureDx12::Evaluate Color not exist!!"); + return false; + } + + ID3D12Resource* paramVelocity; + if (InParameters->Get(NVSDK_NGX_Parameter_MotionVectors, ¶mVelocity) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_MotionVectors, (void**)¶mVelocity); + + if (paramVelocity) + { + spdlog::debug("FSR3FeatureDx12::Evaluate MotionVectors exist.."); + + if (Config::Instance()->MVResourceBarrier.has_value()) + ResourceBarrier(commandList, paramVelocity, + (D3D12_RESOURCE_STATES)Config::Instance()->MVResourceBarrier.value(), + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + + params.motionVectors = ffxGetResourceDX12(paramVelocity, GetFfxResourceDescriptionDX12(paramVelocity), (wchar_t*)L"FSR3Upscale_MotionVectors", FFX_RESOURCE_STATE_COMPUTE_READ); + } + else + { + spdlog::error("FSR3FeatureDx12::Evaluate MotionVectors not exist!!"); + return false; + } + + ID3D12Resource* paramOutput; + if (InParameters->Get(NVSDK_NGX_Parameter_Output, ¶mOutput) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_Output, (void**)¶mOutput); + + if (paramOutput) + { + spdlog::debug("FSR3FeatureDx12::Evaluate Output exist.."); + + if (Config::Instance()->OutputResourceBarrier.has_value()) + ResourceBarrier(commandList, paramOutput, + (D3D12_RESOURCE_STATES)Config::Instance()->OutputResourceBarrier.value(), + D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + params.output = ffxGetResourceDX12(paramOutput, GetFfxResourceDescriptionDX12(paramOutput), (wchar_t*)L"FSR3Upscale_Output", FFX_RESOURCE_STATE_UNORDERED_ACCESS); + } + else + { + spdlog::error("FSR3FeatureDx12::Evaluate Output not exist!!"); + return false; + } + + ID3D12Resource* paramDepth; + if (InParameters->Get(NVSDK_NGX_Parameter_Depth, ¶mDepth) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_Depth, (void**)¶mDepth); + + if (paramDepth) + { + spdlog::debug("FSR3FeatureDx12::Evaluate Depth exist.."); + + if (Config::Instance()->DepthResourceBarrier.has_value()) + ResourceBarrier(commandList, paramDepth, + (D3D12_RESOURCE_STATES)Config::Instance()->DepthResourceBarrier.value(), + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + + params.depth = ffxGetResourceDX12(paramDepth, GetFfxResourceDescriptionDX12(paramDepth), (wchar_t*)L"FSR3Upscale_Depth", FFX_RESOURCE_STATE_COMPUTE_READ); + } + else + { + if (!Config::Instance()->DisplayResolution.value_or(false)) + spdlog::error("FSR3FeatureDx12::Evaluate Depth not exist!!"); + else + spdlog::info("FSR3FeatureDx12::Evaluate Using high res motion vectors, depth is not needed!!"); + } + + ID3D12Resource* paramExp = nullptr; + if (!Config::Instance()->AutoExposure.value_or(false)) + { + if (InParameters->Get(NVSDK_NGX_Parameter_ExposureTexture, ¶mExp) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_ExposureTexture, (void**)¶mExp); + + if (paramExp) + spdlog::debug("FSR3FeatureDx12::Evaluate ExposureTexture exist.."); + else + spdlog::debug("FSR3FeatureDx12::Evaluate AutoExposure disabled but ExposureTexture is not exist, it may cause problems!!"); + + if (Config::Instance()->ExposureResourceBarrier.has_value()) + ResourceBarrier(commandList, paramExp, + (D3D12_RESOURCE_STATES)Config::Instance()->ExposureResourceBarrier.value(), + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + + params.exposure = ffxGetResourceDX12(paramExp, GetFfxResourceDescriptionDX12(paramExp), (wchar_t*)L"FSR3Upscale_Exposure", FFX_RESOURCE_STATE_COMPUTE_READ); + } + else + spdlog::debug("FSR3FeatureDx12::Evaluate AutoExposure enabled!"); + + ID3D12Resource* paramMask = nullptr; + if (!Config::Instance()->DisableReactiveMask.value_or(true)) + { + if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, ¶mMask) != NVSDK_NGX_Result_Success) + InParameters->Get(NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, (void**)¶mMask); + + if (paramMask) + spdlog::debug("FSR3FeatureDx12::Evaluate Bias mask exist.."); + else + spdlog::debug("FSR3FeatureDx12::Evaluate Bias mask not exist and its enabled in config, it may cause problems!!"); + + if (Config::Instance()->MaskResourceBarrier.has_value()) + ResourceBarrier(commandList, paramMask, + (D3D12_RESOURCE_STATES)Config::Instance()->MaskResourceBarrier.value(), + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + + params.reactive = ffxGetResourceDX12(paramMask, GetFfxResourceDescriptionDX12(paramMask), (wchar_t*)L"FSR3Upscale_Reactive", FFX_RESOURCE_STATE_COMPUTE_READ); + } + + float MVScaleX; + float MVScaleY; + + if (InParameters->Get(NVSDK_NGX_Parameter_MV_Scale_X, &MVScaleX) == NVSDK_NGX_Result_Success && + InParameters->Get(NVSDK_NGX_Parameter_MV_Scale_Y, &MVScaleY) == NVSDK_NGX_Result_Success) + { + params.motionVectorScale.x = MVScaleX; + params.motionVectorScale.y = MVScaleY; + } + else + spdlog::warn("FSR3FeatureDx12::Evaluate Can't get motion vector scales!"); + + + float shapness; + if (InParameters->Get(NVSDK_NGX_Parameter_Sharpness, &shapness) == NVSDK_NGX_Result_Success) + { + params.enableSharpening = shapness != 0 && shapness != 1; + + if (params.enableSharpening) + { + if (shapness < 0) + params.sharpness = (shapness + 1.0f) / 2.0f; + else + params.sharpness = shapness; + } + } + + if (IsDepthInverted()) + { + params.cameraFar = 0.0f; + params.cameraNear = FLT_MAX; + } + else + { + params.cameraNear = 0.0f; + params.cameraFar = FLT_MAX; + } + + params.cameraFovAngleVertical = 1.047198f; + + params.frameTimeDelta = (float)GetDeltaTime(); + params.preExposure = 1.0f; + + spdlog::debug("FSR3FeatureDx12::Evaluate Dispatch!!"); + auto result = ffxFsr3UpscalerContextDispatch(&_context, ¶ms); + + if (result != FFX_OK) + { + spdlog::error("FSR3FeatureDx12::Evaluate ffxFsr3UpscalerContextDispatch error: {0:x}", result); + return false; + } + + // restore resource states + if (paramColor && Config::Instance()->ColorResourceBarrier.value_or(false)) + ResourceBarrier(commandList, paramColor, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + (D3D12_RESOURCE_STATES)Config::Instance()->ColorResourceBarrier.value()); + + if (paramVelocity && Config::Instance()->MVResourceBarrier.has_value()) + ResourceBarrier(commandList, paramVelocity, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + (D3D12_RESOURCE_STATES)Config::Instance()->MVResourceBarrier.value()); + + if (paramOutput && Config::Instance()->OutputResourceBarrier.has_value()) + ResourceBarrier(commandList, paramOutput, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, + (D3D12_RESOURCE_STATES)Config::Instance()->OutputResourceBarrier.value()); + + if (paramDepth && Config::Instance()->DepthResourceBarrier.has_value()) + ResourceBarrier(commandList, paramDepth, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + (D3D12_RESOURCE_STATES)Config::Instance()->DepthResourceBarrier.value()); + + if (paramExp && Config::Instance()->ExposureResourceBarrier.has_value()) + ResourceBarrier(commandList, paramExp, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + (D3D12_RESOURCE_STATES)Config::Instance()->ExposureResourceBarrier.value()); + + if (paramMask && Config::Instance()->MaskResourceBarrier.has_value()) + ResourceBarrier(commandList, paramMask, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, + (D3D12_RESOURCE_STATES)Config::Instance()->MaskResourceBarrier.value()); + + return true; +} + +void FSR3FeatureDx12::ReInit(const NVSDK_NGX_Parameter* InParameters) +{ + SetInit(false); + + if (IsInited()) + { + auto errorCode = ffxFsr3UpscalerContextDestroy(&_context); + + if (errorCode != FFX_OK) + spdlog::error("FSR3Feature::~FSR3Feature ffxFsr3UpscalerContextDestroy error: {0:x}", errorCode); + + free(_contextDesc.backendInterface.scratchBuffer); + } + + SetInit(Init(Device, InParameters)); +} + +void FSR3FeatureDx12::SetInit(bool value) +{ + FSR3Feature::SetInit(value); +} + +bool FSR3FeatureDx12::IsInited() +{ + return FSR3Feature::IsInited(); +} diff --git a/CyberXeSS/FSR3Feature_Dx12.h b/CyberXeSS/FSR3Feature_Dx12.h new file mode 100644 index 00000000..ae715d08 --- /dev/null +++ b/CyberXeSS/FSR3Feature_Dx12.h @@ -0,0 +1,24 @@ +#include "IFeature_Dx12.h" +#include "FSR3Feature.h" +#include + +class FSR3FeatureDx12 : public FSR3Feature, public IFeature_Dx12 +{ +private: + +protected: + +public: + FSR3FeatureDx12(unsigned int handleId, const NVSDK_NGX_Parameter* InParameters) : FSR3Feature(handleId, InParameters), IFeature_Dx12(handleId, InParameters) + { + } + + // Inherited via IFeatureContextDx12 + bool Init(ID3D12Device* device, const NVSDK_NGX_Parameter* InParameters) override; + bool Evaluate(ID3D12GraphicsCommandList* commandList, const NVSDK_NGX_Parameter* InParameters) override; + void ReInit(const NVSDK_NGX_Parameter* InParameters) override; + + // Inherited via XeSSContext + void SetInit(bool value) override; + bool IsInited() override; +}; \ No newline at end of file diff --git a/CyberXeSS/NVNGX_DLSS_Dx12.cpp b/CyberXeSS/NVNGX_DLSS_Dx12.cpp index 62a3c22a..0c14aa13 100644 --- a/CyberXeSS/NVNGX_DLSS_Dx12.cpp +++ b/CyberXeSS/NVNGX_DLSS_Dx12.cpp @@ -4,6 +4,7 @@ #include "Config.h" #include "XeSSFeature_Dx12.h" +#include "FSR3Feature_Dx12.h" #include "NVNGX_Parameter.h" inline ID3D12Device* D3D12Device = nullptr; @@ -170,7 +171,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsComma // Create feature auto handleId = IFeature::GetNextHandleId(); - Dx12Contexts[handleId] = std::make_unique(handleId, InParameters); + Dx12Contexts[handleId] = std::make_unique(handleId, InParameters); auto deviceContext = Dx12Contexts[handleId].get(); *OutHandle = deviceContext->Handle(); @@ -262,27 +263,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom } } - //if (!deviceContext->IsInited()) - //{ - // ID3D12Device* device; - // spdlog::debug("NVSDK_NGX_D3D12_EvaluateFeature Get D3d12 device from InCmdList!"); - // auto deviceResult = InCmdList->GetDevice(IID_PPV_ARGS(&device)); - - // if (deviceResult != S_OK || device == nullptr) - // { - // spdlog::error("NVSDK_NGX_D3D12_EvaluateFeature Can't get Dx12Device from InCmdList!"); - // return NVSDK_NGX_Result_Fail; - // } - - // deviceContext->Init(device, InParameters); - - // if (!deviceContext->IsInited()) - // { - // spdlog::error("NVSDK_NGX_D3D12_EvaluateFeature deviceContext.XessInit is false, init failed!"); - // return NVSDK_NGX_Result_Fail; - // } - //} - //dumpParams.frame_count = 1; //dumpParams.frame_idx = cnt++; //dumpParams.path = "F:\\";