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) ...@@ -5991,37 +5991,31 @@ static void cnd_test(IDirect3DDevice9 *device)
color = getPixelColor(device, 158, 358); color = getPixelColor(device, 158, 358);
ok(color == 0x00ffffff, "pixel 158, 358 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 158, 358 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 162, 358); color = getPixelColor(device, 162, 358);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 162, 358 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 162, 358 has color %08x, expected 0x00000000\n", color);
color = getPixelColor(device, 158, 362); color = getPixelColor(device, 158, 362);
ok(color == 0x00ffffff, "pixel 158, 362 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 158, 362 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 162, 362); color = getPixelColor(device, 162, 362);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 162, 362 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 162, 362 has color %08x, expected 0x00000000\n", color);
/* 1.2 shader */ /* 1.2 shader */
color = getPixelColor(device, 478, 358); color = getPixelColor(device, 478, 358);
ok(color == 0x00ffffff, "pixel 478, 358 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 478, 358 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 358); color = getPixelColor(device, 482, 358);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 482, 358 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 482, 358 has color %08x, expected 0x00000000\n", color);
color = getPixelColor(device, 478, 362); color = getPixelColor(device, 478, 362);
ok(color == 0x00ffffff, "pixel 478, 362 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 478, 362 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 362); color = getPixelColor(device, 482, 362);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 482, 362 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 482, 362 has color %08x, expected 0x00000000\n", color);
/* 1.3 shader */ /* 1.3 shader */
color = getPixelColor(device, 478, 118); color = getPixelColor(device, 478, 118);
ok(color == 0x00ffffff, "pixel 478, 118 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 478, 118 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 118); color = getPixelColor(device, 482, 118);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 482, 118 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 482, 118 has color %08x, expected 0x00000000\n", color);
color = getPixelColor(device, 478, 122); color = getPixelColor(device, 478, 122);
ok(color == 0x00ffffff, "pixel 478, 122 has color %08x, expected 0x00ffffff\n", color); ok(color == 0x00ffffff, "pixel 478, 122 has color %08x, expected 0x00ffffff\n", color);
color = getPixelColor(device, 482, 122); color = getPixelColor(device, 482, 122);
ok( (((color & 0x00ff0000) >> 16) <= 0x01) && (((color & 0x0000ff00) >> 8) <= 0x01) && ((color & 0x000000ff) <= 0x01), ok(color_match(color, 0x00000000, 1), "pixel 482, 122 has color 0x%08x, expected 0x00000000.\n", color);
"pixel 482, 122 has color %08x, expected 0x00000000\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
...@@ -6287,8 +6281,8 @@ static void nested_loop_test(IDirect3DDevice9 *device) ...@@ -6287,8 +6281,8 @@ static void nested_loop_test(IDirect3DDevice9 *device)
} }
color = getPixelColor(device, 360, 240); color = getPixelColor(device, 360, 240);
ok(color == 0x007f0000 || color == 0x00800000 || color == 0x00810000, ok(color_match(color, 0x00800000, 1),
"Nested loop test returned color 0x%08x, expected 0x00800000\n", color); "Nested loop test returned color 0x%08x, expected 0x00800000.\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
...@@ -6488,7 +6482,7 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device) ...@@ -6488,7 +6482,7 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device)
IDirect3DVertexDeclaration9 *decl; IDirect3DVertexDeclaration9 *decl;
HRESULT hr; HRESULT hr;
unsigned int i; unsigned int i;
DWORD color, r, g, b, r_e, g_e, b_e; DWORD color;
memcpy(data2, data, sizeof(data2)); memcpy(data2, data, sizeof(data2));
data2[0].pos_x = 0; data2[0].pos_y = 0; data2[0].pos_x = 0; data2[0].pos_y = 0;
...@@ -6528,29 +6522,20 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device) ...@@ -6528,29 +6522,20 @@ static void pretransformed_varying_test(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %08x\n", hr); 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); color = getPixelColor(device, 360, 240);
r = color & 0x00ff0000 >> 16; if (tests[i].todo_rhw)
g = color & 0x0000ff00 >> 8; todo_wine ok(color_match(color, tests[i].color_rhw, 1),
b = color & 0x000000ff; "Test %s returned color 0x%08x, expected 0x%08x (todo).\n",
r_e = tests[i].color_rhw & 0x00ff0000 >> 16; tests[i].name, color, tests[i].color_rhw);
g_e = tests[i].color_rhw & 0x0000ff00 >> 8; else
b_e = tests[i].color_rhw & 0x000000ff; 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); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr); 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++) for(i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
...@@ -7256,7 +7241,7 @@ static void srgbtexture_test(IDirect3DDevice9 *device) ...@@ -7256,7 +7241,7 @@ static void srgbtexture_test(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_SetSamplerState failed with %08x\n", hr);
color = getPixelColor(device, 320, 240); 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); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
...@@ -9646,7 +9631,6 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device) ...@@ -9646,7 +9631,6 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device)
IDirect3DSurface9 *backbuffer = NULL, *offscreen = NULL; IDirect3DSurface9 *backbuffer = NULL, *offscreen = NULL;
IDirect3D9 *d3d = NULL; IDirect3D9 *d3d = NULL;
DWORD color; DWORD color;
DWORD r0, g0, b0, r1, g1, b1;
int fmt_index; int fmt_index;
static const float quad[][5] = { static const float quad[][5] = {
...@@ -9768,27 +9752,26 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device) ...@@ -9768,27 +9752,26 @@ static void pixelshader_blending_test(IDirect3DDevice9 *device)
IDirect3DDevice9_EndScene(device); IDirect3DDevice9_EndScene(device);
} }
if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, fmt) == D3D_OK) { if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
/* Compare the color of the center quad with our expectation */ D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, fmt) == D3D_OK)
{
/* Compare the color of the center quad with our expectation. */
color = getPixelColor(device, 320, 240); color = getPixelColor(device, 320, 240);
r0 = (color & 0x00ff0000) >> 16; ok(color_match(color, test_formats[fmt_index].resultColorBlending, 1),
g0 = (color & 0x0000ff00) >> 8; "Offscreen failed for %s: Got color 0x%08x, expected 0x%08x.\n",
b0 = (color & 0x000000ff) >> 0; test_formats[fmt_index].fmtName, color, test_formats[fmt_index].resultColorBlending);
}
r1 = (test_formats[fmt_index].resultColorBlending & 0x00ff0000) >> 16; else
g1 = (test_formats[fmt_index].resultColorBlending & 0x0000ff00) >> 8; {
b1 = (test_formats[fmt_index].resultColorBlending & 0x000000ff) >> 0; /* No pixel shader blending is supported so expect garbage. The
* type of 'garbage' depends on the driver version and OS. E.g. on
ok(r0 >= max(r1, 1) - 1 && r0 <= r1 + 1 && * G16R16 ATI reports (on old r9600 drivers) 0x00ffffff and on
g0 >= max(g1, 1) - 1 && g0 <= g1 + 1 && * modern ones 0x002010ff which is also what NVIDIA reports. On
b0 >= max(b1, 1) - 1 && b0 <= b1 + 1, * Vista NVIDIA seems to report 0x00ffffff on Geforce7 cards. */
"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. */
color = getPixelColor(device, 320, 240); 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); 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