[dx12] Return OOM error when GetResourceAllocationInfo() returns SizeInBytes == 0

Some versions of WARP return an allocation info with SizeInBytes == 0
for very large allocations. Proceeding to attempt to allocate a zero-
sized resource results in a device lost error. It's preferable to
instead return an out of memory error.
This commit is contained in:
Jamie Nicol 2025-06-17 11:58:53 +01:00 committed by Connor Fitzgerald
parent aeb2c3e6c7
commit ad4286102a

View File

@ -566,6 +566,14 @@ impl<'a> DeviceAllocationContext<'a> {
.GetResourceAllocationInfo(0, core::slice::from_ref(desc))
};
// Some versions of WARP return SizeInBytes == 0 for very large
// allocations. Proceeding to attempt to allocate a zero-sized resource
// will result in a device lost error, so it seems preferable to return
// an out of memory error now.
if allocation_info.SizeInBytes == 0 {
return Err(crate::DeviceError::OutOfMemory);
}
let Some(threshold) = self
.mem_allocator
.memory_budget_thresholds