Commit 03389acc authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Do not free regularily locked surfaces.

parent a7916d80
...@@ -824,6 +824,19 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED ...@@ -824,6 +824,19 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
} }
} }
/* Performance optimization: Count how often a surface is locked, if it is locked regularly do not throw away the system memory copy.
* This avoids the need to download the surface from opengl all the time. The surface is still downloaded if the opengl texture is
* changed
*/
if(!(This->Flags & SFLAG_DYNLOCK)) {
This->lockCount++;
/* MAXLOCKCOUNT is defined in wined3d_private.h */
if(This->lockCount > MAXLOCKCOUNT) {
TRACE("Surface is locked regularily, not freeing the system memory copy any more\n");
This->Flags |= SFLAG_DYNLOCK;
}
}
TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect->pBits, pLockedRect->Pitch, This->Flags & SFLAG_DIRTY ? 0 : 1); TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect->pBits, pLockedRect->Pitch, This->Flags & SFLAG_DIRTY ? 0 : 1);
This->Flags |= SFLAG_LOCKED; This->Flags |= SFLAG_LOCKED;
......
...@@ -984,6 +984,8 @@ struct IWineD3DSurfaceImpl ...@@ -984,6 +984,8 @@ struct IWineD3DSurfaceImpl
RECT lockedRect; RECT lockedRect;
RECT dirtyRect; RECT dirtyRect;
int lockCount;
#define MAXLOCKCOUNT 50 /* After this amount of locks do not free the sysmem copy */
glDescriptor glDescription; glDescriptor glDescription;
......
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