From 9d7f63dc26b72132f36fde545aa997e1294b658a Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Tue, 9 Apr 2024 17:26:32 +1000 Subject: [PATCH] vkd3d: Validate that a resource with initial state RENDER_TARGET is a render target. --- libs/vkd3d/resource.c | 5 +++++ tests/d3d12.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 60dffe3d..17999914 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -2003,6 +2003,11 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12 WARN("Invalid initial resource state %#x.\n", initial_state); return E_INVALIDARG; } + if (initial_state == D3D12_RESOURCE_STATE_RENDER_TARGET && !(desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)) + { + WARN("Invalid initial resource state %#x for non-render-target.\n", initial_state); + return E_INVALIDARG; + } if (optimized_clear_value && d3d12_resource_is_buffer(resource)) { diff --git a/tests/d3d12.c b/tests/d3d12.c index 69d72fb7..aaea5e31 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1634,9 +1634,7 @@ static void test_create_committed_resource(void) hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, NULL, &IID_ID3D12Resource, (void **)&resource); - todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) - ID3D12Resource_Release(resource); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); /* A texture cannot be created on a UPLOAD heap. */ heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD;