Module: vkd3d Branch: master Commit: 0aef5f927e9a023b0663776a978ae55cd2da7d10 URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=0aef5f927e9a023b0663776a...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Jan 11 17:03:48 2018 +0100
tests: Add test for creating vkd3d instances.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
Makefile.am | 11 +++++--- tests/vkd3d_api.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 4d32b2f..2876f64 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,9 @@ vkd3d_demos_shaders = \ demos/triangle_vs.h
vkd3d_tests = \ + tests/vkd3d_api + +vkd3d_cross_tests = \ tests/d3d12
vkd3d_demos = \ @@ -101,9 +104,9 @@ vkd3d_compiler_SOURCES = programs/vkd3d-compiler/main.c vkd3d_compiler_LDADD = libvkd3d-shader.la
LDADD = libvkd3d.la libvkd3d-utils.la -check_PROGRAMS = $(vkd3d_tests) +check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests) AM_DEFAULT_SOURCE_EXT = .c -TESTS = $(vkd3d_tests) +TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @XCB_LIBS@ @VULKAN_LIBS@ @@ -154,7 +157,7 @@ if HAS_CROSSTARGET32 CROSS32_CC = @CROSSCC32@ CROSS32_DLLTOOL = @CROSSTARGET32@-dlltool CROSS32_IMPLIBS = $(cross_implibs:=.cross32.a) -CROSS32_EXEFILES = $(vkd3d_tests:=.cross32.exe) $(vkd3d_demos:=.cross32.exe) +CROSS32_EXEFILES = $(vkd3d_cross_tests:=.cross32.exe) $(vkd3d_demos:=.cross32.exe) CROSS32_FILES = $(CROSS32_IMPLIBS) $(CROSS32_EXEFILES)
CLEANFILES += $(CROSS32_FILES) @@ -179,7 +182,7 @@ if HAS_CROSSTARGET64 CROSS64_CC = @CROSSCC64@ CROSS64_DLLTOOL = @CROSSTARGET64@-dlltool CROSS64_IMPLIBS = $(cross_implibs:=.cross64.a) -CROSS64_EXEFILES = $(vkd3d_tests:=.cross64.exe) $(vkd3d_demos:=.cross64.exe) +CROSS64_EXEFILES = $(vkd3d_cross_tests:=.cross64.exe) $(vkd3d_demos:=.cross64.exe) CROSS64_FILES = $(CROSS64_IMPLIBS) $(CROSS64_EXEFILES)
CLEANFILES += $(CROSS64_FILES) diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c new file mode 100644 index 0000000..871dbe2 --- /dev/null +++ b/tests/vkd3d_api.c @@ -0,0 +1,84 @@ +/* + * Copyright 2018 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 +#define INITGUID +#define WIDL_C_INLINE_WRAPPERS +#include "vkd3d_test.h" +#include <vkd3d.h> + +static bool signal_event(HANDLE event) +{ + trace("Signal event %p.\n", event); + return true; +} + +static void test_create_instance(void) +{ + struct vkd3d_instance_create_info create_info; + struct vkd3d_instance *instance; + ULONG refcount; + HRESULT hr; + + memset(&create_info, 0, sizeof(create_info)); + create_info.wchar_size = sizeof(WCHAR); + + hr = vkd3d_create_instance(&create_info, &instance); + ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr); + refcount = vkd3d_instance_incref(instance); + ok(refcount == 2, "Got unexpected refcount %u.\n", refcount); + vkd3d_instance_decref(instance); + refcount = vkd3d_instance_decref(instance); + ok(!refcount, "Instance has %u references left.\n", refcount); + + create_info.signal_event_pfn = signal_event; + hr = vkd3d_create_instance(&create_info, &instance); + ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr); + refcount = vkd3d_instance_decref(instance); + ok(!refcount, "Instance has %u references left.\n", refcount); +} + +static bool have_d3d12_device(void) +{ + struct vkd3d_instance_create_info instance_create_info = + { + .wchar_size = sizeof(WCHAR), + }; + struct vkd3d_device_create_info device_create_info = + { + .minimum_feature_level = D3D_FEATURE_LEVEL_11_0, + .instance_create_info = &instance_create_info, + }; + ID3D12Device *device; + HRESULT hr; + + if (SUCCEEDED(hr = vkd3d_create_device(&device_create_info, &IID_ID3D12Device, (void **)&device))) + ID3D12Device_Release(device); + return hr == S_OK; +} + +START_TEST(vkd3d_api) +{ + if (!have_d3d12_device()) + { + skip("D3D12 device cannot be created.\n"); + return; + } + + run_test(test_create_instance); +}