d3d9/tests: Uninitialized varyings tests.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2015-10-12 23:17:05 +02:00 committed by Alexandre Julliard
parent f4d9f8c212
commit f63386f43e

View file

@ -19961,6 +19961,307 @@ static void test_flip(void)
DestroyWindow(window);
}
static void test_uninitialized_varyings(void)
{
static const D3DMATRIX mat =
{{{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
}}};
static const struct vec3 quad[] =
{
{-1.0f, -1.0f, 0.1f},
{-1.0f, 1.0f, 0.1f},
{ 1.0f, -1.0f, 0.1f},
{ 1.0f, 1.0f, 0.1f},
};
static const DWORD vs1_code[] =
{
0xfffe0101, /* vs_1_1 */
0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
0x0000ffff
};
static const DWORD vs1_partial_code[] =
{
0xfffe0101, /* vs_1_1 */
0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x00000051, 0xa00f0000, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, /* def c0, 0.5, 0.5, 0.5, 0.5 */
0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
0x00000001, 0xd0010000, 0xa0e40000, /* mov oD0.x, c0 */
0x00000001, 0xd0010001, 0xa0e40000, /* mov oD1.x, c0 */
0x00000001, 0xe0010000, 0xa0e40000, /* mov oT0.x, c0 */
0x0000ffff
};
static const DWORD vs2_code[] =
{
0xfffe0200, /* vs_2_0 */
0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
0x0000ffff
};
static const DWORD vs2_partial_code[] =
{
0xfffe0200, /* vs_2_0 */
0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x05000051, 0xa00f0000, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, /* def c0, 0.5, 0.5, 0.5, 0.5 */
0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
0x02000001, 0xd0010000, 0xa0e40000, /* mov oD0.x, c0 */
0x02000001, 0xd0010001, 0xa0e40000, /* mov oD1.x, c0 */
0x02000001, 0xe0010000, 0xa0e40000, /* mov oT0.x, c0 */
0x0000ffff
};
static const DWORD vs3_code[] =
{
0xfffe0300, /* vs_3_0 */
0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x0200001f, 0x80000000, 0xe00f0000, /* dcl_position o0 */
0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */
0x0000ffff
};
static const DWORD vs3_partial_code[] =
{
0xfffe0300, /* vs_3_0 */
0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
0x0200001f, 0x80000000, 0xe00f0000, /* dcl_position o0 */
0x0200001f, 0x8000000a, 0xe00f0001, /* dcl_color0 o1 */
0x0200001f, 0x8001000a, 0xe00f0002, /* dcl_color1 o2 */
0x0200001f, 0x80000005, 0xe00f0003, /* dcl_texcoord0 o3 */
0x05000051, 0xa00f0000, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, /* def c0, 0.5, 0.5, 0.5, 0.5 */
0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */
0x02000001, 0xe0010001, 0xa0e40000, /* mov o1.x, c0 */
0x02000001, 0xe0010002, 0xa0e40000, /* mov o2.x, c0 */
0x02000001, 0xe0010003, 0xa0e40000, /* mov o3.x, c0 */
0x0000ffff
};
static const DWORD ps1_diffuse_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
0x0000ffff
};
static const DWORD ps1_specular_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000001, 0x800f0000, 0x90e40001, /* mov r0, v1 */
0x0000ffff
};
static const DWORD ps1_texcoord_code[] =
{
0xffff0101, /* ps_1_1 */
0x00000040, 0xb00f0000, /* texcoord t0 */
0x00000001, 0x800f0000, 0xb0e40000, /* mov r0, t0 */
0x0000ffff
};
static const DWORD ps2_diffuse_code[] =
{
0xffff0200, /* ps_2_0 */
0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
0x0000ffff
};
static const DWORD ps2_specular_code[] =
{
0xffff0200, /* ps_2_0 */
0x0200001f, 0x80000000, 0x900f0001, /* dcl v1 */
0x02000001, 0x800f0800, 0x90e40001, /* mov oC0, v1 */
0x0000ffff
};
static const DWORD ps2_texcoord_code[] =
{
0xffff0200, /* ps_2_0 */
0x0200001f, 0x80000000, 0xb00f0000, /* dcl t0 */
0x02000001, 0x800f0800, 0xb0e40000, /* mov oC0, t0 */
0x0000ffff
};
static const DWORD ps3_diffuse_code[] =
{
0xffff0300, /* ps_3_0 */
0x0200001f, 0x8000000a, 0x900f0000, /* dcl_color0 v0 */
0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
0x0000ffff
};
static const DWORD ps3_specular_code[] =
{
0xffff0300, /* ps_3_0 */
0x0200001f, 0x8001000a, 0x900f0001, /* dcl_color1 v1 */
0x02000001, 0x800f0800, 0x90e40001, /* mov oC0, v1 */
0x0000ffff
};
static const DWORD ps3_texcoord_code[] =
{
0xffff0300, /* ps_3_0 */
0x0200001f, 0x80000005, 0x900f0000, /* dcl_texcoord0 v0 */
0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
0x0000ffff
};
static const struct
{
DWORD vs_version;
const DWORD *vs;
DWORD ps_version;
const DWORD *ps;
D3DCOLOR expected;
BOOL allow_zero_alpha;
BOOL allow_zero;
BOOL broken_warp;
}
/* On AMD specular color is generally initialized to 0x00000000 and texcoords to 0xff000000
* while on Nvidia it's the opposite. Just allow both. */
tests[] =
{
{D3DVS_VERSION(1, 1), vs1_code, 0, NULL, 0xffffffff},
{ 0, NULL, D3DPS_VERSION(1, 1), ps1_texcoord_code, 0xff000000, TRUE},
{ 0, NULL, D3DPS_VERSION(2, 0), ps2_texcoord_code, 0xff000000, TRUE},
{D3DVS_VERSION(1, 1), vs1_code, D3DPS_VERSION(1, 1), ps1_diffuse_code, 0xffffffff},
{D3DVS_VERSION(1, 1), vs1_code, D3DPS_VERSION(1, 1), ps1_specular_code, 0xff000000, TRUE, FALSE, TRUE},
{D3DVS_VERSION(1, 1), vs1_code, D3DPS_VERSION(1, 1), ps1_texcoord_code, 0xff000000, TRUE},
{D3DVS_VERSION(2, 0), vs2_code, D3DPS_VERSION(2, 0), ps2_diffuse_code, 0xffffffff},
{D3DVS_VERSION(2, 0), vs2_code, D3DPS_VERSION(2, 0), ps2_specular_code, 0xff000000, TRUE, FALSE, TRUE},
{D3DVS_VERSION(2, 0), vs2_code, D3DPS_VERSION(2, 0), ps2_texcoord_code, 0xff000000, TRUE},
{D3DVS_VERSION(3, 0), vs3_code, D3DPS_VERSION(3, 0), ps3_diffuse_code, 0xffffffff, FALSE, TRUE},
{D3DVS_VERSION(3, 0), vs3_code, D3DPS_VERSION(3, 0), ps3_specular_code, 0x00000000, FALSE, FALSE, TRUE},
{D3DVS_VERSION(3, 0), vs3_code, D3DPS_VERSION(3, 0), ps3_texcoord_code, 0x00000000, FALSE, FALSE, TRUE},
{D3DVS_VERSION(1, 1), vs1_partial_code, 0, NULL, 0xff7fffff, FALSE, FALSE, TRUE},
{D3DVS_VERSION(1, 1), vs1_partial_code, D3DPS_VERSION(1, 1), ps1_diffuse_code, 0xff7fffff, FALSE, FALSE, TRUE},
{D3DVS_VERSION(1, 1), vs1_partial_code, D3DPS_VERSION(1, 1), ps1_specular_code, 0xff7f0000, TRUE},
{D3DVS_VERSION(1, 1), vs1_partial_code, D3DPS_VERSION(1, 1), ps1_texcoord_code, 0xff7f0000, TRUE},
{D3DVS_VERSION(2, 0), vs2_partial_code, D3DPS_VERSION(2, 0), ps2_diffuse_code, 0xff7fffff, FALSE, FALSE, TRUE},
{D3DVS_VERSION(2, 0), vs2_partial_code, D3DPS_VERSION(2, 0), ps2_specular_code, 0xff7f0000, TRUE},
{D3DVS_VERSION(2, 0), vs2_partial_code, D3DPS_VERSION(2, 0), ps2_texcoord_code, 0xff7f0000, TRUE},
/* Fails on Radeon HD 2600 with 0x008000ff aka nonsensical color. */
/* {D3DVS_VERSION(3, 0), vs3_partial_code, D3DPS_VERSION(3, 0), ps3_diffuse_code, 0xff7fffff, TRUE}, */
/* Randomly fails on Radeon HD 2600. */
/* {D3DVS_VERSION(3, 0), vs3_partial_code, D3DPS_VERSION(3, 0), ps3_specular_code, 0x007f0000}, */
{D3DVS_VERSION(3, 0), vs3_partial_code, D3DPS_VERSION(3, 0), ps3_texcoord_code, 0xff7f0000, TRUE},
};
IDirect3DDevice9 *device;
IDirect3D9 *d3d;
HWND window;
HRESULT hr;
D3DADAPTER_IDENTIFIER9 identifier;
IDirect3DSurface9 *backbuffer;
struct surface_readback rb;
IDirect3DVertexShader9 *vs;
IDirect3DPixelShader9 *ps;
unsigned int i;
ULONG refcount;
D3DCAPS9 caps;
D3DCOLOR color;
BOOL warp;
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 = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
warp = !strcmp(identifier.Description, "Microsoft Basic Render Driver");
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
hr = IDirect3DDevice9_GetRenderTarget(device, 0, &backbuffer);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
{
if (caps.VertexShaderVersion < tests[i].vs_version
|| caps.PixelShaderVersion < tests[i].ps_version)
{
skip("Vertex / pixel shader version not supported, skipping test %u.\n", i);
continue;
}
if (tests[i].vs)
{
hr = IDirect3DDevice9_CreateVertexShader(device, tests[i].vs, &vs);
ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x (case %u).\n", hr, i);
}
else
{
vs = NULL;
}
if (tests[i].ps)
{
hr = IDirect3DDevice9_CreatePixelShader(device, tests[i].ps, &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x (case %u).\n", hr, i);
}
else
{
ps = NULL;
}
hr = IDirect3DDevice9_SetVertexShader(device, vs);
ok(SUCCEEDED(hr), "Failed to set vertex shader, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, ps);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 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, sizeof(quad[0]));
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);
get_rt_readback(backbuffer, &rb);
color = get_readback_color(&rb, 320, 240);
ok(color_match(color, tests[i].expected, 1)
|| (tests[i].allow_zero_alpha && color_match(color, tests[i].expected & 0x00ffffff, 1))
|| (tests[i].allow_zero && !color) || (broken(warp && tests[i].broken_warp)),
"Got unexpected color 0x%08x, case %u.\n", color, i);
release_surface_readback(&rb);
if (vs)
IDirect3DVertexShader9_Release(vs);
if (ps)
IDirect3DVertexShader9_Release(ps);
}
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
IDirect3DSurface9_Release(backbuffer);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER9 identifier;
@ -20080,4 +20381,5 @@ START_TEST(visual)
test_updatetexture();
test_depthbias();
test_flip();
test_uninitialized_varyings();
}