From c30caec1dec66b2568b06bb6e26119a05954c467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Thu, 17 Dec 2009 22:44:07 +0100 Subject: [PATCH 8/8] 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 715c823..e225c9e 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -79,6 +79,7 @@ static inline BOOL buffer_is_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)); @@ -133,6 +134,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 @@ -1019,6 +1027,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); @@ -1052,6 +1061,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); @@ -1134,7 +1155,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 a1356e9..ec2627f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2354,6 +2354,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 { -- 1.6.4.4