Commit 23f05028 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Add some error handling to create_primary_opengl_context().

parent 4c66141c
...@@ -6293,45 +6293,65 @@ void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_ ...@@ -6293,45 +6293,65 @@ void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_
HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_iface) { HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) swapchain_iface; IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) swapchain_iface;
struct wined3d_context *context;
HRESULT hr; HRESULT hr;
IWineD3DSurfaceImpl *target; IWineD3DSurfaceImpl *target;
/* Recreate the primary swapchain's context */ /* Recreate the primary swapchain's context */
swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain->context)); swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain->context));
if(swapchain->backBuffer) { if (!swapchain->context)
target = (IWineD3DSurfaceImpl *) swapchain->backBuffer[0]; {
} else { ERR("Failed to allocate memory for swapchain context array.\n");
target = (IWineD3DSurfaceImpl *) swapchain->frontBuffer; return E_OUTOFMEMORY;
} }
swapchain->context[0] = context_create(This, target, swapchain->win_handle, FALSE, &swapchain->presentParms);
swapchain->num_contexts = 1;
create_dummy_textures(This); target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
context = context_create(This, target, swapchain->win_handle, FALSE, &swapchain->presentParms);
if (!context)
{
WARN("Failed to create context.\n");
HeapFree(GetProcessHeap(), 0, swapchain->context);
return E_FAIL;
}
context_release(swapchain->context[0]); swapchain->context[0] = context;
swapchain->num_contexts = 1;
create_dummy_textures(This);
context_release(context);
hr = This->shader_backend->shader_alloc_private(iface); hr = This->shader_backend->shader_alloc_private(iface);
if(FAILED(hr)) { if (FAILED(hr))
ERR("Failed to recreate shader private data\n"); {
goto err_out; ERR("Failed to allocate shader private data, hr %#x.\n", hr);
goto err;
} }
hr = This->frag_pipe->alloc_private(iface); hr = This->frag_pipe->alloc_private(iface);
if(FAILED(hr)) { if (FAILED(hr))
TRACE("Fragment pipeline private data couldn't be allocated\n"); {
goto err_out; ERR("Failed to allocate fragment pipe private data, hr %#x.\n", hr);
This->shader_backend->shader_free_private(iface);
goto err;
} }
hr = This->blitter->alloc_private(iface); hr = This->blitter->alloc_private(iface);
if(FAILED(hr)) { if (FAILED(hr))
TRACE("Blitter private data couldn't be allocated\n"); {
goto err_out; ERR("Failed to allocate blitter private data, hr %#x.\n", hr);
This->frag_pipe->free_private(iface);
This->shader_backend->shader_free_private(iface);
goto err;
} }
return WINED3D_OK; return WINED3D_OK;
err_out: err:
This->blitter->free_private(iface); context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
This->frag_pipe->free_private(iface); destroy_dummy_textures(This, context->gl_info);
This->shader_backend->shader_free_private(iface); context_release(context);
context_destroy(This, context);
HeapFree(GetProcessHeap(), 0, swapchain->context);
swapchain->num_contexts = 0;
return hr; return hr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment