mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-09-03 20:15:35 +00:00
Add ui alpha premult setting (not saved yet), some logs and checks
This commit is contained in:
@@ -350,6 +350,7 @@ class Config
|
||||
CustomOptional<FGInput> FGInput { FGInput::NoFG };
|
||||
CustomOptional<FGOutput> FGOutput { FGOutput::NoFG };
|
||||
CustomOptional<bool> DrawUIOverFG { false };
|
||||
CustomOptional<bool> UIPremultipliedAlpha { true };
|
||||
|
||||
// OptiFG
|
||||
CustomOptional<bool> FGEnabled { false };
|
||||
|
||||
@@ -12,9 +12,11 @@ bool IFGFeature_Dx12::GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATE
|
||||
|
||||
auto resource = GetResource(type);
|
||||
|
||||
// TODO: add some warning
|
||||
if (resource->copy == nullptr)
|
||||
if (resource->copy == nullptr && resource->validity == FG_ResourceValidity::ValidNow)
|
||||
{
|
||||
LOG_WARN("No resource copy of type {} to use", magic_enum::enum_name(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = _copyCommandAllocator->Reset();
|
||||
if (result != S_OK)
|
||||
@@ -24,7 +26,7 @@ bool IFGFeature_Dx12::GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATE
|
||||
if (result != S_OK)
|
||||
return false;
|
||||
|
||||
_copyCommandList->CopyResource(output, resource->copy);
|
||||
_copyCommandList->CopyResource(output, resource->GetResource());
|
||||
|
||||
_copyCommandList->Close();
|
||||
ID3D12CommandList* commandList = _copyCommandList;
|
||||
|
||||
@@ -54,6 +54,8 @@ bool Sl_Inputs_Dx12::setConstants(const sl::Constants& values, uint32_t frameId)
|
||||
memcpy(&data, &values, sizeof(values) - sizeof(sl::Constants::minRelativeLinearDepthObjectSeparation));
|
||||
data.value().structVersion = sl::kStructVersion2;
|
||||
data.value().next = pNext;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,9 @@ bool FSRFG_Dx12::Dispatch()
|
||||
LOG_TRACE("Using UI: {:X}", (size_t) uiColor->GetResource());
|
||||
|
||||
uiDesc.uiResource = ffxApiGetResourceDX12(uiColor->GetResource(), GetFfxApiState(uiColor->state));
|
||||
// uiDesc.flags = FFX_FRAMEGENERATION_UI_COMPOSITION_FLAG_USE_PREMUL_ALPHA;
|
||||
|
||||
if (Config::Instance()->UIPremultipliedAlpha.value_or_default())
|
||||
uiDesc.flags = FFX_FRAMEGENERATION_UI_COMPOSITION_FLAG_USE_PREMUL_ALPHA;
|
||||
}
|
||||
else if (hudless != nullptr && IsResourceReady(FG_ResourceType::HudlessColor))
|
||||
{
|
||||
|
||||
@@ -279,6 +279,9 @@ bool XeFG_Dx12::CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQu
|
||||
if (Config::Instance()->FGXeFGHighResMV.value_or_default())
|
||||
params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_HIGH_RES_MV;
|
||||
|
||||
if (!Config::Instance()->UIPremultipliedAlpha.value_or_default())
|
||||
params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_UITEXTURE_NOT_PREMUL_ALPHA;
|
||||
|
||||
LOG_DEBUG("Inverted Depth: {}", Config::Instance()->FGXeFGDepthInverted.value_or_default());
|
||||
LOG_DEBUG("Jittered Velocity: {}", Config::Instance()->FGXeFGJitteredMV.value_or_default());
|
||||
LOG_DEBUG("High Res MV: {}", Config::Instance()->FGXeFGHighResMV.value_or_default());
|
||||
@@ -353,6 +356,9 @@ bool XeFG_Dx12::CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQ
|
||||
if (Config::Instance()->FGXeFGHighResMV.value_or_default())
|
||||
params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_HIGH_RES_MV;
|
||||
|
||||
if (!Config::Instance()->UIPremultipliedAlpha.value_or_default())
|
||||
params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_UITEXTURE_NOT_PREMUL_ALPHA;
|
||||
|
||||
LOG_DEBUG("Inverted Depth: {}", Config::Instance()->FGXeFGDepthInverted.value_or_default());
|
||||
LOG_DEBUG("Jittered Velocity: {}", Config::Instance()->FGXeFGJitteredMV.value_or_default());
|
||||
LOG_DEBUG("High Res MV: {}", Config::Instance()->FGXeFGHighResMV.value_or_default());
|
||||
@@ -437,7 +443,7 @@ bool XeFG_Dx12::Dispatch()
|
||||
|
||||
xefg_swapchain_frame_constant_data_t constData = {};
|
||||
|
||||
if (_cameraPosition[0] != 0.0 || _cameraPosition[1] != 0.0 || _cameraPosition[2] != 0.0)
|
||||
if (_cameraPosition[0] != 0.0f || _cameraPosition[1] != 0.0f || _cameraPosition[2] != 0.0f)
|
||||
{
|
||||
XMVECTOR right = XMLoadFloat3(reinterpret_cast<const XMFLOAT3*>(_cameraRight));
|
||||
XMVECTOR up = XMLoadFloat3(reinterpret_cast<const XMFLOAT3*>(_cameraUp));
|
||||
@@ -466,6 +472,10 @@ bool XeFG_Dx12::Dispatch()
|
||||
auto projectionMatrix = XMMatrixPerspectiveFovLH(_cameraVFov, _cameraAspectRatio, _cameraNear, _cameraFar);
|
||||
memcpy(constData.projectionMatrix, projectionMatrix.r, sizeof(projectionMatrix));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARN("Can't calculate projectionMatrix");
|
||||
}
|
||||
|
||||
constData.jitterOffsetX = _jitterX;
|
||||
constData.jitterOffsetY = _jitterY;
|
||||
@@ -633,6 +643,8 @@ void XeFG_Dx12::SetResource(FG_ResourceType type, ID3D12GraphicsCommandList* cmd
|
||||
// We usually don't copy any resources for XeFG, the ones with this tag are the exception
|
||||
if (cmdList != nullptr && fResource->validity == FG_ResourceValidity::ValidButMakeCopy)
|
||||
{
|
||||
LOG_DEBUG("Making a resource copy of: {}", magic_enum::enum_name(type));
|
||||
|
||||
ID3D12Resource* copyOutput = nullptr;
|
||||
|
||||
if (_resourceCopy[fIndex].contains(type))
|
||||
|
||||
@@ -3323,6 +3323,12 @@ bool MenuCommon::RenderMenu()
|
||||
if (bool drawUIOverFG = Config::Instance()->DrawUIOverFG.value_or_default();
|
||||
ImGui::Checkbox("Draw UI over FG", &drawUIOverFG))
|
||||
Config::Instance()->DrawUIOverFG = drawUIOverFG;
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (bool uiPremultipliedAlpha = Config::Instance()->UIPremultipliedAlpha.value_or_default();
|
||||
ImGui::Checkbox("UI Premult. alpha", &uiPremultipliedAlpha))
|
||||
Config::Instance()->UIPremultipliedAlpha = uiPremultipliedAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user