Return FG commandlist when queried

This commit is contained in:
cdozdil
2025-09-05 13:44:39 +03:00
parent 9c62155f5b
commit 598d19116a
5 changed files with 71 additions and 74 deletions
+10 -10
View File
@@ -20,20 +20,19 @@ bool IFGFeature_Dx12::GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATE
auto fIndex = GetIndex();
auto result = _copyCommandAllocator[fIndex]->Reset();
if (result != S_OK)
return false;
if (!_uiCommandListResetted[fIndex])
{
auto result = _copyCommandAllocator[fIndex]->Reset();
if (result != S_OK)
return false;
result = _copyCommandList[fIndex]->Reset(_copyCommandAllocator[fIndex], nullptr);
if (result != S_OK)
return false;
result = _copyCommandList[fIndex]->Reset(_copyCommandAllocator[fIndex], nullptr);
if (result != S_OK)
return false;
}
_copyCommandList[fIndex]->CopyResource(output, resource->GetResource());
_copyCommandList[fIndex]->Close();
ID3D12CommandList* commandList = _copyCommandList[fIndex];
_gameCommandQueue->ExecuteCommandLists(1, &commandList);
return true;
}
@@ -62,6 +61,7 @@ void IFGFeature_Dx12::NewFrame()
LOG_DEBUG("_frameCount: {}, fIndex: {}", _frameCount, fIndex);
_frameResources[fIndex].clear();
_uiCommandListResetted[fIndex] = false;
}
void IFGFeature_Dx12::FlipResource(Dx12Resource* resource)
+1
View File
@@ -48,6 +48,7 @@ class IFGFeature_Dx12 : public virtual IFGFeature
ID3D12GraphicsCommandList* _uiCommandList[BUFFER_COUNT] {};
ID3D12CommandAllocator* _uiCommandAllocator[BUFFER_COUNT] {};
bool _uiCommandListResetted[BUFFER_COUNT] {};
std::unordered_map<FG_ResourceType, Dx12Resource> _frameResources[BUFFER_COUNT] {};
std::unordered_map<FG_ResourceType, ID3D12Resource*> _resourceCopy[BUFFER_COUNT] {};
+29 -13
View File
@@ -822,12 +822,25 @@ bool FSRFG_Dx12::ExecuteCommandList(int index)
{
LOG_DEBUG();
std::vector<ID3D12CommandList*> lists;
if (_uiCommandListResetted[index])
{
LOG_DEBUG("Executing UI cmdList: {:X}", (size_t) _uiCommandList[index]);
lists.push_back(_uiCommandList[index]);
_uiCommandListResetted[index] = false;
}
if (WaitingExecution(index))
{
LOG_DEBUG("Executing FG cmdList: {:X} with queue: {:X}", (size_t) _fgCommandList[index],
(size_t) _gameCommandQueue);
_gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_fgCommandList[index]);
LOG_DEBUG("Executing FG cmdList: {:X}", (size_t) _fgCommandList[index]);
lists.push_back(_fgCommandList[index]);
SetExecuted();
}
if (lists.size() > 0)
{
_gameCommandQueue->ExecuteCommandLists(lists.size(), lists.data());
return true;
}
@@ -930,18 +943,21 @@ ID3D12GraphicsCommandList* FSRFG_Dx12::GetUICommandList(int index)
if (index < 0)
index = GetIndex();
auto result = _uiCommandAllocator[index]->Reset();
if (result == S_OK)
if (!_uiCommandListResetted[index])
{
result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr);
auto result = _uiCommandAllocator[index]->Reset();
if (result != S_OK)
LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result);
}
else
{
LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result);
if (result == S_OK)
{
result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr);
if (result != S_OK)
LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result);
}
else
{
LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result);
}
}
return _uiCommandList[index];
+24 -2
View File
@@ -775,6 +775,14 @@ bool XeFG_Dx12::Present()
}
}
auto fIndex = GetIndex();
if (_uiCommandListResetted[fIndex])
{
LOG_DEBUG("Executing UI cmdList: {:X}", (size_t) _uiCommandList[fIndex]);
_gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[fIndex]);
_uiCommandListResetted[fIndex] = false;
}
return Dispatch();
}
@@ -893,8 +901,22 @@ ID3D12GraphicsCommandList* XeFG_Dx12::GetUICommandList(int index)
if (index < 0)
index = GetIndex();
_uiCommandAllocator[index]->Reset();
_uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr);
if (!_uiCommandListResetted[index])
{
auto result = _uiCommandAllocator[index]->Reset();
if (result == S_OK)
{
result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr);
if (result != S_OK)
LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result);
}
else
{
LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result);
}
}
return _uiCommandList[index];
}
+7 -49
View File
@@ -483,48 +483,6 @@ ffxReturnCode_t ffxConfigure_Dx12FG(ffxContext* context, ffxConfigureDescHeader*
_presentCallback = cDesc->presentCallback;
_presentCallbackUserContext = cDesc->presentCallbackUserContext;
_presentCallbackFrameId = cDesc->frameID;
// Probably because of queue can't capture at correct state
// if (fg->GetResource(FG_ResourceType::HudlessColor) == nullptr)
//{
// LOG_DEBUG("Trying to copy current swapchain buffer as hudless");
// IDXGISwapChain3* sc = (IDXGISwapChain3*) State::Instance().currentFGSwapchain;
// auto scIndex = sc->GetCurrentBackBufferIndex();
// ID3D12Resource* currentBuffer = nullptr;
// auto hr = sc->GetBuffer(scIndex, IID_PPV_ARGS(&currentBuffer));
// if (hr != S_OK)
// {
// LOG_ERROR("sc->GetBuffer error: {:X}", (UINT) hr);
// }
// auto cmdList = fg->GetUICommandList();
// auto hDesc = currentBuffer->GetDesc();
// Dx12Resource hudless {};
// hudless.cmdList = cmdList;
// hudless.height = hDesc.Height;
// hudless.resource = currentBuffer;
// hudless.state = D3D12_RESOURCE_STATE_PRESENT;
// hudless.type = FG_ResourceType::HudlessColor;
// hudless.validity = FG_ResourceValidity::ValidNow;
// hudless.width = hDesc.Width;
// fg->SetResource(&hudless);
// hr = cmdList->Close();
// if (hr == S_OK)
// {
// ID3D12CommandList* cmdLists[1] = { cmdList };
// fg->GetCommandQueue()->ExecuteCommandLists(1, cmdLists);
// }
// else
// {
// LOG_ERROR("cmdList->Close() error: {:X}", (UINT) hr);
// }
// currentBuffer->Release();
//}
}
if (cDesc->allowAsyncWorkloads || cDesc->onlyPresentGenerated)
@@ -735,14 +693,14 @@ ffxReturnCode_t ffxQuery_Dx12FG(ffxContext* context, ffxQueryDescHeader* desc)
}
else if (desc->type == FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_INTERPOLATIONCOMMANDLIST_DX12)
{
// auto cDesc = (ffxQueryDescFrameGenerationSwapChainInterpolationCommandListDX12*) desc;
// auto fg = State::Instance().currentFG;
auto cDesc = (ffxQueryDescFrameGenerationSwapChainInterpolationCommandListDX12*) desc;
auto fg = State::Instance().currentFG;
// if (fg != nullptr)
//{
// *cDesc->pOutCommandList = fg->GetUICommandList();
// LOG_DEBUG("Returning cmdList: {:X}", (size_t) *cDesc->pOutCommandList);
// }
if (fg != nullptr)
{
*cDesc->pOutCommandList = fg->GetUICommandList();
LOG_DEBUG("Returning cmdList: {:X}", (size_t) *cDesc->pOutCommandList);
}
return FFX_API_RETURN_OK;
}