From a59e0119db78ec4f8a68b223bc7b989fa02c967a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Sun, 17 Nov 2013 20:19:24 +0100
Subject: wined3d: Pass a context to surface_load_location.

---
 dlls/wined3d/surface.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index e4aaef4b..f425b5a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -754,9 +754,14 @@ static void surface_unmap(struct wined3d_surface *surface)
 
     if (surface->container->swapchain && surface->container->swapchain->front_buffer == surface->container)
     {
-        context = context_acquire(device, surface);
+        struct wined3d_device *device = surface->resource.device;
+        struct wined3d_context *context = NULL;
+
+        if (device->d3d_initialized)
+            context = context_acquire(device, surface);
         surface_load_location(surface, context, surface->container->resource.draw_binding);
-        context_release(context);
+        if (context)
+            context_release(context);
     }
     else if (surface->container->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
         FIXME("Depth / stencil buffer locking is not implemented.\n");
-- 
2.6.1

