wined3d: Initialization functions don't allocate.

This commit is contained in:
Henri Verbeet 2010-03-30 11:24:43 +02:00 committed by Alexandre Julliard
parent a9e43cad15
commit 2533860114
3 changed files with 19 additions and 26 deletions

View File

@ -798,15 +798,21 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
if(!This->query) if(!This->query)
{ {
HRESULT hr;
TRACE("Creating event query for buffer %p\n", This); TRACE("Creating event query for buffer %p\n", This);
hr = wined3d_event_query_init(gl_info, &This->query); if (!wined3d_event_query_supported(gl_info))
if(FAILED(hr))
{ {
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; 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 */ /* Since we don't know about old draws a glFinish is needed once */
wglFinish(); wglFinish();
return; return;

View File

@ -27,22 +27,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION (*gl_info) #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; return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
*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;
} }
void wined3d_event_query_destroy(struct wined3d_event_query *query) 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) WINED3DQUERYTYPE type, IUnknown *parent)
{ {
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
HRESULT hr;
switch (type) switch (type)
{ {
@ -616,9 +602,7 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:
TRACE("Event query.\n"); TRACE("Event query.\n");
query->lpVtbl = &IWineD3DEventQuery_Vtbl; if (!wined3d_event_query_supported(gl_info))
hr = wined3d_event_query_init(gl_info, (struct wined3d_event_query **) &query->extendedData);
if (hr == E_NOTIMPL)
{ {
/* Half-Life 2 needs this query. It does not render the main /* Half-Life 2 needs this query. It does not render the main
* menu correctly otherwise. Pretend to support it, faking * menu correctly otherwise. Pretend to support it, faking
@ -626,9 +610,12 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
* lowering performance. */ * lowering performance. */
FIXME("Event query: Unimplemented, but pretending to be supported.\n"); 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; break;

View File

@ -1033,11 +1033,11 @@ enum wined3d_event_query_result
WINED3D_EVENT_QUERY_ERROR 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; 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_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; 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; 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 struct wined3d_context
{ {