From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/vkd3d_main.c | 8 +++++++- tests/d3d12.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 97d642a7cf91..0e2d422d216b 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -28,7 +28,7 @@ HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
TRACE("create_info %p, iid %s, device %p.\n", create_info, debugstr_guid(iid), device);
- if (!create_info || !device) + if (!create_info) return E_INVALIDARG; if (create_info->type != VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO) { @@ -76,6 +76,12 @@ HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info, if (FAILED(hr)) return hr;
+ if (!device) + { + ID3D12Device_Release(&object->ID3D12Device_iface); + return S_FALSE; + } + return return_interface((IUnknown *)&object->ID3D12Device_iface, &IID_ID3D12Device, iid, device); } diff --git a/tests/d3d12.c b/tests/d3d12.c index 6128a402d3a6..e2337c4427ab 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1080,6 +1080,9 @@ static void test_create_device(void) ok(hr == S_OK, "Failed to create device, hr %#x.\n", hr); ID3D12Device_Release(device);
+ hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, NULL); + ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr); + hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_9_1, &IID_ID3D12Device, (void **)&device); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_9_2, &IID_ID3D12Device, (void **)&device);