=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: d3d9: Return D3D_OK from the palette setters.

Alexandre Julliard julliard at winehq.org
Mon Jan 14 15:55:50 CST 2013


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Jan 14 11:56:53 2013 +0100

d3d9: Return D3D_OK from the palette setters.

---

 dlls/d3d9/device.c       |   13 ++++++---
 dlls/d3d9/tests/device.c |   65 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index d79ad62..67f9906 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1832,9 +1832,14 @@ static HRESULT WINAPI d3d9_device_ValidateDevice(IDirect3DDevice9Ex *iface, DWOR
 static HRESULT WINAPI d3d9_device_SetPaletteEntries(IDirect3DDevice9Ex *iface,
         UINT palette_idx, const PALETTEENTRY *entries)
 {
-    FIXME("iface %p, palette_idx %u, entries %p unimplemented.\n", iface, palette_idx, entries);
+    WARN("iface %p, palette_idx %u, entries %p unimplemented.\n", iface, palette_idx, entries);
 
-    return D3DERR_INVALIDCALL;
+    /* The d3d9 palette API is non-functional on Windows. Getters and setters are implemented,
+     * and some drivers allow the creation of P8 surfaces. These surfaces can be copied to
+     * other P8 surfaces with StretchRect, but cannot be converted to (A)RGB.
+     *
+     * Some older(dx7) cards may have support for P8 textures, but games cannot rely on this. */
+    return D3D_OK;
 }
 
 static HRESULT WINAPI d3d9_device_GetPaletteEntries(IDirect3DDevice9Ex *iface,
@@ -1847,9 +1852,9 @@ static HRESULT WINAPI d3d9_device_GetPaletteEntries(IDirect3DDevice9Ex *iface,
 
 static HRESULT WINAPI d3d9_device_SetCurrentTexturePalette(IDirect3DDevice9Ex *iface, UINT palette_idx)
 {
-    FIXME("iface %p, palette_idx %u unimplemented.\n", iface, palette_idx);
+    WARN("iface %p, palette_idx %u unimplemented.\n", iface, palette_idx);
 
-    return D3DERR_INVALIDCALL;
+    return D3D_OK;
 }
 
 static HRESULT WINAPI d3d9_device_GetCurrentTexturePalette(IDirect3DDevice9Ex *iface, UINT *palette_idx)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index c81047a..7e7fe40 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2006 Vitaliy Margolen
  * Copyright (C) 2006 Chris Robinson
- * Copyright 2006-2007, 2010, 2011 Stefan Dösinger for CodeWeavers
+ * Copyright 2006-2008, 2010-2011, 2013 Stefan Dösinger for CodeWeavers
  * Copyright 2005, 2006, 2007 Henri Verbeet
  * Copyright 2013 Henri Verbeet for CodeWeavers
  * Copyright (C) 2008 Rico Schüller
@@ -5968,6 +5968,68 @@ static void test_surface_lockrect_blocks(void)
     DestroyWindow(window);
 }
 
+static void test_set_palette(void)
+{
+    IDirect3DDevice9 *device;
+    IDirect3D9 *d3d9;
+    UINT refcount;
+    HWND window;
+    HRESULT hr;
+    PALETTEENTRY pal[256];
+    unsigned int i;
+    D3DCAPS9 caps;
+
+    if (!(d3d9 = pDirect3DCreate9(D3D_SDK_VERSION)))
+    {
+        skip("Failed to create IDirect3D9 object, skipping tests.\n");
+        return;
+    }
+
+    window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW,
+            0, 0, 640, 480, 0, 0, 0, 0);
+    if (!(device = create_device(d3d9, window, window, TRUE)))
+    {
+        skip("Failed to create a D3D device, skipping tests.\n");
+        DestroyWindow(window);
+        return;
+    }
+
+    for (i = 0; i < sizeof(pal) / sizeof(*pal); i++)
+    {
+        pal[i].peRed = i;
+        pal[i].peGreen = i;
+        pal[i].peBlue = i;
+        pal[i].peFlags = 0xff;
+    }
+    hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    for (i = 0; i < sizeof(pal) / sizeof(*pal); i++)
+    {
+        pal[i].peRed = i;
+        pal[i].peGreen = i;
+        pal[i].peBlue = i;
+        pal[i].peFlags = i;
+    }
+    if (caps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE)
+    {
+        hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
+        ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    }
+    else
+    {
+        hr = IDirect3DDevice9_SetPaletteEntries(device, 0, pal);
+        ok(hr == D3DERR_INVALIDCALL, "SetPaletteEntries returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
+    }
+
+    refcount = IDirect3DDevice9_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+    IDirect3D9_Release(d3d9);
+    DestroyWindow(window);
+}
+
 START_TEST(device)
 {
     HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
@@ -6053,6 +6115,7 @@ START_TEST(device)
         test_surface_format_null();
         test_surface_double_unlock();
         test_surface_lockrect_blocks();
+        test_set_palette();
     }
 
 out:




More information about the wine-cvs mailing list