Commit 5193f670 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Implement copy_mipmap_chain() on top of wined3d_surface_blt().

parent 94fd6dc0
...@@ -5942,12 +5942,11 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device, ...@@ -5942,12 +5942,11 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
IDirectDrawSurface7 *temp; IDirectDrawSurface7 *temp;
DDSURFACEDESC2 ddsd; DDSURFACEDESC2 ddsd;
POINT point; POINT point;
RECT rect; RECT src_rect;
HRESULT hr; HRESULT hr;
IDirectDrawPalette *pal = NULL, *pal_src = NULL; IDirectDrawPalette *pal = NULL, *pal_src = NULL;
DWORD ckeyflag; DWORD ckeyflag;
DDCOLORKEY ddckey; DDCOLORKEY ddckey;
BOOL palette_missing = FALSE;
/* Copy palette, if possible. */ /* Copy palette, if possible. */
IDirectDrawSurface7_GetPalette(&src->IDirectDrawSurface7_iface, &pal_src); IDirectDrawSurface7_GetPalette(&src->IDirectDrawSurface7_iface, &pal_src);
...@@ -5961,12 +5960,6 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device, ...@@ -5961,12 +5960,6 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
IDirectDrawPalette_SetEntries(pal, 0, 0, 256, palent); IDirectDrawPalette_SetEntries(pal, 0, 0, 256, palent);
} }
if (dest->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 |
DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8) && !pal)
{
palette_missing = TRUE;
}
if (pal) IDirectDrawPalette_Release(pal); if (pal) IDirectDrawPalette_Release(pal);
if (pal_src) IDirectDrawPalette_Release(pal_src); if (pal_src) IDirectDrawPalette_Release(pal_src);
...@@ -5985,28 +5978,20 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device, ...@@ -5985,28 +5978,20 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
dest_level = dest; dest_level = dest;
point = *DestPoint; point = *DestPoint;
rect = *SrcRect; src_rect = *SrcRect;
for (;src_level && dest_level;) for (;src_level && dest_level;)
{ {
if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth && if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight) src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
{ {
/* Try UpdateSurface that may perform a more direct OpenGL UINT src_w = src_rect.right - src_rect.left;
* loading. But skip this if destination is paletted texture and UINT src_h = src_rect.bottom - src_rect.top;
* has no palette. Some games like Sacrifice set palette after RECT dst_rect = {point.x, point.y, point.x + src_w, point.y + src_h};
* Load, and it is a waste of effort to try to load texture
* without palette and generates warnings in wined3d. */ if (FAILED(hr = wined3d_surface_blt(dest_level->wined3d_surface, &dst_rect,
if (!palette_missing) src_level->wined3d_surface, &src_rect, 0, NULL, WINED3DTEXF_POINT)))
hr = wined3d_device_update_surface(device->wined3d_device, src_level->wined3d_surface, ERR("Blit failed, hr %#x.\n", hr);
&rect, dest_level->wined3d_surface, &point);
if (palette_missing || FAILED(hr))
{
/* UpdateSurface may fail e.g. if dest is in system memory. Fall back to BltFast that is less strict. */
wined3d_surface_bltfast(dest_level->wined3d_surface, point.x, point.y,
src_level->wined3d_surface, &rect, 0);
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE; ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL; ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
...@@ -6028,10 +6013,10 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device, ...@@ -6028,10 +6013,10 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
point.x /= 2; point.x /= 2;
point.y /= 2; point.y /= 2;
rect.top /= 2; src_rect.top /= 2;
rect.left /= 2; src_rect.left /= 2;
rect.right = (rect.right + 1) / 2; src_rect.right = (src_rect.right + 1) / 2;
rect.bottom = (rect.bottom + 1) / 2; src_rect.bottom = (src_rect.bottom + 1) / 2;
} }
if (src_level && src_level != src) IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface); if (src_level && src_level != src) IDirectDrawSurface7_Release(&src_level->IDirectDrawSurface7_iface);
......
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