diff --git a/OptiScaler/FfxApi_Dx12.cpp b/OptiScaler/FfxApi_Dx12.cpp index 85ed92ab..2750adaf 100644 --- a/OptiScaler/FfxApi_Dx12.cpp +++ b/OptiScaler/FfxApi_Dx12.cpp @@ -6,7 +6,7 @@ #include "FfxApi_Proxy.h" #include "NVNGX_Parameter.h" -static UINT64 _handleCounter = 73310000; +static UINT64 _handleCounter = 0x73310000; static ffxContext _currentContext = nullptr; static std::map _initParams; @@ -133,11 +133,11 @@ static std::optional GetQualityOverrideRatioFfx(const FfxApiUpscaleQualit ffxReturnCode_t ffxCreateContext_Dx12(ffxContext* context, ffxCreateContextDescHeader* desc, const ffxAllocationCallbacks* memCb) { - LOG_DEBUG(""); - if (desc == nullptr) return FFX_API_RETURN_ERROR_PARAMETER; + LOG_DEBUG("type: {:X}", desc->type); + bool upscaleContext = false; ffxApiHeader* header = desc; ffxCreateContextDescUpscale* createDesc = nullptr; @@ -160,10 +160,7 @@ ffxReturnCode_t ffxCreateContext_Dx12(ffxContext* context, ffxCreateContextDescH } while (header != nullptr); if (!upscaleContext || _d3d12Device == nullptr) - { - LOG_INFO("desc type: {:X}", desc->type); return FfxApiProxy::D3D12_CreateContext()(context, desc, memCb); - } NVSDK_NGX_FeatureCommonInfo fcInfo{}; wchar_t const** paths = new const wchar_t* [1]; @@ -175,11 +172,11 @@ ffxReturnCode_t ffxCreateContext_Dx12(ffxContext* context, ffxCreateContextDescH if (!_nvnxgInited) { - auto nvResult = NVSDK_NGX_D3D12_Init_with_ProjectID("OptiScaler", NVSDK_NGX_ENGINE_TYPE_CUSTOM, VER_PRODUCT_VERSION_STR, dllPath.c_str(), - _d3d12Device, &fcInfo, Config::Instance()->NVNGX_Version); + auto nvResult = NVSDK_NGX_D3D12_Init_with_ProjectID("OptiScaler", NVSDK_NGX_ENGINE_TYPE_CUSTOM, VER_PRODUCT_VERSION_STR, dllPath.c_str(), + _d3d12Device, &fcInfo, Config::Instance()->NVNGX_Version); - if (nvResult != NVSDK_NGX_Result_Success) - return FFX_API_RETURN_ERROR_RUNTIME_ERROR; + if (nvResult != NVSDK_NGX_Result_Success) + return FFX_API_RETURN_ERROR_RUNTIME_ERROR; _nvnxgInited = true; } @@ -200,12 +197,17 @@ ffxReturnCode_t ffxCreateContext_Dx12(ffxContext* context, ffxCreateContextDescH ccd.maxUpscaleSize = createDesc->maxUpscaleSize; _initParams[*context] = ccd; + LOG_INFO("context created: {:X}", (size_t)_currentContext); + return FFX_API_RETURN_OK; } ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationCallbacks* memCb) { - LOG_DEBUG(""); + if (context == nullptr) + return FFX_API_RETURN_ERROR_PARAMETER; + + LOG_DEBUG("context: {:X}", (size_t)*context); if (!_contexts.contains(*context) && *context != _currentContext) { @@ -227,11 +229,11 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC ffxReturnCode_t ffxConfigure_Dx12(ffxContext* context, const ffxConfigureDescHeader* desc) { - LOG_DEBUG(""); - if (desc == nullptr) return FFX_API_RETURN_ERROR_PARAMETER; + LOG_DEBUG("type: {:X}", desc->type); + if (desc->type == FFX_API_CONFIGURE_DESC_TYPE_UPSCALE_KEYVALUE) return FFX_API_RETURN_OK; @@ -240,11 +242,11 @@ ffxReturnCode_t ffxConfigure_Dx12(ffxContext* context, const ffxConfigureDescHea ffxReturnCode_t ffxQuery_Dx12(ffxContext* context, ffxQueryDescHeader* desc) { - LOG_DEBUG(""); - if (desc == nullptr) return FFX_API_RETURN_ERROR_PARAMETER; + LOG_DEBUG("type: {:X}", desc->type); + if (desc->type == FFX_API_QUERY_DESC_TYPE_UPSCALE_GETRENDERRESOLUTIONFROMQUALITYMODE) { auto ratioDesc = (ffxQueryDescUpscaleGetRenderResolutionFromQualityMode*)desc; @@ -283,11 +285,11 @@ ffxReturnCode_t ffxQuery_Dx12(ffxContext* context, ffxQueryDescHeader* desc) ffxReturnCode_t ffxDispatch_Dx12(ffxContext* context, ffxDispatchDescHeader* desc) { - LOG_DEBUG(""); - if (desc == nullptr) return FFX_API_RETURN_ERROR_PARAMETER; + LOG_DEBUG("type: {:X}", desc->type); + if (context == nullptr || (!_contexts.contains(*context) && *context != _currentContext)) { LOG_INFO("Not in _contexts, desc type: {:X}", desc->type); @@ -313,7 +315,7 @@ ffxReturnCode_t ffxDispatch_Dx12(ffxContext* context, ffxDispatchDescHeader* des } while (header != nullptr); - if (dispatchDesc == nullptr ) + if (dispatchDesc == nullptr) { if (!rmDesc) { diff --git a/OptiScaler/resource.h b/OptiScaler/resource.h index 0f882391..811ad7f0 100644 --- a/OptiScaler/resource.h +++ b/OptiScaler/resource.h @@ -21,7 +21,7 @@ #define VER_MAJOR_VERSION 0 #define VER_MINOR_VERSION 7 #define VER_HOTFIX_VERSION 0 -#define VER_BUILD_NUMBER 77 +#define VER_BUILD_NUMBER 78 #define VER_PRE_RELEASE