d3d9: Return D3D_OK from the palette setters.

This commit is contained in:
Stefan Dösinger 2013-01-14 11:56:53 +01:00 committed by Alexandre Julliard
parent 865078b05a
commit c57511ce4a
2 changed files with 73 additions and 5 deletions

View File

@ -1832,9 +1832,14 @@ static HRESULT WINAPI d3d9_device_ValidateDevice(IDirect3DDevice9Ex *iface, DWOR
static HRESULT WINAPI d3d9_device_SetPaletteEntries(IDirect3DDevice9Ex *iface, static HRESULT WINAPI d3d9_device_SetPaletteEntries(IDirect3DDevice9Ex *iface,
UINT palette_idx, const PALETTEENTRY *entries) 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, 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) 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) static HRESULT WINAPI d3d9_device_GetCurrentTexturePalette(IDirect3DDevice9Ex *iface, UINT *palette_idx)

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2006 Vitaliy Margolen * Copyright (C) 2006 Vitaliy Margolen
* Copyright (C) 2006 Chris Robinson * 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 2005, 2006, 2007 Henri Verbeet
* Copyright 2013 Henri Verbeet for CodeWeavers * Copyright 2013 Henri Verbeet for CodeWeavers
* Copyright (C) 2008 Rico Schüller * Copyright (C) 2008 Rico Schüller
@ -5968,6 +5968,68 @@ static void test_surface_lockrect_blocks(void)
DestroyWindow(window); 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) START_TEST(device)
{ {
HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" ); HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
@ -6053,6 +6115,7 @@ START_TEST(device)
test_surface_format_null(); test_surface_format_null();
test_surface_double_unlock(); test_surface_double_unlock();
test_surface_lockrect_blocks(); test_surface_lockrect_blocks();
test_set_palette();
} }
out: out: