d3d9/tests: Test NVDB (depth bounds test) behavior

Ričardas Barkauskas miegalius at gmail.com
Sun Sep 12 11:33:34 CDT 2010


Test NVDB behaviour if support is available.

Ričardas Barkauskas
REalm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100912/7cc58809/attachment.htm>
-------------- next part --------------
From 9f0fbc6f80142f76b0cd7fd4e6595d05ecfc09b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= <miegalius at gmail.com>
Date: Sun, 12 Sep 2010 19:19:11 +0300
Subject: d3d9/tests: Test NVDB (depth bounds test) behavior

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

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 48aad75..61c4783 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -10549,6 +10549,119 @@ static void depth_clamp_test(IDirect3DDevice9 *device)
     ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
 }
 
+static void depth_bounds_test(IDirect3DDevice9 *device)
+{
+    const struct tvertex quad1[] =
+    {
+            {    0,  300, 0.6f, 1, 0xfff9e814},
+            {  640,  300, 0.6f, 1, 0xfff9e814},
+            {    0,  360, 0.6f, 1, 0xfff9e814},
+            {  640,  360, 0.6f, 1, 0xfff9e814},
+    };
+    const struct tvertex quad2[] =
+    {
+            {    0,    0,  0.6f, 1, 0xff002b7f},
+            {  640,    0,  0.6f, 1, 0xff002b7f},
+            {    0,  480,  0.6f, 1, 0xff002b7f},
+            {  640,  480,  0.6f, 1, 0xff002b7f},
+    };
+    const struct tvertex quad3[] =
+    {
+            {    0,  100, 0.6f, 1, 0xfff91414},
+            {  640,  100, 0.6f, 1, 0xfff91414},
+            {    0,  160, 0.6f, 1, 0xfff91414},
+            {  640,  160, 0.6f, 1, 0xfff91414},
+    };
+
+    union {
+        DWORD d;
+        float f;
+    } tmpvalue;
+
+    IDirect3D9 *d3d = NULL;
+    IDirect3DSurface9 *offscreen_surface = NULL;
+    D3DCOLOR color;
+    HRESULT hr;
+
+    IDirect3DDevice9_GetDirect3D(device, &d3d);
+    if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
+            0,  D3DRTYPE_SURFACE, MAKEFOURCC('N','V','D','B')) != D3D_OK) {
+        skip("No NVDB (depth bounds test) support\n");
+        IDirect3D9_Release(d3d);
+        return;
+    }
+    IDirect3D9_Release(d3d);
+
+    hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
+            MAKEFOURCC('N','V','D','B'), D3DPOOL_DEFAULT, &offscreen_surface, NULL);
+    todo_wine ok(hr != D3D_OK, "Able to create surface, hr = %08x\n", hr);
+    if(offscreen_surface)
+    {
+        IDirect3DSurface9_Release(offscreen_surface);
+    }
+
+    hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0, 0);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, TRUE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, TRUE);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_ALWAYS);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+
+
+    hr = IDirect3DDevice9_BeginScene(device);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
+    ok(SUCCEEDED(hr), "SetFVF failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(*quad1));
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_X, MAKEFOURCC('N','V','D','B'));
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+    tmpvalue.f = 0.5;
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Z, tmpvalue.d);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+    tmpvalue.f = 0.9;
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_W, tmpvalue.d);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(*quad2));
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+
+    tmpvalue.f = 0.9;
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_Z, tmpvalue.d);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(*quad3));
+    ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ADAPTIVETESS_X, 0);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_EndScene(device);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+
+    color = getPixelColor(device, 150, 130);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    color = getPixelColor(device, 150, 200);
+    ok(color_match(color, 0x00ffffff, 1), "color 0x%08x.\n", color);
+    color = getPixelColor(device, 150, 330);
+    ok(color_match(color, 0x00002b7f, 1), "color 0x%08x.\n", color);
+
+
+    hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+}
+
 static void depth_buffer_test(IDirect3DDevice9 *device)
 {
     static const struct vertex quad1[] =
@@ -11246,6 +11359,7 @@ START_TEST(visual)
     depth_buffer_test(device_ptr);
     shadow_test(device_ptr);
     fp_special_test(device_ptr);
+    depth_bounds_test(device_ptr);
 
 cleanup:
     if(device_ptr) {
-- 
1.7.1


More information about the wine-patches mailing list