vkd3d: Validate that a resource with initial state RENDER_TARGET is a render target.

This commit is contained in:
Conor McCarthy 2024-04-09 17:26:32 +10:00 committed by Alexandre Julliard
parent 78301d7202
commit 9d7f63dc26
Notes: Alexandre Julliard 2024-04-11 17:04:33 -05:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/772
2 changed files with 6 additions and 3 deletions

View File

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

View File

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