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,21 +408,22 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
}
#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 width = ddsd.dwWidth;
int height = ddsd.dwHeight;
switch(ddsd.u4.ddpfPixelFormat.dwFourCC) {
case MAKE_FOURCC('D','X','T','1'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 8; break;
case MAKE_FOURCC('D','X','T','3'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
case MAKE_FOURCC('D','X','T','5'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
default: FIXME("FOURCC not supported\n"); break;
}
ddsd.u1.dwLinearSize = size;
} else
ddsd.u1.lPitch = DDRAW_width_bpp_to_pitch(ddsd.dwWidth, GET_BPP(ddsd)*8);
int size = 0;
int width = ddsd.dwWidth;
int height = ddsd.dwHeight;
switch(ddsd.u4.ddpfPixelFormat.dwFourCC) {
case MAKE_FOURCC('D','X','T','1'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 8; break;
case MAKE_FOURCC('D','X','T','3'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
case MAKE_FOURCC('D','X','T','5'): size = ((width+3)&~3) * ((height+3)&~3) / 16 * 16; break;
default: FIXME("FOURCC not supported\n"); break;
}
ddsd.u1.dwLinearSize = size;
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.dwFlags |= DDSD_PITCH;
}
/* Check also for the MIPMAP / MIPMAPCOUNT flags.
......@@ -433,7 +434,7 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
ddsd.u2.dwMipMapCount = 1;
}
ddsd.dwFlags |= DDSD_PITCH | DDSD_PIXELFORMAT;
ddsd.dwFlags |= DDSD_PIXELFORMAT;
hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level);
if (FAILED(hr)) return hr;
......
......@@ -253,17 +253,20 @@ HRESULT DIB_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
}
/* 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
= VirtualAlloc(NULL, This->surface_desc.u1.dwLinearSize, MEM_COMMIT, PAGE_READWRITE);
else
This->surface_desc.dwFlags |= DDSD_LINEARSIZE;
} else {
This->surface_desc.lpSurface
= 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
when reading the last byte / half using word access */
MEM_COMMIT, PAGE_READWRITE);
This->surface_desc.dwFlags |= DDSD_PITCH;
}
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