Alexander Dorofeyev : d3d8/tests: Cover one more case in p8_texture_test.

Alexandre Julliard julliard at winehq.org
Mon Mar 10 07:17:01 CDT 2008


Module: wine
Branch: master
Commit: 785e6fa61f2366ca16fb6c1634231aa5ddf5db0e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=785e6fa61f2366ca16fb6c1634231aa5ddf5db0e

Author: Alexander Dorofeyev <alexd4 at inbox.lv>
Date:   Sun Mar  9 16:09:26 2008 +0200

d3d8/tests: Cover one more case in p8_texture_test.

Test if a P8 texture gets properly updated if there was a palette change while 
this texture wasn't bound to any stage.

---

 dlls/d3d8/tests/visual.c |   59 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 601a33c..f997bc9 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -914,7 +914,7 @@ static void p8_texture_test(IDirect3DDevice8 *device)
 {
     IDirect3D8 *d3d = NULL;
     HRESULT hr;
-    IDirect3DTexture8 *texture = NULL;
+    IDirect3DTexture8 *texture = NULL, *texture2 = NULL;
     D3DLOCKED_RECT lr;
     unsigned char *data;
     DWORD color, red, green, blue;
@@ -943,6 +943,23 @@ static void p8_texture_test(IDirect3DDevice8 *device)
     }
 
     hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_P8,
+                                        D3DPOOL_MANAGED, &texture2);
+    ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr = %08x\n", hr);
+    if(!texture2) {
+        skip("Failed to create D3DFMT_P8 texture\n");
+        goto out;
+    }
+
+    memset(&lr, 0, sizeof(lr));
+    hr = IDirect3DTexture8_LockRect(texture2, 0, &lr, NULL, 0);
+    ok(hr == D3D_OK, "IDirect3DTexture8_LockRect failed, hr = %08x\n", hr);
+    data = lr.pBits;
+    *data = 1;
+
+    hr = IDirect3DTexture8_UnlockRect(texture2, 0);
+    ok(hr == D3D_OK, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr);
+
+    hr = IDirect3DDevice8_CreateTexture(device, 1, 1, 1, 0, D3DFMT_P8,
                                         D3DPOOL_MANAGED, &texture);
     ok(hr == D3D_OK, "IDirect3DDevice8_CreateTexture failed, hr = %08x\n", hr);
     if(!texture) {
@@ -959,9 +976,6 @@ static void p8_texture_test(IDirect3DDevice8 *device)
     hr = IDirect3DTexture8_UnlockRect(texture, 0);
     ok(hr == D3D_OK, "IDirect3DTexture8_UnlockRect failed, hr = %08x\n", hr);
 
-    hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) texture);
-    ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr);
-
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
     ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
 
@@ -998,12 +1012,18 @@ static void p8_texture_test(IDirect3DDevice8 *device)
         hr = IDirect3DDevice8_SetCurrentTexturePalette(device, 0);
         ok(hr == D3D_OK, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr);
 
+        hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) texture2);
+        ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr);
+        hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
+        ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr);
+
+        hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) texture);
+        ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr);
         hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
         ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr);
 
         hr = IDirect3DDevice8_SetCurrentTexturePalette(device, 1);
         ok(hr == D3D_OK, "IDirect3DDevice8_SetCurrentTexturePalette failed, hr = %08x\n", hr);
-
         hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, 5 * sizeof(float));
         ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr);
 
@@ -1030,6 +1050,34 @@ static void p8_texture_test(IDirect3DDevice8 *device)
         "got color %08x, expected 0x000000ff\n", color);
     }
 
+    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
+    ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
+
+    hr = IDirect3DDevice8_BeginScene(device);
+    ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr = %08x\n", hr);
+    if(SUCCEEDED(hr)) {
+        hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *) texture2);
+        ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture failed, hr = %08x\n", hr);
+
+        hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
+        ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr = %08x\n", hr);
+
+        hr = IDirect3DDevice8_EndScene(device);
+        ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr = %08x\n", hr);
+    }
+
+    hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+    ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
+
+    todo_wine {
+        color = getPixelColor(device, 32, 32);
+        red   = (color & 0x00ff0000) >> 16;
+        green = (color & 0x0000ff00) >>  8;
+        blue  = (color & 0x000000ff) >>  0;
+        ok(red == 0 && blue == 0xff && green == 0,
+        "got color %08x, expected 0x000000ff\n", color);
+    }
+
     /* Test palettes with alpha */
     IDirect3DDevice8_GetDeviceCaps(device, &caps);
     if (!(caps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE)) {
@@ -1110,6 +1158,7 @@ static void p8_texture_test(IDirect3DDevice8 *device)
 
 out:
     if(texture) IDirect3DTexture8_Release(texture);
+    if(texture2) IDirect3DTexture8_Release(texture2);
     IDirect3D8_Release(d3d);
 }
 




More information about the wine-cvs mailing list