@@ -5746,29 +5746,31 @@ HRESULT CurrentBudgetData::UpdateBudget(IDXGIAdapter3* adapter3, bool useMutex)
57465746 DXGI_QUERY_VIDEO_MEMORY_INFO infoLocal = {};
57475747 DXGI_QUERY_VIDEO_MEMORY_INFO infoNonLocal = {};
57485748 const HRESULT hrLocal = adapter3->QueryVideoMemoryInfo (0 , DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &infoLocal);
5749+ if (FAILED (hrLocal))
5750+ {
5751+ return hrLocal;
5752+ }
57495753 const HRESULT hrNonLocal = adapter3->QueryVideoMemoryInfo (0 , DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &infoNonLocal);
5754+ if (FAILED (hrNonLocal))
5755+ {
5756+ return hrNonLocal;
5757+ }
57505758
5751- if (SUCCEEDED (hrLocal) || SUCCEEDED (hrNonLocal))
57525759 {
57535760 MutexLockWrite lockWrite (m_BudgetMutex, useMutex);
57545761
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 ;
57655767
57665768 m_BlockBytesAtD3D12Fetch[0 ] = m_BlockBytes[0 ];
57675769 m_BlockBytesAtD3D12Fetch[1 ] = m_BlockBytes[1 ];
57685770 m_OperationsSinceBudgetFetch = 0 ;
57695771 }
57705772
5771- return FAILED (hrLocal) ? hrLocal : hrNonLocal ;
5773+ return S_OK ;
57725774}
57735775#endif // #if D3D12MA_DXGI_1_4
57745776
@@ -6851,26 +6853,27 @@ void AllocatorPimpl::GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget
68516853 outLocalBudget ? &outLocalBudget->BudgetBytes : NULL ,
68526854 outNonLocalBudget ? &outNonLocalBudget->UsageBytes : NULL ,
68536855 outNonLocalBudget ? &outNonLocalBudget->BudgetBytes : NULL );
6856+ return ;
68546857 }
6855- else
6858+
6859+ if (SUCCEEDED (UpdateD3D12Budget ()))
68566860 {
6857- UpdateD3D12Budget ();
6858- GetBudget (outLocalBudget, outNonLocalBudget); // Recursion
6861+ GetBudget (outLocalBudget, outNonLocalBudget); // Recursion.
6862+ return ;
68596863 }
68606864 }
6861- else
68626865#endif
6866+
6867+ // Fallback path - manual calculation, not real budget.
6868+ if (outLocalBudget)
68636869 {
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.
68746877 }
68756878}
68766879
0 commit comments