Skip to content

Commit 42981b7

Browse files
Fix in AllocatorPimpl::GetResourceAllocationInfoMiddle
When GetResourceAllocationInfo fails, it returns SizeInBytes == UINT64_MAX. Also a fix in TestDevice12 for cases when it fails.
1 parent d57fd6b commit 42981b7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/D3D12MemAlloc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7722,7 +7722,7 @@ HRESULT AllocatorPimpl::GetResourceAllocationInfoMiddle(
77227722
}
77237723

77247724
outAllocInfo = GetResourceAllocationInfoNative(inOutResourceDesc);
7725-
return S_OK;
7725+
return outAllocInfo.SizeInBytes != UINT64_MAX ? S_OK : E_INVALIDARG;
77267726
}
77277727

77287728
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
@@ -7738,15 +7738,15 @@ HRESULT AllocatorPimpl::GetResourceAllocationInfoMiddle(
77387738
if (m_Device12 != NULL)
77397739
{
77407740
outAllocInfo = GetResourceAllocationInfo3Native(inOutResourceDesc, NumCastableFormats, pCastableFormats);
7741-
return S_OK;
7741+
return outAllocInfo.SizeInBytes != UINT64_MAX ? S_OK : E_INVALIDARG;
77427742
}
77437743
#else
77447744
return E_NOTIMPL;
77457745
#endif
77467746
}
77477747

77487748
outAllocInfo = GetResourceAllocationInfo2Native(inOutResourceDesc);
7749-
return S_OK;
7749+
return outAllocInfo.SizeInBytes != UINT64_MAX ? S_OK : E_INVALIDARG;
77507750
}
77517751

77527752
#endif // #ifdef __ID3D12Device8_INTERFACE_DEFINED__

src/Tests.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,10 +3152,18 @@ static void TestDevice12(const TestContext& ctx)
31523152

31533153
ComPtr<D3D12MA::Allocation> alloc0;
31543154
ComPtr<ID3D12Resource> res0;
3155-
CHECK_HR(ctx.allocator->CreateResource3(&allocDesc, &resourceDesc,
3155+
HRESULT hr = ctx.allocator->CreateResource3(&allocDesc, &resourceDesc,
31563156
D3D12_BARRIER_LAYOUT_UNDEFINED, NULL,
31573157
_countof(castableFormats), castableFormats,
3158-
&alloc0, IID_PPV_ARGS(&res0)));
3158+
&alloc0, IID_PPV_ARGS(&res0));
3159+
3160+
if (hr == E_INVALIDARG)
3161+
{
3162+
wprintf(L"Allocator::CreateResource3 failed with E_INVALIDARG!\n");
3163+
return;
3164+
}
3165+
3166+
CHECK_HR(hr);
31593167
CHECK_BOOL(alloc0 && res0);
31603168
}
31613169
#endif // #ifdef __ID3D12Device12_INTERFACE_DEFINED__

0 commit comments

Comments
 (0)