From c3f0eb489b95fef577dd4d0cb7af74eddddb678c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Tue, 13 Feb 2007 20:21:41 +0100 Subject: [PATCH] wined3d: Remove pow2Size from the surfaces. --- dlls/wined3d/device.c | 3 --- dlls/wined3d/surface.c | 13 ++----------- dlls/wined3d/surface_gdi.c | 1 - dlls/wined3d/wined3d_private.h | 25 +++++++++++-------------- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5b188c61edf..51caef6ca56 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -832,11 +832,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U if (WINED3DFMT_UNKNOWN != Format) { object->bytesPerPixel = tableEntry->bpp; - object->pow2Size = ((pow2Width * object->bytesPerPixel) + SURFACE_ALIGNMENT - 1) & ~(SURFACE_ALIGNMENT - 1); - object->pow2Size *= pow2Height; } else { object->bytesPerPixel = 0; - object->pow2Size = 0; } /** TODO: change this into a texture transform matrix so that it's processed in hardware **/ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 3cd5e1e8a85..3d60b3fe2e1 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -628,12 +628,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED /*Surface has no memory currently allocated to it!*/ TRACE("(%p) Locking rect\n" , This); if(!This->resource.allocatedMemory) { - This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This->pow2Size); + This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + 4); } if (0 != This->glDescription.textureName) { /* Now I have to copy thing bits back */ - This->Flags |= SFLAG_ACTIVELOCK; /* When this flag is set to true, loading the surface again won't free THis->resource.allocatedMemory */ - /* TODO: make activeLock a bit more intelligent, maybe implement a method to purge the texture memory. */ /* Make sure that a proper texture unit is selected, bind the texture and dirtify the sampler to restore the texture on the next draw */ if (GL_SUPPORT(ARB_MULTITEXTURE)) { @@ -681,7 +679,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED if (This->resource.allocatedMemory == NULL) This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 ,This->resource.size); - This->Flags |= SFLAG_ACTIVELOCK; /*When this flag is set to true, loading the surface again won't free THis->resource.allocatedMemory*/ pLockedRect->pBits = This->resource.allocatedMemory; glFlush(); @@ -1243,10 +1240,6 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { int extraline = 0; SYSTEM_INFO sysInfo; - if(This->Flags & SFLAG_ACTIVELOCK) { - ERR("Creating a DIB section while a lock is active. Uncertain consequences\n"); - } - switch (This->bytesPerPixel) { case 2: case 4: @@ -2092,17 +2085,15 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORM if (format != WINED3DFMT_UNKNOWN) { This->bytesPerPixel = formatEntry->bpp; - This->pow2Size = (This->pow2Width * This->bytesPerPixel) * This->pow2Height; } else { This->bytesPerPixel = 0; - This->pow2Size = 0; } This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0; This->resource.format = format; - TRACE("(%p) : Size %d, pow2Size %d, bytesPerPixel %d, glFormat %d, glFotmatInternal %d, glType %d\n", This, This->resource.size, This->pow2Size, This->bytesPerPixel, This->glDescription.glFormat, This->glDescription.glFormatInternal, This->glDescription.glType); + TRACE("(%p) : Size %d, bytesPerPixel %d, glFormat %d, glFotmatInternal %d, glType %d\n", This, This->resource.size, This->bytesPerPixel, This->glDescription.glFormat, This->glDescription.glFormatInternal, This->glDescription.glType); return WINED3D_OK; } diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c index 292059325d1..34d6bff1a4f 100644 --- a/dlls/wined3d/surface_gdi.c +++ b/dlls/wined3d/surface_gdi.c @@ -1522,7 +1522,6 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface) /* We don't mind the nonpow2 stuff in GDI */ This->resource.size = IWineD3DSurface_GetPitch(iface) * This->currentDesc.Height; - This->pow2Size = This->resource.size; This->pow2Width = This->currentDesc.Width; This->pow2Height = This->currentDesc.Height; This->Flags &= ~SFLAG_NONPOW2; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f654b384de4..9c5cf339b0d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1069,18 +1069,17 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *S #define SFLAG_LOCKABLE 0x00000010 /* Surface can be locked */ #define SFLAG_DISCARD 0x00000020 /* ??? */ #define SFLAG_LOCKED 0x00000040 /* Surface is locked atm */ -#define SFLAG_ACTIVELOCK 0x00000080 /* Not locked, but surface memory is needed */ -#define SFLAG_INTEXTURE 0x00000100 /* ??? */ -#define SFLAG_INPBUFFER 0x00000200 /* ??? */ -#define SFLAG_NONPOW2 0x00000400 /* Surface sizes are not a power of 2 */ -#define SFLAG_DYNLOCK 0x00000800 /* Surface is often locked by the app */ -#define SFLAG_DYNCHANGE 0x00001800 /* Surface contents are changed very often, implies DYNLOCK */ -#define SFLAG_DCINUSE 0x00002000 /* Set between GetDC and ReleaseDC calls */ -#define SFLAG_GLDIRTY 0x00004000 /* The opengl texture is more up to date than the surface mem */ -#define SFLAG_LOST 0x00008000 /* Surface lost flag for DDraw */ -#define SFLAG_FORCELOAD 0x00010000 /* To force PreLoading of a scratch cursor */ -#define SFLAG_USERPTR 0x00020000 /* The application allocated the memory for this surface */ -#define SFLAG_GLCKEY 0x00040000 /* The gl texture was created with a color key */ +#define SFLAG_INTEXTURE 0x00000080 /* ??? */ +#define SFLAG_INPBUFFER 0x00000100 /* ??? */ +#define SFLAG_NONPOW2 0x00000200 /* Surface sizes are not a power of 2 */ +#define SFLAG_DYNLOCK 0x00000400 /* Surface is often locked by the app */ +#define SFLAG_DYNCHANGE 0x00000C00 /* Surface contents are changed very often, implies DYNLOCK */ +#define SFLAG_DCINUSE 0x00001000 /* Set between GetDC and ReleaseDC calls */ +#define SFLAG_GLDIRTY 0x00002000 /* The opengl texture is more up to date than the surface mem */ +#define SFLAG_LOST 0x00004000 /* Surface lost flag for DDraw */ +#define SFLAG_FORCELOAD 0x00008000 /* To force PreLoading of a scratch cursor */ +#define SFLAG_USERPTR 0x00010000 /* The application allocated the memory for this surface */ +#define SFLAG_GLCKEY 0x00020000 /* The gl texture was created with a color key */ /* In some conditions the surface memory must not be freed: * SFLAG_OVERSIZE: Not all data can be kept in GL @@ -1088,7 +1087,6 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *S * SFLAG_DIBSECTION: The dib code manages the memory * SFLAG_DIRTY: GL surface isn't up to date * SFLAG_LOCKED: The app requires access to the surface data - * SFLAG_ACTIVELOCK: Some wined3d code needs the memory * SFLAG_DYNLOCK: Avoid freeing the data for performance * SFLAG_DYNCHANGE: Same reason as DYNLOCK */ @@ -1097,7 +1095,6 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *S SFLAG_DIBSECTION | \ SFLAG_DIRTY | \ SFLAG_LOCKED | \ - SFLAG_ACTIVELOCK | \ SFLAG_DYNLOCK | \ SFLAG_DYNCHANGE | \ SFLAG_USERPTR)