From 5a92395cf71f5c18c9430cb4ac34e6b4c2f89ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Tue, 22 Dec 2009 16:38:20 +0100 Subject: [PATCH 05/13] WineD3D: Implement D3DLOCK_DISCARD asynchronity --- dlls/wined3d/buffer.c | 16 +++++++++++++--- dlls/wined3d/device.c | 2 +- dlls/wined3d/drawprim.c | 5 ----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 729cd5e..90d44c8 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1057,14 +1057,24 @@ static inline void buffer_sync_apple(struct wined3d_buffer *This, struct wined3d { /* No fencing needs to be done if the app promises not to override * existing data */ + if(flags & WINED3DLOCK_DISCARD) + { + GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, NULL, This->buffer_object_usage)); + checkGLcall("glBufferDataARB\n"); + return; + } if(flags & WINED3DLOCK_NOOVERWRITE) return; if(!This->query.context) { - /* Don't allocate - this is done during the draw. - * The idea is that locks usually can happen on any thread, because apps - * pass WINED3DLOCK_NOOVERRIDE, while the draw isn't that flexible + /* The query isn't allocated unless it is really needed. Usually apps always + * use D3DLOCK_NOOVERWRITE or D3DLOCK_DISCARD for dynamic buffers, so in + * most cases we will never have to synchronize buffer changes against + * draw calls. */ + context_alloc_event_query(context, &This->query); + /* Since we don't know about old draws a glFinish is needed now. */ + wine_glFinish(); } else if(This->query.context != context || This->flags & WINED3D_BUFFER_GLFINISH) { diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 94d9532..4541213 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -321,7 +321,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, if (vb) { IWineD3DBuffer_PreLoad(vb); - if(((struct wined3d_buffer *) vb)->flags & WINED3D_BUFFER_APPLESYNC) + if(((struct wined3d_buffer *) vb)->query.context) { This->buffer_fences[This->num_buffer_fences++] = vb; } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index c34fe7e..b2b66bd 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -691,11 +691,6 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT { struct wined3d_buffer *cur = (struct wined3d_buffer *) This->buffer_fences[i]; - if(!cur->query.context) - { - context_alloc_event_query(context, &cur->query); - } - if(cur->query.context != context) { cur->flags |= WINED3D_BUFFER_GLFINISH; -- 1.6.4.4