@@ -5746,29 +5746,31 @@ HRESULT CurrentBudgetData::UpdateBudget(IDXGIAdapter3* adapter3, bool useMutex)
5746
5746
DXGI_QUERY_VIDEO_MEMORY_INFO infoLocal = {};
5747
5747
DXGI_QUERY_VIDEO_MEMORY_INFO infoNonLocal = {};
5748
5748
const HRESULT hrLocal = adapter3->QueryVideoMemoryInfo (0 , DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &infoLocal);
5749
+ if (FAILED (hrLocal))
5750
+ {
5751
+ return hrLocal;
5752
+ }
5749
5753
const HRESULT hrNonLocal = adapter3->QueryVideoMemoryInfo (0 , DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &infoNonLocal);
5754
+ if (FAILED (hrNonLocal))
5755
+ {
5756
+ return hrNonLocal;
5757
+ }
5750
5758
5751
- if (SUCCEEDED (hrLocal) || SUCCEEDED (hrNonLocal))
5752
5759
{
5753
5760
MutexLockWrite lockWrite (m_BudgetMutex, useMutex);
5754
5761
5755
- if (SUCCEEDED (hrLocal))
5756
- {
5757
- m_D3D12Usage[0 ] = infoLocal.CurrentUsage ;
5758
- m_D3D12Budget[0 ] = infoLocal.Budget ;
5759
- }
5760
- if (SUCCEEDED (hrNonLocal))
5761
- {
5762
- m_D3D12Usage[1 ] = infoNonLocal.CurrentUsage ;
5763
- m_D3D12Budget[1 ] = infoNonLocal.Budget ;
5764
- }
5762
+ m_D3D12Usage[0 ] = infoLocal.CurrentUsage ;
5763
+ m_D3D12Budget[0 ] = infoLocal.Budget ;
5764
+
5765
+ m_D3D12Usage[1 ] = infoNonLocal.CurrentUsage ;
5766
+ m_D3D12Budget[1 ] = infoNonLocal.Budget ;
5765
5767
5766
5768
m_BlockBytesAtD3D12Fetch[0 ] = m_BlockBytes[0 ];
5767
5769
m_BlockBytesAtD3D12Fetch[1 ] = m_BlockBytes[1 ];
5768
5770
m_OperationsSinceBudgetFetch = 0 ;
5769
5771
}
5770
5772
5771
- return FAILED (hrLocal) ? hrLocal : hrNonLocal ;
5773
+ return S_OK ;
5772
5774
}
5773
5775
#endif // #if D3D12MA_DXGI_1_4
5774
5776
@@ -6851,26 +6853,27 @@ void AllocatorPimpl::GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget
6851
6853
outLocalBudget ? &outLocalBudget->BudgetBytes : NULL ,
6852
6854
outNonLocalBudget ? &outNonLocalBudget->UsageBytes : NULL ,
6853
6855
outNonLocalBudget ? &outNonLocalBudget->BudgetBytes : NULL );
6856
+ return ;
6854
6857
}
6855
- else
6858
+
6859
+ if (SUCCEEDED (UpdateD3D12Budget ()))
6856
6860
{
6857
- UpdateD3D12Budget ();
6858
- GetBudget (outLocalBudget, outNonLocalBudget); // Recursion
6861
+ GetBudget (outLocalBudget, outNonLocalBudget); // Recursion.
6862
+ return ;
6859
6863
}
6860
6864
}
6861
- else
6862
6865
#endif
6866
+
6867
+ // Fallback path - manual calculation, not real budget.
6868
+ if (outLocalBudget)
6863
6869
{
6864
- if (outLocalBudget)
6865
- {
6866
- outLocalBudget->UsageBytes = outLocalBudget->Stats .BlockBytes ;
6867
- outLocalBudget->BudgetBytes = GetMemoryCapacity (DXGI_MEMORY_SEGMENT_GROUP_LOCAL_COPY) * 8 / 10 ; // 80% heuristics.
6868
- }
6869
- if (outNonLocalBudget)
6870
- {
6871
- outNonLocalBudget->UsageBytes = outNonLocalBudget->Stats .BlockBytes ;
6872
- outNonLocalBudget->BudgetBytes = GetMemoryCapacity (DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL_COPY) * 8 / 10 ; // 80% heuristics.
6873
- }
6870
+ outLocalBudget->UsageBytes = outLocalBudget->Stats .BlockBytes ;
6871
+ outLocalBudget->BudgetBytes = GetMemoryCapacity (DXGI_MEMORY_SEGMENT_GROUP_LOCAL_COPY) * 8 / 10 ; // 80% heuristics.
6872
+ }
6873
+ if (outNonLocalBudget)
6874
+ {
6875
+ outNonLocalBudget->UsageBytes = outNonLocalBudget->Stats .BlockBytes ;
6876
+ outNonLocalBudget->BudgetBytes = GetMemoryCapacity (DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL_COPY) * 8 / 10 ; // 80% heuristics.
6874
6877
}
6875
6878
}
6876
6879
0 commit comments