Stefan Dösinger : wined3d: Implement subrange flushing with GL_APPLE_flush_buffer_range.

Alexandre Julliard julliard at winehq.org
Mon Jan 4 10:54:18 CST 2010


Module: wine
Branch: master
Commit: a756caac0ca3dcd80019b56422779c59394fdfd7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a756caac0ca3dcd80019b56422779c59394fdfd7

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Thu Dec 17 22:44:07 2009 +0100

wined3d: Implement subrange flushing with GL_APPLE_flush_buffer_range.

---

 dlls/wined3d/buffer.c          |   24 +++++++++++++++++++++++-
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 57dca35..20201b1 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -95,6 +95,7 @@ static inline BOOL buffer_is_fully_dirty(struct wined3d_buffer *This)
 static void buffer_create_buffer_object(struct wined3d_buffer *This)
 {
     GLenum error, gl_usage;
+    const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
 
     TRACE("Creating an OpenGL vertex buffer object for IWineD3DVertexBuffer %p Usage(%s)\n",
             This, debug_d3dusage(This->resource.usage));
@@ -149,6 +150,13 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This)
     {
         TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n");
         gl_usage = GL_DYNAMIC_DRAW_ARB;
+
+        if(gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
+        {
+            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;
+        }
     }
 
     /* Reserve memory for the buffer. The amount of data won't change
@@ -1061,6 +1069,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
 static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
 {
     struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
+    ULONG i;
 
     TRACE("(%p)\n", This);
 
@@ -1094,6 +1103,18 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
         context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
         ENTER_GL();
         GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+
+        if(This->flags & WINED3D_BUFFER_FLUSH)
+        {
+            for(i = 0; i < This->modified_areas; i++)
+            {
+                GL_EXTCALL(glFlushMappedBufferRangeAPPLE(This->buffer_type_hint,
+                                                         This->maps[i].offset,
+                                                         This->maps[i].size));
+                checkGLcall("glFlushMappedBufferRangeAPPLE");
+            }
+        }
+
         GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
         LEAVE_GL();
         context_release(context);
@@ -1175,7 +1196,8 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
     TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage,
             debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer);
 
-    dynamic_buffer_ok = FALSE; /* TODO: GL_APPLE_map_buffer_range, GL_ARB_map_buffer_range */
+    /* TODO: GL_ARB_map_buffer_range */
+    dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE];
 
     /* Observations show that drawStridedSlow is faster on dynamic VBs than converting +
      * drawStridedFast (half-life 2 and others).
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f0e0fd3..de0bcdc 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2368,6 +2368,7 @@ struct wined3d_map_range
 #define WINED3D_BUFFER_HASDESC      0x02    /* A vertex description has been found */
 #define WINED3D_BUFFER_CREATEBO     0x04    /* Attempt to create a buffer object next PreLoad */
 #define WINED3D_BUFFER_DOUBLEBUFFER 0x08    /* Use a vbo and local allocated memory */
+#define WINED3D_BUFFER_FLUSH        0x10    /* Manual unmap flushing */
 
 struct wined3d_buffer
 {




More information about the wine-cvs mailing list