mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-26 08:06:33 +00:00
More fixes to FFX inputs
This commit is contained in:
@@ -344,7 +344,7 @@ ffxReturnCode_t ffxCreateContext_Dx12FG(ffxContext* context, ffxCreateContextDes
|
||||
return FFX_API_RETURN_ERROR_PARAMETER;
|
||||
}
|
||||
|
||||
return rcContinue;
|
||||
return PASSTHRU_RETURN_CODE; // rcContinue;
|
||||
}
|
||||
|
||||
ffxReturnCode_t ffxDestroyContext_Dx12FG(ffxContext* context, const ffxAllocationCallbacks* memCb)
|
||||
@@ -368,7 +368,7 @@ ffxReturnCode_t ffxDestroyContext_Dx12FG(ffxContext* context, const ffxAllocatio
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
|
||||
return rcContinue;
|
||||
return PASSTHRU_RETURN_CODE; // rcContinue;
|
||||
}
|
||||
|
||||
ffxReturnCode_t ffxConfigure_Dx12FG(ffxContext* context, ffxConfigureDescHeader* desc)
|
||||
@@ -749,7 +749,7 @@ ffxReturnCode_t ffxConfigure_Dx12FG(ffxContext* context, ffxConfigureDescHeader*
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
|
||||
return rcContinue;
|
||||
return PASSTHRU_RETURN_CODE; // rcContinue;
|
||||
}
|
||||
|
||||
ffxReturnCode_t ffxQuery_Dx12FG(ffxContext* context, ffxQueryDescHeader* desc)
|
||||
@@ -827,7 +827,7 @@ ffxReturnCode_t ffxQuery_Dx12FG(ffxContext* context, ffxQueryDescHeader* desc)
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
|
||||
return rcContinue;
|
||||
return PASSTHRU_RETURN_CODE; // rcContinue;
|
||||
}
|
||||
|
||||
ffxReturnCode_t ffxDispatch_Dx12FG(ffxContext* context, ffxDispatchDescHeader* desc)
|
||||
@@ -1031,7 +1031,7 @@ void ffxPresentCallback()
|
||||
|
||||
auto fg = State::Instance().currentFG;
|
||||
|
||||
if (fg == nullptr && fg->FrameGenerationContext() != nullptr)
|
||||
if (fg == nullptr || fg->FrameGenerationContext() == nullptr)
|
||||
return;
|
||||
|
||||
// if (_lastCallbackFrameId == 0 || _lastCallbackFrameId > _callbackFrameId ||
|
||||
|
||||
@@ -416,17 +416,19 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC
|
||||
return result;
|
||||
}
|
||||
|
||||
bool upscalerContext = false;
|
||||
bool upscalerContext =
|
||||
_contexts.contains(*context) || _initParams.contains(*context) || _nvParams.contains(*context);
|
||||
|
||||
if (_contexts.contains(*context))
|
||||
{
|
||||
NVSDK_NGX_D3D12_ReleaseFeature(_contexts[*context]);
|
||||
upscalerContext = true;
|
||||
}
|
||||
|
||||
_contexts.erase(*context);
|
||||
_nvParams.erase(*context);
|
||||
_initParams.erase(*context);
|
||||
|
||||
if (upscalerContext && !Config::Instance()->EnableHotSwapping.value_or_default())
|
||||
return FFX_API_RETURN_OK;
|
||||
|
||||
if (State::Instance().currentFG != nullptr)
|
||||
LOG_DEBUG("context: {:X}, SwapchainContext: {:X}, FGContext: {:X}", (size_t) *context,
|
||||
(size_t) State::Instance().currentFG->SwapchainContext(),
|
||||
@@ -441,7 +443,7 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
|
||||
if (State::Instance().activeFgInput == FGInput::FSRFG)
|
||||
if (State::Instance().activeFgInput == FGInput::FSRFG && !upscalerContext)
|
||||
{
|
||||
auto result = ffxDestroyContext_Dx12FG(context, memCb);
|
||||
|
||||
@@ -449,14 +451,9 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC
|
||||
return result;
|
||||
}
|
||||
|
||||
if (Config::Instance()->EnableHotSwapping.value_or_default())
|
||||
{
|
||||
auto cdResult = FfxApiProxy::D3D12_DestroyContext(context, memCb);
|
||||
LOG_INFO("result: {:X}", (UINT) cdResult);
|
||||
return cdResult;
|
||||
}
|
||||
|
||||
return FFX_API_RETURN_OK;
|
||||
auto cdResult = FfxApiProxy::D3D12_DestroyContext(context, memCb);
|
||||
LOG_INFO("result: {:X}", (UINT) cdResult);
|
||||
return cdResult;
|
||||
}
|
||||
|
||||
ffxReturnCode_t ffxConfigure_Dx12(ffxContext* context, ffxConfigureDescHeader* desc)
|
||||
@@ -508,10 +505,12 @@ ffxReturnCode_t ffxQuery_Dx12(ffxContext* context, ffxQueryDescHeader* desc)
|
||||
LOG_DEBUG("type: {}", FfxGetGetDescTypeName(desc->type));
|
||||
|
||||
auto type = FfxApiProxy::GetIndirectType(desc);
|
||||
if (State::Instance().activeFgInput == FGInput::FSRFG &&
|
||||
(type == FFXStructType::SwapchainDX12 || type == FFXStructType::FG))
|
||||
if (type == FFXStructType::SwapchainDX12 || type == FFXStructType::FG)
|
||||
{
|
||||
auto result = ffxQuery_Dx12FG(context, desc);
|
||||
ffxReturnCode_t result = PASSTHRU_RETURN_CODE;
|
||||
|
||||
if (State::Instance().activeFgInput == FGInput::FSRFG)
|
||||
result = ffxQuery_Dx12FG(context, desc);
|
||||
|
||||
if (result == PASSTHRU_RETURN_CODE)
|
||||
return FfxApiProxy::D3D12_Query(context, desc);
|
||||
@@ -554,12 +553,15 @@ ffxReturnCode_t ffxQuery_Dx12(ffxContext* context, ffxQueryDescHeader* desc)
|
||||
auto jitterPhaseDesc = (ffxQueryDescUpscaleGetJitterPhaseCount*) desc;
|
||||
|
||||
if (jitterPhaseDesc && State::Instance().currentFeature)
|
||||
{
|
||||
jitterPhaseDesc->displayWidth = State::Instance().currentFeature->TargetWidth();
|
||||
jitterPhaseDesc->renderWidth = State::Instance().currentFeature->RenderWidth();
|
||||
}
|
||||
|
||||
if (!Config::Instance()->EnableHotSwapping.value_or_default())
|
||||
{
|
||||
float ratio = (float) jitterPhaseDesc->displayWidth / (float) jitterPhaseDesc->renderWidth;
|
||||
*jitterPhaseDesc->pOutPhaseCount = static_cast<uint32_t>(ceil(ratio * ratio * 8.0f)); // ceil(8*n^2)
|
||||
*jitterPhaseDesc->pOutPhaseCount = static_cast<int32_t>(ceil(ratio * ratio * 8.0f)); // ceil(8*n^2)
|
||||
LOG_DEBUG("Render resolution: {}, Display resolution: {}, Ratio: {}, Jitter phase count: {}",
|
||||
jitterPhaseDesc->renderWidth, jitterPhaseDesc->displayWidth, ratio,
|
||||
*jitterPhaseDesc->pOutPhaseCount);
|
||||
@@ -567,6 +569,10 @@ ffxReturnCode_t ffxQuery_Dx12(ffxContext* context, ffxQueryDescHeader* desc)
|
||||
return FFX_API_RETURN_OK;
|
||||
}
|
||||
}
|
||||
else if (desc->type == FFX_API_QUERY_DESC_TYPE_UPSCALE_GETJITTEROFFSET)
|
||||
{
|
||||
return FfxApiProxy::D3D12_Query(context, desc);
|
||||
}
|
||||
|
||||
if (context != nullptr && _contexts.contains(*context) && !Config::Instance()->EnableHotSwapping.value_or_default())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user