Module: wine Branch: master Commit: 2533860114290f2310e4a4ce50ac9e26a8b3c21e URL: http://source.winehq.org/git/wine.git/?a=commit;h=2533860114290f2310e4a4ce50...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Mar 30 11:24:43 2010 +0200
wined3d: Initialization functions don't allocate.
---
dlls/wined3d/buffer.c | 14 ++++++++++---- dlls/wined3d/query.c | 29 ++++++++--------------------- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 68417ff..1447a4f 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -798,15 +798,21 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
if(!This->query) { - HRESULT hr; TRACE("Creating event query for buffer %p\n", This);
- hr = wined3d_event_query_init(gl_info, &This->query); - if(FAILED(hr)) + if (!wined3d_event_query_supported(gl_info)) { - ERR("Failed to create an event query, dropping async buffer locks\n"); + FIXME("Event queries not supported, dropping async buffer locks.\n"); goto drop_query; } + + This->query = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This->query)); + if (!This->query) + { + ERR("Failed to allocate event query memory, dropping async buffer locks.\n"); + goto drop_query; + } + /* Since we don't know about old draws a glFinish is needed once */ wglFinish(); return; diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c index 59e385e..90cdbd4 100644 --- a/dlls/wined3d/query.c +++ b/dlls/wined3d/query.c @@ -27,22 +27,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); #define GLINFO_LOCATION (*gl_info)
-HRESULT wined3d_event_query_init(const struct wined3d_gl_info *gl_info, struct wined3d_event_query **query) +BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info) { - struct wined3d_event_query *ret; - *query = NULL; - if (!gl_info->supported[ARB_SYNC] && !gl_info->supported[NV_FENCE] - && !gl_info->supported[APPLE_FENCE]) return E_NOTIMPL; - - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret)); - if (!ret) - { - ERR("Failed to allocate a wined3d event query structure.\n"); - return E_OUTOFMEMORY; - } - ret->context = NULL; - *query = ret; - return WINED3D_OK; + return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE]; }
void wined3d_event_query_destroy(struct wined3d_event_query *query) @@ -593,7 +580,6 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3DQUERYTYPE type, IUnknown *parent) { const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - HRESULT hr;
switch (type) { @@ -616,9 +602,7 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
case WINED3DQUERYTYPE_EVENT: TRACE("Event query.\n"); - query->lpVtbl = &IWineD3DEventQuery_Vtbl; - hr = wined3d_event_query_init(gl_info, (struct wined3d_event_query **) &query->extendedData); - if (hr == E_NOTIMPL) + if (!wined3d_event_query_supported(gl_info)) { /* Half-Life 2 needs this query. It does not render the main * menu correctly otherwise. Pretend to support it, faking @@ -626,9 +610,12 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, * lowering performance. */ FIXME("Event query: Unimplemented, but pretending to be supported.\n"); } - else if(FAILED(hr)) + query->lpVtbl = &IWineD3DEventQuery_Vtbl; + query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query)); + if (!query->extendedData) { - return hr; + ERR("Failed to allocate event query memory.\n"); + return E_OUTOFMEMORY; } break;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 77c7d83..867510c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1033,11 +1033,11 @@ enum wined3d_event_query_result WINED3D_EVENT_QUERY_ERROR };
-HRESULT wined3d_event_query_init(const struct wined3d_gl_info *gl_info, struct wined3d_event_query **query) DECLSPEC_HIDDEN; void wined3d_event_query_destroy(struct wined3d_event_query *query) DECLSPEC_HIDDEN; enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; +HRESULT wined3d_event_query_supported(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
struct wined3d_context {