Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 91ae2e34ae..925ae96aa7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3441,8 +3441,8 @@ static void compute_light(struct wined3d_color *ambient, struct wined3d_color *d float att;
wined3d_vec4_transform(&position_transformed, position, &ls->modelview_matrix); + wined3d_vec3_scale((struct wined3d_vec3 *)&position_transformed, 1.0f / position_transformed.w); position_transformed_normalised = *(const struct wined3d_vec3 *)&position_transformed; - wined3d_vec3_scale(&position_transformed_normalised, 1.0f / position_transformed.w); wined3d_vec3_normalise(&position_transformed_normalised);
if (normal)
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/vertexbuffer.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c index d2c2f8ff80..07c0d28c62 100644 --- a/dlls/ddraw/vertexbuffer.c +++ b/dlls/ddraw/vertexbuffer.c @@ -260,7 +260,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 struct d3d_device *device_impl = dst_buffer_impl->version == 7 ? unsafe_impl_from_IDirect3DDevice7(device) : unsafe_impl_from_IDirect3DDevice3((IDirect3DDevice3 *)device); - BOOL oldClip, doClip; + BOOL old_clip, do_clip, old_lighting, do_lighting; HRESULT hr;
TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n", @@ -285,10 +285,20 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 * render states instead. Set the render states according to * the vertex ops */ - doClip = !!(vertex_op & D3DVOP_CLIP); - oldClip = wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING); - if (doClip != oldClip) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, doClip); + do_clip = !!(vertex_op & D3DVOP_CLIP); + old_clip = !!wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING); + if (do_clip != old_clip) + wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, do_clip); + + old_lighting = !!wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING); + if (dst_buffer_impl->version == 3) + do_lighting = device_impl->material && (src_buffer_impl->fvf & D3DFVF_NORMAL) + && (vertex_op & D3DVOP_LIGHT); + else + do_lighting = old_lighting && (vertex_op & D3DVOP_LIGHT); + + if (do_lighting != old_lighting) + wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING, do_lighting);
wined3d_device_set_stream_source(device_impl->wined3d_device, 0, src_buffer_impl->wined3d_buffer, 0, get_flexible_vertex_size(src_buffer_impl->fvf)); @@ -297,8 +307,10 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 count, dst_buffer_impl->wined3d_buffer, NULL, flags, dst_buffer_impl->fvf);
/* Restore the states if needed */ - if (doClip != oldClip) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, oldClip); + if (do_clip != old_clip) + wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, old_clip); + if (do_lighting != old_lighting) + wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING, old_lighting);
wined3d_mutex_unlock();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=52687
Your paranoid android.
=== debian9 (64 bit WoW report) ===
ddraw: ddraw1.c:2681: Test failed: Expected message 0x46, but didn't receive it. ddraw1.c:2683: Test failed: Expected screen size 1920x1200, got 0x0. ddraw1.c:2688: Test failed: Expected (0,0)-(1920,1200), got (0,0)-(1920,1080).
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 925ae96aa7..ffa6b59003 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3190,8 +3190,7 @@ static void wined3d_colour_from_mcs(struct wined3d_color *colour, enum wined3d_m case WINED3D_MCS_COLOR2: if (!(stream_info->use_map & (1u << WINED3D_FFP_SPECULAR))) { - colour->r = colour->g = colour->b = 0.0f; - colour->a = 1.0f; + colour->r = colour->g = colour->b = colour->a = 0.0f; return; } element = &stream_info->elements[WINED3D_FFP_SPECULAR]; @@ -3845,7 +3844,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO specular_colour.r = specular.r * material_specular.r; specular_colour.g = specular.g * material_specular.g; specular_colour.b = specular.b * material_specular.b; - specular_colour.a = 1.0f; + specular_colour.a = ls.legacy_lighting ? 0.0f : material_specular.a; } else {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw7.c | 377 ++++++++++++++++++++++++++++---------- 1 file changed, 281 insertions(+), 96 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 9ba6a06ecc..889d12f230 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -20,6 +20,7 @@ #define COBJMACROS
#include "wine/test.h" +#include "wine/heap.h" #include <limits.h> #include <math.h> #include "d3d.h" @@ -3644,7 +3645,7 @@ static void test_lighting(void) 0.0f, 0.0f, 1.0f, -1.0f, 10.f, 10.0f, 10.0f, 0.0f, }; - static struct + static struct vertex { struct vec3 position; DWORD diffuse; @@ -3663,7 +3664,7 @@ static void test_lighting(void) {{ 0.0f, 1.0f, 0.1f}, 0xff00ff00}, {{ 0.0f, 0.0f, 0.1f}, 0xff00ff00}, }; - static struct + static struct vertex_normal { struct vec3 position; struct vec3 normal; @@ -3709,26 +3710,41 @@ static void test_lighting(void) { D3DMATRIX *world_matrix; void *quad; - DWORD expected; + DWORD expected, expected_process_vertices; + BOOL process_vertices_todo; const char *message; } tests[] = { - {&mat, nquad, 0x000000ff, "Lit quad with light"}, - {&mat_singular, nquad, 0x000000ff, "Lit quad with singular world matrix"}, - {&mat_transf, rotatedquad, 0x000000ff, "Lit quad with transformation matrix"}, - {&mat_nonaffine, translatedquad, 0x00000000, "Lit quad with non-affine matrix"}, + {&mat, nquad, 0x000000ff, 0xff0000ff, FALSE, "Lit quad with light"}, + {&mat_singular, nquad, 0x000000ff, 0xff000000, TRUE, "Lit quad with singular world matrix"}, + {&mat_transf, rotatedquad, 0x000000ff, 0xff0000ff, FALSE, "Lit quad with transformation matrix"}, + {&mat_nonaffine, translatedquad, 0x00000000, 0xff000000, FALSE, "Lit quad with non-affine matrix"}, };
- HWND window; + DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL; + IDirect3DVertexBuffer7 *src_vb1, *src_vb2, *dst_vb; + DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE; + struct vertex_normal *src_data2; + D3DVERTEXBUFFERDESC vb_desc; + struct vertex *src_data1; IDirect3DDevice7 *device; IDirectDrawSurface7 *rt; - HRESULT hr; - DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE; - DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL; + IDirectDraw7 *ddraw; + IDirect3D7 *d3d; D3DCOLOR color; ULONG refcount; unsigned int i; + BOOL is_warp; + HWND window; + HRESULT hr; + struct + { + struct vec4 position; + DWORD diffuse; + DWORD specular; + } + *dst_data;
window = create_window(); if (!(device = create_device(window, DDSCL_NORMAL))) @@ -3737,97 +3753,198 @@ static void test_lighting(void) DestroyWindow(window); return; } + hr = IDirect3DDevice7_GetDirect3D(device, &d3d); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + is_warp = ddraw_is_warp(ddraw);
hr = IDirect3DDevice7_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); - ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat); - ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat); - ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat); - ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable stencil buffering, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); - ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = fvf; + vb_desc.dwNumVertices = 2; + hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb1, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = nfvf; + vb_desc.dwNumVertices = 2; + hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb2, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR; + vb_desc.dwNumVertices = 4; + hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_Lock(src_vb1, 0, (void **)&src_data1, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data1, unlitquad, sizeof(*src_data1)); + memcpy(&src_data1[1], litquad, sizeof(*src_data1)); + hr = IDirect3DVertexBuffer7_Unlock(src_vb1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_Lock(src_vb2, 0, (void **)&src_data2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data2, unlitnquad, sizeof(*src_data2)); + memcpy(&src_data2[1], litnquad, sizeof(*src_data2)); + hr = IDirect3DVertexBuffer7_Unlock(src_vb2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* No lights are defined... That means, lit vertices should be entirely black. */ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, + 1, src_vb1, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE); - ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 1, + 1, src_vb1, 1, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 2, + 1, src_vb2, 0, device, 0); hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE); - ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 3, + 1, src_vb2, 1, device, 0); hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x, expected 0x00ff0000.\n", color); + ok(dst_data[0].diffuse == 0xffff0000, + "Unlit quad without normals has color 0x%08x, expected 0xffff0000.\n", dst_data[0].diffuse); + ok(!dst_data[0].specular, + "Unexpected specular color 0x%08x.\n", dst_data[0].specular); color = get_surface_color(rt, 160, 120); - ok(color == 0x00000000, "Lit quad without normals has color 0x%08x, expected 0x00000000.\n", color); + /* Broken on some of WARP drivers. */ + ok(color == 0x00000000 || broken(is_warp && color == 0x000000ff), + "Lit quad without normals has color 0x%08x, expected 0x00000000.\n", color); + ok(dst_data[1].diffuse == 0xff000000, + "Lit quad without normals has color 0x%08x, expected 0xff000000.\n", dst_data[1].diffuse); + ok(!dst_data[1].specular, + "Unexpected specular color 0x%08x.\n", dst_data[1].specular); color = get_surface_color(rt, 480, 360); ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08x, expected 0x000000ff.\n", color); + ok(dst_data[2].diffuse == 0xff0000ff, + "Unlit quad with normals has color 0x%08x, expected 0xff0000ff.\n", dst_data[2].diffuse); + ok(!dst_data[2].specular, + "Unexpected specular color 0x%08x.\n", dst_data[2].specular); color = get_surface_color(rt, 480, 120); - ok(color == 0x00000000, "Lit quad with normals has color 0x%08x, expected 0x00000000.\n", color); + ok(color == 0x00000000 || broken(is_warp && color == 0x000000ff), + "Lit quad with normals has color 0x%08x, expected 0x00000000.\n", color); + ok(dst_data[3].diffuse == 0xff000000, + "Lit quad with normals has color 0x%08x, expected 0xff000000.\n", dst_data[3].diffuse); + ok(!dst_data[3].specular, + "Unexpected specular color 0x%08x.\n", dst_data[3].specular); + + hr = IDirect3DVertexBuffer7_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); - ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(tests); ++i) { + hr = IDirect3DVertexBuffer7_Lock(src_vb2, 0, (void **)&src_data2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data2, tests[i].quad, sizeof(*src_data2)); + hr = IDirect3DVertexBuffer7_Unlock(src_vb2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix); - ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); - ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0, + 1, src_vb2, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, tests[i].quad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240); - ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color); + ok(color == tests[i].expected || broken(is_warp && color == 0x000000ff), + "%s has color 0x%08x.\n", tests[i].message, color); + todo_wine_if(tests[i].process_vertices_todo) + ok(dst_data[0].diffuse == tests[i].expected_process_vertices, + "%s has color 0x%08x.\n", tests[i].message, dst_data[0].diffuse); + ok(!dst_data[0].specular, + "%s has specular color 0x%08x.\n", tests[i].message, dst_data[0].specular); + + hr = IDirect3DVertexBuffer7_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); }
+ IDirect3DVertexBuffer7_Release(src_vb1); + IDirect3DVertexBuffer7_Release(src_vb2); + IDirect3DVertexBuffer7_Release(dst_vb); + IDirectDrawSurface7_Release(rt);
+ IDirect3D7_Release(d3d); refcount = IDirect3DDevice7_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); DestroyWindow(window); @@ -3845,6 +3962,24 @@ static void test_specular_lighting(void) 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; + static const struct vertex + { + struct vec3 position; + struct vec3 normal; + } + vertices[] = + { + {{-0.5f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{-0.5f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{-0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + }; + static D3DLIGHT7 directional = { D3DLIGHT_DIRECTIONAL, @@ -4006,18 +4141,6 @@ static void test_specular_lighting(void) {320, 360, 0x00000000}, {480, 360, 0x00000000}, }, - expected_directional_0[] = - { - {160, 120, 0x00ffffff}, - {320, 120, 0x00ffffff}, - {480, 120, 0x00ffffff}, - {160, 240, 0x00ffffff}, - {320, 240, 0x00ffffff}, - {480, 240, 0x00ffffff}, - {160, 360, 0x00ffffff}, - {320, 360, 0x00ffffff}, - {480, 360, 0x00ffffff}, - }, expected_directional_local_0[] = { {160, 120, 0x00ffffff}, @@ -4071,41 +4194,56 @@ static void test_specular_lighting(void) D3DLIGHT7 *light; BOOL local_viewer; float specular_power; - const struct expected_color *expected; + const struct expected_color *expected, *expected_process_vertices; unsigned int expected_count; + BOOL todo_process_vertices; } tests[] = { - {&directional, FALSE, 30.0f, expected_directional, ARRAY_SIZE(expected_directional)}, - {&directional, TRUE, 30.0f, expected_directional_local, ARRAY_SIZE(expected_directional_local)}, - {&point, FALSE, 30.0f, expected_point, ARRAY_SIZE(expected_point)}, - {&point, TRUE, 30.0f, expected_point_local, ARRAY_SIZE(expected_point_local)}, - {&spot, FALSE, 30.0f, expected_spot, ARRAY_SIZE(expected_spot)}, - {&spot, TRUE, 30.0f, expected_spot_local, ARRAY_SIZE(expected_spot_local)}, - {&point_range, FALSE, 30.0f, expected_point_range, ARRAY_SIZE(expected_point_range)}, - {&point_side, TRUE, 0.0f, expected_point_side, ARRAY_SIZE(expected_point_side)}, - {&directional, FALSE, 0.0f, expected_directional_0, ARRAY_SIZE(expected_directional_0)}, - {&directional, TRUE, 0.0f, expected_directional_local_0, ARRAY_SIZE(expected_directional_local_0)}, - {&point, FALSE, 0.0f, expected_point_0, ARRAY_SIZE(expected_point_0)}, - {&point, TRUE, 0.0f, expected_point_0, ARRAY_SIZE(expected_point_0)}, - {&spot, FALSE, 0.0f, expected_spot_0, ARRAY_SIZE(expected_spot_0)}, - {&spot, TRUE, 0.0f, expected_spot_0, ARRAY_SIZE(expected_spot_0)}, - {&point_range, FALSE, 0.0f, expected_point_range_0, ARRAY_SIZE(expected_point_range_0)}, - }; + {&directional, FALSE, 30.0f, expected_directional, expected_directional, + ARRAY_SIZE(expected_directional)}, + {&directional, TRUE, 30.0f, expected_directional_local, expected_directional_local, + ARRAY_SIZE(expected_directional_local)}, + {&point, FALSE, 30.0f, expected_point, expected_point, ARRAY_SIZE(expected_point)}, + {&point, TRUE, 30.0f, expected_point_local, expected_point_local, ARRAY_SIZE(expected_point_local)}, + {&spot, FALSE, 30.0f, expected_spot, expected_spot, ARRAY_SIZE(expected_spot)}, + {&spot, TRUE, 30.0f, expected_spot_local, expected_spot_local, ARRAY_SIZE(expected_spot_local)}, + {&point_range, FALSE, 30.0f, expected_point_range, expected_point_range, + ARRAY_SIZE(expected_point_range)}, + + /* For zero material shininess _ProcessVertices() seem to keep non-zero material shininess set previously. */ + {&point_side, TRUE, 0.0f, expected_point_side, expected_point_side, ARRAY_SIZE(expected_point_side), TRUE}, + {&directional, FALSE, 0.0f, expected_directional, expected_directional, + ARRAY_SIZE(expected_directional), TRUE}, + {&directional, TRUE, 0.0f, expected_directional_local_0, expected_directional_local, + ARRAY_SIZE(expected_directional_local_0), TRUE}, + {&point, FALSE, 0.0f, expected_point_0, expected_point, ARRAY_SIZE(expected_point_0), TRUE}, + {&point, TRUE, 0.0f, expected_point_0, expected_point_local, ARRAY_SIZE(expected_point_0), TRUE}, + {&spot, FALSE, 0.0f, expected_spot_0, expected_spot, ARRAY_SIZE(expected_spot_0), TRUE}, + {&spot, TRUE, 0.0f, expected_spot_0, expected_spot_local, ARRAY_SIZE(expected_spot_0), TRUE}, + {&point_range, FALSE, 0.0f, expected_point_range_0, expected_point_range, ARRAY_SIZE(expected_point_range_0), TRUE}, + }; + + IDirect3DVertexBuffer7 *src_vb, *dst_vb; + D3DCOLOR color, expected_color; + D3DVERTEXBUFFERDESC vb_desc; IDirect3DDevice7 *device; + unsigned int i, j, x, y; IDirectDrawSurface7 *rt; D3DMATERIAL7 material; - D3DCOLOR color; + struct vec3 *src_data; + struct vertex *quad; + IDirect3D7 *d3d; ULONG refcount; + WORD *indices; HWND window; HRESULT hr; - unsigned int i, j, x, y; struct { - struct vec3 position; - struct vec3 normal; - } *quad; - WORD *indices; + struct vec4 position; + DWORD diffuse; + DWORD specular; + } *dst_data;
window = create_window(); if (!(device = create_device(window, DDSCL_NORMAL))) @@ -4114,9 +4252,11 @@ static void test_specular_lighting(void) DestroyWindow(window); return; } + hr = IDirect3DDevice7_GetDirect3D(device, &d3d); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- quad = HeapAlloc(GetProcessHeap(), 0, vertices_side * vertices_side * sizeof(*quad)); - indices = HeapAlloc(GetProcessHeap(), 0, indices_count * sizeof(*indices)); + quad = heap_alloc(vertices_side * vertices_side * sizeof(*quad)); + indices = heap_alloc(indices_count * sizeof(*indices)); for (i = 0, y = 0; y < vertices_side; ++y) { for (x = 0; x < vertices_side; ++x) @@ -4143,56 +4283,89 @@ static void test_specular_lighting(void) }
hr = IDirect3DDevice7_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat); - ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat); - ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat); - ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_LightEnable(device, 0, TRUE); - ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE); - ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = fvf; + vb_desc.dwNumVertices = ARRAY_SIZE(vertices); + hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer7_Lock(src_vb, 0, (void **)&src_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data, vertices, sizeof(vertices)); + hr = IDirect3DVertexBuffer7_Unlock(src_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR; + vb_desc.dwNumVertices = ARRAY_SIZE(vertices); + hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(tests); ++i) { hr = IDirect3DDevice7_SetLight(device, 0, tests[i].light); - ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LOCALVIEWER, tests[i].local_viewer); - ok(SUCCEEDED(hr), "Failed to set local viewer state, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
memset(&material, 0, sizeof(material)); U1(U2(material).specular).r = 1.0f; U2(U2(material).specular).g = 1.0f; U3(U2(material).specular).b = 1.0f; - U4(U2(material).specular).a = 1.0f; + U4(U2(material).specular).a = 0.5f; U4(material).power = tests[i].specular_power; hr = IDirect3DDevice7_SetMaterial(device, &material); - ok(SUCCEEDED(hr), "Failed to set material, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); - ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memset(dst_data, 0, sizeof(*dst_data) * ARRAY_SIZE(vertices)); + hr = IDirect3DVertexBuffer7_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0, + ARRAY_SIZE(vertices), src_vb, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, quad, vertices_side * vertices_side, indices, indices_count, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + ok(tests[i].expected_count == ARRAY_SIZE(vertices), "Array size mismatch.\n"); for (j = 0; j < tests[i].expected_count; ++j) { color = get_surface_color(rt, tests[i].expected[j].x, tests[i].expected[j].y); @@ -4200,16 +4373,28 @@ static void test_specular_lighting(void) "Expected color 0x%08x at location (%u, %u), got 0x%08x, case %u.\n", tests[i].expected[j].color, tests[i].expected[j].x, tests[i].expected[j].y, color, i); + ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08x, case %u.\n", + j, dst_data[j].diffuse, i); + expected_color = tests[i].expected_process_vertices[j].color | 0x80000000; + todo_wine_if(tests[i].todo_process_vertices && dst_data[j].specular != expected_color) + ok(compare_color(dst_data[j].specular, expected_color, 1), + "Expected color 0x%08x for vertex %u, got 0x%08x, case %u.\n", + expected_color, j, dst_data[j].specular, i); } + hr = IDirect3DVertexBuffer7_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); }
+ IDirect3DVertexBuffer7_Release(dst_vb); + IDirect3DVertexBuffer7_Release(src_vb); IDirectDrawSurface7_Release(rt);
+ IDirect3D7_Release(d3d); refcount = IDirect3DDevice7_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); DestroyWindow(window); - HeapFree(GetProcessHeap(), 0, indices); - HeapFree(GetProcessHeap(), 0, quad); + heap_free(indices); + heap_free(quad); }
static void test_clear_rect_count(void)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=52689
Your paranoid android.
=== w1064v1809 (32 bit report) ===
ddraw: 1a2c:ddraw7: unhandled exception c0000005 at 72DB40F8
I've tested with a dummy patch (adding a newline into ddraw7.c), it happens regardless of my changes: https://testbot.winehq.org/JobDetails.pl?Key=52691#k214
On 5/22/19 13:38, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=52689
Your paranoid android.
=== w1064v1809 (32 bit report) ===
ddraw: 1a2c:ddraw7: unhandled exception c0000005 at 72DB40F8
On Wed, 22 May 2019 at 14:10, Paul Gofman gofmanp@gmail.com wrote:
@@ -3709,26 +3710,41 @@ static void test_lighting(void) { D3DMATRIX *world_matrix; void *quad;
DWORD expected;
DWORD expected, expected_process_vertices;
} tests[] = {BOOL process_vertices_todo; const char *message;
{&mat, nquad, 0x000000ff, "Lit quad with light"},
{&mat_singular, nquad, 0x000000ff, "Lit quad with singular world matrix"},
{&mat_transf, rotatedquad, 0x000000ff, "Lit quad with transformation matrix"},
{&mat_nonaffine, translatedquad, 0x00000000, "Lit quad with non-affine matrix"},
{&mat, nquad, 0x000000ff, 0xff0000ff, FALSE, "Lit quad with light"},
{&mat_singular, nquad, 0x000000ff, 0xff000000, TRUE, "Lit quad with singular world matrix"},
{&mat_transf, rotatedquad, 0x000000ff, 0xff0000ff, FALSE, "Lit quad with transformation matrix"},
};{&mat_nonaffine, translatedquad, 0x00000000, 0xff000000, FALSE, "Lit quad with non-affine matrix"},
If you make the "todo" field the last one in the structure, you only need to explicitly set it when TRUE. (As you do in test_specular_lighting().)
@@ -3737,97 +3753,198 @@ static void test_lighting(void) DestroyWindow(window); return; }
- hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
- ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
You leak this reference.
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw4.c | 298 +++++++++++++++++++++++++++++--------- 1 file changed, 233 insertions(+), 65 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 56194427d1..42609f201e 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -20,6 +20,7 @@ #define COBJMACROS
#include "wine/test.h" +#include "wine/heap.h" #include <limits.h> #include <math.h> #include "ddrawi.h" @@ -3995,7 +3996,7 @@ static void test_lighting(void) 0.0f, 0.0f, 1.0f, -1.0f, 10.f, 10.0f, 10.0f, 0.0f, }; - static struct + static struct vertex { struct vec3 position; DWORD diffuse; @@ -4014,7 +4015,7 @@ static void test_lighting(void) {{ 0.0f, 1.0f, 0.1f}, 0xff00ff00}, {{ 0.0f, 0.0f, 0.1f}, 0xff00ff00}, }; - static struct + static struct vertex_normal { struct vec3 position; struct vec3 normal; @@ -4070,13 +4071,16 @@ static void test_lighting(void) {&mat_transf, rotatedquad, 0x000080ff, "Lit quad with transformation matrix"}, {&mat_nonaffine, translatedquad, 0x000080ff, "Lit quad with non-affine matrix"}, }; - DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL; + IDirect3DVertexBuffer *src_vb1, *src_vb2, *dst_vb; IDirect3DViewport3 *viewport, *viewport2; DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE; + struct vertex_normal *src_data2; IDirect3DMaterial3 *material; D3DMATERIALHANDLE mat_handle; + D3DVERTEXBUFFERDESC vb_desc; IDirect3DDevice3 *device; + struct vertex *src_data1; IDirectDrawSurface4 *rt; IDirect3DLight *light; D3DLIGHT2 light_desc; @@ -4086,6 +4090,13 @@ static void test_lighting(void) unsigned int i; HWND window; HRESULT hr; + struct + { + struct vec4 position; + DWORD diffuse; + DWORD specular; + } + *dst_data;
window = create_window(); if (!(device = create_device(window, DDSCL_NORMAL))) @@ -4096,74 +4107,144 @@ static void test_lighting(void) }
hr = IDirect3DDevice3_GetDirect3D(device, &d3d); - ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
viewport = create_viewport(device, 0, 0, 640, 480); hr = IDirect3DDevice3_SetCurrentViewport(device, viewport); - ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat); - ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat); - ok(SUCCEEDED(hr), "Failed to set view transformation, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat); - ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable zbuffer, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable stencil buffer, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); - ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = fvf; + vb_desc.dwNumVertices = 2; + hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb1, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = nfvf; + vb_desc.dwNumVertices = 2; + hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb2, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR; + vb_desc.dwNumVertices = 4; + hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_Lock(src_vb1, 0, (void **)&src_data1, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data1, unlitquad, sizeof(*src_data1)); + memcpy(&src_data1[1], litquad, sizeof(*src_data1)); + hr = IDirect3DVertexBuffer_Unlock(src_vb1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_Lock(src_vb2, 0, (void **)&src_data2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data2, unlitnquad, sizeof(*src_data2)); + memcpy(&src_data2[1], litnquad, sizeof(*src_data2)); + hr = IDirect3DVertexBuffer_Unlock(src_vb2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* There is no D3DRENDERSTATE_LIGHTING on ddraw < 7. */ hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, + 1, src_vb1, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE); - ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 1, + 1, src_vb1, 1, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); - ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 2, + 1, src_vb2, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE); - ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 3, + 1, src_vb2, 1, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x.\n", color); + ok(dst_data[0].diffuse == 0xffff0000, + "Unlit quad without normals has color 0x%08x, expected 0xffff0000.\n", dst_data[0].diffuse); + ok(!dst_data[0].specular, + "Unexpected specular color 0x%08x.\n", dst_data[0].specular); + color = get_surface_color(rt, 160, 120); ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08x.\n", color); + ok(dst_data[1].diffuse == 0xff00ff00, + "Lit quad without normals has color 0x%08x, expected 0xff000000.\n", dst_data[1].diffuse); + ok(!dst_data[1].specular, + "Unexpected specular color 0x%08x.\n", dst_data[1].specular); + color = get_surface_color(rt, 480, 360); ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08x.\n", color); + ok(dst_data[2].diffuse == 0xff0000ff, + "Unlit quad with normals has color 0x%08x, expected 0xff0000ff.\n", dst_data[2].diffuse); + ok(!dst_data[2].specular, + "Unexpected specular color 0x%08x.\n", dst_data[2].specular); + color = get_surface_color(rt, 480, 120); ok(color == 0x00ffff00, "Lit quad with normals has color 0x%08x.\n", color); + ok(dst_data[3].diffuse == 0xffffff00, + "Lit quad with normals has color 0x%08x, expected 0xff000000.\n", dst_data[3].diffuse); + ok(!dst_data[3].specular, + "Unexpected specular color 0x%08x.\n", dst_data[3].specular);
- material = create_diffuse_and_ambient_material(device, 0.0f, 1.0f, 1.0f, 0.0f); + hr = IDirect3DVertexBuffer_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + material = create_diffuse_and_ambient_material(device, 0.0f, 1.0f, 1.0f, 0.5f); hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle); @@ -4179,7 +4260,7 @@ static void test_lighting(void) U1(light_desc.dcvColor).r = 1.0f; U2(light_desc.dcvColor).g = 1.0f; U3(light_desc.dcvColor).b = 1.0f; - U4(light_desc.dcvColor).a = 1.0f; + U4(light_desc.dcvColor).a = 0.5f; U3(light_desc.dvDirection).z = 1.0f; hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -4224,28 +4305,51 @@ static void test_lighting(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i) { + hr = IDirect3DVertexBuffer_Lock(src_vb2, 0, (void **)&src_data2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data2, tests[i].quad, sizeof(*src_data2)); + hr = IDirect3DVertexBuffer_Unlock(src_vb2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix); - ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0, + 1, src_vb2, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, tests[i].quad, 4, indices, 6, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240); ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color); + ok(dst_data[0].diffuse == (tests[i].expected | 0xff000000), + "%s has color 0x%08x.\n", tests[i].message, dst_data[0].diffuse); + ok(!dst_data[0].specular, + "%s has specular color 0x%08x.\n", tests[i].message, dst_data[0].specular); + + hr = IDirect3DVertexBuffer_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); }
+ IDirect3DVertexBuffer_Release(src_vb1); + IDirect3DVertexBuffer_Release(src_vb2); + IDirect3DVertexBuffer_Release(dst_vb); + hr = IDirect3DViewport3_DeleteLight(viewport, light); - ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); IDirect3DLight_Release(light); destroy_material(material); IDirect3DViewport3_Release(viewport); @@ -4260,8 +4364,8 @@ static void test_specular_lighting(void) { static const unsigned int vertices_side = 5; const unsigned int indices_count = (vertices_side - 1) * (vertices_side - 1) * 2 * 3; - static const DWORD fvf = D3DFVF_XYZ | D3DFVF_NORMAL; static D3DRECT clear_rect = {{0}, {0}, {640}, {480}}; + static const DWORD fvf = D3DFVF_XYZ | D3DFVF_NORMAL; static D3DMATRIX mat = { 1.0f, 0.0f, 0.0f, 0.0f, @@ -4269,6 +4373,24 @@ static void test_specular_lighting(void) 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; + static const struct vertex + { + struct vec3 position; + struct vec3 normal; + } + vertices[] = + { + {{-0.5f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, -0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{-0.5f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{-0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.0f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + {{ 0.5f, 0.5f, 1.0f}, {0.0f, 0.0f, -1.0f}}, + }; + static D3DLIGHT2 directional = { sizeof(D3DLIGHT2), @@ -4433,13 +4555,17 @@ static void test_specular_lighting(void) {¶llelpoint, TRUE, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)}, {&point_far, TRUE, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)}, }; - IDirect3D3 *d3d; - IDirect3DDevice3 *device; - IDirectDrawSurface4 *rt; + + IDirect3DVertexBuffer *src_vb, *dst_vb; + struct vertex *quad, *src_data; + D3DVERTEXBUFFERDESC vb_desc; + D3DMATERIALHANDLE mat_handle; IDirect3DViewport3 *viewport; IDirect3DMaterial3 *material; + IDirect3DDevice3 *device; + IDirectDrawSurface4 *rt; IDirect3DLight *light; - D3DMATERIALHANDLE mat_handle; + IDirect3D3 *d3d; D3DCOLOR color; ULONG refcount; HWND window; @@ -4447,9 +4573,10 @@ static void test_specular_lighting(void) unsigned int i, j, x, y; struct { - struct vec3 position; - struct vec3 normal; - } *quad; + struct vec4 position; + DWORD diffuse; + DWORD specular; + } *dst_data; WORD *indices;
window = create_window(); @@ -4460,8 +4587,8 @@ static void test_specular_lighting(void) return; }
- quad = HeapAlloc(GetProcessHeap(), 0, vertices_side * vertices_side * sizeof(*quad)); - indices = HeapAlloc(GetProcessHeap(), 0, indices_count * sizeof(*indices)); + quad = heap_alloc(vertices_side * vertices_side * sizeof(*quad)); + indices = heap_alloc(indices_count * sizeof(*indices)); for (i = 0, y = 0; y < vertices_side; ++y) { for (x = 0; x < vertices_side; ++x) @@ -4488,61 +4615,92 @@ static void test_specular_lighting(void) }
hr = IDirect3DDevice3_GetDirect3D(device, &d3d); - ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
viewport = create_viewport(device, 0, 0, 640, 480); hr = IDirect3DDevice3_SetCurrentViewport(device, viewport); - ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat); - ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat); - ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat); - ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE); - ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D3_CreateLight(d3d, &light, NULL); - ok(SUCCEEDED(hr), "Failed to create a light object, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DViewport3_AddLight(viewport, light); - ok(SUCCEEDED(hr), "Failed to add a light to the viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE); - ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = fvf; + vb_desc.dwNumVertices = ARRAY_SIZE(vertices); + hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DVertexBuffer_Lock(src_vb, 0, (void **)&src_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(src_data, vertices, sizeof(vertices)); + hr = IDirect3DVertexBuffer_Unlock(src_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + memset(&vb_desc, 0, sizeof(vb_desc)); + vb_desc.dwSize = sizeof(vb_desc); + vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR; + vb_desc.dwNumVertices = ARRAY_SIZE(vertices); + hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(tests); ++i) { tests[i].light->dwFlags = D3DLIGHT_ACTIVE; hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)tests[i].light); - ok(SUCCEEDED(hr), "Failed to set light, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LOCALVIEWER, tests[i].local_viewer); - ok(SUCCEEDED(hr), "Failed to set local viewer state, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- material = create_specular_material(device, 1.0f, 1.0f, 1.0f, 1.0f, tests[i].specular_power); + material = create_specular_material(device, 1.0f, 1.0f, 1.0f, 0.5f, tests[i].specular_power); hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle); - ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle); - ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device); - ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memset(dst_data, 0, sizeof(*dst_data) * ARRAY_SIZE(vertices)); + hr = IDirect3DVertexBuffer_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0, + ARRAY_SIZE(vertices), src_vb, 0, device, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, quad, vertices_side * vertices_side, indices, indices_count, 0); - ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device); - ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (j = 0; j < tests[i].expected_count; ++j) { @@ -4551,13 +4709,23 @@ static void test_specular_lighting(void) "Expected color 0x%08x at location (%u, %u), got 0x%08x, case %u.\n", tests[i].expected[j].color, tests[i].expected[j].x, tests[i].expected[j].y, color, i); + ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08x, case %u.\n", + j, dst_data[j].diffuse, i); + ok(compare_color(dst_data[j].specular, tests[i].expected[j].color, 1), + "Expected color 0x%08x for vertex %u, got 0x%08x, case %u.\n", + tests[i].expected[j].color, j, dst_data[j].specular, i); } + hr = IDirect3DVertexBuffer_Unlock(dst_vb); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
destroy_material(material); }
+ IDirect3DVertexBuffer_Release(dst_vb); + IDirect3DVertexBuffer_Release(src_vb); + hr = IDirect3DViewport3_DeleteLight(viewport, light); - ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); IDirect3DLight_Release(light); IDirect3DViewport3_Release(viewport); IDirectDrawSurface4_Release(rt); @@ -4565,8 +4733,8 @@ static void test_specular_lighting(void) ok(!refcount, "Device has %u references left.\n", refcount); IDirect3D3_Release(d3d); DestroyWindow(window); - HeapFree(GetProcessHeap(), 0, indices); - HeapFree(GetProcessHeap(), 0, quad); + heap_free(indices); + heap_free(quad); }
static void test_clear_rect_count(void)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com