XeFG hudifx has crash issues

FSR-FG Contol has blinking issues
This commit is contained in:
cdozdil
2025-08-09 23:35:49 +03:00
parent f0e4c3b639
commit e1bb92f412
12 changed files with 1087 additions and 884 deletions
+6
View File
@@ -94,6 +94,12 @@ void IFGFeature::SetFrameTimeDelta(float delta) { _ftDelta = delta; }
void IFGFeature::SetReset(UINT reset) { _reset = reset; }
void IFGFeature::SetInterpolationRect(UINT width, UINT height)
{
_interpolationWidth = width;
_interpolationHeight = height;
}
void IFGFeature::ResetCounters()
{
_frameCount = 0;
+4 -2
View File
@@ -60,6 +60,8 @@ class IFGFeature
float _cameraForward[3] {}; ///< The camera forward normalized vector in world space.
float _meterFactor = 0.0;
float _ftDelta = 0.0;
UINT _interpolationWidth = 0;
UINT _interpolationHeight = 0;
UINT _reset = 0;
UINT64 _frameCount = 0;
@@ -85,9 +87,8 @@ class IFGFeature
virtual feature_version Version() = 0;
virtual const char* Name() = 0;
virtual bool ManualPipeline() = 0;
virtual bool Dispatch() = 0;
virtual bool Present() = 0;
virtual void StopAndDestroyContext(bool destroy, bool shutDown) = 0;
int GetIndex();
@@ -113,6 +114,7 @@ class IFGFeature
void SetCameraData(float cameraPosition[3], float cameraUp[3], float cameraRight[3], float cameraForward[3]);
void SetFrameTimeDelta(float delta);
void SetReset(UINT reset);
void SetInterpolationRect(UINT width, UINT height);
void ResetCounters();
void UpdateTarget();
+4 -4
View File
@@ -14,11 +14,14 @@ typedef struct Dx12Resource
{
FG_ResourceType type;
ID3D12Resource* resource = nullptr;
UINT width = 0;
UINT height = 0;
ID3D12Resource* copy = nullptr;
ID3D12CommandList* cmdList = nullptr;
D3D12_RESOURCE_STATES state = D3D12_RESOURCE_STATE_COMMON;
FG_ResourceValidity validity = FG_ResourceValidity::ValidNow;
UINT64 fenceValue = 0;
bool waitingExecution = false;
ID3D12Resource* GetResource() { return (copy == nullptr) ? resource : copy; }
};
@@ -69,10 +72,7 @@ class IFGFeature_Dx12 : public virtual IFGFeature
void GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATES bufferState, ID3D12Resource** output);
virtual void SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource,
D3D12_RESOURCE_STATES state, FG_ResourceValidity validity) = 0;
virtual bool ExecuteCommandList(ID3D12CommandQueue* queue) = 0;
virtual ID3D12CommandList* GetCommandList() = 0;
UINT width, UINT height, D3D12_RESOURCE_STATES state, FG_ResourceValidity validity) = 0;
virtual void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) = 0;
+11 -11
View File
@@ -167,8 +167,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
const auto validity =
(tag.lifecycle == sl::eOnlyValidNow) ? FG_ResourceValidity::ValidNow : FG_ResourceValidity::UntilPresent;
fgOutput->SetResource(FG_ResourceType::HudlessColor, cmdBuffer, hudlessResource,
(D3D12_RESOURCE_STATES) tag.resource->state, validity);
fgOutput->SetResource(FG_ResourceType::HudlessColor, cmdBuffer, hudlessResource, tag.resource->width,
tag.resource->height, (D3D12_RESOURCE_STATES) tag.resource->state, validity);
auto static lastFormat = DXGI_FORMAT_UNKNOWN;
auto format = hudlessResource->GetDesc().Format;
@@ -194,8 +194,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
const auto validity =
(tag.lifecycle == sl::eOnlyValidNow) ? FG_ResourceValidity::ValidNow : FG_ResourceValidity::UntilPresent;
fgOutput->SetResource(FG_ResourceType::Depth, cmdBuffer, depthResource,
(D3D12_RESOURCE_STATES) tag.resource->state, validity);
fgOutput->SetResource(FG_ResourceType::Depth, cmdBuffer, depthResource, tag.resource->width,
tag.resource->height, (D3D12_RESOURCE_STATES) tag.resource->state, validity);
}
else if (tag.type == sl::kBufferTypeMotionVectors)
{
@@ -209,8 +209,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
const auto validity =
(tag.lifecycle == sl::eOnlyValidNow) ? FG_ResourceValidity::ValidNow : FG_ResourceValidity::UntilPresent;
fgOutput->SetResource(FG_ResourceType::Velocity, cmdBuffer, mvResource,
(D3D12_RESOURCE_STATES) tag.resource->state, validity);
fgOutput->SetResource(FG_ResourceType::Velocity, cmdBuffer, mvResource, tag.resource->width,
tag.resource->height, (D3D12_RESOURCE_STATES) tag.resource->state, validity);
}
else if (tag.type == sl::kBufferTypeUIColorAndAlpha)
{
@@ -226,8 +226,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
const auto validity = (tag.lifecycle == sl::eOnlyValidNow) ? FG_ResourceValidity::ValidNow
: FG_ResourceValidity::UntilPresent;
fgOutput->SetResource(FG_ResourceType::UIColor, cmdBuffer, uiResource,
(D3D12_RESOURCE_STATES) tag.resource->state, validity);
fgOutput->SetResource(FG_ResourceType::UIColor, cmdBuffer, uiResource, tag.resource->width,
tag.resource->height, (D3D12_RESOURCE_STATES) tag.resource->state, validity);
}
}
else if (tag.type == sl::kBufferTypeBidirectionalDistortionField)
@@ -242,8 +242,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
const auto validity =
(tag.lifecycle == sl::eOnlyValidNow) ? FG_ResourceValidity::ValidNow : FG_ResourceValidity::UntilPresent;
fgOutput->SetResource(FG_ResourceType::Distortion, cmdBuffer, distortionFieldResource,
(D3D12_RESOURCE_STATES) tag.resource->state, validity);
fgOutput->SetResource(FG_ResourceType::Distortion, cmdBuffer, distortionFieldResource, tag.resource->width,
tag.resource->height, (D3D12_RESOURCE_STATES) tag.resource->state, validity);
}
if (readyForDispatch())
@@ -363,7 +363,7 @@ bool Sl_Inputs_Dx12::dispatchFG(ID3D12GraphicsCommandList* cmdBuffer)
fgOutput->SetReset(slConstsRef.reset == sl::Boolean::eTrue);
return fgOutput->Dispatch();
return true;
}
void Sl_Inputs_Dx12::markLastSendAsRequired()
+40 -94
View File
@@ -158,7 +158,6 @@ bool FSRFG_Dx12::Dispatch()
// use swapchain buffer info
DXGI_SWAP_CHAIN_DESC scDesc1 {};
bool hasSwapChainDesc = State::Instance().currentSwapchain->GetDesc(&scDesc1) == S_OK;
auto feature = State::Instance().currentFeature;
int bufferWidth = hasSwapChainDesc ? scDesc1.BufferDesc.Width : 0;
int bufferHeight = hasSwapChainDesc ? scDesc1.BufferDesc.Height : 0;
@@ -168,26 +167,10 @@ bool FSRFG_Dx12::Dispatch()
int defaultWidth = 0;
int defaultHeight = 0;
if (feature)
{
int displayWidth = feature->DisplayWidth();
int displayHeight = feature->DisplayHeight();
defaultLeft = hasSwapChainDesc ? (bufferWidth - displayWidth) / 2 : 0;
defaultTop = hasSwapChainDesc ? (bufferHeight - displayHeight) / 2 : 0;
defaultWidth = displayWidth;
defaultHeight = displayHeight;
}
else
{
defaultLeft = 0;
defaultTop = 0;
defaultWidth = hasSwapChainDesc ? bufferWidth : 0;
defaultHeight = hasSwapChainDesc ? bufferHeight : 0;
if (!hasSwapChainDesc)
LOG_ERROR("No swapchain or feature, invalid FG Rect values");
}
defaultLeft = hasSwapChainDesc ? (bufferWidth - _interpolationWidth) / 2 : 0;
defaultTop = hasSwapChainDesc ? (bufferHeight - _interpolationHeight) / 2 : 0;
defaultWidth = _interpolationWidth;
defaultHeight = _interpolationHeight;
m_FrameGenerationConfig.generationRect.left = Config::Instance()->FGRectLeft.value_or(defaultLeft);
m_FrameGenerationConfig.generationRect.top = Config::Instance()->FGRectTop.value_or(defaultTop);
@@ -701,7 +684,7 @@ void FSRFG_Dx12::ReleaseObjects()
_fgCommandList = nullptr;
}
// FG_ResourceType
// For each FG_ResourceType
for (size_t i = 0; i < 5; i++)
{
if (this->_copyCommandAllocator.contains((FG_ResourceType) i))
@@ -718,15 +701,10 @@ void FSRFG_Dx12::ReleaseObjects()
_depthFlip.reset();
}
ID3D12CommandList* FSRFG_Dx12::GetCommandList() { return _fgCommandList; }
bool FSRFG_Dx12::ExecuteCommandList(ID3D12CommandQueue* queue)
bool FSRFG_Dx12::ExecuteCommandList()
{
LOG_DEBUG();
if (!ManualPipeline())
return true;
if (WaitingExecution())
{
LOG_DEBUG("Executing FG cmdList: {:X} with queue: {:X}", (size_t) _fgCommandList, (size_t) _gameCommandQueue);
@@ -739,20 +717,26 @@ bool FSRFG_Dx12::ExecuteCommandList(ID3D12CommandQueue* queue)
}
void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource,
D3D12_RESOURCE_STATES state, FG_ResourceValidity validity)
UINT width, UINT height, D3D12_RESOURCE_STATES state, FG_ResourceValidity validity)
{
if (resource == nullptr)
return;
if (cmdList == nullptr && validity == FG_ResourceValidity::ValidNow && _gameCommandQueue == nullptr)
{
LOG_ERROR("{}, validity == ValidNow but _gameCommandQueue is nullptr!", (UINT) type);
LOG_ERROR("{}, validity == ValidNow but _gameCommandQueue is nullptr!", magic_enum::enum_name(type));
return;
}
auto fIndex = GetIndex();
_frameResources[fIndex][type] = {};
auto fResource = &_frameResources[fIndex][type];
fResource->type = type;
fResource->state = state;
fResource->validity = validity;
fResource->resource = resource;
fResource->width = width;
fResource->height = height;
auto willFlip = State::Instance().activeFgInput == FGInput::Upscaler &&
Config::Instance()->FGResourceFlip.value_or_default() &&
@@ -764,7 +748,7 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
{
if (!_copyCommandAllocator.contains(type) || !_copyCommandList.contains(type))
{
LOG_ERROR("{}, _copyCommandAllocator or _copyCommandList is nullptr!", (UINT) type);
LOG_ERROR("{}, _copyCommandAllocator or _copyCommandList is nullptr!", magic_enum::enum_name(type));
return;
}
@@ -775,11 +759,6 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
usingLocalCmdList = true;
}
fResource->type = type;
fResource->state = state;
fResource->validity = validity;
fResource->resource = resource;
// Resource flipping
if (willFlip && _device != nullptr)
{
@@ -792,7 +771,7 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
if (!CreateBufferResource(_device, resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, &flipOutput, true,
false))
{
LOG_ERROR("{}, CreateBufferResource for flip is failed!", (UINT) type);
LOG_ERROR("{}, CreateBufferResource for flip is failed!", magic_enum::enum_name(type));
return;
}
@@ -826,7 +805,7 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
if (!CreateBufferResource(_device, resource, state, &flipOutput, true, true))
{
LOG_ERROR("{}, CreateBufferResource for flip is failed!", (UINT) type);
LOG_ERROR("{}, CreateBufferResource for flip is failed!", magic_enum::enum_name(type));
return;
}
@@ -865,7 +844,7 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
if (!CopyResource(cmdList, resource, &copyOutput, state))
{
LOG_ERROR("{}, CopyResource error!", (UINT) type);
LOG_ERROR("{}, CopyResource error!", magic_enum::enum_name(type));
return;
}
@@ -887,42 +866,15 @@ void FSRFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cm
if (usingLocalCmdList)
{
cmdList->Close();
_fgCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &cmdList);
_gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &cmdList);
}
LOG_TRACE("_frameResources[{}][{}]: {:X}", fIndex, (UINT) type, (size_t) fResource->GetResource());
LOG_TRACE("_frameResources[{}][{}]: {:X}", fIndex, magic_enum::enum_name(type), (size_t) fResource->GetResource());
}
void FSRFG_Dx12::SetResourceReady(FG_ResourceType type)
{
auto fIndex = GetIndex();
_resourceReady[fIndex][type] = true;
void FSRFG_Dx12::SetResourceReady(FG_ResourceType type) { _resourceReady[GetIndex()][type] = true; }
// auto fResource = &_frameResources[fIndex][type];
// if (fResource != nullptr && fResource->validity == FG_ResourceValidity::ValidNow)
//{
// UINT64 fenceValue = (_frameCount * 10) + (UINT64) type;
// fResource->fenceValue = fenceValue;
// LOG_DEBUG("Wait {}: {}, with queue: {:X}", (UINT)type, fResource->fenceValue,
// (size_t) _fgCommandQueue);
// _fgCommandQueue->Wait(_fgFence, fenceValue);
// }
}
void FSRFG_Dx12::SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue)
{
_gameCommandQueue = queue;
// auto fIndex = GetIndex();
// auto fResource = &_frameResources[fIndex][type];
// if (fResource != nullptr && fResource->fenceValue > 0)
//{
// LOG_DEBUG("Signal {}: {} with queue: {:X}", (UINT)type, fResource->fenceValue, (size_t)
// queue); queue->Signal(_fgFence, fResource->fenceValue);
// }
}
void FSRFG_Dx12::SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) { _gameCommandQueue = queue; }
void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice)
{
@@ -941,22 +893,6 @@ void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice)
ID3D12CommandQueue* cmdQueue = nullptr;
// FG
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
result = InDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&_fgCommandQueue));
if (result != S_OK || _fgCommandQueue == nullptr)
{
LOG_DEBUG("CreateCommandQueue _fgCommandQueue: {0:X}", result);
break;
}
_fgCommandQueue->SetName(L"_fgCommandQueue");
if (CheckForRealObject(__FUNCTION__, _fgCommandQueue, (IUnknown**) &cmdQueue))
_fgCommandQueue = cmdQueue;
result = InDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&_fgCommandAllocator));
if (result != S_OK)
{
@@ -964,14 +900,6 @@ void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice)
break;
}
result = InDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&_fgFence));
if (result != S_OK)
{
LOG_ERROR("CreateFence _fgFence: {0:X}", result);
break;
}
_fgCommandAllocator->SetName(L"_fgCommandAllocator");
if (CheckForRealObject(__FUNCTION__, _fgCommandAllocator, (IUnknown**) &allocator))
_fgCommandAllocator = allocator;
@@ -994,6 +922,7 @@ void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice)
break;
}
// For each FG_ResourceType
for (size_t i = 0; i < 5; i++)
{
auto val = (FG_ResourceType) i;
@@ -1037,3 +966,20 @@ void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice)
} while (false);
}
bool FSRFG_Dx12::Present()
{
auto result = false;
if (!IsPaused() && !IsDispatched())
{
Dispatch();
}
if (!IsPaused() && WaitingExecution())
{
result = ExecuteCommandList();
}
return result;
}
+9 -14
View File
@@ -21,12 +21,11 @@ class FSRFG_Dx12 : public virtual IFGFeature_Dx12
// One extra to copy things
ID3D12GraphicsCommandList* _fgCommandList = nullptr;
ID3D12CommandAllocator* _fgCommandAllocator = nullptr;
ID3D12CommandQueue* _fgCommandQueue = nullptr;
ID3D12Fence* _fgFence = nullptr;
// For copy operations
std::map<FG_ResourceType, ID3D12Resource*> _resourceCopy[BUFFER_COUNT] {};
std::map<FG_ResourceType, ID3D12CommandAllocator*> _copyCommandAllocator {};
std::map<FG_ResourceType, ID3D12GraphicsCommandList*> _copyCommandList {};
std::map<FG_ResourceType, ID3D12CommandAllocator*> _copyCommandAllocator {};
static FfxApiResourceState GetFfxApiState(D3D12_RESOURCE_STATES state)
{
@@ -57,11 +56,14 @@ class FSRFG_Dx12 : public virtual IFGFeature_Dx12
}
}
bool ExecuteCommandList();
bool Dispatch();
void ConfigureFramePaceTuning();
public:
// IFGFeature
const char* Name() override final;
feature_version Version() override final;
bool ManualPipeline() override final { return true; }
void* FrameGenerationContext() override final;
void* SwapchainContext() override final;
@@ -80,20 +82,13 @@ class FSRFG_Dx12 : public virtual IFGFeature_Dx12
void ReleaseObjects() override final;
void CreateObjects(ID3D12Device* InDevice) override final;
bool Dispatch() override final;
ID3D12CommandList* GetCommandList() override final;
bool ExecuteCommandList(ID3D12CommandQueue* queue) override final;
void SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource,
D3D12_RESOURCE_STATES state, FG_ResourceValidity validity) override final;
bool Present() override final;
void SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource, UINT width,
UINT height, D3D12_RESOURCE_STATES state, FG_ResourceValidity validity) override final;
void SetResourceReady(FG_ResourceType type) override final;
void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) override final;
// Methods
void ConfigureFramePaceTuning();
ffxReturnCode_t DispatchCallback(ffxDispatchDescFrameGeneration* params);
FSRFG_Dx12() : IFGFeature_Dx12(), IFGFeature()
File diff suppressed because it is too large Load Diff
+74 -59
View File
@@ -1,59 +1,74 @@
//#pragma once
//
//#include <framegen/IFGFeature_Dx12.h>
//
//#include <proxies/XeLL_Proxy.h>
//#include <proxies/XeFG_Proxy.h>
//
//#include <xell.h>
//#include <xell_d3d12.h>
//#include <xefg_swapchain.h>
//#include <xefg_swapchain_d3d12.h>
//#include <xefg_swapchain_debug.h>
//
//#include <nvapi/fakenvapi.h>
//
//class XeFG_Dx12 : public virtual IFGFeature_Dx12
//{
// private:
// xefg_swapchain_handle_t _swapChainContext = nullptr;
// xefg_swapchain_handle_t _fgContext = nullptr;
//
// uint32_t _width = 0;
// uint32_t _height = 0;
// int _featureFlags = 0;
//
// static void xefgLogCallback(const char* message, xefg_swapchain_logging_level_t level, void* userData);
//
// bool CreateSwapchainContext(ID3D12Device* device);
// bool DestroySwapchainContext();
//
// public:
// // IFGFeature
// const char* Name() override final;
// feature_version Version() override final;
// bool ManualPipeline() override final { return false; }
//
// // IFGFeature_Dx12
// bool CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQueue, DXGI_SWAP_CHAIN_DESC* desc,
// IDXGISwapChain** swapChain) override final;
// bool CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQueue, HWND hwnd, DXGI_SWAP_CHAIN_DESC1* desc,
// DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, IDXGISwapChain1** swapChain) override final;
// bool ReleaseSwapchain(HWND hwnd) override final;
//
// void CreateContext(ID3D12Device* device, FG_Constants& fgConstants) override final;
// void StopAndDestroyContext(bool destroy, bool shutDown, bool useMutex) override final;
//
// void EvaluateState(ID3D12Device* device, FG_Constants& fgConstants) override final;
//
// bool Dispatch() override final;
//
// void* FrameGenerationContext() override final;
// void* SwapchainContext() override final;
//
// XeFG_Dx12() : IFGFeature_Dx12(), IFGFeature()
// {
// if (XeFGProxy::Module() == nullptr)
// XeFGProxy::InitXeFG();
// }
//};
#pragma once
#include <framegen/IFGFeature_Dx12.h>
#include <proxies/XeLL_Proxy.h>
#include <proxies/XeFG_Proxy.h>
#include <xell.h>
#include <xell_d3d12.h>
#include <xefg_swapchain.h>
#include <xefg_swapchain_d3d12.h>
#include <xefg_swapchain_debug.h>
#include <nvapi/fakenvapi.h>
class XeFG_Dx12 : public virtual IFGFeature_Dx12
{
private:
xefg_swapchain_handle_t _swapChainContext = nullptr;
xefg_swapchain_handle_t _fgContext = nullptr;
uint32_t _width = 0;
uint32_t _height = 0;
int _featureFlags = 0;
// For copy operations
std::map<FG_ResourceType, ID3D12Resource*> _resourceCopy[BUFFER_COUNT] {};
std::map<FG_ResourceType, ID3D12GraphicsCommandList*> _copyCommandList {};
std::map<FG_ResourceType, ID3D12CommandAllocator*> _copyCommandAllocator {};
static void xefgLogCallback(const char* message, xefg_swapchain_logging_level_t level, void* userData);
bool CreateSwapchainContext(ID3D12Device* device);
bool DestroySwapchainContext();
xefg_swapchain_d3d12_resource_data_t GetResourceData(FG_ResourceType type);
bool Dispatch();
public:
// IFGFeature
const char* Name() override final;
feature_version Version() override final;
// IFGFeature_Dx12
bool CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQueue, DXGI_SWAP_CHAIN_DESC* desc,
IDXGISwapChain** swapChain) override final;
bool CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQueue, HWND hwnd, DXGI_SWAP_CHAIN_DESC1* desc,
DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, IDXGISwapChain1** swapChain) override final;
bool ReleaseSwapchain(HWND hwnd) override final;
void CreateContext(ID3D12Device* device, FG_Constants& fgConstants) override final;
void StopAndDestroyContext(bool destroy, bool shutDown) override final;
void EvaluateState(ID3D12Device* device, FG_Constants& fgConstants) override final;
void ReleaseObjects() override final;
void CreateObjects(ID3D12Device* InDevice) override final;
bool Present() override final;
void SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmdList, ID3D12Resource* resource, UINT width,
UINT height, D3D12_RESOURCE_STATES state, FG_ResourceValidity validity) override final;
void SetResourceReady(FG_ResourceType type) override final;
void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) override final;
void* FrameGenerationContext() override final;
void* SwapchainContext() override final;
XeFG_Dx12() : IFGFeature_Dx12(), IFGFeature()
{
if (XeFGProxy::Module() == nullptr)
XeFGProxy::InitXeFG();
}
};
+15 -27
View File
@@ -271,19 +271,7 @@ static HRESULT hkFGPresent(void* This, UINT SyncInterval, UINT Flags)
if (willPresent && State::Instance().currentCommandQueue != nullptr &&
State::Instance().activeFgInput == FGInput::Upscaler && fg != nullptr && fg->IsActive())
{
if (!fg->IsPaused() && !fg->IsDispatched())
{
LOG_WARN("Dispatch FG from present");
fg->Dispatch();
}
// ResTrack_Dx12::ExecuteWaitingCommandLists();
if (!fg->IsPaused() && fg->WaitingExecution())
{
LOG_WARN("Execute FG commandlist from present");
fg->ExecuteCommandList(State::Instance().currentCommandQueue);
}
fg->Present();
}
State::Instance().slFGInputs.markLastSendAsRequired();
@@ -860,11 +848,11 @@ static HRESULT hkCreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI
Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
}
// else if (State::Instance().activeFgOutput == FGOutput::XeFG && !XeFGProxy::InitXeFG())
//{
// Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
// State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
// }
else if (State::Instance().activeFgOutput == FGOutput::XeFG && !XeFGProxy::InitXeFG())
{
Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
}
ID3D12CommandQueue* real = nullptr;
if (!CheckForRealObject(__FUNCTION__, pDevice, (IUnknown**) &real))
@@ -885,8 +873,8 @@ static HRESULT hkCreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI
{
if (State::Instance().activeFgOutput == FGOutput::FSRFG)
State::Instance().currentFG = new FSRFG_Dx12();
// else if (State::Instance().activeFgOutput == FGOutput::XeFG)
// State::Instance().currentFG = new XeFG_Dx12();
else if (State::Instance().activeFgOutput == FGOutput::XeFG)
State::Instance().currentFG = new XeFG_Dx12();
}
HooksDx::ReleaseDx12SwapChain(pDesc->OutputWindow);
@@ -1162,11 +1150,11 @@ static HRESULT hkCreateSwapChainForHwnd(IDXGIFactory* This, IUnknown* pDevice, H
Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
}
// else if (State::Instance().activeFgOutput == FGOutput::XeFG && !XeFGProxy::InitXeFG())
//{
// Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
// State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
// }
else if (State::Instance().activeFgOutput == FGOutput::XeFG && !XeFGProxy::InitXeFG())
{
Config::Instance()->FGOutput.set_volatile_value(FGOutput::NoFG);
State::Instance().activeFgOutput = Config::Instance()->FGOutput.value_or_default();
}
ID3D12CommandQueue* real = nullptr;
if (!CheckForRealObject(__FUNCTION__, pDevice, (IUnknown**) &real))
@@ -1186,8 +1174,8 @@ static HRESULT hkCreateSwapChainForHwnd(IDXGIFactory* This, IUnknown* pDevice, H
{
if (State::Instance().activeFgOutput == FGOutput::FSRFG)
State::Instance().currentFG = new FSRFG_Dx12();
// else if (State::Instance().activeFgOutput == FGOutput::XeFG)
// State::Instance().currentFG = new XeFG_Dx12();
else if (State::Instance().activeFgOutput == FGOutput::XeFG)
State::Instance().currentFG = new XeFG_Dx12();
}
HooksDx::ReleaseDx12SwapChain(hWnd);
+11 -17
View File
@@ -452,6 +452,13 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
break;
}
DXGI_SWAP_CHAIN_DESC scDesc {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc) != S_OK)
{
LOG_WARN("Can't get swapchain desc!");
break;
}
// Prevent double capture
LOG_DEBUG("Waiting _checkMutex");
std::lock_guard<std::mutex> lock(_checkMutex);
@@ -554,14 +561,6 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
auto fIndex = GetIndex();
DXGI_SWAP_CHAIN_DESC scDesc {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc) != S_OK)
{
LOG_WARN("Can't get swapchain desc!");
_captureCounter[fIndex]--;
break;
}
LOG_TRACE("Capture resource: {:X}, index: {}", (size_t) resource->buffer, fIndex);
if (_commandQueue == nullptr && !CreateObjects())
@@ -600,13 +599,6 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
}
else
{
DXGI_SWAP_CHAIN_DESC scDesc {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc) != S_OK)
{
LOG_WARN("Can't get swapchain desc!");
break;
}
if (CreateBufferResourceWithSize(State::Instance().currentD3D12Device, resource,
D3D12_RESOURCE_STATE_COPY_DEST, &_captureBuffer[fIndex],
scDesc.BufferDesc.Width, scDesc.BufferDesc.Height))
@@ -705,6 +697,7 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
if (fg != nullptr)
fg->SetResource(FG_ResourceType::HudlessColor, cmdList, _formatTransfer[fIndex]->Buffer(),
scDesc.BufferDesc.Width, scDesc.BufferDesc.Height,
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, FG_ResourceValidity::JustTrackCmdlist);
}
else
@@ -723,8 +716,9 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
auto fg = reinterpret_cast<IFGFeature_Dx12*>(State::Instance().currentFG);
if (fg != nullptr)
fg->SetResource(FG_ResourceType::HudlessColor, cmdList, _captureBuffer[fIndex],
D3D12_RESOURCE_STATE_COPY_DEST, FG_ResourceValidity::JustTrackCmdlist);
fg->SetResource(FG_ResourceType::HudlessColor, cmdList, _captureBuffer[fIndex], scDesc.BufferDesc.Width,
scDesc.BufferDesc.Height, D3D12_RESOURCE_STATE_COPY_DEST,
FG_ResourceValidity::JustTrackCmdlist);
}
if (State::Instance().FGcaptureResources)
+22 -5
View File
@@ -1580,6 +1580,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
fg->SetFrameTimeDelta(State::Instance().lastFrameTime);
fg->SetMVScale(mvScaleX, mvScaleY);
fg->SetReset(reset);
fg->SetInterpolationRect(deviceContext->feature->DisplayWidth(), deviceContext->feature->DisplayHeight());
Hudfix_Dx12::UpscaleStart();
}
@@ -1617,10 +1618,24 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
InParameters->Get(NVSDK_NGX_Parameter_MotionVectors, (void**) &paramVelocity);
if (paramVelocity != nullptr)
fg->SetResource(FG_ResourceType::Velocity, commandList, paramVelocity,
(D3D12_RESOURCE_STATES) Config::Instance()->MVResourceBarrier.value_or(
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
FG_ResourceValidity::ValidNow);
{
if (deviceContext->feature->LowResMV())
{
fg->SetResource(FG_ResourceType::Velocity, commandList, paramVelocity,
deviceContext->feature->RenderWidth(), deviceContext->feature->RenderHeight(),
(D3D12_RESOURCE_STATES) Config::Instance()->MVResourceBarrier.value_or(
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
FG_ResourceValidity::ValidNow);
}
else
{
fg->SetResource(FG_ResourceType::Velocity, commandList, paramVelocity,
deviceContext->feature->DisplayWidth(), deviceContext->feature->DisplayHeight(),
(D3D12_RESOURCE_STATES) Config::Instance()->MVResourceBarrier.value_or(
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
FG_ResourceValidity::ValidNow);
}
}
ID3D12Resource* paramDepth = nullptr;
if (InParameters->Get(NVSDK_NGX_Parameter_Depth, &paramDepth) != NVSDK_NGX_Result_Success)
@@ -1646,6 +1661,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
{
DepthScale->SetBufferState(InCmdList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
fg->SetResource(FG_ResourceType::Depth, commandList, DepthScale->Buffer(),
deviceContext->feature->RenderWidth(), deviceContext->feature->RenderHeight(),
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,
FG_ResourceValidity::UntilPresent);
done = true;
@@ -1654,7 +1670,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
}
if (!done)
fg->SetResource(FG_ResourceType::Depth, commandList, paramDepth,
fg->SetResource(FG_ResourceType::Depth, commandList, paramDepth, deviceContext->feature->RenderWidth(),
deviceContext->feature->RenderHeight(),
(D3D12_RESOURCE_STATES) Config::Instance()->DepthResourceBarrier.value_or(
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
FG_ResourceValidity::ValidNow);
@@ -1792,7 +1792,8 @@ void ResTrack_Dx12::HookToQueue(ID3D12Device* InDevice)
void ResTrack_Dx12::HookDevice(ID3D12Device* device)
{
if (State::Instance().activeFgOutput != FGOutput::FSRFG || !Config::Instance()->OverlayMenu.value_or_default())
if ((State::Instance().activeFgOutput != FGOutput::FSRFG && State::Instance().activeFgOutput != FGOutput::XeFG) ||
!Config::Instance()->OverlayMenu.value_or_default())
return;
if (o_CreateDescriptorHeap != nullptr || device == nullptr)