Commit 65a4775b authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Handle correctly DDSD_LINEARSIZE flag for FOURCC textures.

parent d6cf14d7
...@@ -408,9 +408,8 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD, ...@@ -408,9 +408,8 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
} }
#endif #endif
if (!(ddsd.dwFlags & DDSD_PITCH)) if ((ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) && !(ddsd.dwFlags & DDSD_LINEARSIZE))
{ {
if (ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
int size = 0; int size = 0;
int width = ddsd.dwWidth; int width = ddsd.dwWidth;
int height = ddsd.dwHeight; int height = ddsd.dwHeight;
...@@ -421,8 +420,10 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD, ...@@ -421,8 +420,10 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
default: FIXME("FOURCC not supported\n"); break; default: FIXME("FOURCC not supported\n"); break;
} }
ddsd.u1.dwLinearSize = size; ddsd.u1.dwLinearSize = size;
} else ddsd.dwFlags |= DDSD_LINEARSIZE;
} else if (!(ddsd.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) && !(ddsd.dwFlags & DDSD_PITCH)) {
ddsd.u1.lPitch = DDRAW_width_bpp_to_pitch(ddsd.dwWidth, GET_BPP(ddsd)*8); ddsd.u1.lPitch = DDRAW_width_bpp_to_pitch(ddsd.dwWidth, GET_BPP(ddsd)*8);
ddsd.dwFlags |= DDSD_PITCH;
} }
/* Check also for the MIPMAP / MIPMAPCOUNT flags. /* Check also for the MIPMAP / MIPMAPCOUNT flags.
...@@ -433,7 +434,7 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD, ...@@ -433,7 +434,7 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
ddsd.u2.dwMipMapCount = 1; ddsd.u2.dwMipMapCount = 1;
} }
ddsd.dwFlags |= DDSD_PITCH | DDSD_PIXELFORMAT; ddsd.dwFlags |= DDSD_PIXELFORMAT;
hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level); hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
......
...@@ -253,17 +253,20 @@ HRESULT DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This, ...@@ -253,17 +253,20 @@ HRESULT DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
} }
/* XXX else: how should lPitch be verified? */ /* XXX else: how should lPitch be verified? */
This->surface_desc.dwFlags |= DDSD_PITCH|DDSD_LPSURFACE; This->surface_desc.dwFlags |= DDSD_LPSURFACE;
if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
This->surface_desc.lpSurface This->surface_desc.lpSurface
= VirtualAlloc(NULL, This->surface_desc.u1.dwLinearSize, MEM_COMMIT, PAGE_READWRITE); = VirtualAlloc(NULL, This->surface_desc.u1.dwLinearSize, MEM_COMMIT, PAGE_READWRITE);
else This->surface_desc.dwFlags |= DDSD_LINEARSIZE;
} else {
This->surface_desc.lpSurface This->surface_desc.lpSurface
= VirtualAlloc(NULL, This->surface_desc.u1.lPitch = VirtualAlloc(NULL, This->surface_desc.u1.lPitch
* This->surface_desc.dwHeight + 4, /* The + 4 here is for dumb games reading after the end of the surface * This->surface_desc.dwHeight + 4, /* The + 4 here is for dumb games reading after the end of the surface
when reading the last byte / half using word access */ when reading the last byte / half using word access */
MEM_COMMIT, PAGE_READWRITE); MEM_COMMIT, PAGE_READWRITE);
This->surface_desc.dwFlags |= DDSD_PITCH;
}
if (This->surface_desc.lpSurface == NULL) if (This->surface_desc.lpSurface == NULL)
{ {
......
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