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;