[PATCH vkd3d 2/2] vkd3d: Return E_INVALIDARG if a heap is too small for a placed resource.
Conor McCarthy
cmccarthy at codeweavers.com
Sun Jul 25 22:47:39 CDT 2021
Otherwise vkBindBufferMemory() or vkBindImageMemory() will fail, which
can result in a generic E_FAIL.
Based on a vkd3d-proton patch by Samuel Pitoiset which fixes a GPU hang
with Cyberpunk 2077.
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
libs/vkd3d/resource.c | 7 +++++++
tests/d3d12.c | 1 -
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 3faa6794..1ca23a90 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1911,6 +1911,13 @@ static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
heap_offset = align(heap_offset, requirements.alignment);
}
+ if (heap_offset > heap->desc.SizeInBytes || requirements.size > heap->desc.SizeInBytes - heap_offset)
+ {
+ ERR("Heap too small for the resource (offset %"PRIu64", resource size %"PRIu64", heap size %"PRIu64".\n",
+ heap_offset, requirements.size, heap->desc.SizeInBytes);
+ return E_INVALIDARG;
+ }
+
if (heap_offset % requirements.alignment)
{
FIXME("Invalid heap offset %#"PRIx64" (alignment %#"PRIx64").\n",
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 03bae895..0e0f2b8d 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -2290,7 +2290,6 @@ static void test_create_placed_resource(void)
hr = ID3D12Device_CreatePlacedResource(device, heap, heap_desc.SizeInBytes,
&resource_desc, D3D12_RESOURCE_STATE_COMMON, NULL,
&IID_ID3D12Resource, (void **)&resource);
- todo
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ID3D12Heap_Release(heap);
--
2.32.0
More information about the wine-devel
mailing list