mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-11-22 13:47:11 +00:00
Merge branch 'master' of https://github.com/optiscaler/OptiScaler
This commit is contained in:
commit
72b8b42f41
5 files changed
+29
-7
No files matched your search
@@ -126,6 +126,9 @@ int IFGFeature::GetDispatchIndex(UINT64& willDispatchFrame)
|
||||
// Shared by GetDispatchIndex and GetIndexWillBeDispatched so they pick the same slot
|
||||
UINT64 IFGFeature::NextDispatchFrame()
|
||||
{
|
||||
if (_presentFrame > _lastDispatchedFrame && _presentFrame <= _frameCount)
|
||||
return _presentFrame;
|
||||
|
||||
// Nothing dispatched since (re)activation: +1 would be frame 1, XeFG needs it to match the tagged frame id
|
||||
if (_lastDispatchedFrame == 0)
|
||||
return _frameCount;
|
||||
@@ -199,6 +202,8 @@ void IFGFeature::SetFrameCount(UINT64 frameId)
|
||||
_frameCount = frameId;
|
||||
}
|
||||
|
||||
void IFGFeature::SetPresentFrame(UINT64 frame) { _presentFrame = frame; }
|
||||
|
||||
void IFGFeature::SetJitter(float x, float y, int index)
|
||||
{
|
||||
if (index < 0)
|
||||
|
||||
@@ -73,6 +73,7 @@ class IFGFeature
|
||||
UINT64 _frameCount = 0;
|
||||
bool _allowLowerFrameId = false;
|
||||
UINT64 _lastDispatchedFrame = 0;
|
||||
UINT64 _presentFrame = 0; // The frame the next present shows, from inputs that know it, 0 = unknown
|
||||
UINT64 _lastFGFrame = 0;
|
||||
bool _waitingNewFrameData = false;
|
||||
int _framesToInterpolate = -1;
|
||||
@@ -154,6 +155,7 @@ class IFGFeature
|
||||
bool IsInfiniteDepth();
|
||||
|
||||
void SetFrameCount(UINT64 frameId);
|
||||
void SetPresentFrame(UINT64 frame);
|
||||
void SetJitter(float x, float y, int index = -1);
|
||||
void SetMVScale(float x, float y, int index = -1);
|
||||
void SetCameraValues(float nearValue, float farValue, float vFov, float aspectRatio, float meterFactor = 0.0f,
|
||||
|
||||
@@ -502,10 +502,10 @@ NVSDK_NGX_Result Nvngx_FFX::Evaluate(const Nvngx_FFX_Api& api, ffxApiHeader* bac
|
||||
InParameters->Get("DLSSG.CameraFar", &cameraFar);
|
||||
}
|
||||
|
||||
if (cameraNear != 0.0f && cameraFar == 0.0f)
|
||||
if (cameraNear != 0.0f && (cameraFar == 0.0f || !std::isfinite(cameraFar)))
|
||||
{
|
||||
// A CameraFar value of zero indicates an infinite far plane. Due to a bug in FSR's
|
||||
// setupDeviceDepthToViewSpaceDepthParams function, CameraFar must always be greater than
|
||||
// A CameraFar value of zero or infinity (OptiScaler's own DLSSG output) indicates an infinite far plane. Due to
|
||||
// a bug in FSR's setupDeviceDepthToViewSpaceDepthParams function, CameraFar must always be greater than
|
||||
// CameraNear when in use.
|
||||
depthPlaneInfinite = true;
|
||||
cameraFar = cameraNear + 1.0f;
|
||||
|
||||
@@ -111,9 +111,10 @@ int XeFGInputs::FrameIndex(IFGFeature_Dx12* fg, uint32_t presentId)
|
||||
return i;
|
||||
}
|
||||
|
||||
fg->StartNewFrame();
|
||||
auto frame = fg->StartNewFrame();
|
||||
auto index = fg->GetIndex();
|
||||
_frameIds[index] = (uint64_t) presentId + 1;
|
||||
_frameNumbers[index] = frame;
|
||||
_gameDepthMV[index] = false;
|
||||
_reprojectionKnown[index] = false;
|
||||
_pendingDepth[index] = {};
|
||||
@@ -607,6 +608,18 @@ xefg_swapchain_result_t XeFGInputs::TagFrameResource(xefg_swapchain_handle_t, ID
|
||||
return XEFG_SWAPCHAIN_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
// The next present shows this present id's frame, the FG output dispatches it instead of guessing from its frame count
|
||||
xefg_swapchain_result_t XeFGInputs::SetPresentId(xefg_swapchain_handle_t, uint32_t presentId)
|
||||
{
|
||||
auto fg = State::Instance().currentFG;
|
||||
|
||||
if (fg == nullptr || _swapChain == nullptr)
|
||||
return XEFG_SWAPCHAIN_RESULT_SUCCESS;
|
||||
|
||||
fg->SetPresentFrame(_frameNumbers[FrameIndex(fg, presentId)]);
|
||||
return XEFG_SWAPCHAIN_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
xefg_swapchain_result_t XeFGInputs::GetLastPresentStatus(xefg_swapchain_handle_t,
|
||||
xefg_swapchain_present_status_t* status)
|
||||
{
|
||||
|
||||
@@ -34,8 +34,9 @@ class XeFGInputs
|
||||
inline static FG_Constants _constants {};
|
||||
inline static xefg_swapchain_2d_t _mvSize {};
|
||||
inline static bool _enabled = false;
|
||||
inline static uint64_t _frameIds[BUFFER_COUNT] {}; // Present id + 1 of each buffer index, 0 = none
|
||||
inline static float _frameTimeScale = 0.0f; // 1000 when the game passes seconds, 0 until decided
|
||||
inline static uint64_t _frameIds[BUFFER_COUNT] {}; // Present id + 1 of each buffer index, 0 = none
|
||||
inline static UINT64 _frameNumbers[BUFFER_COUNT] {}; // The FG output's frame count of each buffer index
|
||||
inline static float _frameTimeScale = 0.0f; // 1000 when the game passes seconds, 0 until decided
|
||||
inline static float _frameTimeMax = 0.0f;
|
||||
inline static int _frameTimeSamples = 0;
|
||||
inline static bool _gameDepthMV[BUFFER_COUNT] {}; // Frames without them from the game use the upscaler's
|
||||
@@ -98,6 +99,7 @@ class XeFGInputs
|
||||
static xefg_swapchain_result_t TagFrameResource(xefg_swapchain_handle_t, ID3D12CommandList* cmdList,
|
||||
uint32_t presentId,
|
||||
const xefg_swapchain_d3d12_resource_data_t* data);
|
||||
static xefg_swapchain_result_t SetPresentId(xefg_swapchain_handle_t, uint32_t presentId);
|
||||
static xefg_swapchain_result_t GetLastPresentStatus(xefg_swapchain_handle_t,
|
||||
xefg_swapchain_present_status_t* status);
|
||||
static xefg_swapchain_result_t Destroy(xefg_swapchain_handle_t);
|
||||
@@ -119,11 +121,11 @@ class XeFGInputs
|
||||
{ "xefgSwapChainSetEnabled", (PVOID) &SetEnabled },
|
||||
{ "xefgSwapChainTagFrameConstants", (PVOID) &TagFrameConstants },
|
||||
{ "xefgSwapChainD3D12TagFrameResource", (PVOID) &TagFrameResource },
|
||||
{ "xefgSwapChainSetPresentId", (PVOID) &SetPresentId },
|
||||
{ "xefgSwapChainGetLastPresentStatus", (PVOID) &GetLastPresentStatus },
|
||||
{ "xefgSwapChainDestroy", (PVOID) &Destroy },
|
||||
|
||||
// Nothing for the FG output to do
|
||||
{ "xefgSwapChainSetPresentId", (PVOID) &Ok },
|
||||
{ "xefgSwapChainSetLatencyReduction", (PVOID) &Ok },
|
||||
{ "xefgSwapChainSetLoggingCallback", (PVOID) &Ok },
|
||||
{ "xefgSwapChainSetSceneChangeThreshold", (PVOID) &Ok },
|
||||
|
||||
Reference in new issue
Block a user