From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 209 +++++++++++++++++++++++++++++++++------ 1 file changed, 177 insertions(+), 32 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 005b86cdd09..c0cf9e3eea3 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -11711,6 +11711,7 @@ static void test_pointsize(void) static const float a = 1.0f, b = 1.0f, c = 1.0f; float ptsize, ptsizemax_orig, ptsizemin_orig; IDirect3DSurface9 *rt, *backbuffer; + D3DADAPTER_IDENTIFIER9 identifier; IDirect3DTexture9 *tex1, *tex2; IDirect3DDevice9 *device; IDirect3DVertexShader9 *vs; @@ -11883,6 +11884,27 @@ static void test_pointsize(void) ps2_zw = {D3DPS_VERSION(2, 0), pshader2_zw_code}, ps3 = {D3DPS_VERSION(3, 0), pshader3_code}, ps3_zw = {D3DPS_VERSION(3, 0), pshader3_zw_code}; + + static const D3DVERTEXELEMENT9 decl_elements_psize[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_PSIZE, 0}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_no_psize[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_missing_psize[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {1, 0, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_PSIZE, 0}, + D3DDECL_END() + }; + static const struct { const struct test_shader *vs; @@ -11890,7 +11912,7 @@ static void test_pointsize(void) DWORD accepted_fvf; unsigned int nonscaled_size, scaled_size; BOOL gives_0_0_texcoord; - BOOL allow_broken; + BOOL broken_texcoord_u; } test_setups[] = { @@ -11908,26 +11930,33 @@ static void test_pointsize(void) {&vs1_psize, &ps1, D3DFVF_XYZ | D3DFVF_PSIZE, 48, 24, FALSE, FALSE}, {&vs3_psize, &ps3, D3DFVF_XYZ | D3DFVF_PSIZE, 48, 24, FALSE, TRUE}, }; + static const struct { BOOL zero_size; BOOL scale; BOOL override_min; + const D3DVERTEXELEMENT9 *decl_elements; DWORD fvf; const void *vertex_data; unsigned int vertex_size; } tests[] = { - {FALSE, FALSE, FALSE, D3DFVF_XYZ, vertices, sizeof(float) * 3}, - {FALSE, TRUE, FALSE, D3DFVF_XYZ, vertices, sizeof(float) * 3}, - {FALSE, FALSE, TRUE, D3DFVF_XYZ, vertices, sizeof(float) * 3}, - {TRUE, FALSE, FALSE, D3DFVF_XYZ, vertices, sizeof(float) * 3}, - {FALSE, FALSE, FALSE, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize, sizeof(vertex_pointsize)}, - {FALSE, TRUE, FALSE, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize_scaled, sizeof(vertex_pointsize_scaled)}, - {FALSE, FALSE, TRUE, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize, sizeof(vertex_pointsize)}, - {TRUE, FALSE, FALSE, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize_zero, sizeof(vertex_pointsize_zero)}, + {FALSE, FALSE, FALSE, NULL, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {FALSE, TRUE, FALSE, NULL, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {FALSE, FALSE, TRUE, NULL, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {TRUE, FALSE, FALSE, NULL, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {FALSE, FALSE, FALSE, NULL, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize, sizeof(vertex_pointsize)}, + {FALSE, TRUE, FALSE, NULL, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize_scaled, sizeof(vertex_pointsize_scaled)}, + {FALSE, FALSE, TRUE, NULL, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize, sizeof(vertex_pointsize)}, + {TRUE, FALSE, FALSE, NULL, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize_zero, sizeof(vertex_pointsize_zero)}, + {FALSE, FALSE, FALSE, decl_elements_no_psize, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {FALSE, FALSE, FALSE, decl_elements_psize, D3DFVF_XYZ | D3DFVF_PSIZE, &vertex_pointsize, sizeof(vertex_pointsize)}, + {FALSE, FALSE, FALSE, decl_elements_missing_psize, D3DFVF_XYZ, vertices, sizeof(float) * 3}, + {FALSE, FALSE, FALSE, decl_elements_missing_psize, D3DFVF_XYZ | D3DFVF_PSIZE, vertices, sizeof(float) * 3}, }; + /* Transforms the coordinate system [-1.0;1.0]x[1.0;-1.0] to * [0.0;0.0]x[640.0;480.0]. Z is untouched. */ D3DMATRIX matrix = @@ -11947,6 +11976,9 @@ static void test_pointsize(void) goto done; }
+ hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + memset(&caps, 0, sizeof(caps)); hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -12167,10 +12199,13 @@ static void test_pointsize(void)
for (i = 0; i < ARRAY_SIZE(test_setups); ++i) { + winetest_push_context("Setup %u", i); + if (caps.VertexShaderVersion < test_setups[i].vs->version || caps.PixelShaderVersion < test_setups[i].ps->version) { skip("Vertex / pixel shader version not supported, skipping test.\n"); + winetest_pop_context(); continue; } if (test_setups[i].vs->code) @@ -12199,13 +12234,27 @@ static void test_pointsize(void)
for (j = 0; j < ARRAY_SIZE(tests); ++j) { - BOOL allow_broken = test_setups[i].allow_broken; + bool broken_texcoord_u = test_setups[i].broken_texcoord_u; unsigned int size = tests[j].override_min ? 63 : tests[j].zero_size ? 0 : tests[j].scale ? test_setups[i].scaled_size : test_setups[i].nonscaled_size; + struct surface_readback rb;
if (test_setups[i].accepted_fvf != tests[j].fvf) continue;
+ if (tests[j].decl_elements == decl_elements_missing_psize) + { + /* If PSIZE is referenced in the vertex declaration but the + * corresponding buffer is not bound, the point size is + * effectively either zero (NVidia) or one (AMD, WARP). */ + if (!vs || (test_setups[i].accepted_fvf & D3DFVF_PSIZE)) + size = 1; + else + size = 32; + } + + winetest_push_context("test %u (expected size %u)", j, size); + ptsize = tests[j].zero_size ? 0.0f : 32.0f; hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, *(DWORD *)&ptsize); ok(SUCCEEDED(hr), "Failed to set pointsize, hr %#lx.\n", hr); @@ -12217,8 +12266,21 @@ static void test_pointsize(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSCALEENABLE, tests[j].scale); ok(SUCCEEDED(hr), "Failed setting point scale state, hr %#lx.\n", hr);
- hr = IDirect3DDevice9_SetFVF(device, tests[j].fvf); - ok(SUCCEEDED(hr), "Failed setting FVF, hr %#lx.\n", hr); + if (tests[j].decl_elements) + { + IDirect3DVertexDeclaration9 *vertex_declaration; + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, tests[j].decl_elements, &vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DVertexDeclaration9_Release(vertex_declaration); + } + else + { + hr = IDirect3DDevice9_SetFVF(device, tests[j].fvf); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + }
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt); ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr); @@ -12238,40 +12300,116 @@ static void test_pointsize(void) hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer); ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
- if (tests[j].zero_size) + get_rt_readback(backbuffer, &rb); + + if (size <= 1) { - /* Technically 0 pointsize is undefined in OpenGL but in practice it seems like - * it does the "useful" thing on all the drivers I tried. */ - /* On WARP it does draw some pixels, most of the time. */ - color = getPixelColor(device, 64, 64); - todo_wine_if(!color_match(color, 0x0000ffff, 0)) - ok(color_match(color, 0x0000ffff, 0) - || broken(color_match(color, 0x00ff0000, 0)) - || broken(color_match(color, 0x00ffff00, 0)) - || broken(color_match(color, 0x00000000, 0)) - || broken(color_match(color, 0x0000ff00, 0)), - "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); + unsigned int warp_colour = 0x0000ff00; + + if (test_setups[i].broken_texcoord_u) + warp_colour = 0x00000000; + else if (test_setups[i].gives_0_0_texcoord) + warp_colour = 0x00ff0000; + + color = get_readback_color(&rb, 64, 64); + if (size == 0) + { + /* Windows on real hardware draws nothing. WARP draws one + * pixel as if the point size was 1. + * + * Technically 0 pointsize is undefined in OpenGL but in + * practice it seems like it does the "useful" thing on all + * the drivers I tried. */ + todo_wine_if(!color_match(color, 0xff00ffff, 0)) + ok(color == 0xff00ffff + || broken(adapter_is_warp(&identifier) && color == warp_colour), + "Got unexpected color 0x%08x at (64, 64).\n", color); + } + else + { + /* Exact colour varies based on texcoord, but we should get + * a pixel drawn here. */ + ok(color != 0xff00ffff, "Got unexpected color 0x%08x at (64, 64).\n", color); + } + + todo_wine_if (j == 10) + { + color = get_readback_color(&rb, 63, 64); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (63, 64).\n", color); + color = get_readback_color(&rb, 65, 64); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (65, 64).\n", color); + color = get_readback_color(&rb, 64, 63); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 63).\n", color); + color = get_readback_color(&rb, 64, 65); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 65).\n", color); + } } else { - struct surface_readback rb; + /* On AMD and WARP, apparently only the first texcoord is + * modified by the point coordinates when using SM2/3 pixel + * shaders. */ + + for (unsigned int y = 0; y < 128; ++y) + { + /* Skip the edges; coordinates are not pixel-exact. */ + if (y == 64 - size / 2 || y == 64 + size / 2 || y == 64) + continue; + + for (unsigned int x = 0; x < 128; ++x) + { + unsigned int expect = 0xff00ffff, broken_u = 0xff00ffff; + + /* Skip the edges; coordinates are not pixel-exact. */ + if (x == 64 - size / 2 || x == 64 + size / 2 || x == 64) + continue; + + color = get_readback_color(&rb, x, y); + + if (x > 64 - size / 2 && x < 64 + size / 2 + && y > 64 - size / 2 && y < 64 + size / 2) + { + + if (test_setups[i].gives_0_0_texcoord) + expect = broken_u = 0x00ff0000; + else if (y < 64 && x < 64) + expect = broken_u = 0x00ff0000; + else if (y >= 64 && x < 64) + expect = broken_u = 0x00000000; + else if (y < 64 && x >= 64) + { + expect = 0x00ffff00; + broken_u = 0x00ff0000; + } + else if (y >= 64 && x >= 64) + { + expect = 0x0000ff00; + broken_u = 0x00000000; + } + } + + if (!(color == expect || broken(test_setups[i].broken_texcoord_u && color == broken_u))) + { + ok(0, "Expected 0x%08x, got 0x%08x at (%u, %u).\n", expect, color, x, y); + goto stop; + } + } + } +stop:
- get_rt_readback(backbuffer, &rb); - /* On AMD apparently only the first texcoord is modified by the point coordinates - * when using SM2/3 pixel shaders. */ color = get_readback_color(&rb, 64 - size / 2 + 1, 64 - size / 2 + 1); ok(color_match(color, 0x00ff0000, 0), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); color = get_readback_color(&rb, 64 + size / 2 - 1, 64 - size / 2 + 1); ok(color_match(color, test_setups[i].gives_0_0_texcoord ? 0x00ff0000 : 0x00ffff00, 0) - || (allow_broken && broken(color_match(color, 0x00ff0000, 0))), + || (broken_texcoord_u && broken(color_match(color, 0x00ff0000, 0))), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); color = get_readback_color(&rb, 64 - size / 2 + 1, 64 + size / 2 - 1); ok(color_match(color, test_setups[i].gives_0_0_texcoord ? 0x00ff0000 : 0x00000000, 0), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); color = get_readback_color(&rb, 64 + size / 2 - 1, 64 + size / 2 - 1); ok(color_match(color, test_setups[i].gives_0_0_texcoord ? 0x00ff0000 : 0x0000ff00, 0) - || (allow_broken && broken(color_match(color, 0x00000000, 0))), + || (broken_texcoord_u && broken(color_match(color, 0x00000000, 0))), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size);
color = get_readback_color(&rb, 64 - size / 2 - 1, 64 - size / 2 - 1); @@ -12286,9 +12424,14 @@ static void test_pointsize(void) color = get_readback_color(&rb, 64 + size / 2 + 1, 64 + size / 2 + 1); ok(color_match(color, 0xff00ffff, 0), "Got unexpected color 0x%08x (case %u, %u, size %u).\n", color, i, j, size); - - release_surface_readback(&rb); } + + release_surface_readback(&rb); + + IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + Sleep(50); + + winetest_pop_context(); } IDirect3DDevice9_SetVertexShader(device, NULL); IDirect3DDevice9_SetPixelShader(device, NULL); @@ -12296,6 +12439,8 @@ static void test_pointsize(void) IDirect3DVertexShader9_Release(vs); if (ps) IDirect3DVertexShader9_Release(ps); + + winetest_pop_context(); }
cleanup:
From: Elizabeth Figura zfigura@codeweavers.com
Test a stream present in the vertex declaration but not provided as a buffer. --- dlls/d3d9/tests/visual.c | 84 +++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index c0cf9e3eea3..b670c4f49d6 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -25950,6 +25950,30 @@ static void test_color_vertex(void) HWND window; HRESULT hr;
+ static const D3DVERTEXELEMENT9 decl_elements_missing_diffuse[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, + {1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_missing_specular[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + {2, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_missing_both[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + {2, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, + D3DDECL_END() + }; + /* The idea here is to set up ambient light parameters in a way that the * ambient colour from the material is just passed through. The emissive * colour is just passed through anyway. The sum of ambient + emissive @@ -25959,27 +25983,36 @@ static void test_color_vertex(void) * in the struct will be fed into the specular vertex colour slot. */ static const struct { + const D3DVERTEXELEMENT9 *decl_elements; DWORD fvf, color_vertex, ambient, emissive; unsigned int result; } tests[] = { - {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, FALSE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x000000c0}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, FALSE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x000000c0},
- {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ffff00}, - {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x0000ff80}, - {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00ff0040}, - {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR1, 0x00ff0000}, - {D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR2, D3DMCS_COLOR2, 0x0000ff00}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ffff00}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x0000ff80}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00ff0040}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR1, 0x00ff0000}, + {NULL, D3DFVF_DIFFUSE | D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR2, D3DMCS_COLOR2, 0x0000ff00},
- {D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0080}, - {D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x000000c0}, - {D3DFVF_SPECULAR, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x00ff0080}, - {D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0040}, - {D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00ff0040}, - {D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR2, D3DMCS_MATERIAL, 0x000000c0}, + {NULL, D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0080}, + {NULL, D3DFVF_SPECULAR, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x000000c0}, + {NULL, D3DFVF_SPECULAR, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x00ff0080}, + {NULL, D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0040}, + {NULL, D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00ff0040}, + {NULL, D3DFVF_DIFFUSE, TRUE, D3DMCS_COLOR2, D3DMCS_MATERIAL, 0x000000c0},
- {0, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x000000c0}, + {NULL, 0, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x000000c0}, + + {decl_elements_missing_diffuse, 0, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0000}, + {decl_elements_missing_diffuse, 0, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00000040}, + {decl_elements_missing_diffuse, 0, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x00ff0080}, + {decl_elements_missing_specular, 0, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00ff0000}, + {decl_elements_missing_specular, 0, TRUE, D3DMCS_COLOR1, D3DMCS_MATERIAL, 0x00ff0040}, + {decl_elements_missing_specular, 0, TRUE, D3DMCS_MATERIAL, D3DMCS_COLOR2, 0x00000080}, + {decl_elements_missing_both, 0, TRUE, D3DMCS_COLOR1, D3DMCS_COLOR2, 0x00000000}, };
static const struct @@ -26028,8 +26061,22 @@ static void test_color_vertex(void) ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_EMISSIVEMATERIALSOURCE, tests[i].emissive); ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | tests[i].fvf); - ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr); + + if (tests[i].decl_elements) + { + IDirect3DVertexDeclaration9 *vertex_declaration; + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, tests[i].decl_elements, &vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DVertexDeclaration9_Release(vertex_declaration); + } + else + { + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | tests[i].fvf); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + }
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0); ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr); @@ -26042,9 +26089,10 @@ static void test_color_vertex(void) ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
colour = getPixelColor(device, 320, 240); - ok(color_match(colour, tests[i].result, 1), - "Expected colour 0x%08x for test %u, got 0x%08x.\n", - tests[i].result, i, colour); + todo_wine_if (i == 13 || i == 14 || i == 16 || i == 18 || i == 19) + ok(color_match(colour, tests[i].result, 1), + "Expected colour 0x%08x for test %u, got 0x%08x.\n", + tests[i].result, i, colour); }
refcount = IDirect3DDevice9_Release(device);
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 200 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index b670c4f49d6..ef6d831aef3 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -28336,6 +28336,205 @@ static void test_mipmap_upload(void) release_test_context(&context); }
+static void test_default_diffuse(void) +{ + IDirect3DVertexDeclaration9 *vertex_declaration; + struct d3d9_test_context context; + IDirect3DVertexBuffer9 *vb; + IDirect3DDevice9 *device; + HRESULT hr; + void *data; + + static const D3DVERTEXELEMENT9 decl_elements_with_diffuse[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_no_diffuse[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + D3DDECL_END() + }; + + static const D3DVERTEXELEMENT9 decl_elements_missing_diffuse[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + + static const DWORD vs_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_no_diffuse_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x0000ffff /* end */ + }; + + static const DWORD ps_code[] = + { + 0xffff0200, /* ps_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */ + 0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */ + 0x0000ffff /* end */ + }; + + static const struct + { + struct vec3 position; + unsigned int diffuse; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, 0xff0000ff}, + {{-1.0f, 1.0f, 0.1f}, 0xff0000ff}, + {{ 1.0f, -1.0f, 0.1f}, 0xff0000ff}, + {{ 1.0f, 1.0f, 0.1f}, 0xff0000ff}, + }; + + static const struct + { + const DWORD *ps; + DWORD texture_source; + } + ps_tests[] = + { + {ps_code, 0}, + {NULL, D3DTA_CURRENT}, + {NULL, D3DTA_DIFFUSE}, + }; + + static const struct + { + const DWORD *vs; + const D3DVERTEXELEMENT9 *decl_elements; + unsigned int expect_colour; + } + vs_tests[] = + { + {NULL, decl_elements_with_diffuse, 0x000000ff}, + {NULL, decl_elements_no_diffuse, 0x00ffffff}, + {NULL, decl_elements_missing_diffuse, 0x00000000}, + {vs_code, decl_elements_with_diffuse, 0x000000ff}, + {vs_code, decl_elements_no_diffuse, 0x00000000}, + {vs_code, decl_elements_missing_diffuse, 0x00000000}, + {vs_no_diffuse_code, decl_elements_with_diffuse, 0x00ffffff}, + {vs_no_diffuse_code, decl_elements_no_diffuse, 0x00ffffff}, + {vs_no_diffuse_code, decl_elements_missing_diffuse, 0x00ffffff}, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), + D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &vb, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DVertexBuffer9_Lock(vb, 0, 0, &data, D3DLOCK_DISCARD); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + memcpy(data, quad, sizeof(quad)); + hr = IDirect3DVertexBuffer9_Unlock(vb); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(quad[0])); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + for (unsigned int i = 0; i < ARRAY_SIZE(ps_tests); ++i) + { + winetest_push_context("PS test %u", i); + + if (ps_tests[i].ps) + { + IDirect3DPixelShader9 *ps; + + hr = IDirect3DDevice9_CreatePixelShader(device, ps_tests[i].ps, &ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetPixelShader(device, ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DPixelShader9_Release(ps); + } + else + { + hr = IDirect3DDevice9_SetPixelShader(device, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, ps_tests[i].texture_source); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, ps_tests[i].texture_source); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + + for (unsigned int j = 0; j < ARRAY_SIZE(vs_tests); ++j) + { + unsigned int colour; + + winetest_push_context("VS test %u", j); + + if (vs_tests[j].vs) + { + IDirect3DVertexShader9 *vs; + + hr = IDirect3DDevice9_CreateVertexShader(device, vs_tests[j].vs, &vs); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexShader(device, vs); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DVertexShader9_Release(vs); + } + else + { + hr = IDirect3DDevice9_SetVertexShader(device, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, vs_tests[j].decl_elements, &vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDirect3DVertexDeclaration9_Release(vertex_declaration); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + colour = getPixelColor(device, 320, 240); + todo_wine_if (j == 2) + ok(colour == vs_tests[j].expect_colour, "Got unexpected colour %08x.\n", colour); + + winetest_pop_context(); + } + + winetest_pop_context(); + } + + IDirect3DVertexShader9_Release(vb); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -28490,4 +28689,5 @@ START_TEST(visual) test_managed_reset(); test_managed_generate_mipmap(); test_mipmap_upload(); + test_default_diffuse(); }
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 156 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index ef6d831aef3..367c8a9a955 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -28535,6 +28535,161 @@ static void test_default_diffuse(void) release_test_context(&context); }
+/* Test the default values of attribute components when the vertex declaration + * includes less than all 4 components. */ +static void test_default_attribute_components(void) +{ + IDirect3DVertexDeclaration9 *vertex_declaration; + struct d3d9_test_context context; + IDirect3DVertexShader9 *vs; + IDirect3DDevice9 *device; + HRESULT hr; + + static const DWORD vs_texcoord1_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80010005, 0x900f0001, /* dcl_texcoord1 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_texcoord2_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80020005, 0x900f0001, /* dcl_texcoord2 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_texcoord3_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80030005, 0x900f0001, /* dcl_texcoord3 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_color1_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8001000a, 0x900f0001, /* dcl_color1 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_color2_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8002000a, 0x900f0001, /* dcl_color2 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const DWORD vs_color3_code[] = + { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8003000a, 0x900f0001, /* dcl_color3 v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90390001, /* mov oD0, v1.yzwx */ + 0x0000ffff /* end */ + }; + + static const D3DVERTEXELEMENT9 decl_elements[] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, + {0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2}, + {0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 3}, + {0, 36, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, + {0, 40, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 2}, + {0, 48, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 3}, + D3DDECL_END() + }; + + static const struct + { + struct vec3 position; + float texcoord1; + struct vec2 texcoord2; + struct vec3 texcoord3; + float color1; + struct vec2 color2; + struct vec3 color3; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}}, + {{-1.0f, 1.0f, 0.1f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}}, + {{ 1.0f, -1.0f, 0.1f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}}, + {{ 1.0f, 1.0f, 0.1f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}, 0.1f, {0.2f, 0.2f}, {0.3f, 0.3f, 0.3f}}, + }; + + static const struct + { + const DWORD *vs_code; + D3DCOLOR color; + } + tests[] = + { + {vs_texcoord1_code, 0x0000ff}, + {vs_texcoord2_code, 0x3300ff}, + {vs_texcoord3_code, 0x4c4cff}, + {vs_color1_code, 0x0000ff}, + {vs_color2_code, 0x3300ff}, + {vs_color3_code, 0x4c4cff}, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (unsigned int j = 0; j < ARRAY_SIZE(tests); ++j) + { + winetest_push_context("test %u", j); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_CreateVertexShader(device, tests[j].vs_code, &vs); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetVertexShader(device, vs); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad, sizeof(*quad)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + check_rt_color(context.backbuffer, tests[j].color); + + IDirect3DVertexShader9_Release(vs); + winetest_pop_context(); + } + + IDirect3DVertexDeclaration9_Release(vertex_declaration); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -28690,4 +28845,5 @@ START_TEST(visual) test_managed_generate_mipmap(); test_mipmap_upload(); test_default_diffuse(); + test_default_attribute_components(); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=145483
Your paranoid android.
=== w11pro64_amd (64 bit report) ===
d3d9: visual.c:28526: Test failed: PS test 0: VS test 1: Got unexpected colour 00000000. visual.c:28526: Test failed: PS test 0: VS test 6: Got unexpected colour 00000000. visual.c:28526: Test failed: PS test 0: VS test 7: Got unexpected colour 00000000. visual.c:28526: Test failed: PS test 0: VS test 8: Got unexpected colour 00000000.