From: David Adam Subject: patch [5/5] ddraw: Remove Enumdevices from d3d Message-Id: Date: Tue, 2 Apr 2019 20:40:53 -1000

From 04dc461a712a10c8cb77ac03cd35f26582ed9f25 Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 2 Apr 2019 20:31:08 -1000 Subject: [PATCH 2/2] Remove Enumdevices tests from d3d Signed-off-by: David Adam --- dlls/ddraw/tests/d3d.c | 349 ----------------------------------------- 1 file changed, 349 deletions(-) diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 64f68fde56..5c43c3c302 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -44,29 +44,6 @@ static IDirect3DExecuteBuffer *ExecuteBuffer = NULL; static IDirect3DViewport *Viewport = NULL; static IDirect3DLight *Light = NULL; -typedef struct { - int total; - int rgb; - int hal; - int tnlhal; - int unk; -} D3D7ETest; - -typedef struct { - HRESULT desired_ret; - int total; -} D3D7ECancelTest; - -#define MAX_ENUMERATION_COUNT 10 -typedef struct -{ - unsigned int count; - char *callback_description_ptrs[MAX_ENUMERATION_COUNT]; - char callback_description_strings[MAX_ENUMERATION_COUNT][100]; - char *callback_name_ptrs[MAX_ENUMERATION_COUNT]; - char callback_name_strings[MAX_ENUMERATION_COUNT][100]; -} D3D7ELifetimeTest; - static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID *driver_guid, void **ddraw, REFIID interface_iid, IUnknown *outer); @@ -470,329 +447,6 @@ static void SceneTest(void) /* TODO: Verify that blitting works in the same way as in d3d9 */ } -static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription, - char *DeviceName, D3DDEVICEDESC *hal, D3DDEVICEDESC *hel, void *ctx) -{ - UINT ver = *((UINT *) ctx); - if(IsEqualGUID(&IID_IDirect3DRGBDevice, Guid)) - { - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "RGB Device %d hal line caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "RGB Device %d hal tri caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "RGB Device %d hel line caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "RGB Device %d hel tri caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "RGB Device %d hal line caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "RGB Device %d hal tri caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "RGB Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "RGB Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - - ok(hal->dcmColorModel == 0, "RGB Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel); - ok(hel->dcmColorModel == D3DCOLOR_RGB, "RGB Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel); - - ok(hal->dwFlags == 0, "RGB Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags); - ok(hel->dwFlags != 0, "RGB Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags); - } - else if(IsEqualGUID(&IID_IDirect3DHALDevice, Guid)) - { - trace("HAL Device %d\n", ver); - ok(hal->dcmColorModel == D3DCOLOR_RGB, "HAL Device %u hal caps has colormodel %u\n", ver, hel->dcmColorModel); - ok(hel->dcmColorModel == 0, "HAL Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel); - - ok(hal->dwFlags != 0, "HAL Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags); - ok(hel->dwFlags != 0, "HAL Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags); - } - else if(IsEqualGUID(&IID_IDirect3DRefDevice, Guid)) - { - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "REF Device %d hal line caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "REF Device %d hal tri caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "REF Device %d hel line caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "REF Device %d hel tri caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "REF Device %d hal line caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "REF Device %d hal tri caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "REF Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "REF Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - } - else if(IsEqualGUID(&IID_IDirect3DRampDevice, Guid)) - { - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "Ramp Device %d hal line caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "Ramp Device %d hal tri caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "Ramp Device %d hel line caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "Ramp Device %d hel tri caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "Ramp Device %d hal line caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "Ramp Device %d hal tri caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "Ramp Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "Ramp Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - - ok(hal->dcmColorModel == 0, "Ramp Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel); - ok(hel->dcmColorModel == D3DCOLOR_MONO, "Ramp Device %u hel caps has colormodel %u\n", - ver, hel->dcmColorModel); - - ok(hal->dwFlags == 0, "Ramp Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags); - ok(hel->dwFlags != 0, "Ramp Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags); - } - else if(IsEqualGUID(&IID_IDirect3DMMXDevice, Guid)) - { - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "MMX Device %d hal line caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) == 0, - "MMX Device %d hal tri caps has D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "MMX Device %d hel line caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2, - "MMX Device %d hel tri caps does not have D3DPTEXTURECAPS_POW2 flag set\n", ver); - - ok((hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "MMX Device %d hal line caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok((hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE) == 0, - "MMX Device %d hal tri caps has D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "MMX Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, - "MMX Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); - - ok(hal->dcmColorModel == 0, "MMX Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel); - ok(hel->dcmColorModel == D3DCOLOR_RGB, "MMX Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel); - - ok(hal->dwFlags == 0, "MMX Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags); - ok(hel->dwFlags != 0, "MMX Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags); - } - else - { - ok(FALSE, "Unexpected device enumerated: \"%s\" \"%s\"\n", DeviceDescription, DeviceName); - if(hal->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) trace("hal line has pow2 set\n"); - else trace("hal line does NOT have pow2 set\n"); - if(hal->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) trace("hal tri has pow2 set\n"); - else trace("hal tri does NOT have pow2 set\n"); - if(hel->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) trace("hel line has pow2 set\n"); - else trace("hel line does NOT have pow2 set\n"); - if(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2) trace("hel tri has pow2 set\n"); - else trace("hel tri does NOT have pow2 set\n"); - } - return DDENUMRET_OK; -} - -static HRESULT WINAPI enumDevicesCallbackTest7(char *DeviceDescription, char *DeviceName, - D3DDEVICEDESC7 *lpdd7, void *Context) -{ - D3D7ETest *d3d7et = Context; - if(IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DRGBDevice)) - d3d7et->rgb++; - else if(IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DHALDevice)) - d3d7et->hal++; - else if(IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DTnLHalDevice)) - d3d7et->tnlhal++; - else - d3d7et->unk++; - - d3d7et->total++; - - return DDENUMRET_OK; -} - -static HRESULT WINAPI enumDevicesCancelTest7(char *DeviceDescription, char *DeviceName, - D3DDEVICEDESC7 *lpdd7, void *Context) -{ - D3D7ECancelTest *d3d7et = Context; - - d3d7et->total++; - - return d3d7et->desired_ret; -} - -static HRESULT WINAPI enumDevicesLifetimeTest7(char *DeviceDescription, char *DeviceName, - D3DDEVICEDESC7 *lpdd7, void *Context) -{ - D3D7ELifetimeTest *ctx = Context; - - if (ctx->count == MAX_ENUMERATION_COUNT) - { - ok(0, "Enumerated too many devices for context in callback\n"); - return DDENUMRET_CANCEL; - } - - ctx->callback_description_ptrs[ctx->count] = DeviceDescription; - strcpy(ctx->callback_description_strings[ctx->count], DeviceDescription); - ctx->callback_name_ptrs[ctx->count] = DeviceName; - strcpy(ctx->callback_name_strings[ctx->count], DeviceName); - - ctx->count++; - return DDENUMRET_OK; -} - -/* Check the deviceGUID of devices enumerated by - IDirect3D7_EnumDevices. */ -static void D3D7EnumTest(void) -{ - HRESULT hr; - D3D7ETest d3d7et; - D3D7ECancelTest d3d7_cancel_test; - - hr = IDirect3D7_EnumDevices(lpD3D, NULL, NULL); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - memset(&d3d7et, 0, sizeof(d3d7et)); - hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCallbackTest7, &d3d7et); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - /* A couple of games (Delta Force LW and TFD) rely on this behaviour */ - ok(d3d7et.tnlhal < d3d7et.total, "TnLHal device enumerated as only device.\n"); - - /* We make two additional assumptions. */ - ok(d3d7et.rgb, "No RGB Device enumerated.\n"); - - if(d3d7et.tnlhal) - ok(d3d7et.hal, "TnLHal device enumerated, but no Hal device found.\n"); - - d3d7_cancel_test.desired_ret = DDENUMRET_CANCEL; - d3d7_cancel_test.total = 0; - hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCancelTest7, &d3d7_cancel_test); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - 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(lpD3D, enumDevicesCancelTest7, &d3d7_cancel_test); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - ok(d3d7_cancel_test.total == 1, "Enumerated a total of %u devices\n", - d3d7_cancel_test.total); -} - -static void D3D7EnumLifetimeTest(void) -{ - D3D7ELifetimeTest ctx, ctx2; - HRESULT hr; - unsigned int i; - - ctx.count = 0; - hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - /* The enumeration strings remain valid even after IDirect3D7_EnumDevices finishes. */ - for (i = 0; i < ctx.count; i++) - { - ok(!strcmp(ctx.callback_description_ptrs[i], ctx.callback_description_strings[i]), - "Got '%s' and '%s'\n", ctx.callback_description_ptrs[i], ctx.callback_description_strings[i]); - ok(!strcmp(ctx.callback_name_ptrs[i], ctx.callback_name_strings[i]), - "Got '%s' and '%s'\n", ctx.callback_name_ptrs[i], ctx.callback_name_strings[i]); - } - - ctx2.count = 0; - hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx2); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - /* The enumeration strings and their order are identical across enumerations. */ - ok(ctx.count == ctx2.count, "Enumerated %u and %u devices\n", ctx.count, ctx2.count); - if (ctx.count == ctx2.count) - { - for (i = 0; i < ctx.count; i++) - { - ok(ctx.callback_description_ptrs[i] == ctx2.callback_description_ptrs[i], - "Unequal description pointers %p and %p\n", ctx.callback_description_ptrs[i], ctx2.callback_description_ptrs[i]); - ok(!strcmp(ctx.callback_description_strings[i], ctx2.callback_description_strings[i]), - "Got '%s' and '%s'\n", ctx.callback_description_strings[i], ctx2.callback_description_strings[i]); - ok(ctx.callback_name_ptrs[i] == ctx2.callback_name_ptrs[i], - "Unequal name pointers %p and %p\n", ctx.callback_name_ptrs[i], ctx2.callback_name_ptrs[i]); - ok(!strcmp(ctx.callback_name_strings[i], ctx2.callback_name_strings[i]), - "Got '%s' and '%s'\n", ctx.callback_name_strings[i], ctx2.callback_name_strings[i]); - } - } - - /* Try altering the contents of the enumeration strings. */ - for (i = 0; i < ctx2.count; i++) - { - strcpy(ctx2.callback_description_ptrs[i], "Fake Description"); - strcpy(ctx2.callback_name_ptrs[i], "Fake Device"); - } - - ctx2.count = 0; - hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx2); - ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr); - - /* The original contents of the enumeration strings are not restored. */ - ok(ctx.count == ctx2.count, "Enumerated %u and %u devices\n", ctx.count, ctx2.count); - if (ctx.count == ctx2.count) - { - for (i = 0; i < ctx.count; i++) - { - ok(ctx.callback_description_ptrs[i] == ctx2.callback_description_ptrs[i], - "Unequal description pointers %p and %p\n", ctx.callback_description_ptrs[i], ctx2.callback_description_ptrs[i]); - ok(strcmp(ctx.callback_description_strings[i], ctx2.callback_description_strings[i]) != 0, - "Got '%s' and '%s'\n", ctx.callback_description_strings[i], ctx2.callback_description_strings[i]); - ok(ctx.callback_name_ptrs[i] == ctx2.callback_name_ptrs[i], - "Unequal name pointers %p and %p\n", ctx.callback_name_ptrs[i], ctx2.callback_name_ptrs[i]); - ok(strcmp(ctx.callback_name_strings[i], ctx2.callback_name_strings[i]) != 0, - "Got '%s' and '%s'\n", ctx.callback_name_strings[i], ctx2.callback_name_strings[i]); - } - } -} - -static void CapsTest(void) -{ - IDirect3D3 *d3d3; - IDirect3D3 *d3d2; - IDirectDraw *dd1; - HRESULT hr; - UINT ver; - - hr = DirectDrawCreate(NULL, &dd1, NULL); - ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08x\n", hr); - hr = IDirectDraw_QueryInterface(dd1, &IID_IDirect3D3, (void **) &d3d3); - ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08x\n", hr); - - hr = IDirect3D3_EnumDevices(d3d3, NULL, NULL); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3D3_EnumDevices returned 0x%08x\n", hr); - - ver = 3; - IDirect3D3_EnumDevices(d3d3, enumDevicesCallback, &ver); - - IDirect3D3_Release(d3d3); - IDirectDraw_Release(dd1); - - hr = DirectDrawCreate(NULL, &dd1, NULL); - ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08x\n", hr); - hr = IDirectDraw_QueryInterface(dd1, &IID_IDirect3D2, (void **) &d3d2); - ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08x\n", hr); - - hr = IDirect3D2_EnumDevices(d3d2, NULL, NULL); - ok(hr == DDERR_INVALIDPARAMS, "IDirect3D2_EnumDevices returned 0x%08x\n", hr); - - ver = 2; - IDirect3D2_EnumDevices(d3d2, enumDevicesCallback, &ver); - - IDirect3D2_Release(d3d2); - IDirectDraw_Release(dd1); -} - struct v_in { float x, y, z; }; @@ -2223,10 +1877,7 @@ START_TEST(d3d) } else { LightTest(); SceneTest(); - D3D7EnumTest(); - D3D7EnumLifetimeTest(); SetMaterialTest(); - CapsTest(); VertexBufferDescTest(); SetRenderTargetTest(); VertexBufferLockRest(); -- 2.19.1