From 99cbab729b79321340bb08874f079a6ae997991a Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 23 Mar 2023 16:15:05 -0500 Subject: [PATCH] ddraw/tests: Make test_texture_wrong_caps() a bit clearer. * Disable lighting, which affects rendering tests in non-obvious ways. * Show that the texture is explicitly never set in ddraw7. * Show that the diffuse color is rendered in ddraw4 and ddraw7, which is consistent with the texture being unset in ddraw7 and suggests that the same applies to ddraw4. This may or may not help with bug 54069, but if it does not, it hopefully will at least make the reason for failure clearer. --- dlls/ddraw/tests/ddraw1.c | 1 + dlls/ddraw/tests/ddraw2.c | 8 +++++++- dlls/ddraw/tests/ddraw4.c | 24 ++++++++++++++++-------- dlls/ddraw/tests/ddraw7.c | 20 +++++++++++++------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index d52824dbc43..cde80c58e99 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -14748,6 +14748,7 @@ static void test_texture_wrong_caps(const GUID *device_guid) ptr = (BYTE *)exec_desc.lpData + sizeof(quad); emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4); emit_set_rs(&ptr, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle); + emit_set_rs(&ptr, D3DRENDERSTATE_LIGHTING, FALSE); emit_tquad(&ptr, 0); emit_end(&ptr); inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData - sizeof(quad); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index c24975daa92..86056014f96 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -15651,9 +15651,9 @@ static void test_texture_wrong_caps(const GUID *device_guid) {32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000} }; D3DRECT clear_rect = {{0}, {0}, {640}, {480}}; + D3DTEXTUREHANDLE texture_handle, ret_handle; unsigned int color, expected_color; IDirectDrawSurface *surface, *rt; - D3DTEXTUREHANDLE texture_handle; IDirect3DMaterial2 *background; IDirect3DViewport2 *viewport; IDirect3DTexture2 *texture; @@ -15698,8 +15698,14 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &ret_handle); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine_if (!is_software_device_type(device_guid)) + ok(ret_handle == texture_handle, "Got handle %#lx.\n", ret_handle); background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f); viewport_set_background(device, viewport, background); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 8bd3f3eac53..4458cea5145 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -18697,14 +18697,15 @@ static void test_texture_wrong_caps(const GUID *device_guid) static struct { struct vec3 position; + unsigned int diffuse; struct vec2 texcoord; } quad[] = { - {{-1.0f, -1.0f, 0.0f}, {0.0f, 1.0f}}, - {{-1.0f, 1.0f, 0.0f}, {0.0f, 0.0f}}, - {{ 1.0f, -1.0f, 0.0f}, {1.0f, 1.0f}}, - {{ 1.0f, 1.0f, 0.0f}, {1.0f, 0.0f}}, + {{-1.0f, -1.0f, 0.0f}, 0x00ff0000, {0.0f, 1.0f}}, + {{-1.0f, 1.0f, 0.0f}, 0x00ff0000, {0.0f, 0.0f}}, + {{ 1.0f, -1.0f, 0.0f}, 0x00ff0000, {1.0f, 1.0f}}, + {{ 1.0f, 1.0f, 0.0f}, 0x00ff0000, {1.0f, 0.0f}}, }; static DDPIXELFORMAT fmt = { @@ -18712,10 +18713,10 @@ static void test_texture_wrong_caps(const GUID *device_guid) {32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000} }; D3DRECT clear_rect = {{0}, {0}, {640}, {480}}; + IDirect3DTexture2 *texture, *ret_texture; unsigned int color, expected_color; IDirectDrawSurface4 *surface, *rt; IDirect3DViewport3 *viewport; - IDirect3DTexture2 *texture; IDirect3DDevice3 *device; IDirectDraw4 *ddraw; DDSURFACEDESC2 ddsd; @@ -18758,6 +18759,8 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); @@ -18766,21 +18769,26 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); - ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice3_SetTexture(device, 0, texture); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice3_GetTexture(device, 0, &ret_texture); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine_if (!is_software_device_type(device_guid)) + ok(ret_texture == texture, "Got texture %p.\n", ret_texture); + hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_BeginScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, - D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0); + D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, quad, 4, 0); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_EndScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); - expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff; + expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ff0000; color = get_surface_color(rt, 320, 240); ok(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 1980fbc993e..bbb78169aea 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -19031,21 +19031,22 @@ static void test_texture_wrong_caps(const GUID *device_guid) static struct { struct vec3 position; + unsigned int diffuse; struct vec2 texcoord; } quad[] = { - {{-1.0f, -1.0f, 0.0f}, {0.0f, 1.0f}}, - {{-1.0f, 1.0f, 0.0f}, {0.0f, 0.0f}}, - {{ 1.0f, -1.0f, 0.0f}, {1.0f, 1.0f}}, - {{ 1.0f, 1.0f, 0.0f}, {1.0f, 0.0f}}, + {{-1.0f, -1.0f, 0.0f}, 0x00ff0000, {0.0f, 1.0f}}, + {{-1.0f, 1.0f, 0.0f}, 0x00ff0000, {0.0f, 0.0f}}, + {{ 1.0f, -1.0f, 0.0f}, 0x00ff0000, {1.0f, 1.0f}}, + {{ 1.0f, 1.0f, 0.0f}, 0x00ff0000, {1.0f, 0.0f}}, }; static DDPIXELFORMAT fmt = { sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0, {32}, {0x00ff0000}, {0x0000ff00}, {0x000000ff}, {0xff000000} }; - IDirectDrawSurface7 *surface, *rt; + IDirectDrawSurface7 *surface, *rt, *ret_surface; IDirect3DDevice7 *device; IDirectDraw7 *ddraw; DDSURFACEDESC2 ddsd; @@ -19083,6 +19084,8 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); @@ -19095,6 +19098,9 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice7_SetTexture(device, 0, surface); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice7_GetTexture(device, 0, &ret_surface); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + ok(!ret_surface, "Got surface %p.\n", ret_surface); hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0); ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); @@ -19104,13 +19110,13 @@ static void test_texture_wrong_caps(const GUID *device_guid) hr = IDirect3DDevice7_BeginScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, - D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0); + D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, quad, 4, 0); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice7_EndScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); color = get_surface_color(rt, 320, 240); - ok(color == 0, "Got unexpected color 0x%08x.\n", color); + ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color); IDirectDrawSurface7_Release(surface); IDirectDrawSurface7_Release(rt);