Re: Re: Complex Surfaces patch
Marius Grigoriu <[email protected]> Fri, 20 Aug 2004 22:59:54 -0400
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
Ove Kaaven wrote: >fre, 20.08.2004 kl. 00.12 skrev Marius Grigoriu: > > >>So aside from fixing the indentation and log thing, is there anything >>else you want me to do before the patch can be merged? >> >> > >Can't think of anything much, unless you feel like adding error >checking. > > Here is the revised patch, sans error checking.
ddraw-ddraw-main.diff
(text/x-patch, 2 KB)
? dlls/ddraw/ddraw/complex_mipmap_v2.patch
Index: dlls/ddraw/ddraw/main.c
===================================================================
RCS file: /cvsroot/winex/dlls/ddraw/ddraw/main.c,v
retrieving revision 1.77
diff -u -r1.77 main.c
--- dlls/ddraw/ddraw/main.c 18 Feb 2004 22:27:36 -0000 1.77
+++ dlls/ddraw/ddraw/main.c 21 Aug 2004 02:36:19 -0000
@@ -323,20 +323,41 @@
{
DWORD mipmap_level = 0;
HRESULT hr;
+ DWORD max;
+ DDSURFACEDESC2 mipmap_surface_desc;
- hr = This->create_texture(This, pDDSD, ppSurf, pUnkOuter, mipmap_level);
+ mipmap_surface_desc = *pDDSD;
+
+ /* A somewhat undocumented feature, if DDSCAPS_COMPLEX is set,
+ * "It is permissible to omit the number of mipmaps levels, in which case
+ * CreateSurface() will create a chain of surfaces each a power of two
+ * smaller than the previous one down to the smallest possible size."
+ */
+ if(!(mipmap_surface_desc.dwFlags & DDSD_MIPMAPCOUNT) &&
+ (mipmap_surface_desc.ddsCaps.dwCaps & DDSCAPS_COMPLEX) &&
+ (mipmap_surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)){
+ DDRAW_dump_surface_desc(pDDSD);
+ max = (mipmap_surface_desc.dwWidth > mipmap_surface_desc.dwHeight) ?
+ mipmap_surface_desc.dwWidth : mipmap_surface_desc.dwHeight;
+ mipmap_surface_desc.u2.dwMipMapCount = 1;
+ while(max > 1){
+ max /= 2;
+ ++mipmap_surface_desc.u2.dwMipMapCount;
+ }
+ mipmap_surface_desc.dwFlags |= DDSD_MIPMAPCOUNT;
+ }
+
+ hr = This->create_texture(This, &mipmap_surface_desc, ppSurf, pUnkOuter, mipmap_level);
if (FAILED(hr)) return hr;
/* Create attached mipmaps if required. */
- if (more_mipmaps(pDDSD))
+ if (more_mipmaps(&mipmap_surface_desc))
{
LPDIRECTDRAWSURFACE7 mipmap;
LPDIRECTDRAWSURFACE7 prev_mipmap;
- DDSURFACEDESC2 mipmap_surface_desc;
prev_mipmap = *ppSurf;
IDirectDrawSurface7_AddRef(prev_mipmap);
- mipmap_surface_desc = *pDDSD;
mipmap_surface_desc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
while (more_mipmaps(&mipmap_surface_desc))