d3d9/tests: Add a test for color varyings clamping.
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:
parent
9ba6784d22
commit
05f57dae24
|
@ -20003,7 +20003,7 @@ static void test_depthbias(void)
|
|||
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
|
||||
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %08x\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
|
@ -21451,6 +21451,229 @@ done:
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_color_clamping(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 */
|
||||
0x00000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, /* def c0, 1.0, 1.0, 1.0, 1.0 */
|
||||
0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
|
||||
0x00000002, 0xd00f0000, 0xa0e40000, 0xa0e40000, /* add oD0, c0, c0 */
|
||||
0x00000002, 0xd00f0001, 0xa0e40000, 0xa0e40000, /* add oD1, c0, c0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const DWORD vs2_code[] =
|
||||
{
|
||||
0xfffe0200, /* vs_2_0 */
|
||||
0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
|
||||
0x05000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, /* def c0, 1.0, 1.0, 1.0, 1.0 */
|
||||
0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
|
||||
0x03000002, 0xd00f0000, 0xa0e40000, 0xa0e40000, /* add oD0, c0, c0 */
|
||||
0x03000002, 0xd00f0001, 0xa0e40000, 0xa0e40000, /* add oD1, c0, c0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const DWORD vs3_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 */
|
||||
0x05000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, /* def c0, 1.0, 1.0, 1.0, 1.0 */
|
||||
0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */
|
||||
0x03000002, 0xe00f0001, 0xa0e40000, 0xa0e40000, /* add o1, c0, c0 */
|
||||
0x03000002, 0xe00f0002, 0xa0e40000, 0xa0e40000, /* add o2, c0, c0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const DWORD ps1_code[] =
|
||||
{
|
||||
0xffff0101, /* ps_1_1 */
|
||||
0x00000051, 0xa00f0000, 0x3e800000, 0x3e800000, 0x3e800000, 0x3e800000, /* def c0, 0.25, 0.25, 0.25, 0.25 */
|
||||
0x00000002, 0x800f0000, 0x90e40000, 0x90e40001, /* add r0, v0, v1 */
|
||||
0x00000005, 0x800f0000, 0x80e40000, 0xa0e40000, /* mul r0, r0, c0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const DWORD ps2_code[] =
|
||||
{
|
||||
0xffff0200, /* ps_2_0 */
|
||||
0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
|
||||
0x0200001f, 0x80000000, 0x900f0001, /* dcl v1 */
|
||||
0x05000051, 0xa00f0000, 0x3e800000, 0x3e800000, 0x3e800000, 0x3e800000, /* def c0, 0.25, 0.25, 0.25, 0.25 */
|
||||
0x02000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
|
||||
0x03000002, 0x800f0000, 0x80e40000, 0x90e40001, /* add r0, r0, v1 */
|
||||
0x03000005, 0x800f0000, 0x80e40000, 0xa0e40000, /* mul r0, r0, c0 */
|
||||
0x02000001, 0x800f0800, 0x80e40000, /* mov oC0, r0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const DWORD ps3_code[] =
|
||||
{
|
||||
0xffff0300, /* ps_3_0 */
|
||||
0x0200001f, 0x8000000a, 0x900f0000, /* dcl_color0 v0 */
|
||||
0x0200001f, 0x8001000a, 0x900f0001, /* dcl_color1 v1 */
|
||||
0x05000051, 0xa00f0000, 0x3e800000, 0x3e800000, 0x3e800000, 0x3e800000, /* def c0, 0.25, 0.25, 0.25, 0.25 */
|
||||
0x02000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
|
||||
0x03000002, 0x800f0000, 0x80e40000, 0x90e40001, /* add r0, r0, v1 */
|
||||
0x03000005, 0x800f0800, 0x80e40000, 0xa0e40000, /* mul oC0, r0, c0 */
|
||||
0x0000ffff
|
||||
};
|
||||
static const struct
|
||||
{
|
||||
DWORD vs_version;
|
||||
const DWORD *vs;
|
||||
DWORD ps_version;
|
||||
const DWORD *ps;
|
||||
D3DCOLOR expected, broken;
|
||||
}
|
||||
tests[] =
|
||||
{
|
||||
{0, NULL, 0, NULL, 0x00404040},
|
||||
{0, NULL, D3DPS_VERSION(1, 1), ps1_code, 0x00404040, 0x00808080},
|
||||
{D3DVS_VERSION(1, 1), vs1_code, 0, NULL, 0x00404040},
|
||||
{D3DVS_VERSION(1, 1), vs1_code, D3DPS_VERSION(1, 1), ps1_code, 0x007f7f7f},
|
||||
{D3DVS_VERSION(2, 0), vs2_code, D3DPS_VERSION(2, 0), ps2_code, 0x007f7f7f},
|
||||
{D3DVS_VERSION(3, 0), vs3_code, D3DPS_VERSION(3, 0), ps3_code, 0x00ffffff},
|
||||
};
|
||||
IDirect3DVertexShader9 *vs;
|
||||
IDirect3DPixelShader9 *ps;
|
||||
IDirect3DDevice9 *device;
|
||||
IDirect3D9 *d3d9;
|
||||
unsigned int i;
|
||||
ULONG refcount;
|
||||
D3DCOLOR color;
|
||||
D3DCAPS9 caps;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
|
||||
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
ok(!!d3d9, "Failed to create a D3D object.\n");
|
||||
if (!(device = create_device(d3d9, window, window, TRUE)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
IDirect3D9_Release(d3d9);
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
|
||||
ok(SUCCEEDED(hr), "Failed to get caps, 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_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0xff404040);
|
||||
ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
|
||||
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_SPECULAR);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||
ok(SUCCEEDED(hr), "Failed to set color arg, 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.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, 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);
|
||||
|
||||
color = getPixelColor(device, 320, 240);
|
||||
ok(color_match(color, tests[i].expected, 1) || broken(color_match(color, tests[i].broken, 1)),
|
||||
"Got unexpected color 0x%08x, case %u.\n", color, i);
|
||||
|
||||
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);
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
IDirect3D9_Release(d3d9);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(visual)
|
||||
{
|
||||
D3DADAPTER_IDENTIFIER9 identifier;
|
||||
|
@ -21573,4 +21796,5 @@ START_TEST(visual)
|
|||
test_uninitialized_varyings();
|
||||
test_multisample_init();
|
||||
test_texture_blending();
|
||||
test_color_clamping();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue