Commit a1b96349 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9/tests: Direct3DCreate9() is always available if we have d3d9.

parent 56d1225e
TESTDLL = d3d9.dll
IMPORTS = user32 gdi32
IMPORTS = d3d9 user32 gdi32
C_SRCS = \
d3d9ex.c \
......
......@@ -35,7 +35,6 @@ static BOOL (WINAPI *pEnumDisplaySettingsExA)(const char *device_name,
static LONG (WINAPI *pChangeDisplaySettingsExA)(const char *device_name,
DEVMODEA *mode, HWND window, DWORD flags, void *param);
static IDirect3D9 * (WINAPI *pDirect3DCreate9)(UINT SDKVersion);
static HRESULT (WINAPI *pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **d3d9ex);
static HWND create_window(void)
......@@ -117,7 +116,7 @@ static ULONG getref(IUnknown *obj) {
static void test_qi_base_to_ex(void)
{
IDirect3D9 *d3d9 = pDirect3DCreate9(D3D_SDK_VERSION);
IDirect3D9 *d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
IDirect3D9Ex *d3d9ex = (void *) 0xdeadbeef;
IDirect3DDevice9 *device;
IDirect3DDevice9Ex *deviceEx = (void *) 0xdeadbeef;
......@@ -1203,11 +1202,6 @@ START_TEST(d3d9ex)
skip("Could not load d3d9.dll\n");
return;
}
pDirect3DCreate9 = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(pDirect3DCreate9 != NULL, "Failed to get address of Direct3DCreate9\n");
if(!pDirect3DCreate9) {
return;
}
pDirect3DCreate9Ex = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9Ex");
if (!pDirect3DCreate9Ex) {
......
......@@ -21,8 +21,6 @@
#include <d3d9.h>
#include "wine/test.h"
static HMODULE d3d9_handle = 0;
static DWORD texture_stages;
static HWND create_window(void)
......@@ -36,38 +34,33 @@ static HWND create_window(void)
0, 0, 0, 0, 0, 0, 0, 0);
}
static HRESULT init_d3d9(
IDirect3DDevice9** device,
D3DPRESENT_PARAMETERS* device_pparams)
static IDirect3DDevice9 *init_d3d9(D3DPRESENT_PARAMETERS *present_parameters)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
HRESULT hres;
IDirect3DDevice9 *device;
IDirect3D9 *d3d9;
HWND window;
HRESULT hr;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return E_FAIL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
if (!d3d9_ptr)
if (!(d3d9 = Direct3DCreate9(D3D_SDK_VERSION)))
{
skip("could not create D3D9\n");
return E_FAIL;
return NULL;
}
window = create_window();
ZeroMemory(device_pparams, sizeof(D3DPRESENT_PARAMETERS));
device_pparams->Windowed = TRUE;
device_pparams->hDeviceWindow = window;
device_pparams->SwapEffect = D3DSWAPEFFECT_DISCARD;
memset(present_parameters, 0, sizeof(*present_parameters));
present_parameters->Windowed = TRUE;
present_parameters->hDeviceWindow = window;
present_parameters->SwapEffect = D3DSWAPEFFECT_DISCARD;
hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, device_pparams, device);
ok(hres == D3D_OK || hres == D3DERR_NOTAVAILABLE,
"IDirect3D_CreateDevice returned: 0x%x\n", hres);
return hres;
hr = IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, present_parameters, &device);
ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Failed to create device, hr %#x.\n", hr);
if (SUCCEEDED(hr))
return device;
return NULL;
}
static void test_begin_end_state_block(IDirect3DDevice9 *device_ptr)
......@@ -2441,26 +2434,18 @@ static void test_vdecl_apply(IDirect3DDevice9 *device)
START_TEST(stateblock)
{
IDirect3DDevice9 *device_ptr = NULL;
D3DPRESENT_PARAMETERS device_pparams;
HRESULT hret;
IDirect3DDevice9 *device;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
if (!(device = init_d3d9(&device_pparams)))
return;
}
hret = init_d3d9(&device_ptr, &device_pparams);
if (hret != D3D_OK) return;
test_begin_end_state_block(device_ptr);
test_state_management(device_ptr, &device_pparams);
test_shader_constant_apply(device_ptr);
test_vdecl_apply(device_ptr);
test_begin_end_state_block(device);
test_state_management(device, &device_pparams);
test_shader_constant_apply(device);
test_vdecl_apply(device);
refcount = IDirect3DDevice9_Release(device_ptr);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left\n", refcount);
}
......@@ -21,8 +21,6 @@
#include <d3d9.h>
#include "wine/test.h"
static HMODULE d3d9_handle = 0;
#define VDECL_CHECK(fcall) \
if(fcall != S_OK) \
trace(" Test failed on line #%d\n", __LINE__);
......@@ -40,41 +38,31 @@ static HWND create_window(void)
static IDirect3DDevice9 *init_d3d9(void)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hres;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
IDirect3DDevice9 *device = NULL;
IDirect3D9 *d3d9;
HRESULT hr;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
if (!d3d9_ptr)
if (!(d3d9 = Direct3DCreate9(D3D_SDK_VERSION)))
{
skip("could not create D3D9\n");
return NULL;
}
ZeroMemory(&present_parameters, sizeof(present_parameters));
memset(&present_parameters, 0, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if (SUCCEEDED(IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device)))
return device;
if (SUCCEEDED(hr = IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, NULL,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device)))
return device;
if(FAILED(hres))
{
hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hres))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hres);
return NULL;
}
}
return device_ptr;
trace("Failed to create device, hr %#x.\n", hr);
return NULL;
}
static int get_refcount(IUnknown *object)
......@@ -851,15 +839,7 @@ START_TEST(vertexdeclaration)
IDirect3DVertexDeclaration9 *decl_ptr = 0;
ULONG refcount;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9();
if (!device_ptr)
if (!(device_ptr = init_d3d9()))
{
skip("Failed to initialise d3d9\n");
return;
......
......@@ -32,8 +32,6 @@
#include <d3d9.h>
#include "wine/test.h"
static HMODULE d3d9_handle = 0;
struct vec2
{
float x, y;
......@@ -197,24 +195,18 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9)
static IDirect3DDevice9 *init_d3d9(void)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
HRESULT hr;
D3DADAPTER_IDENTIFIER9 identifier;
IDirect3D9 *d3d9;
HRESULT hr;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
if (!d3d9_ptr)
if (!(d3d9 = Direct3DCreate9(D3D_SDK_VERSION)))
{
win_skip("could not create D3D9\n");
return NULL;
}
memset(&identifier, 0, sizeof(identifier));
hr = IDirect3D9_GetAdapterIdentifier(d3d9_ptr, 0, 0, &identifier);
hr = IDirect3D9_GetAdapterIdentifier(d3d9, 0, 0, &identifier);
ok(hr == D3D_OK, "Failed to get adapter identifier description\n");
trace("Driver string: \"%s\"\n", identifier.Driver);
trace("Description string: \"%s\"\n", identifier.Description);
......@@ -228,7 +220,7 @@ static IDirect3DDevice9 *init_d3d9(void)
HIWORD(U(identifier.DriverVersion).HighPart), LOWORD(U(identifier.DriverVersion).HighPart),
HIWORD(U(identifier.DriverVersion).LowPart), LOWORD(U(identifier.DriverVersion).LowPart));
return create_device(d3d9_ptr);
return create_device(d3d9);
}
static void cleanup_device(IDirect3DDevice9 *device)
......@@ -15114,15 +15106,7 @@ START_TEST(visual)
HRESULT hr;
DWORD color;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9();
if (!device_ptr)
if (!(device_ptr = init_d3d9()))
{
skip("Creating the device failed\n");
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment