From 62db95ee0f1fc0f627e13a9fda1021500001d73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Tue, 26 Jan 2010 11:17:23 +0100 Subject: [PATCH 06/18] WineD3D: Implement D3DLOCK_DISCARD asynchronity --- dlls/wined3d/buffer.c | 25 ++++++++++++++++++++++++- dlls/wined3d/device.c | 2 +- dlls/wined3d/drawprim.c | 12 ------------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 8642130..c8d43d7 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1065,8 +1065,31 @@ 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; + } + + if(!This->query) + { + IWineD3DDevice *device = (IWineD3DDevice *) This->resource.device; + + /* Since we don't know about old draws a glFinish is needed now. */ + LEAVE_GL(); + wglFinish(); + + hr = IWineD3DDevice_CreateQuery(device, WINED3DQUERYTYPE_EVENT, &This->query, NULL); + if(FAILED(hr)) + { + ERR("Creating an event query for the buffer failed\n"); + } + ENTER_GL(); + + return; + } - if(!This->query) return; /* No draw yet */ LEAVE_GL(); hr = wined3d_event_query_finish(This->query); ENTER_GL(); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 739de5c..63023a1 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) { This->buffer_fences[This->num_buffer_fences++] = vb; } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 1bdae6d..34d986e 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -695,18 +695,6 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT for(i = 0; i < This->num_buffer_fences; i++) { struct wined3d_buffer *cur = (struct wined3d_buffer *) This->buffer_fences[i]; - - if(!cur->query) - { - HRESULT hr; - hr = IWineD3DDevice_CreateQuery(iface, WINED3DQUERYTYPE_EVENT, &cur->query, NULL); - if(FAILED(hr)) - { - ERR("Creating an event query for the buffer failed\n"); - continue; - } - } - IWineD3DQuery_Issue(cur->query, WINED3DISSUE_END); } -- 1.6.4.4