mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:54:13 +00:00
d3d11/tests: Add test for D3D11CreateDevice.
This commit is contained in:
parent
4cf1bb929f
commit
6038e2ab79
1 changed files with 53 additions and 0 deletions
|
@ -21,6 +21,12 @@
|
|||
#include "d3d11.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static ULONG get_refcount(IUnknown *iface)
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
return IUnknown_Release(iface);
|
||||
}
|
||||
|
||||
static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level)
|
||||
{
|
||||
ID3D11Device *device;
|
||||
|
@ -38,6 +44,52 @@ static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void test_create_device(void)
|
||||
{
|
||||
D3D_FEATURE_LEVEL feature_level, supported_feature_level;
|
||||
ID3D11DeviceContext *immediate_context = NULL;
|
||||
ID3D11Device *device;
|
||||
ULONG refcount;
|
||||
HRESULT hr;
|
||||
|
||||
hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &device,
|
||||
NULL, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
skip("Failed to create HAL device, skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
supported_feature_level = ID3D11Device_GetFeatureLevel(device);
|
||||
ID3D11Device_Release(device);
|
||||
|
||||
hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
|
||||
|
||||
hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL,
|
||||
&feature_level, NULL);
|
||||
ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
|
||||
ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
|
||||
feature_level, supported_feature_level);
|
||||
|
||||
hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL,
|
||||
&immediate_context);
|
||||
ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
|
||||
|
||||
todo_wine ok(!!immediate_context, "Immediate context is NULL.\n");
|
||||
if (!immediate_context) return;
|
||||
|
||||
refcount = get_refcount((IUnknown *)immediate_context);
|
||||
ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
|
||||
|
||||
ID3D11DeviceContext_GetDevice(immediate_context, &device);
|
||||
refcount = ID3D11Device_Release(device);
|
||||
ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
|
||||
|
||||
refcount = ID3D11DeviceContext_Release(immediate_context);
|
||||
ok(!refcount, "ID3D11DeviceContext has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
static void test_device_interfaces(void)
|
||||
{
|
||||
static const D3D_FEATURE_LEVEL feature_levels[] =
|
||||
|
@ -96,5 +148,6 @@ static void test_device_interfaces(void)
|
|||
|
||||
START_TEST(d3d11)
|
||||
{
|
||||
test_create_device();
|
||||
test_device_interfaces();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue