mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
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>
This commit is contained in:
parent
0f46ae3e55
commit
0aef5f927e
11
Makefile.am
11
Makefile.am
@ -33,6 +33,9 @@ vkd3d_demos_shaders = \
|
|||||||
demos/triangle_vs.h
|
demos/triangle_vs.h
|
||||||
|
|
||||||
vkd3d_tests = \
|
vkd3d_tests = \
|
||||||
|
tests/vkd3d_api
|
||||||
|
|
||||||
|
vkd3d_cross_tests = \
|
||||||
tests/d3d12
|
tests/d3d12
|
||||||
|
|
||||||
vkd3d_demos = \
|
vkd3d_demos = \
|
||||||
@ -101,9 +104,9 @@ vkd3d_compiler_SOURCES = programs/vkd3d-compiler/main.c
|
|||||||
vkd3d_compiler_LDADD = libvkd3d-shader.la
|
vkd3d_compiler_LDADD = libvkd3d-shader.la
|
||||||
|
|
||||||
LDADD = libvkd3d.la libvkd3d-utils.la
|
LDADD = libvkd3d.la libvkd3d-utils.la
|
||||||
check_PROGRAMS = $(vkd3d_tests)
|
check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests)
|
||||||
AM_DEFAULT_SOURCE_EXT = .c
|
AM_DEFAULT_SOURCE_EXT = .c
|
||||||
TESTS = $(vkd3d_tests)
|
TESTS = $(vkd3d_tests) $(vkd3d_cross_tests)
|
||||||
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@
|
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@
|
||||||
|
|
||||||
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @XCB_LIBS@ @VULKAN_LIBS@
|
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @XCB_LIBS@ @VULKAN_LIBS@
|
||||||
@ -154,7 +157,7 @@ if HAS_CROSSTARGET32
|
|||||||
CROSS32_CC = @CROSSCC32@
|
CROSS32_CC = @CROSSCC32@
|
||||||
CROSS32_DLLTOOL = @CROSSTARGET32@-dlltool
|
CROSS32_DLLTOOL = @CROSSTARGET32@-dlltool
|
||||||
CROSS32_IMPLIBS = $(cross_implibs:=.cross32.a)
|
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)
|
CROSS32_FILES = $(CROSS32_IMPLIBS) $(CROSS32_EXEFILES)
|
||||||
|
|
||||||
CLEANFILES += $(CROSS32_FILES)
|
CLEANFILES += $(CROSS32_FILES)
|
||||||
@ -179,7 +182,7 @@ if HAS_CROSSTARGET64
|
|||||||
CROSS64_CC = @CROSSCC64@
|
CROSS64_CC = @CROSSCC64@
|
||||||
CROSS64_DLLTOOL = @CROSSTARGET64@-dlltool
|
CROSS64_DLLTOOL = @CROSSTARGET64@-dlltool
|
||||||
CROSS64_IMPLIBS = $(cross_implibs:=.cross64.a)
|
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)
|
CROSS64_FILES = $(CROSS64_IMPLIBS) $(CROSS64_EXEFILES)
|
||||||
|
|
||||||
CLEANFILES += $(CROSS64_FILES)
|
CLEANFILES += $(CROSS64_FILES)
|
||||||
|
84
tests/vkd3d_api.c
Normal file
84
tests/vkd3d_api.c
Normal file
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user