Stefan Dösinger : wined3d: Partially implement unserialized buffers with the apple extension.
Alexandre Julliard
julliard at winehq.org
Tue Mar 23 12:12:46 CDT 2010
Module: wine
Branch: master
Commit: fd13a6ae232c5504ae925468e173e2ac89c593cc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fd13a6ae232c5504ae925468e173e2ac89c593cc
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Thu Mar 18 12:11:35 2010 +0100
wined3d: Partially implement unserialized buffers with the apple extension.
---
dlls/wined3d/buffer.c | 34 ++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 1 +
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index aedade9..1b1c4c2 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -107,6 +107,8 @@ static void delete_gl_buffer(struct wined3d_buffer *This)
checkGLcall("glDeleteBuffersARB");
LEAVE_GL();
This->buffer_object = 0;
+
+ This->flags &= ~WINED3D_BUFFER_APPLESYNC;
}
/* Context activation is done by the caller. */
@@ -169,6 +171,10 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This)
GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE));
checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE)");
This->flags |= WINED3D_BUFFER_FLUSH;
+
+ GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE));
+ checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE)");
+ This->flags |= WINED3D_BUFFER_APPLESYNC;
}
/* No setup is needed here for GL_ARB_map_buffer_range */
}
@@ -768,6 +774,26 @@ static DWORD STDMETHODCALLTYPE buffer_GetPriority(IWineD3DBuffer *iface)
return resource_get_priority((IWineD3DResource *)iface);
}
+/* The caller provides a context and GL locking and binds the buffer */
+static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags)
+{
+ /* No fencing needs to be done if the app promises not to overwrite
+ * existing data */
+ if(flags & WINED3DLOCK_NOOVERWRITE) return;
+ if(flags & WINED3DLOCK_DISCARD)
+ {
+ GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, NULL, This->buffer_object_usage));
+ checkGLcall("glBufferDataARB\n");
+ return;
+ }
+
+ /* Drop the unserialized updates for now */
+ FIXME("Implement fences for unserialized buffers\n");
+ GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE));
+ checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)");
+ This->flags &= ~WINED3D_BUFFER_APPLESYNC;
+}
+
/* The caller provides a GL context */
static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info, DWORD flags)
{
@@ -795,6 +821,13 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
}
else
{
+ if (This->flags & WINED3D_BUFFER_APPLESYNC)
+ {
+ DWORD syncflags = 0;
+ if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3DLOCK_DISCARD;
+ if (flags & WINED3D_BUFFER_NOSYNC) syncflags |= WINED3DLOCK_NOOVERWRITE;
+ buffer_sync_apple(This, syncflags);
+ }
map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
checkGLcall("glMapBufferARB");
}
@@ -1183,6 +1216,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
}
else
{
+ if(This->flags & WINED3D_BUFFER_APPLESYNC) buffer_sync_apple(This, flags);
This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
checkGLcall("glMapBufferARB");
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index db063dc..317fb80 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2476,6 +2476,7 @@ struct wined3d_map_range
#define WINED3D_BUFFER_FLUSH 0x10 /* Manual unmap flushing */
#define WINED3D_BUFFER_DISCARD 0x20 /* A DISCARD lock has occurred since the last PreLoad */
#define WINED3D_BUFFER_NOSYNC 0x40 /* All locks since the last PreLoad had NOOVERWRITE set */
+#define WINED3D_BUFFER_APPLESYNC 0x80 /* Using sync as in GL_APPLE_flush_buffer_range */
struct wined3d_buffer
{
More information about the wine-cvs
mailing list