[PATCH 4/4] d3d9/tests: Add a test for clamp + swizzle.

Matteo Bruni mbruni at codeweavers.com
Thu Nov 3 09:26:38 CDT 2011


This test should fail with Nvidia binary drivers versions 27x/280 because of a
bug in the drivers themselves. The bug was fixed in the 285.xx driver series.

Alexandre, if this affects you and is a hassle to update, probably just
dropping this patch for the time being is fine...

---
 dlls/d3d9/tests/visual.c |   83 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 2d651bf..01e0596 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -12657,6 +12657,88 @@ static void multisample_get_rtdata_test(IDirect3DDevice9 *device)
     IDirect3DSurface9_Release(rt);
 }
 
+static void clamp_test(IDirect3DDevice9 *device)
+{
+    HRESULT hr;
+    IDirect3DVertexShader9 *vs;
+    IDirect3DPixelShader9 *ps;
+    DWORD color;
+
+    static const DWORD vs_code[] =
+    {
+        0xfffe0300,                                                             /* vs_3_0                     */
+        0x0200001f, 0x80000000, 0x900f0000,                                     /* dcl_position v0            */
+        0x0200001f, 0x80000000, 0xe00f0000,                                     /* dcl_position o0            */
+        0x0200001f, 0x8000000a, 0xe00f0001,                                     /* dcl_color o1               */
+        0x05000051, 0xa00f0000, 0x40000000, 0x3f800000, 0x00000000, 0x00000000, /* def c0, 2.0, 1.0, 0.0, 0.0 */
+        0x02000001, 0x801f0000, 0x90d80000,                                     /* mov_sat r0, v0.xzyw        */
+        0x03000005, 0x80030001, 0x80e40000, 0xa0000000,                         /* mul r1.xy, r0, c0.x        */
+        0x03000002, 0xe0030000, 0x80e40001, 0xa1550000,                         /* sub o0.xy, r1, c0.y        */
+        0x02000001, 0xe0040000, 0x80aa0000,                                     /* mov o0.z, r0.z             */
+        0x02000001, 0xe0080000, 0xa0550000,                                     /* mov o0.w, c0.y             */
+        0x02000001, 0xe00f0001, 0x80e40000,                                     /* mov o1, r0                 */
+        0x0000ffff
+    };
+    static const DWORD ps_code[] =
+    {
+        0xffff0300,                                                             /* ps_3_0                     */
+        0x0200001f, 0x8000000a, 0x900f0000,                                     /* dcl_color v0               */
+        0x02000001, 0x800f0800, 0x90e40000,                                     /* mov oC0, v0                */
+        0x0000ffff
+    };
+
+    static const struct
+    {
+        float x, y, z;
+    }
+    quad[] =
+    {
+        {-2.0f, 0.0f, -2.0f},
+        {-2.0f, 0.0f,  2.0f},
+        { 2.0f, 0.0f, -2.0f},
+        { 2.0f, 0.0f,  2.0f},
+    };
+
+    hr = IDirect3DDevice9_CreateVertexShader(device, vs_code, &vs);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexShader failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_CreatePixelShader failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetFVF failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0, 0);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetVertexShader(device, vs);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetPixelShader(device, ps);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_BeginScene(device);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_BeginScene failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_DrawPrimitiveUP failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_EndScene(device);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_EndScene failed, hr %#x.\n", hr);
+
+    color = getPixelColor(device, 128, 128);
+    ok(color_match(color, 0x0033bb00, 1), "Clamp test: expected color 0x0033bb00, got 0x%08x.\n", color);
+    color = getPixelColor(device, 400, 128);
+    ok(color_match(color, 0x009fbb00, 1), "Clamp test: expected color 0x009fbb00, got 0x%08x.\n", color);
+    color = getPixelColor(device, 128, 400);
+    ok(color_match(color, 0x00332a00, 1), "Clamp test: expected color 0x00332a00, got 0x%08x.\n", color);
+
+    hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+    ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetVertexShader(device, NULL);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetPixelShader(device, NULL);
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_SetPixelShader failed, hr %#x.\n", hr);
+    IDirect3DPixelShader9_Release(vs);
+    IDirect3DPixelShader9_Release(ps);
+}
+
 START_TEST(visual)
 {
     IDirect3DDevice9 *device_ptr;
@@ -12807,6 +12889,7 @@ START_TEST(visual)
                     vFace_register_test(device_ptr);
                     vpos_register_test(device_ptr);
                     multiple_rendertargets_test(device_ptr);
+                    clamp_test(device_ptr);
                 } else {
                     skip("No ps_3_0 or vs_3_0 support\n");
                 }
-- 
1.7.3.4




More information about the wine-patches mailing list