Module: wine
Branch: master
Commit: e6ab3832b20707108f8611a32ae61085ee4f76d8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e6ab3832b20707108f8611a32…
Author: Henri Verbeet <hverbeet(a)codeweavers.com>
Date: Tue May 10 21:18:44 2011 +0200
wined3d: Set SFLAG_DYNLOCK for lockable render targets.
---
dlls/wined3d/surface.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index ff84102..9891b96 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -7423,6 +7423,15 @@ HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE surface_ty
surface->flags |= SFLAG_DISCARD;
if (lockable || format_id == WINED3DFMT_D16_LOCKABLE)
surface->flags |= SFLAG_LOCKABLE;
+ /* I'm not sure if this qualifies as a hack or as an optimization. It
+ * seems reasonable to assume that lockable render targets will get
+ * locked, so we might as well set SFLAG_DYNLOCK right at surface
+ * creation. However, the other reason we want to do this is that several
+ * ddraw applications access surface memory while the surface isn't
+ * mapped. The SFLAG_DYNLOCK behaviour of keeping SYSMEM around for
+ * future locks prevents these from crashing. */
+ if (lockable && (usage & WINED3DUSAGE_RENDERTARGET))
+ surface->flags |= SFLAG_DYNLOCK;
/* Mark the texture as dirty so that it gets loaded first time around. */
surface_add_dirty_rect(surface, NULL);