vkd3d: Return E_INVALIDARG if a heap is too small for a placed resource.

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@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2021-07-26 13:47:39 +10:00 committed by Alexandre Julliard
parent 7cd4cf8aba
commit e292351fa9
2 changed files with 7 additions and 1 deletions

View File

@ -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",

View File

@ -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);