[PATCH] WineD3D: add a test for zenable=3Dfalse, =

Stefan Doesinger stefan at codeweavers.com
Sun Sep 7 20:04:34 CDT 2008


zwriteenable=3Dfalse=0A=
=0A=
I suspected that in this situation d3d writes to the z buffer,=0A=
but the test shows that I was mistaken=0A=
---=0A=
 dlls/d3d9/tests/visual.c |   60 =
++++++++++++++++++++++++++++++++++++++++++++++=0A=
 1 files changed, 60 insertions(+), 0 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c=0A=
index c889e7e..6538a60 100644=0A=
--- a/dlls/d3d9/tests/visual.c=0A=
+++ b/dlls/d3d9/tests/visual.c=0A=
@@ -9652,6 +9652,65 @@ static void dp3_alpha_test(IDirect3DDevice9 =
*device) {=0A=
     ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetTextureStageState failed =
with 0x%08x\n", hr);=0A=
 }=0A=
 =0A=
+static void zwriteenable_test(IDirect3DDevice9 *device) {=0A=
+    HRESULT hr;=0A=
+    DWORD color;=0A=
+    struct vertex quad1[] =3D {=0A=
+        { -1.0,  -1.0,  0.1,    0x00ff0000},=0A=
+        { -1.0,   1.0,  0.1,    0x00ff0000},=0A=
+        {  1.0,  -1.0,  0.1,    0x00ff0000},=0A=
+        {  1.0,   1.0,  0.1,    0x00ff0000},=0A=
+    };=0A=
+    struct vertex quad2[] =3D {=0A=
+        { -1.0,  -1.0,  0.9,    0x0000ff00},=0A=
+        { -1.0,   1.0,  0.9,    0x0000ff00},=0A=
+        {  1.0,  -1.0,  0.9,    0x0000ff00},=0A=
+        {  1.0,   1.0,  0.9,    0x0000ff00},=0A=
+    };=0A=
+=0A=
+    hr =3D IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | =
D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", =
hr);=0A=
+=0A=
+    hr =3D IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetFVF failed with =
0x%08x\n", hr);=0A=
+    hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, =
D3DZB_FALSE);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed with =
0x%08x\n", hr);=0A=
+    hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, =
TRUE);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed with =
0x%08x\n", hr);=0A=
+    hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, =
D3DCMP_LESSEQUAL);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed with =
0x%08x\n", hr);=0A=
+=0A=
+    hr =3D IDirect3DDevice9_BeginScene(device);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_BeginScene failed with =
0x%08x\n", hr);=0A=
+    if(SUCCEEDED(hr)) {=0A=
+        /* The Z buffer is filled with 1.0. Draw a red quad with z =3D =
0.1, zenable =3D D3DZB_FALSE, zwriteenable =3D TRUE.=0A=
+         * The red color is written because the z test is disabled. The =
question is wether the z =3D 0.1 values=0A=
+         * are written into the Z buffer. After the draw, set zenable =
=3D TRUE and draw a green quad at z =3D 0.9.=0A=
+         * If the values are written, the z test will fail(0.9 > 0.1) =
and the red color remains. If the values=0A=
+         * are not written, the z test succeeds(0.9 < 1.0) and the =
green color is written. It turns out that=0A=
+         * the screen is green, so zenable =3D D3DZB_FALSE and =
zwriteenable  =3D TRUE does NOT write to the z buffer.=0A=
+         */=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));=0A=
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, =
D3DZB_TRUE);=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed =
with 0x%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));=0A=
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed with 0x%08x\n", hr);=0A=
+=0A=
+        hr =3D IDirect3DDevice9_EndScene(device);=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_BeginScene failed with =
0x%08x\n", hr);=0A=
+    }=0A=
+=0A=
+    hr =3D IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);=0A=
+    ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", =
hr);=0A=
+    color =3D getPixelColor(device, 320, 240);=0A=
+    ok(color_match(color, 0x0000ff00, 1), "zwriteenable test returned =
0x%08x, expected 0x0000ff00\n",=0A=
+       color);=0A=
+=0A=
+    hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, =
D3DZB_FALSE);=0A=
+    ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed with =
0x%08x\n", hr);=0A=
+}=0A=
+=0A=
 START_TEST(visual)=0A=
 {=0A=
     IDirect3DDevice9 *device_ptr;=0A=
@@ -9748,6 +9807,7 @@ START_TEST(visual)=0A=
     tssargtemp_test(device_ptr);=0A=
     np2_stretch_rect_test(device_ptr);=0A=
     yuv_color_test(device_ptr);=0A=
+    zwriteenable_test(device_ptr);=0A=
 =0A=
     if (caps.VertexShaderVersion >=3D D3DVS_VERSION(1, 1))=0A=
     {=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_0011_01C9132F.96A81BC0--




More information about the wine-patches mailing list