Add resource base position

This commit is contained in:
FakeMichau
2025-08-15 14:22:42 +02:00
parent 1a8738ffd6
commit 0d6444684e
8 changed files with 67 additions and 45 deletions
+6
View File
@@ -99,6 +99,12 @@ void IFGFeature::SetInterpolationRect(UINT width, UINT height)
_interpolationHeight = height;
}
void IFGFeature::GetInterpolationRect(UINT& width, UINT& height)
{
width = _interpolationWidth;
height = _interpolationHeight;
}
void IFGFeature::ResetCounters()
{
_frameCount = 0;
+1
View File
@@ -115,6 +115,7 @@ class IFGFeature
void SetFrameTimeDelta(float delta);
void SetReset(UINT reset);
void SetInterpolationRect(UINT width, UINT height);
void GetInterpolationRect(UINT& width, UINT& height);
void ResetCounters();
void UpdateTarget();
+2
View File
@@ -14,6 +14,8 @@ typedef struct Dx12Resource
{
FG_ResourceType type;
ID3D12Resource* resource = nullptr;
UINT top = 0;
UINT left = 0;
UINT width = 0;
UINT height = 0;
ID3D12GraphicsCommandList* cmdList = nullptr;
@@ -204,6 +204,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
setResource.type = FG_ResourceType::HudlessColor;
setResource.cmdList = cmdBuffer;
setResource.resource = hudlessResource;
setResource.top = tag.extent.top;
setResource.left = tag.extent.left;
setResource.width = width;
setResource.height = height;
setResource.state = (D3D12_RESOURCE_STATES) tag.resource->state;
@@ -253,6 +255,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
setResource.type = FG_ResourceType::Depth;
setResource.cmdList = cmdBuffer;
setResource.resource = depthResource;
setResource.top = tag.extent.top;
setResource.left = tag.extent.left;
setResource.width = width;
setResource.height = height;
setResource.state = (D3D12_RESOURCE_STATES) tag.resource->state;
@@ -288,6 +292,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
setResource.type = FG_ResourceType::Velocity;
setResource.cmdList = cmdBuffer;
setResource.resource = mvResource;
setResource.top = tag.extent.top;
setResource.left = tag.extent.left;
setResource.width = width;
setResource.height = height;
setResource.state = (D3D12_RESOURCE_STATES) tag.resource->state;
@@ -322,6 +328,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
setResource.type = FG_ResourceType::UIColor;
setResource.cmdList = cmdBuffer;
setResource.resource = uiResource;
setResource.top = tag.extent.top;
setResource.left = tag.extent.left;
setResource.width = width;
setResource.height = height;
setResource.state = (D3D12_RESOURCE_STATES) tag.resource->state;
@@ -355,6 +363,8 @@ bool Sl_Inputs_Dx12::reportResource(const sl::ResourceTag& tag, ID3D12GraphicsCo
setResource.type = FG_ResourceType::Distortion;
setResource.cmdList = cmdBuffer;
setResource.resource = distortionFieldResource;
setResource.top = tag.extent.top;
setResource.left = tag.extent.left;
setResource.width = width;
setResource.height = height;
setResource.state = (D3D12_RESOURCE_STATES) tag.resource->state;
+2
View File
@@ -272,6 +272,8 @@ bool FSRFG_Dx12::Dispatch()
if (State::Instance().currentFeature && State::Instance().activeFgInput == FGInput::Upscaler)
dfgPrepare.renderSize = { State::Instance().currentFeature->RenderWidth(),
State::Instance().currentFeature->RenderHeight() };
else if (depth != nullptr)
dfgPrepare.renderSize = { depth->width, depth->height };
else
dfgPrepare.renderSize = { dfgPrepare.depth.description.width, dfgPrepare.depth.description.height };
+12 -41
View File
@@ -154,6 +154,7 @@ xefg_swapchain_d3d12_resource_data_t XeFG_Dx12::GetResourceData(FG_ResourceType
? XEFG_SWAPCHAIN_RV_ONLY_NOW
: XEFG_SWAPCHAIN_RV_UNTIL_NEXT_PRESENT;
resourceParam.resourceBase = { fResource->left, fResource->top };
resourceParam.resourceSize = { fResource->width, fResource->height };
resourceParam.pResource = fResource->GetResource();
resourceParam.incomingState = fResource->state;
@@ -180,36 +181,6 @@ xefg_swapchain_d3d12_resource_data_t XeFG_Dx12::GetResourceData(FG_ResourceType
return xefg_swapchain_d3d12_resource_data_t {};
}
if (type == FG_ResourceType::UIColor || type == FG_ResourceType::HudlessColor)
{
uint32_t left = 0;
uint32_t top = 0;
// use swapchain buffer info
DXGI_SWAP_CHAIN_DESC scDesc1 {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc1) == S_OK)
{
LOG_DEBUG("SwapChain Res: {}x{}, Upscaler Display Res: {}x{}", scDesc1.BufferDesc.Width,
scDesc1.BufferDesc.Height, _interpolationWidth, _interpolationHeight);
auto calculatedLeft = ((int) scDesc1.BufferDesc.Width - (int) _interpolationWidth) / 2;
if (calculatedLeft > 0)
left = Config::Instance()->FGRectLeft.value_or(calculatedLeft);
auto calculatedTop = ((int) scDesc1.BufferDesc.Height - (int) _interpolationHeight) / 2;
if (calculatedTop > 0)
top = Config::Instance()->FGRectTop.value_or(calculatedTop);
}
else
{
left = Config::Instance()->FGRectLeft.value_or(0);
top = Config::Instance()->FGRectTop.value_or(0);
}
resourceParam.resourceBase = { left, top };
resourceParam.resourceSize = { _interpolationWidth, _interpolationHeight };
}
return resourceParam;
}
@@ -438,8 +409,8 @@ bool XeFG_Dx12::Dispatch()
Config::Instance()->FGXeFGDebugView.value_or_default(), nullptr);
XeFGProxy::EnableDebugFeature()(_swapChainContext, XEFG_SWAPCHAIN_DEBUG_FEATURE_SHOW_ONLY_INTERPOLATION,
State::Instance().FGonlyGenerated, nullptr);
XeFGProxy::EnableDebugFeature()(_swapChainContext, XEFG_SWAPCHAIN_DEBUG_FEATURE_PRESENT_FAILED_INTERPOLATION,
State::Instance().FGonlyGenerated, nullptr);
// XeFGProxy::EnableDebugFeature()(_swapChainContext, XEFG_SWAPCHAIN_DEBUG_FEATURE_PRESENT_FAILED_INTERPOLATION,
// State::Instance().FGonlyGenerated, nullptr);
xefg_swapchain_frame_constant_data_t constData = {};
@@ -465,6 +436,11 @@ bool XeFG_Dx12::Dispatch()
if (Config::Instance()->FGXeFGDepthInverted.value_or_default())
std::swap(_cameraNear, _cameraFar);
if (_infiniteDepth && _cameraFar > _cameraNear)
_cameraFar = INFINITE;
else if (_infiniteDepth && _cameraNear > _cameraFar)
_cameraNear = INFINITE;
// Cyberpunk seems to be sending LH so do the same
// it also sends some extra data in usually empty spots but no idea what that is
if (_cameraNear > 0.f && _cameraFar > 0.f)
@@ -509,7 +485,7 @@ bool XeFG_Dx12::Dispatch()
DXGI_SWAP_CHAIN_DESC scDesc1 {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc1) == S_OK)
{
LOG_DEBUG("SwapChain Res: {}x{}, Upscaler Display Res: {}x{}", scDesc1.BufferDesc.Width,
LOG_DEBUG("SwapChain Res: {}x{}, Interpolation Res: {}x{}", scDesc1.BufferDesc.Width,
scDesc1.BufferDesc.Height, _interpolationWidth, _interpolationHeight);
auto calculatedLeft = ((int) scDesc1.BufferDesc.Width - (int) _interpolationWidth) / 2;
@@ -556,14 +532,7 @@ void XeFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants)
if (!Config::Instance()->OverlayMenu.value_or_default())
return;
static bool lastInfiniteDepth = false;
bool currentInfiniteDepth = static_cast<bool>(fgConstants.flags & FG_Flags::InfiniteDepth);
if (lastInfiniteDepth != currentInfiniteDepth)
{
lastInfiniteDepth = currentInfiniteDepth;
LOG_DEBUG("Infinite Depth changed: {}", currentInfiniteDepth);
State::Instance().FGchanged = true;
}
_infiniteDepth = static_cast<bool>(fgConstants.flags & FG_Flags::InfiniteDepth);
if (!State::Instance().FGchanged && Config::Instance()->FGEnabled.value_or_default() && !IsPaused() &&
XeFGProxy::InitXeFG() && _fgContext == nullptr && HooksDx::CurrentSwapchainFormat() != DXGI_FORMAT_UNKNOWN)
@@ -667,6 +636,8 @@ void XeFG_Dx12::SetResource(Dx12Resource* inputResource)
fResource->state = inputResource->state;
fResource->validity = inputResource->validity;
fResource->resource = inputResource->resource;
fResource->top = inputResource->top;
fResource->left = inputResource->left;
fResource->width = inputResource->width;
fResource->height = inputResource->height;
fResource->cmdList = inputResource->cmdList;
+1 -1
View File
@@ -21,7 +21,7 @@ class XeFG_Dx12 : public virtual IFGFeature_Dx12
uint32_t _width = 0;
uint32_t _height = 0;
int _featureFlags = 0;
bool _infiniteDepth = false;
static void xefgLogCallback(const char* message, xefg_swapchain_logging_level_t level, void* userData);
+33 -3
View File
@@ -658,6 +658,35 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
}
}
auto fg = reinterpret_cast<IFGFeature_Dx12*>(State::Instance().currentFG);
UINT interpolationRectWidth, interpolationRectHeight = 0;
if (fg != nullptr)
fg->GetInterpolationRect(interpolationRectWidth, interpolationRectHeight);
uint32_t left = 0;
uint32_t top = 0;
// use swapchain buffer info
DXGI_SWAP_CHAIN_DESC scDesc1 {};
if (State::Instance().currentSwapchain->GetDesc(&scDesc1) == S_OK)
{
LOG_DEBUG("SwapChain Res: {}x{}, Upscaler Display Res: {}x{}", scDesc1.BufferDesc.Width,
scDesc1.BufferDesc.Height, interpolationRectWidth, interpolationRectHeight);
auto calculatedLeft = ((int) scDesc1.BufferDesc.Width - (int) interpolationRectWidth) / 2;
if (calculatedLeft > 0)
left = Config::Instance()->FGRectLeft.value_or(calculatedLeft);
auto calculatedTop = ((int) scDesc1.BufferDesc.Height - (int) interpolationRectHeight) / 2;
if (calculatedTop > 0)
top = Config::Instance()->FGRectTop.value_or(calculatedTop);
}
else
{
left = Config::Instance()->FGRectLeft.value_or(0);
top = Config::Instance()->FGRectTop.value_or(0);
}
// needs conversion?
if (resource->format != scDesc.BufferDesc.Format)
{
@@ -693,14 +722,14 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
LOG_TRACE("Using _formatTransfer->Buffer()");
auto fg = reinterpret_cast<IFGFeature_Dx12*>(State::Instance().currentFG);
if (fg != nullptr)
{
Dx12Resource setResource {};
setResource.type = FG_ResourceType::HudlessColor;
setResource.cmdList = cmdList;
setResource.resource = _formatTransfer[fIndex]->Buffer();
setResource.left = left;
setResource.top = top;
setResource.width = scDesc.BufferDesc.Width;
setResource.height = scDesc.BufferDesc.Height;
setResource.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
@@ -722,7 +751,6 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
// Will reset after FG dispatch
_skipHudlessChecks = true;
LOG_DEBUG("Using _captureBuffer");
auto fg = reinterpret_cast<IFGFeature_Dx12*>(State::Instance().currentFG);
if (fg != nullptr)
{
@@ -730,6 +758,8 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
setResource.type = FG_ResourceType::HudlessColor;
setResource.cmdList = cmdList;
setResource.resource = _captureBuffer[fIndex];
setResource.left = left;
setResource.top = top;
setResource.width = scDesc.BufferDesc.Width;
setResource.height = scDesc.BufferDesc.Height;
setResource.state = D3D12_RESOURCE_STATE_COPY_DEST;