mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-26 16:17:01 +00:00
Do not update heap info for same resource
This commit is contained in:
@@ -329,11 +329,12 @@ void Hudfix_Dx12::HudlessFound(ID3D12GraphicsCommandList* cmdList)
|
||||
|
||||
std::lock_guard<std::mutex> lock(_counterMutex);
|
||||
|
||||
if (_captureCounter[GetIndex()] > 1000)
|
||||
auto index = GetIndex();
|
||||
if (_captureCounter[index] > 1000)
|
||||
return;
|
||||
|
||||
// Set it above 1000 to prvent capture
|
||||
_captureCounter[GetIndex()] = 9999;
|
||||
_captureCounter[index] = 9999;
|
||||
|
||||
// auto fg = State::Instance().currentFG;
|
||||
// if (fg != nullptr)
|
||||
@@ -583,13 +584,13 @@ bool Hudfix_Dx12::CheckForHudless(std::string callerName, ID3D12GraphicsCommandL
|
||||
|
||||
// Using state D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE as skip flag
|
||||
if (state != D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE)
|
||||
ResourceBarrier(cmdList, resource->buffer, state, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
ResourceBarrier(cmdList, resource->buffer, resource->state, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
|
||||
cmdList->CopyResource(_captureBuffer[fIndex], resource->buffer);
|
||||
|
||||
// Using state D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE as skip flag
|
||||
if (state != D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE)
|
||||
ResourceBarrier(cmdList, resource->buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, state);
|
||||
ResourceBarrier(cmdList, resource->buffer, D3D12_RESOURCE_STATE_COPY_SOURCE, resource->state);
|
||||
|
||||
LOG_DEBUG("Copy created");
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ bool ResTrack_Dx12::CheckResource(ID3D12Resource* resource)
|
||||
resDesc.Height <= scDesc.BufferDesc.Height + 32 &&
|
||||
resDesc.Width >= scDesc.BufferDesc.Width - 32 && resDesc.Width <= scDesc.BufferDesc.Width + 32;
|
||||
|
||||
LOG_TRACK("Resource: {}x{} ({}), Swapchain: {}x{} ({}), Relaxed Result: {}", resDesc.Width, resDesc.Height,
|
||||
(UINT) resDesc.Format, scDesc.BufferDesc.Width, scDesc.BufferDesc.Height,
|
||||
(UINT) scDesc.BufferDesc.Format, result);
|
||||
// LOG_TRACK("Resource: {}x{} ({}), Swapchain: {}x{} ({}), Relaxed Result: {}", resDesc.Width, resDesc.Height,
|
||||
// (UINT) resDesc.Format, scDesc.BufferDesc.Width, scDesc.BufferDesc.Height,
|
||||
// (UINT) scDesc.BufferDesc.Format, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1150,8 +1150,9 @@ void ResTrack_Dx12::hkSetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList*
|
||||
fgPossibleHudless[fIndex].insert_or_assign(This, newMap);
|
||||
}
|
||||
|
||||
LOG_TRACK("CmdList: {:X}, AddRef Resource: {:X}, Desc: {:X}", (size_t) This,
|
||||
(size_t) capturedBuffer->buffer, BaseDescriptor.ptr);
|
||||
LOG_TRACK("CmdList: {:X}, AddRef Resource: {:X}, Desc: {:X}, Format: {}", (size_t) This,
|
||||
(size_t) capturedBuffer->buffer, BaseDescriptor.ptr, (UINT) capturedBuffer->format);
|
||||
|
||||
fgPossibleHudless[fIndex][This].insert_or_assign(capturedBuffer->buffer, *capturedBuffer);
|
||||
}
|
||||
} while (false);
|
||||
@@ -1182,6 +1183,7 @@ void ResTrack_Dx12::hkOMSetRenderTargets(ID3D12GraphicsCommandList* This, UINT N
|
||||
{
|
||||
LOG_DEBUG_ONLY("Menu cmdlist: {} || fgCommandList: {}", This == MenuOverlayDx::MenuCommandList(),
|
||||
IsFGCommandList(This));
|
||||
|
||||
o_OMSetRenderTargets(This, NumRenderTargetDescriptors, pRenderTargetDescriptors,
|
||||
RTsSingleHandleToDescriptorRange, pDepthStencilDescriptor);
|
||||
return;
|
||||
@@ -1229,7 +1231,8 @@ void ResTrack_Dx12::hkOMSetRenderTargets(ID3D12GraphicsCommandList* This, UINT N
|
||||
{
|
||||
if (Hudfix_Dx12::CheckForHudless(__FUNCTION__, This, capturedBuffer, capturedBuffer->state))
|
||||
{
|
||||
LOG_TRACK("Hudless Resource: {:X}, Desc: {:X}", (size_t) capturedBuffer->buffer, handle.ptr);
|
||||
LOG_TRACK("CmdList: {:X}, Hudless Resource: {:X}, Format: {} Desc: {:X}", (size_t) This,
|
||||
(size_t) capturedBuffer->buffer, (UINT) capturedBuffer->format, handle.ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,12 @@ typedef struct HeapInfo
|
||||
#ifdef DEBUG_TRACKING
|
||||
TestResource(&setInfo);
|
||||
#endif
|
||||
|
||||
DetachFromOldResource(index);
|
||||
info[index] = setInfo;
|
||||
AttachToNewResource(index);
|
||||
if (info[index].buffer != setInfo.buffer)
|
||||
{
|
||||
DetachFromOldResource(index);
|
||||
info[index] = setInfo;
|
||||
AttachToNewResource(index);
|
||||
}
|
||||
}
|
||||
|
||||
void SetByGpuHandle(SIZE_T gpuHandle, ResourceInfo setInfo) const
|
||||
@@ -152,9 +154,12 @@ typedef struct HeapInfo
|
||||
TestResource(&setInfo);
|
||||
#endif
|
||||
|
||||
DetachFromOldResource(index);
|
||||
info[index] = setInfo;
|
||||
AttachToNewResource(index);
|
||||
if (info[index].buffer != setInfo.buffer)
|
||||
{
|
||||
DetachFromOldResource(index);
|
||||
info[index] = setInfo;
|
||||
AttachToNewResource(index);
|
||||
}
|
||||
}
|
||||
|
||||
void ClearByCpuHandle(SIZE_T cpuHandle) const
|
||||
@@ -168,6 +173,7 @@ typedef struct HeapInfo
|
||||
{
|
||||
LOG_TRACK("Resource: {:X}, Res: {}x{}, Format: {}", (size_t) info[index].buffer, info[index].width,
|
||||
info[index].height, (UINT) info[index].format);
|
||||
|
||||
DetachFromOldResource(index);
|
||||
}
|
||||
|
||||
@@ -186,6 +192,7 @@ typedef struct HeapInfo
|
||||
{
|
||||
LOG_TRACK("Resource: {:X}, Res: {}x{}, Format: {}", (size_t) info[index].buffer, info[index].width,
|
||||
info[index].height, (UINT) info[index].format);
|
||||
|
||||
DetachFromOldResource(index);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user