From e3fb82d544eb5267da8a319197417505a5ac06f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 17 Oct 2016 14:24:22 +0200 Subject: [PATCH] libs/vkd3d: Forbid creating textures on UPLOAD/READBACK heaps. --- libs/vkd3d/resource.c | 7 +++++++ tests/d3d12.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 42765710..e1a3d4be 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -620,6 +620,13 @@ static HRESULT d3d12_committed_resource_init(struct d3d12_resource *resource, st if (optimized_clear_value) FIXME("Ignoring optimized clear value.\n"); + if (desc->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER + && (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD || heap_properties->Type == D3D12_HEAP_TYPE_READBACK)) + { + WARN("Texture cannot be created on a UPLOAD/READBACK heap.\n"); + return E_INVALIDARG; + } + if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD && initial_state != D3D12_RESOURCE_STATE_GENERIC_READ) { WARN("For D3D12_HEAP_TYPE_UPLOAD the state must be D3D12_RESOURCE_STATE_GENERIC_READ.\n"); diff --git a/tests/d3d12.c b/tests/d3d12.c index 6a4bf983..c1290a51 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -853,6 +853,26 @@ static void test_create_committed_resource(void) refcount = ID3D12Resource_Release(resource); ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount); + resource_desc.Flags = 0; + hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, + &resource_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value, + &IID_ID3D12Resource, (void **)&resource); + todo(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D12Resource_Release(resource); + + heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD; + hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, + &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, + &IID_ID3D12Resource, (void **)&resource); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + heap_properties.Type = D3D12_HEAP_TYPE_READBACK; + hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, + &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST, NULL, + &IID_ID3D12Resource, (void **)&resource); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD; resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;