[Bug 19153] DX3 game does not recognize graphics capabilities
WineHQ Bugzilla
wine-bugs at winehq.org
Sun Oct 13 22:29:49 CDT 2019
https://bugs.winehq.org/show_bug.cgi?id=19153
--- Comment #36 from joaopa <jeremielapuree at yahoo.fr> ---
Comment on attachment 65435
--> https://bugs.winehq.org/attachment.cgi?id=65435
Test for enumdevices
>From 4b3480a405db9f7be4cddbfffad86b2538b84574 Mon Sep 17 00:00:00 2001
>From: David Adam <david.adam.cnrs at gmail.com>
>Date: Fri, 11 Oct 2019 21:03:26 -1000
>Subject:ddraw: Port Enumdevices tests to ddraw*.c and extent them
>
>---
> dlls/ddraw/tests/ddraw1.c | 143 +++++++++++++++++++++++++++++++++++++
> dlls/ddraw/tests/ddraw2.c | 145 ++++++++++++++++++++++++++++++++++++++
> dlls/ddraw/tests/ddraw4.c | 145 ++++++++++++++++++++++++++++++++++++++
> dlls/ddraw/tests/ddraw7.c | 116 ++++++++++++++++++++++++++++++
> 4 files changed, 549 insertions(+)
>
>diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
>old mode 100644
>new mode 100755
>index a23e76e1f7..8b9773d5a3
>--- a/dlls/ddraw/tests/ddraw1.c
>+++ b/dlls/ddraw/tests/ddraw1.c
>@@ -49,6 +49,11 @@ struct create_window_thread_param
> HANDLE thread;
> };
>
>+typedef struct {
>+ HRESULT desired_ret;
>+ int total;
>+} D3D1ECancelTest;
>+
> static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
> {
> if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
>@@ -13065,6 +13070,143 @@ static void test_d32_support(void)
> DestroyWindow(window);
> }
>
>+static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ UINT i;
>+ UINT *number_devices = (UINT *)ctx;
>+ char name[][20] =
>+ {"Ramp Emulation", "RGB Emulation", "Direct3D HAL", "MMX Emulation", "Reference Rasterizer", "Null device", "Direct3D T&L HAL"};
>+ struct
>+ {
>+ GUID guid;
>+ DWORD hal_line_pow2;
>+ DWORD hal_tri_pow2;
>+ DWORD hal_line_nonpow2cond;
>+ DWORD hal_tri_nonpow2cond;
>+ D3DCOLORMODEL hal_colormodel;
>+ BOOL hal_dwFlags;
>+ DWORD size;
>+ } test_device_hal[]=
>+ {
>+ {IID_IDirect3DRampDevice, 0, 0, 0, 0, 0, 0, 0xac},
>+ {IID_IDirect3DRGBDevice, 0, 0, 0, 0, 0, 0, 0xac},
>+ {IID_IDirect3DHALDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xac},
>+ {IID_IDirect3DRefDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xac},
>+ {IID_IDirect3DNullDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xac},
>+ {IID_IDirect3DTnLHalDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xac}
>+ };
>+
>+ struct
>+ {
>+ DWORD hel_line_pow2;
>+ DWORD hel_tri_pow2;
>+ DWORD hel_line_nonpow2cond;
>+ DWORD hel_tri_nonpow2cond;
>+ D3DCOLORMODEL hel_colormodel;
>+ BOOL hel_dwFlags;
>+ DWORD size;
>+ } test_device_hel[]=
>+ {
>+ {0x2, 0x2, 0, 0, D3DCOLOR_MONO, 1, 0xac},
>+ {0x2, 0x2, 0, 0, D3DCOLOR_RGB, 1, 0xac},
>+ {0, 0, 0, 0, 0, 1, 0xac},
>+ {0, 0, 0xff, 0xff, D3DCOLOR_RGB, 1, 0xac},
>+ {0, 0, 0xff, 0xff, 0, 1, 0xac},
>+ {0, 0, 0xff, 0xff, 1, D3DCOLOR_RGB, 0xac}
>+ };
>+
>+ i = 0;
>+ while((!IsEqualGUID(&test_device_hal[i].guid, Guid)) && (i < ARRAY_SIZE(name)))
>+ i++;
>+
>+ ok(!strcmp(DeviceName, name[i]), "Test %d, wrong device name\n", i);
>+ number_devices[i]++;
>+
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_line_pow2,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_tri_pow2,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_line_nonpow2cond,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_tri_nonpow2cond,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hal->dwFlags == test_device_hal[i].hal_dwFlags, "Test %d, hal device hal caps has a wrong hardware flag %x\n", i, hal->dwFlags);
>+ ok(hal->dcmColorModel == test_device_hal[i].hal_colormodel, "Test %d, hal caps has a wrong colormodel %u\n", i, hal->dcmColorModel);
>+ ok(hal->dwSize == test_device_hal[i].size, "Test %d, hal has a wrong size %u instead of %u\n", i, hal->dwSize, test_device_hal[i].size);
>+
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_line_pow2,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_tri_pow2,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_line_nonpow2cond,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_tri_nonpow2cond,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hel->dwFlags == test_device_hel[i].hel_dwFlags, "Test %d, hel device hel caps has a wrong hardware flag %x\n", i, hel->dwFlags);
>+ ok(hel->dcmColorModel == test_device_hel[i].hel_colormodel, "Test %d, hel caps has a wrong colormodel %u\n", i, hel->dcmColorModel);
>+ ok(hel->dwSize == test_device_hel[i].size, "Test %d, hel has a wrong size %u instead of %u\n", i, hel->dwSize, test_device_hel[i].size);
>+
>+ return DDENUMRET_OK;
>+}
>+
>+static HRESULT WINAPI enumDevicesCancelTest(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ D3D1ECancelTest *d3d1et = ctx;
>+
>+ d3d1et->total++;
>+ return d3d1et->desired_ret;
>+}
>+
>+void test_enum_device(void)
>+{
>+ BOOL enumerated[] = {1, 1, 1, 0, 0, 1, 0};
>+ D3D1ECancelTest d3d1_cancel_test;
>+ IDirectDraw *ddraw;
>+ IDirect3D *d3d;
>+ HRESULT hr;
>+ UINT nb_devices[] = {0, 0, 0, 0, 0, 0, 0};
>+ UINT i;
>+
>+ ddraw = create_ddraw();
>+ ok(!!ddraw, "Failed to create a ddraw object.\n");
>+ hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
>+ ok(hr == DD_OK, "Failed to get d3d interface, hr %#x.\n", hr);
>+
>+ hr = IDirect3D_EnumDevices(d3d, NULL, NULL);
>+ ok(hr == DDERR_INVALIDPARAMS, "IDirect3D3_EnumDevices returned 0x%08x\n", hr);
>+ hr = IDirect3D_EnumDevices(d3d, enumDevicesCallback, &nb_devices);
>+ ok(hr == DD_OK, "IDirect3D3_EnumDevices returned 0x%08x\n", hr);
>+
>+ for(i = 0; i < ARRAY_SIZE(enumerated); i++)
>+ ok(nb_devices[i] == !enumerated[i], "device %d should not be enumerated in ddraw 1\n", i);
>+
>+ /* RGB device should always be enumerated */
>+ ok(nb_devices[1], "No RGB Device enumerated.\n");
>+
>+ d3d1_cancel_test.desired_ret = DDENUMRET_CANCEL;
>+ d3d1_cancel_test.total = 0;
>+ hr = IDirect3D_EnumDevices(d3d, enumDevicesCancelTest, &d3d1_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d1_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d1_cancel_test.total);
>+
>+ /* An enumeration callback can return any value besides DDENUMRET_OK to stop enumeration. */
>+ d3d1_cancel_test.desired_ret = E_INVALIDARG;
>+ d3d1_cancel_test.total = 0;
>+ hr = IDirect3D_EnumDevices(d3d, enumDevicesCancelTest, &d3d1_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d1_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d1_cancel_test.total);
>+
>+ IDirect3D_Release(d3d);
>+ IDirectDraw_Release(ddraw);
>+ return;
>+}
>+
> START_TEST(ddraw1)
> {
> DDDEVICEIDENTIFIER identifier;
>@@ -13177,4 +13319,5 @@ START_TEST(ddraw1)
> test_clipper_refcount();
> test_caps();
> test_d32_support();
>+ test_enum_device();
> }
>diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
>old mode 100644
>new mode 100755
>index 2156bd5849..8d171ce7fa
>--- a/dlls/ddraw/tests/ddraw2.c
>+++ b/dlls/ddraw/tests/ddraw2.c
>@@ -50,6 +50,11 @@ struct create_window_thread_param
> HANDLE thread;
> };
>
>+typedef struct {
>+ HRESULT desired_ret;
>+ int total;
>+} D3D2ECancelTest;
>+
> static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
> {
> if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
>@@ -13949,6 +13954,145 @@ static void test_d32_support(void)
> DestroyWindow(window);
> }
>
>+static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ UINT i;
>+ UINT *number_devices = (UINT *)ctx;
>+ char name[][20] =
>+ {"Ramp Emulation", "RGB Emulation", "Direct3D HAL", "MMX Emulation", "Reference Rasterizer", "Null device", "Direct3D T&L HAL"};
>+ struct
>+ {
>+ GUID guid;
>+ DWORD hal_line_pow2;
>+ DWORD hal_tri_pow2;
>+ DWORD hal_line_nonpow2cond;
>+ DWORD hal_tri_nonpow2cond;
>+ D3DCOLORMODEL hal_colormodel;
>+ BOOL hal_dwFlags;
>+ DWORD size;
>+ } test_device_hal[]=
>+ {
>+ {IID_IDirect3DRampDevice, 0, 0, 0, 0, 0, 0, 0xcc},
>+ {IID_IDirect3DRGBDevice, 0, 0, 0, 0, 0, 0, 0xcc},
>+ {IID_IDirect3DHALDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xcc},
>+ {IID_IDirect3DMMXDevice, 0, 0, 0, 0, 0, 0, 0xcc},
>+ {IID_IDirect3DRefDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xcc},
>+ {IID_IDirect3DNullDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xcc},
>+ {IID_IDirect3DTnLHalDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xcc}
>+ };
>+
>+ struct
>+ {
>+ DWORD hel_line_pow2;
>+ DWORD hel_tri_pow2;
>+ DWORD hel_line_nonpow2cond;
>+ DWORD hel_tri_nonpow2cond;
>+ D3DCOLORMODEL hel_colormodel;
>+ BOOL hel_dwFlags;
>+ DWORD size;
>+ } test_device_hel[]=
>+ {
>+ {0x2, 0x2, 0, 0, D3DCOLOR_MONO, 1, 0xcc},
>+ {0x2, 0x2, 0, 0, D3DCOLOR_RGB, 1, 0xcc},
>+ {0, 0, 0, 0, 0, 1, 0xcc},
>+ {0x2, 0x2, 0, 0, D3DCOLOR_RGB, 1, 0xcc},
>+ {0, 0, 0xff, 0xff, 0, 1, 0xcc},
>+ {0, 0, 0xff, 0xff, 0, 1, 0xcc},
>+ {0, 0, 0xff, 0xff, 1, D3DCOLOR_RGB, 0xcc}
>+ };
>+
>+ i = 0;
>+ while((!IsEqualGUID(&test_device_hal[i].guid, Guid)) && (i < ARRAY_SIZE(name)))
>+ i++;
>+
>+ ok(!strcmp(DeviceName, name[i]), "Test %d, wrong device name\n", i);
>+ number_devices[i]++;
>+
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_line_pow2,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_tri_pow2,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_line_nonpow2cond,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_tri_nonpow2cond,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hal->dwFlags == test_device_hal[i].hal_dwFlags, "Test %d, hal device hal caps has a wrong hardware flag %x\n", i, hal->dwFlags);
>+ ok(hal->dcmColorModel == test_device_hal[i].hal_colormodel, "Test %d, hal caps has a wrong colormodel %u\n", i, hal->dcmColorModel);
>+ ok(hal->dwSize == test_device_hal[i].size, "Test %d, hal has a wrong size %u instead of %u\n", i, hal->dwSize, test_device_hal[i].size);
>+
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_line_pow2,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_tri_pow2,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_line_nonpow2cond,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_tri_nonpow2cond,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hel->dwFlags == test_device_hel[i].hel_dwFlags, "Test %d, hel device hel caps has a wrong hardware flag %x\n", i, hel->dwFlags);
>+ ok(hel->dcmColorModel == test_device_hel[i].hel_colormodel, "Test %d, hel caps has a wrong colormodel %u\n", i, hel->dcmColorModel);
>+ ok(hel->dwSize == test_device_hel[i].size, "Test %d, hel has a wrong size %u instead of %u\n", i, hel->dwSize, test_device_hel[i].size);
>+
>+ return DDENUMRET_OK;
>+}
>+
>+static HRESULT WINAPI enumDevicesCancelTest(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ D3D2ECancelTest *d3d2et = ctx;
>+
>+ d3d2et->total++;
>+ return d3d2et->desired_ret;
>+}
>+
>+static void test_enum_device(void)
>+{
>+ BOOL enumerated[] = {1, 1, 1, 1, 0, 1, 0};
>+ D3D2ECancelTest d3d2_cancel_test;
>+ IDirectDraw2 *ddraw;
>+ IDirect3D2 *d3d2;
>+ HRESULT hr;
>+ UINT nb_devices[] = {0, 0, 0, 0, 0, 0, 0};
>+ UINT i;
>+
>+ ddraw = create_ddraw();
>+ ok(!!ddraw, "Failed to create a ddraw object.\n");
>+ hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d2);
>+ ok(hr == DD_OK, "Failed to get d3d interface, hr %#x.\n", hr);
>+
>+ hr = IDirect3D2_EnumDevices(d3d2, NULL, NULL);
>+ ok(hr == DDERR_INVALIDPARAMS, "IDirect3D2_EnumDevices returned 0x%08x\n", hr);
>+ hr = IDirect3D2_EnumDevices(d3d2, enumDevicesCallback, &nb_devices);
>+ ok(hr == DD_OK, "IDirect3D2_EnumDevices returned 0x%08x\n", hr);
>+
>+ for(i = 0; i < ARRAY_SIZE(enumerated); i++)
>+ ok(nb_devices[i] == !enumerated[i], "device %u should not be enumerated in ddraw 2\n", i);
>+
>+ /* RGB device should always be enumerated */
>+ ok(nb_devices[1], "No RGB Device enumerated.\n");
>+
>+ d3d2_cancel_test.desired_ret = DDENUMRET_CANCEL;
>+ d3d2_cancel_test.total = 0;
>+ hr = IDirect3D2_EnumDevices(d3d2, enumDevicesCancelTest, &d3d2_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d2_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d2_cancel_test.total);
>+
>+ /* An enumeration callback can return any value besides DDENUMRET_OK to stop enumeration. */
>+ d3d2_cancel_test.desired_ret = E_INVALIDARG;
>+ d3d2_cancel_test.total = 0;
>+ hr = IDirect3D2_EnumDevices(d3d2, enumDevicesCancelTest, &d3d2_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d2_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d2_cancel_test.total);
>+
>+ IDirect3D2_Release(d3d2);
>+ IDirectDraw2_Release(ddraw);
>+ return;
>+}
>+
> START_TEST(ddraw2)
> {
> DDDEVICEIDENTIFIER identifier;
>@@ -14068,4 +14212,5 @@ START_TEST(ddraw2)
> test_clipper_refcount();
> test_caps();
> test_d32_support();
>+ test_enum_device();
> }
>diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
>old mode 100644
>new mode 100755
>index fdcf6dff87..ab0e19b739
>--- a/dlls/ddraw/tests/ddraw4.c
>+++ b/dlls/ddraw/tests/ddraw4.c
>@@ -56,6 +56,11 @@ struct create_window_thread_param
> HANDLE thread;
> };
>
>+typedef struct {
>+ HRESULT desired_ret;
>+ int total;
>+} D3D4ECancelTest;
>+
> static BOOL compare_float(float f, float g, unsigned int ulps)
> {
> int x = *(int *)&f;
>@@ -16504,6 +16509,145 @@ static void test_d32_support(void)
> DestroyWindow(window);
> }
>
>+static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ UINT i;
>+ UINT *number_devices = (UINT *)ctx;
>+ char name[][20] =
>+ {"Ramp Emulation", "RGB Emulation", "Direct3D HAL", "MMX Emulation", "Reference Rasterizer", "Null device", "Direct3D T&L HAL"};
>+ struct
>+ {
>+ GUID guid;
>+ DWORD hal_line_pow2;
>+ DWORD hal_tri_pow2;
>+ DWORD hal_line_nonpow2cond;
>+ DWORD hal_tri_nonpow2cond;
>+ D3DCOLORMODEL hal_colormodel;
>+ BOOL hal_dwFlags;
>+ DWORD size;
>+ } test_device_hal[]=
>+ {
>+ {IID_IDirect3DRampDevice, 0, 0, 0, 0, 0, 0, 0xfc},
>+ {IID_IDirect3DRGBDevice, 0, 0, 0, 0, 0, 0, 0xfc},
>+ {IID_IDirect3DHALDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xfc},
>+ {IID_IDirect3DMMXDevice, 0, 0, 0, 0, 0, 0, 0xfc},
>+ {IID_IDirect3DRefDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xfc},
>+ {IID_IDirect3DNullDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xfc},
>+ {IID_IDirect3DTnLHalDevice, 0, 0, 0, 0, D3DCOLOR_RGB, 1, 0xfc}
>+ };
>+
>+ struct
>+ {
>+ DWORD hel_line_pow2;
>+ DWORD hel_tri_pow2;
>+ DWORD hel_line_nonpow2cond;
>+ DWORD hel_tri_nonpow2cond;
>+ D3DCOLORMODEL hel_colormodel;
>+ BOOL hel_dwFlags;
>+ DWORD size;
>+ } test_device_hel[]=
>+ {
>+ {0x2, 0x2, 0, 0, D3DCOLOR_MONO, 1, 0xfc},
>+ {0x2, 0x2, 0, 0, D3DCOLOR_RGB, 1, 0xfc},
>+ {0, 0, 0, 0, 0, 1, 0xfc},
>+ {0, 0, 0xff, 0xff, D3DCOLOR_RGB, 1, 0xfc},
>+ {0, 0, 0xff, 0xff, 0, 1, 0xfc},
>+ {0, 0, 0xff, 0xff, 0, 1, 0xfc},
>+ {0, 0, 0xff, 0xff, 1, D3DCOLOR_RGB, 0xfc}
>+ };
>+
>+ i = 0;
>+ while((!IsEqualGUID(&test_device_hal[i].guid, Guid)) && (i < ARRAY_SIZE(name)))
>+ i++;
>+
>+ ok(!strcmp(DeviceName, name[i]), "Test %d, wrong device name\n", i);
>+ number_devices[i]++;
>+
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_line_pow2,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hal[i].hal_tri_pow2,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_line_nonpow2cond,
>+ "Test %d, hal line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hal[i].hal_tri_nonpow2cond,
>+ "Test %d, hal tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hal->dwFlags == test_device_hal[i].hal_dwFlags, "Test %d, hal device hal caps has a wrong hardware flag %x\n", i, hal->dwFlags);
>+ ok(hal->dcmColorModel == test_device_hal[i].hal_colormodel, "Test %d, hal caps has a wrong colormodel %u\n", i, hal->dcmColorModel);
>+ ok(hal->dwSize == test_device_hal[i].size, "Test %d, hal has a wrong size %u instead of %u\n", i, hal->dwSize, test_device_hal[i].size);
>+
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_line_pow2,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device_hel[i].hel_tri_pow2,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_line_nonpow2cond,
>+ "Test %d, hel line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device_hel[i].hel_tri_nonpow2cond,
>+ "Test %d, hel tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok(!!hel->dwFlags == test_device_hel[i].hel_dwFlags, "Test %d, hel device hel caps has a wrong hardware flag %x\n", i, hel->dwFlags);
>+ ok(hel->dcmColorModel == test_device_hel[i].hel_colormodel, "Test %d, hel caps has a wrong colormodel %u\n", i, hel->dcmColorModel);
>+ ok(hel->dwSize == test_device_hel[i].size, "Test %d, hel has a wrong size %u instead of %u\n", i, hel->dwSize, test_device_hel[i].size);
>+
>+ return DDENUMRET_OK;
>+}
>+
>+static HRESULT WINAPI enumDevicesCancelTest(GUID *Guid, char *DeviceDescription,
>+ char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx)
>+{
>+ D3D4ECancelTest *d3d3et = ctx;
>+
>+ d3d3et->total++;
>+ return d3d3et->desired_ret;
>+}
>+
>+static void test_enum_device(void)
>+{
>+ BOOL enumerated[] = {0, 1, 1, 1, 0, 1, 0};
>+ D3D4ECancelTest d3d3_cancel_test;
>+ IDirectDraw4 *ddraw;
>+ IDirect3D3 *d3d3;
>+ HRESULT hr;
>+ UINT nb_devices[] = {0, 0, 0, 0, 0, 0, 0};
>+ UINT i;
>+
>+ ddraw = create_ddraw();
>+ ok(!!ddraw, "Failed to create a ddraw object.\n");
>+ hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d3);
>+ ok(hr == DD_OK, "Failed to get d3d interface, hr %#x.\n", hr);
>+
>+ hr = IDirect3D3_EnumDevices(d3d3, NULL, NULL);
>+ ok(hr == DDERR_INVALIDPARAMS, "IDirect3D3_EnumDevices returned 0x%08x\n", hr);
>+ hr = IDirect3D3_EnumDevices(d3d3, enumDevicesCallback, &nb_devices);
>+ ok(hr == DD_OK, "IDirect3D3_EnumDevices returned 0x%08x\n", hr);
>+
>+ for(i = 0; i < ARRAY_SIZE(enumerated); i++)
>+ ok(nb_devices[i] == !enumerated[i], "device %u should not be enumerated in ddraw 4\n", i);
>+
>+ /* RGB device should always be enumerated */
>+ ok(nb_devices[1], "No RGB Device enumerated.\n");
>+
>+ d3d3_cancel_test.desired_ret = DDENUMRET_CANCEL;
>+ d3d3_cancel_test.total = 0;
>+ hr = IDirect3D3_EnumDevices(d3d3, enumDevicesCancelTest, &d3d3_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d3_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d3_cancel_test.total);
>+
>+ /* An enumeration callback can return any value besides DDENUMRET_OK to stop enumeration. */
>+ d3d3_cancel_test.desired_ret = E_INVALIDARG;
>+ d3d3_cancel_test.total = 0;
>+ hr = IDirect3D3_EnumDevices(d3d3, enumDevicesCancelTest, &d3d3_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d3_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d3_cancel_test.total);
>+
>+ IDirect3D3_Release(d3d3);
>+ IDirectDraw4_Release(ddraw);
>+ return;
>+}
>+
> START_TEST(ddraw4)
> {
> DDDEVICEIDENTIFIER identifier;
>@@ -16638,4 +16782,5 @@ START_TEST(ddraw4)
> test_clipper_refcount();
> test_caps();
> test_d32_support();
>+ test_enum_device();
> }
>diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
>old mode 100644
>new mode 100755
>index 279263fe37..7e5fbf73bc
>--- a/dlls/ddraw/tests/ddraw7.c
>+++ b/dlls/ddraw/tests/ddraw7.c
>@@ -56,6 +56,11 @@ struct create_window_thread_param
> HANDLE thread;
> };
>
>+typedef struct {
>+ HRESULT desired_ret;
>+ int total;
>+} D3D7ECancelTest;
>+
> static BOOL compare_float(float f, float g, unsigned int ulps)
> {
> int x = *(int *)&f;
>@@ -16475,6 +16480,116 @@ static void test_d32_support(void)
> DestroyWindow(window);
> }
>
>+static HRESULT WINAPI enumDevicesCallback(char *DeviceDescription, char *DeviceName,
>+ D3DDEVICEDESC7 *dd7, void *ctx)
>+{
>+ UINT i;
>+ UINT *number_devices = (UINT *)ctx;
>+ char name[][20] =
>+ {"Ramp Emulation", "RGB Emulation", "Direct3D HAL", "MMX Emulation", "Reference Rasterizer", "Null device", "Direct3D T&L HAL"};
>+ struct
>+ {
>+ GUID guid;
>+ DWORD line_pow2;
>+ DWORD tri_pow2;
>+ DWORD line_nonpow2cond;
>+ DWORD tri_nonpow2cond;
>+ } test_device[]=
>+ {
>+ {IID_IDirect3DRampDevice, 0, 0, 0, 0},
>+ {IID_IDirect3DRGBDevice, 2, 2, 0, 0},
>+ {IID_IDirect3DHALDevice, 0, 0, 0, 0},
>+ {IID_IDirect3DMMXDevice, 0, 0, 0, 0},
>+ {IID_IDirect3DRefDevice, 0, 0, 0, 0},
>+ {IID_IDirect3DNullDevice, 0, 0, 0, 0},
>+ {IID_IDirect3DTnLHalDevice, 0, 0, 0, 0},
>+ };
>+
>+ i = 0;
>+ while((!IsEqualGUID(&test_device[i].guid, &dd7->deviceGUID)) && (i < ARRAY_SIZE(name)))
>+ i++;
>+
>+ ok(!strcmp(DeviceName, name[i]), "Test %d, wrong device name\n", i);
>+ number_devices[i]++;
>+ number_devices[ARRAY_SIZE(name)]++;
>+
>+ ok((dd7->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device[i].line_pow2,
>+ "Test %d, device line caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((dd7->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == test_device[i].tri_pow2,
>+ "Test %d, device tri caps has a wrong D3DPTEXTURECAPS_POW2 flag\n", i);
>+ ok((dd7->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device[i].line_nonpow2cond,
>+ "Test %d, device line caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+ ok((dd7->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == test_device[i].tri_nonpow2cond,
>+ "Test %d, device tri caps has a wrong D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag\n", i);
>+
>+ return DDENUMRET_OK;
>+}
>+
>+static HRESULT WINAPI enumDevicesCancelTest(char *DeviceDescription, char *DeviceName,
>+ D3DDEVICEDESC7 *dd7, void *ctx)
>+{
>+ D3D7ECancelTest *d3d7et = ctx;
>+
>+ d3d7et->total++;
>+ return d3d7et->desired_ret;
>+}
>+
>+static void test_enum_device(void)
>+{
>+ BOOL enumerated[] = {0, 1, 1, 1, 0, 1, 1};
>+ D3D7ECancelTest d3d7_cancel_test;
>+ IDirectDraw7 *ddraw;
>+ IDirect3D7 *d3d7;
>+ HRESULT hr;
>+ UINT nb_devices[] = {0, 0, 0, 0, 0, 0, 0, 0};
>+ UINT i, size;
>+
>+ ddraw = create_ddraw();
>+ ok(!!ddraw, "Failed to create a ddraw object.\n");
>+ hr = IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d7);
>+ ok(hr == DD_OK, "Failed to get d7d interface, hr %#x.\n", hr);
>+
>+ hr = IDirect3D7_EnumDevices(d3d7, NULL, NULL);
>+ ok(hr == DDERR_INVALIDPARAMS, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
>+ hr = IDirect3D7_EnumDevices(d3d7, enumDevicesCallback, &nb_devices);
>+ ok(hr == DD_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
>+
>+ size = ARRAY_SIZE(enumerated);
>+ for(i = 0; i < size; i++)
>+ ok(nb_devices[i] == !enumerated[i], "device %u should not be enumerated in ddraw 7\n", i);
>+
>+ ok(nb_devices[size - 2] < nb_devices[size - 1], "TnLHal device enumerated as only device.\n");
>+ ok(nb_devices[1], "No RGB Device enumerated.\n");
>+
>+ d3d7_cancel_test.desired_ret = DDENUMRET_CANCEL;
>+ d3d7_cancel_test.total = 0;
>+ hr = IDirect3D7_EnumDevices(d3d7, enumDevicesCancelTest, &d3d7_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ for(i = 0; i < ARRAY_SIZE(enumerated); i++)
>+ if (2== 2)
>+ ok(enumerated[i] == !!nb_devices[i], "uncorrect enumeration of device %u\n", i);
>+ else /*windows >=8 enumerates HAL device*/
>+ ok(enumerated[i] == !!nb_devices[i] || broken(enumerated[i] != !!nb_devices[i]),
>+ "uncorrect enumeration of device %u\n", i);
>+
>+ ok(d3d7_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d7_cancel_test.total);
>+
>+ /* An enumeration callback can return any value besides DDENUMRET_OK to stop enumeration. */
>+ d3d7_cancel_test.desired_ret = E_INVALIDARG;
>+ d3d7_cancel_test.total = 0;
>+ hr = IDirect3D7_EnumDevices(d3d7, enumDevicesCancelTest, &d3d7_cancel_test);
>+ ok(hr == D3D_OK, "IDirect3D_EnumDevices returned 0x%08x\n", hr);
>+
>+ ok(d3d7_cancel_test.total == 1, "Enumerated a total of %u devices\n",
>+ d3d7_cancel_test.total);
>+
>+ IDirect3D7_Release(d3d7);
>+ IDirectDraw7_Release(ddraw);
>+ return;
>+}
>+
> START_TEST(ddraw7)
> {
> DDDEVICEIDENTIFIER2 identifier;
>@@ -16623,4 +16738,5 @@ START_TEST(ddraw7)
> test_begin_end_state_block();
> test_caps();
> test_d32_support();
>+ test_enum_device();
> }
>--
>2.19.1
>
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list