From 3fe8383d68770398720839e579de182e69b16ff5 Mon Sep 17 00:00:00 2001
From: Kimmo Myllyvirta <kimmo.myllyvirta@gmail.com>
Date: Sun, 27 May 2018 11:44:36 +1000
Subject: [PATCH] d3d11: Correctly align map info buffer

---
 dlls/d3d11/device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 745a22d91b..210f9600d2 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -4692,6 +4692,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_deferred_context_Map(ID3D11DeviceContext
     struct wined3d_resource *wined3d_resource;
     struct wined3d_map_info map_info;
     struct deferred_call *call, *previous = NULL;
+    SIZE_T align;
     HRESULT hr;
 
     TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
@@ -4727,7 +4728,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_deferred_context_Map(ID3D11DeviceContext
     if (FAILED(hr))
         return hr;
 
-    if (!(call = add_deferred_call(context, map_info.size)))
+    align = ((sizeof(*call) + 0xf) & ~0xf) - sizeof(*call);
+    if (!(call = add_deferred_call(context, map_info.size + align)))
         return E_OUTOFMEMORY;
 
     call->cmd = DEFERRED_MAP;
@@ -4736,7 +4738,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_deferred_context_Map(ID3D11DeviceContext
     call->map_info.subresource_idx = subresource_idx;
     call->map_info.map_type = map_type;
     call->map_info.map_flags = map_flags;
-    call->map_info.buffer = (void *)(call + 1);
+    call->map_info.buffer = (BYTE *)(call + 1) + align;
     call->map_info.size = map_info.size;
 
     if (previous)
-- 
2.17.0

