d3d9/tests: Add a test for signed formats.

This commit is contained in:
Stefan Dösinger 2015-03-07 10:03:37 +01:00 committed by Alexandre Julliard
parent 6f2f73a456
commit cdb7e825ce
1 changed files with 383 additions and 124 deletions

View File

@ -5178,129 +5178,6 @@ done:
DestroyWindow(window);
}
static void x8l8v8u8_test(void)
{
IDirect3DPixelShader9 *shader2;
IDirect3DPixelShader9 *shader;
IDirect3DTexture9 *texture;
IDirect3DDevice9 *device;
D3DLOCKED_RECT lr;
IDirect3D9 *d3d;
ULONG refcount;
D3DCAPS9 caps;
DWORD color;
HWND window;
HRESULT hr;
static const DWORD shader_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000042, 0xb00f0000, /* tex t0 */
0x00000001, 0x800f0000, 0xb0e40000, /* mov r0, t0 */
0x0000ffff /* end */
};
static const DWORD shader_code2[] =
{
0xffff0101, /* ps_1_1 */
0x00000042, 0xb00f0000, /* tex t0 */
0x00000001, 0x800f0000, 0xb0ff0000, /* mov r0, t0.w */
0x0000ffff /* end */
};
static const float quad[] =
{
-1.0f, -1.0f, 0.1f, 0.5f, 0.5f,
-1.0f, 1.0f, 0.1f, 0.5f, 0.5f,
1.0f, -1.0f, 0.1f, 0.5f, 0.5f,
1.0f, 1.0f, 0.1f, 0.5f, 0.5f,
};
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
}
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
{
skip("No ps_1_1 support, skipping tests.\n");
IDirect3DDevice9_Release(device);
goto done;
}
if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_X8L8V8U8)))
{
skip("No D3DFMT_X8L8V8U8 support, skipping tests.\n");
IDirect3DDevice9_Release(device);
goto done;
}
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_X8L8V8U8, D3DPOOL_MANAGED, &texture, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed (%08x)\n", hr);
memset(&lr, 0, sizeof(lr));
hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed (%08x)\n", hr);
*((DWORD *) lr.pBits) = 0x11ca3141;
hr = IDirect3DTexture9_UnlockRect(texture, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed (%08x)\n", hr);
hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateShader failed (%08x)\n", hr);
hr = IDirect3DDevice9_CreatePixelShader(device, shader_code2, &shader2);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateShader failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, shader);
ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed (%08x)\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 578, 430);
ok(color_match(color, D3DCOLOR_ARGB(0x00, 0x82, 0x62, 0xca), 1),
"D3DFMT_X8L8V8U8 = 0x112131ca returns color %08x, expected 0x008262ca\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, shader2);
ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed (%08x)\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
color = getPixelColor(device, 578, 430);
ok(color == 0x00ffffff, "w component of D3DFMT_X8L8V8U8 = 0x11ca3141 returns color %08x\n", color);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
IDirect3DPixelShader9_Release(shader);
IDirect3DPixelShader9_Release(shader2);
IDirect3DTexture9_Release(texture);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
static void autogen_mipmap_test(void)
{
IDirect3DTexture9 *texture = NULL;
@ -17493,6 +17370,388 @@ done:
DestroyWindow(window);
}
static void test_signed_formats(void)
{
IDirect3DDevice9 *device;
HWND window;
HRESULT hr;
unsigned int i, j, x, y;
IDirect3DTexture9 *texture, *texture_sysmem;
IDirect3DSurface9 *src_surface, *dst_surface;
D3DLOCKED_RECT locked_rect;
IDirect3DPixelShader9 *shader, *shader_alpha;
IDirect3D9 *d3d;
D3DCOLOR color;
D3DCAPS9 caps;
ULONG refcount;
/* The input data was designed for D3DFMT_L6V5U5 and then transfered
* to the other formats because L6V5U5 is the lowest precision format.
* It tests the extreme values -1.0 (-16) and 1.0 (15) for U/V and
* 0.0 (0) and 1.0 (63) for L, the neutral point 0 as well as -1 and 1.
* Some other intermediate values are tested too. The input value -15
* (min + 1) is tested as well. Unlike what OpenGL 4.4 says in section
* 2.3.4.1, this value does not represent -1.0. In the interest of re-
* using the expected output data the 8 bit and 16 bit values in V8U8
* and V16U16 match (post-normalization) the 5 bit input values. Thus
* -1, 1 and -127 are not tested in V8U8.
*
* 8 bit specific values like -127 are tested in the Q channel of
* D3DFMT_Q8W8V8U8. Here d3d seems to follow the rules from the GL
* spec. AMD's r200 is broken though and returns a value < -1.0 for
* -128. The difference between using -127 or -128 as the lowest
* possible value gets lost in the slop of 1 though. */
static const USHORT content_v8u8[4][4] =
{
{0x0000, 0x7f7f, 0x8880, 0x0000},
{0x0080, 0x8000, 0x7f00, 0x007f},
{0x193b, 0xe8c8, 0x0808, 0xf8f8},
{0x4444, 0xc0c0, 0xa066, 0x22e0},
};
static const DWORD content_v16u16[4][4] =
{
{0x00000000, 0x7fff7fff, 0x88008000, 0x00000000},
{0x00008000, 0x80000000, 0x7fff0000, 0x00007fff},
{0x19993bbb, 0xe800c800, 0x08880888, 0xf800f800},
{0x44444444, 0xc000c000, 0xa0006666, 0x2222e000},
};
static const DWORD content_q8w8v8u8[4][4] =
{
{0x00000000, 0xff7f7f7f, 0x7f008880, 0x817f0000},
{0x10000080, 0x20008000, 0x30007f00, 0x4000007f},
{0x5020193b, 0x6028e8c8, 0x70020808, 0x807ff8f8},
{0x90414444, 0xa000c0c0, 0x8261a066, 0x834922e0},
};
static const DWORD content_x8l8v8u8[4][4] =
{
{0x00000000, 0x00ff7f7f, 0x00008880, 0x00ff0000},
{0x00000080, 0x00008000, 0x00007f00, 0x0000007f},
{0x0041193b, 0x0051e8c8, 0x00040808, 0x00fff8f8},
{0x00824444, 0x0000c0c0, 0x00c2a066, 0x009222e0},
};
/* D3DFMT_L6V5U5 has poor precision on some GPUs. On a GeForce 7 the highest V and U value (15)
* results in the output color 0xfb, which is 4 steps away from the correct value 0xff. It is
* not the ~0xf0 you'd get if you blindly left-shifted the 5 bit value to form an 8 bit value
* though.
*
* There may also be an off-by-one bug involved: The value -7 should result in the output 0x47,
* but ends up as 0x4d. Likewise, -3 becomes 0x6e instead of 0x67. Those values are close to
* the proper results of -6 and -2.
*
* On Wine the emulation with unsigned R5G6B5 has poor precision, e.g. the signed 0 becomes 16,
* and ((16 / 31) - 0.5) * 2.0 is 0.032 instead of 0.000. The final output result we read back
* is 0x84 instead of 0x80. */
static const USHORT content_l6v5u5[4][4] =
{
{0x0000, 0xfdef, 0x0230, 0xfc00},
{0x0010, 0x0200, 0x01e0, 0x000f},
{0x4067, 0x53b9, 0x0421, 0xffff},
{0x8108, 0x0318, 0xc28c, 0x909c},
};
static const struct
{
D3DFORMAT format;
const char *name;
const void *content;
SIZE_T pixel_size;
BOOL blue, alpha;
unsigned int slop, slop_broken, alpha_broken;
}
formats[] =
{
{D3DFMT_V8U8, "D3DFMT_V8U8", content_v8u8, sizeof(WORD), FALSE, FALSE, 1, 0, FALSE},
{D3DFMT_V16U16, "D3DFMT_V16U16", content_v16u16, sizeof(DWORD), FALSE, FALSE, 1, 0, FALSE},
{D3DFMT_Q8W8V8U8, "D3DFMT_Q8W8V8U8", content_q8w8v8u8, sizeof(DWORD), TRUE, TRUE, 1, 0, TRUE },
{D3DFMT_X8L8V8U8, "D3DFMT_X8L8V8U8", content_x8l8v8u8, sizeof(DWORD), TRUE, FALSE, 1, 0, FALSE},
{D3DFMT_L6V5U5, "D3DFMT_L6V5U5", content_l6v5u5, sizeof(WORD), TRUE, FALSE, 4, 7, FALSE},
};
static const struct
{
D3DPOOL pool;
UINT width;
RECT src_rect;
POINT dst_point;
}
tests[] =
{
{D3DPOOL_SYSTEMMEM, 4, {1, 1, 2, 3}, {2, 0}},
{D3DPOOL_SYSTEMMEM, 1, {0, 1, 1, 3}, {0, 0}},
{D3DPOOL_MANAGED, 4, {1, 1, 2, 3}, {2, 0}},
{D3DPOOL_MANAGED, 1, {0, 1, 1, 3}, {0, 0}},
};
static const DWORD shader_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000051, 0xa00f0000, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, /* def c0, 0.5, 0.5, 0,5, 0,5 */
0x00000042, 0xb00f0000, /* tex t0 */
0x00000004, 0x800f0000, 0xb0e40000, 0xa0e40000, 0xa0e40000, /* mad r0, t0, c0, c0 */
0x0000ffff /* end */
};
static const DWORD shader_code_alpha[] =
{
/* The idea of this shader is to replicate the alpha value in .rg, and set
* blue to 1.0 iff the alpha value is < -1.0 and 0.0 otherwise. */
0xffff0101, /* ps_1_1 */
0x00000051, 0xa00f0000, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, /* def c0, 0.5, 0.5, 0.5, 0.5 */
0x00000051, 0xa00f0001, 0x3f800000, 0x3f800000, 0x00000000, 0x3f800000, /* def c1, 1.0, 1.0, 0.0, 1.0 */
0x00000051, 0xa00f0002, 0x00000000, 0x00000000, 0x3f800000, 0x00000000, /* def c2, 0.0, 0.0, 1.0, 0.0 */
0x00000042, 0xb00f0000, /* tex t0 */
0x00000004, 0x80070000, 0xb0ff0000, 0xa0e40000, 0xa0e40000, /* mad r0.rgb, t0.a, c0, c0 */
0x00000003, 0x80080000, 0xb1ff0000, 0xa0e40000, /* sub r0.a, -t0.a, c0 */
0x00000050, 0x80080000, 0x80ff0000, 0xa0ff0001, 0xa0ff0002, /* cnd r0.a, r0.a, c1.a, c2.a */
0x00000005, 0x80070001, 0xa0e40001, 0x80e40000, /* mul r1.rgb, c1, r0 */
0x00000004, 0x80070000, 0x80ff0000, 0xa0e40002, 0x80e40001, /* mad r0.rgb, r0.a, c2, r1 */
0x0000ffff /* end */
};
static const struct
{
struct vec3 position;
struct vec2 texcrd;
}
quad[] =
{
/* Flip the y coordinate to make the input and
* output arrays easier to compare. */
{{ -1.0f, -1.0f, 0.0f}, { 0.0f, 1.0f}},
{{ -1.0f, 1.0f, 0.0f}, { 0.0f, 0.0f}},
{{ 1.0f, -1.0f, 0.0f}, { 1.0f, 1.0f}},
{{ 1.0f, 1.0f, 0.0f}, { 1.0f, 0.0f}},
};
static const D3DCOLOR expected_alpha[4][4] =
{
{0x00808000, 0x007f7f00, 0x00ffff00, 0x00000000},
{0x00909000, 0x00a0a000, 0x00b0b000, 0x00c0c000},
{0x00d0d000, 0x00e0e000, 0x00f0f000, 0x00000000},
{0x00101000, 0x00202000, 0x00010100, 0x00020200},
};
static const BOOL alpha_broken[4][4] =
{
{FALSE, FALSE, FALSE, FALSE},
{FALSE, FALSE, FALSE, FALSE},
{FALSE, FALSE, FALSE, TRUE },
{FALSE, FALSE, FALSE, FALSE},
};
static const D3DCOLOR expected_colors[4][4] =
{
{0x00808080, 0x00fefeff, 0x00010780, 0x008080ff},
{0x00018080, 0x00800180, 0x0080fe80, 0x00fe8080},
{0x00ba98a0, 0x004767a8, 0x00888881, 0x007878ff},
{0x00c3c3c0, 0x003f3f80, 0x00e51fe1, 0x005fa2c8},
};
static const D3DCOLOR expected_colors2[4][4] =
{
{0x00808080, 0x00fefeff, 0x00800180, 0x008080ff},
{0x00018080, 0x00800180, 0x004767a8, 0x00fe8080},
{0x00ba98a0, 0x004767a8, 0x00888881, 0x007878ff},
{0x00c3c3c0, 0x003f3f80, 0x00e51fe1, 0x005fa2c8},
};
static const D3DCOLOR expected_colors3[4] =
{
0x00018080,
0x00ba98a0,
0x00ba98a0,
0x00c3c3c0,
};
D3DCOLOR expected_color;
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a D3D device, skipping tests.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
{
skip("Pixel shaders not supported, skipping converted format test.\n");
goto done;
}
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreatePixelShader(device, shader_code_alpha, &shader_alpha);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
for (i = 0; i < sizeof(formats) / sizeof(*formats); i++)
{
hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, formats[i].format);
if (FAILED(hr))
{
skip("Format %s not supported, skipping.\n", formats[i].name);
continue;
}
for (j = 0; j < sizeof(tests) / sizeof(*tests); j++)
{
texture_sysmem = NULL;
hr = IDirect3DDevice9_CreateTexture(device, tests[j].width, 4, 1, 0,
formats[i].format, tests[j].pool, &texture, NULL);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
for (y = 0; y < 4; y++)
{
memcpy((char *)locked_rect.pBits + y * locked_rect.Pitch,
(char *)formats[i].content + y * 4 * formats[i].pixel_size,
tests[j].width * formats[i].pixel_size);
}
hr = IDirect3DTexture9_UnlockRect(texture, 0);
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
if (tests[j].pool == D3DPOOL_SYSTEMMEM)
{
texture_sysmem = texture;
hr = IDirect3DDevice9_CreateTexture(device, tests[j].width, 4, 1, 0,
formats[i].format, D3DPOOL_DEFAULT, &texture, NULL);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture_sysmem,
(IDirect3DBaseTexture9 *)texture);
ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr);
}
hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, shader_alpha);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00330033, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
for (y = 0; y < 4; y++)
{
for (x = 0; x < tests[j].width; x++)
{
BOOL r200_broken = formats[i].alpha_broken && alpha_broken[y][x];
if (formats[i].alpha)
expected_color = expected_alpha[y][x];
else
expected_color = 0x00ffff00;
color = getPixelColor(device, 80 + 160 * x, 60 + 120 * y);
ok(color_match(color, expected_color, 1) || broken(r200_broken),
"Expected color 0x%08x, got 0x%08x, format %s, location %ux%u.\n",
expected_color, color, formats[i].name, x, y);
}
}
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, shader);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00330033, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
for (y = 0; y < 4; y++)
{
for (x = 0; x < tests[j].width; x++)
{
expected_color = expected_colors[y][x];
if (!formats[i].blue)
expected_color |= 0x000000ff;
color = getPixelColor(device, 80 + 160 * x, 60 + 120 * y);
ok(color_match(color, expected_color, formats[i].slop)
|| broken(color_match(color, expected_color, formats[i].slop_broken)),
"Expected color 0x%08x, got 0x%08x, format %s, location %ux%u.\n",
expected_color, color, formats[i].name, x, y);
}
}
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
if (tests[j].pool != D3DPOOL_SYSTEMMEM)
{
IDirect3DTexture9_Release(texture);
continue;
}
hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &dst_surface);
ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
IDirect3DTexture9_GetSurfaceLevel(texture_sysmem, 0, &src_surface);
ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
hr = IDirect3DDevice9_UpdateSurface(device, src_surface,
&tests[j].src_rect, dst_surface, &tests[j].dst_point);
ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr);
IDirect3DSurface9_Release(dst_surface);
IDirect3DSurface9_Release(src_surface);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00003300, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(*quad));
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
for (y = 0; y < 4; y++)
{
for (x = 0; x < tests[j].width; x++)
{
if (tests[j].width == 4)
expected_color = expected_colors2[y][x];
else
expected_color = expected_colors3[y];
if (!formats[i].blue)
expected_color |= 0x000000ff;
color = getPixelColor(device, 80 + 160 * x, 60 + 120 * y);
ok(color_match(color, expected_color, formats[i].slop)
|| broken(color_match(color, expected_color, formats[i].slop_broken)),
"Expected color 0x%08x, got 0x%08x, format %s, location %ux%u.\n",
expected_color, color, formats[i].name, x, y);
}
}
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
IDirect3DTexture9_Release(texture_sysmem);
IDirect3DTexture9_Release(texture);
}
}
IDirect3DPixelShader9_Release(shader);
IDirect3DPixelShader9_Release(shader_alpha);
done:
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER9 identifier;
@ -17566,7 +17825,6 @@ START_TEST(visual)
texbem_test();
texdepth_test();
texkill_test();
x8l8v8u8_test();
volume_v16u16_test();
constant_clamp_ps_test();
cnd_test();
@ -17605,4 +17863,5 @@ START_TEST(visual)
test_negative_fixedfunction_fog();
test_position_index();
test_table_fog_zw();
test_signed_formats();
}