Commit 5346039d authored by Alexander Dorofeyev's avatar Alexander Dorofeyev Committed by Alexandre Julliard

wined3d: Take alpha from device palette entry for d3d 8 and later.

Adds support for D3D >= 8 style palettes that contain alpha. This fixes rendering problems in games like Commandos 3 and Madden NFL 2004.
parent 74c380cb
...@@ -2000,6 +2000,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4] ...@@ -2000,6 +2000,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
IWineD3DPaletteImpl* pal = This->palette; IWineD3DPaletteImpl* pal = This->palette;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL index_in_alpha = FALSE; BOOL index_in_alpha = FALSE;
int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion;
int i; int i;
/* Old games like StarCraft, C&C, Red Alert and others use P8 render targets. /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
...@@ -2016,12 +2017,18 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4] ...@@ -2016,12 +2017,18 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
if (pal == NULL) { if (pal == NULL) {
/* Still no palette? Use the device's palette */ /* Still no palette? Use the device's palette */
/* Get the surface's palette */ /* can ddraw and d3d < 8 surfaces use device's palette (d3d >= 8 feature)? */
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
table[i][0] = device->palettes[device->currentPalette][i].peRed; table[i][0] = device->palettes[device->currentPalette][i].peRed;
table[i][1] = device->palettes[device->currentPalette][i].peGreen; table[i][1] = device->palettes[device->currentPalette][i].peGreen;
table[i][2] = device->palettes[device->currentPalette][i].peBlue; table[i][2] = device->palettes[device->currentPalette][i].peBlue;
if(dxVersion >= 8) {
/* Direct3D >= 8 palette usage style: P8 textures use device palettes, palette entry format is A8R8G8B8,
alpha is stored in peFlags and may be used by the app if D3DPTEXTURECAPS_ALPHAPALETTE device
capability flag is present (wine does advertise this capability) */
table[i][3] = device->palettes[device->currentPalette][i].peFlags;
} else {
/* BltOverride uses a GL_ALPHA_TEST based on GL_NOT_EQUAL 0, so the alpha component /* BltOverride uses a GL_ALPHA_TEST based on GL_NOT_EQUAL 0, so the alpha component
of pixels that should be masked away should be 0. When inde_in_alpha is set, of pixels that should be masked away should be 0. When inde_in_alpha is set,
we will store the palette index (the glReadPixels code reads GL_ALPHA back) we will store the palette index (the glReadPixels code reads GL_ALPHA back)
...@@ -2034,6 +2041,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4] ...@@ -2034,6 +2041,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
table[i][3] = 0xFF; table[i][3] = 0xFF;
} }
} }
}
} else { } else {
TRACE("Using surface palette %p\n", pal); TRACE("Using surface palette %p\n", pal);
/* Get the surface's palette */ /* Get the surface's palette */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment