Commit d6ba069d authored by Alexander Dorofeyev's avatar Alexander Dorofeyev Committed by Alexandre Julliard

wined3d: Improve detection of device palette change.

parent 1c897954
...@@ -1041,14 +1041,12 @@ static void p8_texture_test(IDirect3DDevice8 *device) ...@@ -1041,14 +1041,12 @@ static void p8_texture_test(IDirect3DDevice8 *device)
ok(red == 0xff && blue == 0 && green == 0, ok(red == 0xff && blue == 0 && green == 0,
"got color %08x, expected 0x00ff0000\n", color); "got color %08x, expected 0x00ff0000\n", color);
todo_wine { color = getPixelColor(device, 32, 320);
color = getPixelColor(device, 32, 320); red = (color & 0x00ff0000) >> 16;
red = (color & 0x00ff0000) >> 16; green = (color & 0x0000ff00) >> 8;
green = (color & 0x0000ff00) >> 8; blue = (color & 0x000000ff) >> 0;
blue = (color & 0x000000ff) >> 0; ok(red == 0 && blue == 0xff && green == 0,
ok(red == 0 && blue == 0xff && green == 0, "got color %08x, expected 0x000000ff\n", color);
"got color %08x, expected 0x000000ff\n", color);
}
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0); hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr = %08x\n", hr);
...@@ -1069,14 +1067,12 @@ static void p8_texture_test(IDirect3DDevice8 *device) ...@@ -1069,14 +1067,12 @@ static void p8_texture_test(IDirect3DDevice8 *device)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
todo_wine { color = getPixelColor(device, 32, 32);
color = getPixelColor(device, 32, 32); red = (color & 0x00ff0000) >> 16;
red = (color & 0x00ff0000) >> 16; green = (color & 0x0000ff00) >> 8;
green = (color & 0x0000ff00) >> 8; blue = (color & 0x000000ff) >> 0;
blue = (color & 0x000000ff) >> 0; ok(red == 0 && blue == 0xff && green == 0,
ok(red == 0 && blue == 0xff && green == 0, "got color %08x, expected 0x000000ff\n", color);
"got color %08x, expected 0x000000ff\n", color);
}
/* Test palettes with alpha */ /* Test palettes with alpha */
IDirect3DDevice8_GetDeviceCaps(device, &caps); IDirect3DDevice8_GetDeviceCaps(device, &caps);
...@@ -1134,21 +1130,19 @@ static void p8_texture_test(IDirect3DDevice8 *device) ...@@ -1134,21 +1130,19 @@ static void p8_texture_test(IDirect3DDevice8 *device)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr = %08x\n", hr);
todo_wine { color = getPixelColor(device, 32, 32);
color = getPixelColor(device, 32, 32); red = (color & 0x00ff0000) >> 16;
red = (color & 0x00ff0000) >> 16; green = (color & 0x0000ff00) >> 8;
green = (color & 0x0000ff00) >> 8; blue = (color & 0x000000ff) >> 0;
blue = (color & 0x000000ff) >> 0; ok(red >= 0x7e && red <= 0x81 && blue == 0 && green == 0,
ok(red >= 0x7e && red <= 0x81 && blue == 0 && green == 0, "got color %08x, expected 0x00800000 or near\n", color);
"got color %08x, expected 0x00800000 or near\n", color);
color = getPixelColor(device, 32, 320);
color = getPixelColor(device, 32, 320); red = (color & 0x00ff0000) >> 16;
red = (color & 0x00ff0000) >> 16; green = (color & 0x0000ff00) >> 8;
green = (color & 0x0000ff00) >> 8; blue = (color & 0x000000ff) >> 0;
blue = (color & 0x000000ff) >> 0; ok(red == 0 && blue >= 0x7e && blue <= 0x81 && green == 0,
ok(red == 0 && blue >= 0x7e && blue <= 0x81 && green == 0, "got color %08x, expected 0x00000080 or near\n", color);
"got color %08x, expected 0x00000080 or near\n", color);
}
} }
hr = IDirect3DDevice8_SetTexture(device, 0, NULL); hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
......
...@@ -125,6 +125,19 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) { ...@@ -125,6 +125,19 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
} }
IWineD3DCubeTexture_BindTexture(iface); IWineD3DCubeTexture_BindTexture(iface);
if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) {
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
if(palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[j][i])) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(This->surfaces[j][i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[j][i], SFLAG_INTEXTURE, FALSE);
}
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */ /* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
if (This->baseTexture.dirty) { if (This->baseTexture.dirty) {
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
......
...@@ -5490,6 +5490,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, ...@@ -5490,6 +5490,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface,
return WINED3D_OK; return WINED3D_OK;
} }
static void dirtify_p8_texture_samplers(IWineD3DDeviceImpl *device)
{
int i;
for (i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl*)device->stateBlock->textures[i];
if (texture && (texture->resource.format == WINED3DFMT_P8 || texture->resource.format == WINED3DFMT_A8P8)) {
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
}
}
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) { static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
int j; int j;
...@@ -5531,6 +5543,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *ifa ...@@ -5531,6 +5543,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *ifa
This->palettes[PaletteNumber][j].peBlue = pEntries[j].peBlue; This->palettes[PaletteNumber][j].peBlue = pEntries[j].peBlue;
This->palettes[PaletteNumber][j].peFlags = pEntries[j].peFlags; This->palettes[PaletteNumber][j].peFlags = pEntries[j].peFlags;
} }
if (PaletteNumber == This->currentPalette) dirtify_p8_texture_samplers(This);
TRACE("(%p) : returning\n", This); TRACE("(%p) : returning\n", This);
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -5565,7 +5578,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCurrentTexturePalette(IWineD3DDevi ...@@ -5565,7 +5578,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCurrentTexturePalette(IWineD3DDevi
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/*TODO: stateblocks */ /*TODO: stateblocks */
This->currentPalette = PaletteNumber; if (This->currentPalette != PaletteNumber) {
This->currentPalette = PaletteNumber;
dirtify_p8_texture_samplers(This);
}
TRACE("(%p) : returning\n", This); TRACE("(%p) : returning\n", This);
return WINED3D_OK; return WINED3D_OK;
} }
......
...@@ -499,6 +499,15 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { ...@@ -499,6 +499,15 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
} }
if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) {
if(palette9_changed(This)) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(iface, SFLAG_INTEXTURE, FALSE);
}
}
ENTER_GL(); ENTER_GL();
glEnable(This->glDescription.target);/* make sure texture support is enabled in this context */ glEnable(This->glDescription.target);/* make sure texture support is enabled in this context */
if (!This->glDescription.level) { if (!This->glDescription.level) {
...@@ -2149,7 +2158,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve ...@@ -2149,7 +2158,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
} }
} }
static BOOL palette9_changed(IWineD3DSurfaceImpl *This) { BOOL palette9_changed(IWineD3DSurfaceImpl *This) {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
if(This->palette || (This->resource.format != WINED3DFMT_P8 && This->resource.format != WINED3DFMT_A8P8)) { if(This->palette || (This->resource.format != WINED3DFMT_P8 && This->resource.format != WINED3DFMT_A8P8)) {
...@@ -2227,13 +2236,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO ...@@ -2227,13 +2236,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO
/* Make sure the texture is reloaded because of the color key change, this kills performance though :( */ /* Make sure the texture is reloaded because of the color key change, this kills performance though :( */
/* TODO: This is not necessarily needed with hw palettized texture support */ /* TODO: This is not necessarily needed with hw palettized texture support */
This->Flags &= ~SFLAG_INTEXTURE; This->Flags &= ~SFLAG_INTEXTURE;
} else if(palette9_changed(This)) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the color key change, this kills performance though :( */
This->Flags &= ~SFLAG_INTEXTURE;
} else { } else {
TRACE("surface is already in texture\n"); TRACE("surface is already in texture\n");
return WINED3D_OK; return WINED3D_OK;
......
...@@ -116,6 +116,17 @@ static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) { ...@@ -116,6 +116,17 @@ static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
IWineD3DTexture_BindTexture(iface); IWineD3DTexture_BindTexture(iface);
if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) {
for (i = 0; i < This->baseTexture.levels; i++) {
if(palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[i])) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(This->surfaces[i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[i], SFLAG_INTEXTURE, FALSE);
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */ /* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
if (This->baseTexture.dirty) { if (This->baseTexture.dirty) {
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
......
...@@ -1409,6 +1409,8 @@ typedef enum { ...@@ -1409,6 +1409,8 @@ typedef enum {
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode); HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode);
BOOL palette9_changed(IWineD3DSurfaceImpl *This);
/***************************************************************************** /*****************************************************************************
* IWineD3DVertexDeclaration implementation structure * IWineD3DVertexDeclaration implementation structure
*/ */
......
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