Skip to content

Commit fc2e476

Browse files
authored
D3dx12residency fixes for errors with debug layer enabled. (#930)
These changes reset the evict count after the call to evict in ProcessPagingWork, it ports #785 into the other forks of the residency library file, and also removes the D3D12 WARNING: ID3D12CommandQueue1::Wait: Fence values can never be less than zero, so waiting for a fence value of zero will always be satisfied [ EXECUTION WARNING #1424: FENCE_ZERO_WAIT] messages.
1 parent 8b4e9c9 commit fc2e476

3 files changed

Lines changed: 37 additions & 13 deletions

File tree

Libraries/D3DX12Residency/d3dx12Residency.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,16 @@ namespace D3DX12Residency
406406

407407
HRESULT GPUWait(ID3D12CommandQueue* pQueue)
408408
{
409-
HRESULT hr = pQueue->Wait(pFence, FenceValue);
410-
RESIDENCY_CHECK_RESULT(hr);
411-
return hr;
409+
if (FenceValue > 0)
410+
{
411+
HRESULT hr = pQueue->Wait(pFence, FenceValue);
412+
RESIDENCY_CHECK_RESULT(hr);
413+
return hr;
414+
}
415+
else
416+
{
417+
return S_OK;
418+
}
412419
}
413420

414421
HRESULT GPUSignal(ID3D12CommandQueue* pQueue)
@@ -1332,6 +1339,7 @@ namespace D3DX12Residency
13321339
LRU.TrimToSyncPointInclusive(TotalUsage + INT64(SizeToMakeResident), TotalBudget, pEvictionList, NumObjectsToEvict, GenerationToWaitFor);
13331340

13341341
RESIDENCY_CHECK_RESULT(Device->Evict(NumObjectsToEvict, pEvictionList));
1342+
NumObjectsToEvict = 0;
13351343
}
13361344
else
13371345
{

Samples/Desktop/D3D12Residency/src/d3dx12Residency.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,16 @@ namespace D3DX12Residency
406406

407407
HRESULT GPUWait(ID3D12CommandQueue* pQueue)
408408
{
409-
HRESULT hr = pQueue->Wait(pFence, FenceValue);
410-
RESIDENCY_CHECK_RESULT(hr);
411-
return hr;
409+
if (FenceValue > 0)
410+
{
411+
HRESULT hr = pQueue->Wait(pFence, FenceValue);
412+
RESIDENCY_CHECK_RESULT(hr);
413+
return hr;
414+
}
415+
else
416+
{
417+
return S_OK;
418+
}
412419
}
413420

414421
HRESULT GPUSignal(ID3D12CommandQueue* pQueue)
@@ -1296,8 +1303,8 @@ namespace D3DX12Residency
12961303
if (Device3)
12971304
{
12981305
hr = Device3->EnqueueMakeResident(D3D12_RESIDENCY_FLAG_NONE,
1299-
NumObjectsInBatch,
1300-
&pMakeResidentList[BatchStart].pUnderlying,
1306+
NumObjects,
1307+
&pMakeResidentList[MakeResidentIndex].pUnderlying,
13011308
AsyncThreadFence.pFence,
13021309
AsyncThreadFence.FenceValue + 1);
13031310
if (SUCCEEDED(hr))
@@ -1332,6 +1339,7 @@ namespace D3DX12Residency
13321339
LRU.TrimToSyncPointInclusive(TotalUsage + INT64(SizeToMakeResident), TotalBudget, pEvictionList, NumObjectsToEvict, GenerationToWaitFor);
13331340

13341341
RESIDENCY_CHECK_RESULT(Device->Evict(NumObjectsToEvict, pEvictionList));
1342+
NumObjectsToEvict = 0;
13351343
}
13361344
else
13371345
{

Samples/UWP/D3D12Residency/src/d3dx12Residency.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,16 @@ namespace D3DX12Residency
406406

407407
HRESULT GPUWait(ID3D12CommandQueue* pQueue)
408408
{
409-
HRESULT hr = pQueue->Wait(pFence, FenceValue);
410-
RESIDENCY_CHECK_RESULT(hr);
411-
return hr;
409+
if (FenceValue > 0)
410+
{
411+
HRESULT hr = pQueue->Wait(pFence, FenceValue);
412+
RESIDENCY_CHECK_RESULT(hr);
413+
return hr;
414+
}
415+
else
416+
{
417+
return S_OK;
418+
}
412419
}
413420

414421
HRESULT GPUSignal(ID3D12CommandQueue* pQueue)
@@ -1296,8 +1303,8 @@ namespace D3DX12Residency
12961303
if (Device3)
12971304
{
12981305
hr = Device3->EnqueueMakeResident(D3D12_RESIDENCY_FLAG_NONE,
1299-
NumObjectsInBatch,
1300-
&pMakeResidentList[BatchStart].pUnderlying,
1306+
NumObjects,
1307+
&pMakeResidentList[MakeResidentIndex].pUnderlying,
13011308
AsyncThreadFence.pFence,
13021309
AsyncThreadFence.FenceValue + 1);
13031310
if (SUCCEEDED(hr))
@@ -1332,6 +1339,7 @@ namespace D3DX12Residency
13321339
LRU.TrimToSyncPointInclusive(TotalUsage + INT64(SizeToMakeResident), TotalBudget, pEvictionList, NumObjectsToEvict, GenerationToWaitFor);
13331340

13341341
RESIDENCY_CHECK_RESULT(Device->Evict(NumObjectsToEvict, pEvictionList));
1342+
NumObjectsToEvict = 0;
13351343
}
13361344
else
13371345
{

0 commit comments

Comments
 (0)