Commit ee349306 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Destroy primary GL context if initialization fails.

parent 242cdaee
......@@ -1256,10 +1256,13 @@ void wined3d_device_gl_create_primary_opengl_context_cs(void *object)
return;
}
context_gl = wined3d_context_gl(context);
if (!wined3d_allocator_init(&device_gl->allocator, ARRAY_SIZE(gl_memory_types), &wined3d_allocator_gl_ops))
{
WARN("Failed to initialise allocator.\n");
context_release(context);
wined3d_swapchain_gl_context_destroy(wined3d_swapchain_gl(swapchain), context_gl);
return;
}
......@@ -1269,6 +1272,7 @@ void wined3d_device_gl_create_primary_opengl_context_cs(void *object)
ERR("Failed to allocate shader private data, hr %#x.\n", hr);
wined3d_allocator_cleanup(&device_gl->allocator);
context_release(context);
wined3d_swapchain_gl_context_destroy(wined3d_swapchain_gl(swapchain), context_gl);
return;
}
......@@ -1278,11 +1282,10 @@ void wined3d_device_gl_create_primary_opengl_context_cs(void *object)
device->shader_backend->shader_free_private(device, NULL);
wined3d_allocator_cleanup(&device_gl->allocator);
context_release(context);
wined3d_swapchain_gl_context_destroy(wined3d_swapchain_gl(swapchain), context_gl);
return;
}
context_gl = wined3d_context_gl(context);
wined3d_ffp_blitter_create(&device->blitter, context_gl->gl_info);
if (!wined3d_glsl_blitter_create(&device->blitter, device))
wined3d_arbfp_blitter_create(&device->blitter, device);
......
......@@ -1804,6 +1804,25 @@ static struct wined3d_context_gl *wined3d_swapchain_gl_create_context(struct win
return context_gl;
}
void wined3d_swapchain_gl_context_destroy(struct wined3d_swapchain_gl *swapchain_gl, struct wined3d_context_gl *context_gl)
{
unsigned int i, j;
TRACE("swapchain_gl %p, context_gl %p.\n", swapchain_gl, context_gl);
for (i = 0; i < swapchain_gl->context_count; ++i)
{
if (swapchain_gl->contexts[i] == context_gl)
{
wined3d_context_gl_destroy(swapchain_gl->contexts[i]);
for (j = i; j < --swapchain_gl->context_count; ++j)
swapchain_gl->contexts[j] = swapchain_gl->contexts[j + 1];
return;
}
}
ERR("context_gl %p not found in the swapchain list.\n", context_gl);
}
void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl)
{
unsigned int i;
......
......@@ -5720,6 +5720,8 @@ static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_s
}
void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
void wined3d_swapchain_gl_context_destroy(struct wined3d_swapchain_gl *swapchain_gl,
struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
......
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