Stefan Dösinger : wined3d: Check the alignment of mapped buffer pointers.
Alexandre Julliard
julliard at winehq.org
Tue Mar 16 11:49:21 CDT 2010
Module: wine
Branch: master
Commit: cc6d17ba7cacb171a478f63ed81473ee0730ef35
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cc6d17ba7cacb171a478f63ed81473ee0730ef35
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Thu Mar 11 13:20:32 2010 +0100
wined3d: Check the alignment of mapped buffer pointers.
Windows returns 32 byte aligned pointers when locking vertex and index
buffers, and some applications(Half Life 2, Alpha Prime, possibly others)
rely on this. Check the alignment and fall back to double buffered
buffers with HeapAlloced and aligned pointers if the alignment doesn't
fit.
---
dlls/wined3d/buffer.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 08d3097..46131af 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1186,6 +1186,21 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
}
LEAVE_GL();
+
+ if (((DWORD_PTR) This->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
+ {
+ WARN("Pointer %p is not %u byte aligned, falling back to double buffered operation\n",
+ This->resource.allocatedMemory, RESOURCE_ALIGNMENT);
+
+ ENTER_GL();
+ GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+ checkGLcall("glUnmapBufferARB");
+ LEAVE_GL();
+ This->resource.allocatedMemory = NULL;
+
+ buffer_get_sysmem(This);
+ TRACE("New pointer is %p\n", This->resource.allocatedMemory);
+ }
context_release(context);
}
}
More information about the wine-cvs
mailing list