diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 5ebd061f995..49f8782ecc1 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -3572,6 +3572,61 @@ static void cnd_test(IDirect3DDevice9 *device) IDirect3DPixelShader9_Release(shader_11); } +static void nested_loop_test(IDirect3DDevice9 *device) { + const DWORD shader_code[] = { + 0xffff0300, /* ps_3_0 */ + 0x05000051, 0xa00f0000, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, /* def c0, 0, 0, 0, 1 */ + 0x05000051, 0xa00f0001, 0x3d000000, 0x00000000, 0x00000000, 0x00000000, /* def c1, 1/32, 0, 0, 0*/ + 0x05000030, 0xf00f0000, 0x00000004, 0x00000000, 0x00000002, 0x00000000, /* defi i0, 4, 0, 2, 0 */ + 0x02000001, 0x800f0000, 0xa0e40000, /* mov r0, c0 */ + 0x0200001b, 0xf0e40800, 0xf0e40000, /* loop aL, i0 */ + 0x0200001b, 0xf0e40800, 0xf0e40000, /* loop aL, i0 */ + 0x03000002, 0x800f0000, 0x80e40000, 0xa0e40001, /* add r0, r0, c1 */ + 0x0000001d, /* endloop */ + 0x0000001d, /* endloop */ + 0x02000001, 0x800f0800, 0x80e40000, /* mov oC0, r0 */ + 0x0000ffff /* end */ + }; + IDirect3DPixelShader9 *shader; + HRESULT hr; + DWORD color; + const float quad[] = { + -1.0, -1.0, 0.1, + 1.0, -1.0, 0.1, + -1.0, 1.0, 0.1, + 1.0, 1.0, 0.1 + }; + + hr = IDirect3DDevice9_CreatePixelShader(device, shader_code, &shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader failed with %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetPixelShader(device, shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x0000ff00, 0.0, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %s\n", DXGetErrorString9(hr)); + if(SUCCEEDED(hr)) + { + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float)); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %s\n", DXGetErrorString9(hr)); + } + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); + + color = getPixelColor(device, 360, 240); + ok(color == 0x007f0000 || color == 0x00800000 || color == 0x00810000, + "Nested loop test returned color 0x%08x, expected 0x00800000\n", color); + + hr = IDirect3DDevice9_SetPixelShader(device, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with %s\n", DXGetErrorString9(hr)); + IDirect3DPixelShader9_Release(shader); +} + START_TEST(visual) { IDirect3DDevice9 *device_ptr; @@ -3679,6 +3734,11 @@ START_TEST(visual) if (caps.PixelShaderVersion >= D3DPS_VERSION(1, 4)) { constant_clamp_ps_test(device_ptr); cnd_test(device_ptr); + if (caps.PixelShaderVersion >= D3DPS_VERSION(3, 0)) { + nested_loop_test(device_ptr); + } else { + skip("No ps_3_0 support\n"); + } } } else skip("No ps_1_1 support\n");