[D3D] Fix for FOURCC textures
Christian Costa
titan.costa at wanadoo.fr
Sat Jan 1 17:31:21 CST 2005
Happy New Year,
This patch enables Far Gate to enter the download section.
Changelog:
Handle correctly DDSD_LINEARSIZE flag for FOURCC textures.
Christian Costa titan.costa at wanadoo.fr
-------------- next part --------------
Index: dlls/ddraw/ddraw/main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/ddraw/main.c,v
retrieving revision 1.56
diff -u -r1.56 main.c
--- dlls/ddraw/ddraw/main.c 27 Dec 2004 17:12:55 -0000 1.56
+++ dlls/ddraw/ddraw/main.c 1 Jan 2005 22:12:31 -0000
@@ -408,21 +408,22 @@
}
#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 @@
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;
Index: dlls/ddraw/dsurface/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/dsurface/dib.c,v
retrieving revision 1.42
diff -u -r1.42 dib.c
--- dlls/ddraw/dsurface/dib.c 21 Dec 2004 14:47:35 -0000 1.42
+++ dlls/ddraw/dsurface/dib.c 1 Jan 2005 22:12:34 -0000
@@ -253,17 +253,20 @@
}
/* 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)
{
More information about the wine-patches
mailing list