Module: wine Branch: master Commit: 9af58dc110e9f955209f422503ed249c08c81496 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9af58dc110e9f955209f422503...
Author: Józef Kucia jkucia@codeweavers.com Date: Mon Aug 24 01:04:24 2015 +0200
d3d11/tests: Add test for device interfaces.
---
configure | 1 + configure.ac | 1 + dlls/d3d11/tests/Makefile.in | 5 +++ dlls/d3d11/tests/d3d11.c | 100 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+)
diff --git a/configure b/configure index b12b7e3..005533d 100755 --- a/configure +++ b/configure @@ -17236,6 +17236,7 @@ wine_fn_config_dll d3d10_1 enable_d3d10_1 implib wine_fn_config_dll d3d10core enable_d3d10core implib wine_fn_config_test dlls/d3d10core/tests d3d10core_test wine_fn_config_dll d3d11 enable_d3d11 implib +wine_fn_config_test dlls/d3d11/tests d3d11_test wine_fn_config_dll d3d8 enable_d3d8 implib wine_fn_config_test dlls/d3d8/tests d3d8_test wine_fn_config_dll d3d9 enable_d3d9 implib diff --git a/configure.ac b/configure.ac index 0276a1c..004e79d 100644 --- a/configure.ac +++ b/configure.ac @@ -2837,6 +2837,7 @@ WINE_CONFIG_DLL(d3d10_1,,[implib]) WINE_CONFIG_DLL(d3d10core,,[implib]) WINE_CONFIG_TEST(dlls/d3d10core/tests) WINE_CONFIG_DLL(d3d11,,[implib]) +WINE_CONFIG_TEST(dlls/d3d11/tests) WINE_CONFIG_DLL(d3d8,,[implib]) WINE_CONFIG_TEST(dlls/d3d8/tests) WINE_CONFIG_DLL(d3d9,,[implib]) diff --git a/dlls/d3d11/tests/Makefile.in b/dlls/d3d11/tests/Makefile.in new file mode 100644 index 0000000..d977d31 --- /dev/null +++ b/dlls/d3d11/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = d3d11.dll +IMPORTS = d3d11 + +C_SRCS = \ + d3d11.c diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c new file mode 100644 index 0000000..0595ead --- /dev/null +++ b/dlls/d3d11/tests/d3d11.c @@ -0,0 +1,100 @@ +/* + * Copyright 2015 Józef Kucia for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS +#include "initguid.h" +#include "d3d11.h" +#include "wine/test.h" + +static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level) +{ + ID3D11Device *device; + + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION, + &device, NULL, NULL))) + return device; + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION, + &device, NULL, NULL))) + return device; + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION, + &device, NULL, NULL))) + return device; + + return NULL; +} + +static void test_device_interfaces(void) +{ + static const D3D_FEATURE_LEVEL feature_levels[] = + { + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1 + }; + ID3D11Device *device; + IUnknown *iface; + ULONG refcount; + unsigned int i; + HRESULT hr; + + for (i = 0; i < sizeof(feature_levels) / sizeof(*feature_levels); i++) + { + if (!(device = create_device(feature_levels[i]))) + { + skip("Failed to create device for feature level %#x, skipping tests.\n", feature_levels[i]); + continue; + } + + hr = ID3D11Device_QueryInterface(device, &IID_IUnknown, (void **)&iface); + ok(SUCCEEDED(hr), "Device should implement IUnknown interface, hr %#x.\n", hr); + IUnknown_Release(iface); + + hr = ID3D11Device_QueryInterface(device, &IID_IDXGIObject, (void **)&iface); + ok(SUCCEEDED(hr), "Device should implement IDXGIObject interface, hr %#x.\n", hr); + IUnknown_Release(iface); + + hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&iface); + ok(SUCCEEDED(hr), "Device should implement IDXGIDevice interface, hr %#x.\n", hr); + IUnknown_Release(iface); + + hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Multithread, (void **)&iface); + ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, + "Device should implement ID3D10Multithread interface, hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(iface); + + hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device, (void **)&iface); + todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device interface, hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(iface); + + hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device1, (void **)&iface); + todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device1 interface, hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(iface); + + refcount = ID3D11Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + } +} + +START_TEST(d3d11) +{ + test_device_interfaces(); +}