Commit 90bd39c4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9/tests: Use color_match() in more places.

parent a521990a
......@@ -5991,37 +5991,31 @@ static void cnd_test(IDirect3DDevice9 *device)
color = getPixelColor(device, 158, 358);
ok(color == 0x00ffffff, "pixel 158, 358 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 162, 358);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 162, 358 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 162, 358 has color 0x%08x, expected 0x00000000.\n", color);
color = getPixelColor(device, 158, 362);
ok(color == 0x00ffffff, "pixel 158, 362 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 162, 362);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 162, 362 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 162, 362 has color 0x%08x, expected 0x00000000.\n", color);
/* 1.2 shader */
color = getPixelColor(device, 478, 358);
ok(color == 0x00ffffff, "pixel 478, 358 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 358);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 482, 358 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 482, 358 has color 0x%08x, expected 0x00000000.\n", color);
color = getPixelColor(device, 478, 362);
ok(color == 0x00ffffff, "pixel 478, 362 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 362);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 482, 362 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 482, 362 has color 0x%08x, expected 0x00000000.\n", color);
/* 1.3 shader */
color = getPixelColor(device, 478, 118);
ok(color == 0x00ffffff, "pixel 478, 118 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 118);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 482, 118 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 482, 118 has color 0x%08x, expected 0x00000000.\n", color);
color = getPixelColor(device, 478, 122);
ok(color == 0x00ffffff, "pixel 478, 122 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 122);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01),
"pixel 482, 122 has color %08x, expected 0x00000000\n", color);
ok(color_match(color, 0x00000000, 1), "pixel 482, 122 has color 0x%08x, expected 0x00000000.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
......@@ -6287,8 +6281,8 @@ static void nested_loop_test(IDirect3DDevice9 *device)
}
color = getPixelColor(device, 360, 240);
ok(color == 0x007f0000 || color == 0x00800000 || color == 0x00810000,
"Nested loop test returned color 0x%08x, expected 0x00800000\n", color);
ok(color_match(color, 0x00800000, 1),
"Nested loop test returned color 0x%08x, expected 0x00800000.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
......@@ -6488,7 +6482,7 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device)
IDirect3DVertexDeclaration9 *decl;
HRESULT hr;
unsigned int i;
DWORD color, r, g, b, r_e, g_e, b_e;
DWORD color;
memcpy(data2, data, sizeof(data2));
data2[0].pos_x = 0; data2[0].pos_y = 0;
......@@ -6528,29 +6522,20 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %08x\n", hr);
}
/* This isn't a weekend's job to fix, ignore the problem for now.
* Needs a replacement pipeline. */
color = getPixelColor(device, 360, 240);
r = color & 0x00ff0000 >> 16;
g = color & 0x0000ff00 >> 8;
b = color & 0x000000ff;
r_e = tests[i].color_rhw & 0x00ff0000 >> 16;
g_e = tests[i].color_rhw & 0x0000ff00 >> 8;
b_e = tests[i].color_rhw & 0x000000ff;
if (tests[i].todo_rhw)
todo_wine ok(color_match(color, tests[i].color_rhw, 1),
"Test %s returned color 0x%08x, expected 0x%08x (todo).\n",
tests[i].name, color, tests[i].color_rhw);
else
ok(color_match(color, tests[i].color_rhw, 1),
"Test %s returned color 0x%08x, expected 0x%08x.\n",
tests[i].name, color, tests[i].color_rhw);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
if(tests[i].todo_rhw) {
/* This isn't a weekend's job to fix, ignore the problem for now. Needs a replacement
* pipeline
*/
todo_wine ok(abs(r - r_e) <= 1 && abs(g - g_e) <= 1 && abs(b - b_e) <= 1,
"Test %s returned color 0x%08x, expected 0x%08x(todo)\n",
tests[i].name, color, tests[i].color_rhw);
} else {
ok(abs(r - r_e) <= 1 && abs(g - g_e) <= 1 && abs(b - b_e) <= 1,
"Test %s returned color 0x%08x, expected 0x%08x\n",
tests[i].name, color, tests[i].color_rhw);
}
}
for(i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
......@@ -7256,7 +7241,7 @@ static void srgbtexture_test(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr);
color = getPixelColor(device, 320, 240);
ok(color == 0x00363636 || color == 0x00373737, "srgb quad has color %08x, expected 0x00363636\n", color);
ok(color_match(color, 0x00363636, 1), "sRGB quad has color 0x%08x, expected 0x00363636.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
......@@ -9646,7 +9631,6 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device)
IDirect3DSurface9 *backbuffer = NULL, *offscreen = NULL;
IDirect3D9 *d3d = NULL;
DWORD color;
DWORD r0, g0, b0, r1, g1, b1;
int fmt_index;
static const float quad[][5] = {
......@@ -9768,27 +9752,26 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device)
IDirect3DDevice9_EndScene(device);
}
if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, fmt) == D3D_OK) {
/* Compare the color of the center quad with our expectation */
if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, fmt) == D3D_OK)
{
/* Compare the color of the center quad with our expectation. */
color = getPixelColor(device, 320, 240);
r0 = (color & 0x00ff0000) >> 16;
g0 = (color & 0x0000ff00) >> 8;
b0 = (color & 0x000000ff) >> 0;
r1 = (test_formats[fmt_index].resultColorBlending & 0x00ff0000) >> 16;
g1 = (test_formats[fmt_index].resultColorBlending & 0x0000ff00) >> 8;
b1 = (test_formats[fmt_index].resultColorBlending & 0x000000ff) >> 0;
ok(r0 >= max(r1, 1) - 1 && r0 <= r1 + 1 &&
g0 >= max(g1, 1) - 1 && g0 <= g1 + 1 &&
b0 >= max(b1, 1) - 1 && b0 <= b1 + 1,
"Offscreen failed for %s: Got color %#08x, expected %#08x.\n", test_formats[fmt_index].fmtName, color, test_formats[fmt_index].resultColorBlending);
} else {
/* No pixel shader blending is supported so expect garbage. The type of 'garbage' depends on the driver version and OS.
* E.g. on G16R16 ati reports (on old r9600 drivers) 0x00ffffff and on modern ones 0x002010ff which is also what Nvidia
* reports. On Vista Nvidia seems to report 0x00ffffff on Geforce7 cards. */
ok(color_match(color, test_formats[fmt_index].resultColorBlending, 1),
"Offscreen failed for %s: Got color 0x%08x, expected 0x%08x.\n",
test_formats[fmt_index].fmtName, color, test_formats[fmt_index].resultColorBlending);
}
else
{
/* No pixel shader blending is supported so expect garbage. The
* type of 'garbage' depends on the driver version and OS. E.g. on
* G16R16 ATI reports (on old r9600 drivers) 0x00ffffff and on
* modern ones 0x002010ff which is also what NVIDIA reports. On
* Vista NVIDIA seems to report 0x00ffffff on Geforce7 cards. */
color = getPixelColor(device, 320, 240);
ok((color == 0x00ffffff) || (color == test_formats[fmt_index].resultColorNoBlending), "Offscreen failed for %s: expected no color blending but received it anyway.\n", test_formats[fmt_index].fmtName);
ok((color == 0x00ffffff) || (color == test_formats[fmt_index].resultColorNoBlending),
"Offscreen failed for %s: Got unexpected color 0x%08x, expected no color blending.\n",
test_formats[fmt_index].fmtName, color);
}
IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment