[PATCH 4/7] d3d11: Implement d3d11_immediate_context_Map(). (try 2)

Józef Kucia jkucia at codeweavers.com
Mon Nov 2 10:12:28 CST 2015


Try 2: Use wined3d_resource_map() instead of
wined3d_device_map_sub_resource().

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d11/buffer.c        |  2 +-
 dlls/d3d11/d3d11_private.h |  2 +-
 dlls/d3d11/device.c        | 22 ++++++++++++++++++++--
 dlls/d3d11/texture.c       |  4 ++--
 dlls/d3d11/utils.c         | 10 +++++-----
 5 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/dlls/d3d11/buffer.c b/dlls/d3d11/buffer.c
index 043e7da..5af121f 100644
--- a/dlls/d3d11/buffer.c
+++ b/dlls/d3d11/buffer.c
@@ -312,7 +312,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP
 
     wined3d_mutex_lock();
     hr = wined3d_buffer_map(buffer->wined3d_buffer, 0, 0, (BYTE **)data,
-            wined3d_map_flags_from_d3d10_map_type(map_type));
+            wined3d_map_flags_from_d3d11_map_type(map_type));
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index fcd4742..b6d84c0 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -65,7 +65,7 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSP
 DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) DECLSPEC_HIDDEN;
 struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *resource) DECLSPEC_HIDDEN;
 struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
-DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type) DECLSPEC_HIDDEN;
+DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type) DECLSPEC_HIDDEN;
 
 enum D3D11_USAGE d3d11_usage_from_d3d10_usage(enum D3D10_USAGE usage) DECLSPEC_HIDDEN;
 enum D3D10_USAGE d3d10_usage_from_d3d11_usage(enum D3D11_USAGE usage) DECLSPEC_HIDDEN;
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 5f567ab..16aff79 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -202,10 +202,28 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *
 static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource,
         UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource)
 {
-    FIXME("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p stub!\n",
+    struct wined3d_resource *wined3d_resource;
+    struct wined3d_map_desc map_desc;
+    HRESULT hr;
+
+    TRACE("iface %p, resource %p, subresource_idx %u, map_type %u, map_flags %#x, mapped_subresource %p.\n",
             iface, resource, subresource_idx, map_type, map_flags, mapped_subresource);
 
-    return E_NOTIMPL;
+    if (map_flags)
+        FIXME("Ignoring map_flags %#x.\n", map_flags);
+
+    wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
+
+    wined3d_mutex_lock();
+    hr = wined3d_resource_map(wined3d_resource, subresource_idx,
+            &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type));
+    wined3d_mutex_unlock();
+
+    mapped_subresource->pData = map_desc.data;
+    mapped_subresource->RowPitch = map_desc.row_pitch;
+    mapped_subresource->DepthPitch = map_desc.slice_pitch;
+
+    return hr;
 }
 
 static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource,
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index cd6b2fd..ef4c3ac 100644
--- a/dlls/d3d11/texture.c
+++ b/dlls/d3d11/texture.c
@@ -367,7 +367,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN
 
     wined3d_mutex_lock();
     if (SUCCEEDED(hr = wined3d_texture_map(texture->wined3d_texture, sub_resource_idx,
-            &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type))))
+            &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type))))
     {
         mapped_texture->pData = wined3d_map_desc.data;
         mapped_texture->RowPitch = wined3d_map_desc.row_pitch;
@@ -824,7 +824,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
 
     wined3d_mutex_lock();
     if (SUCCEEDED(hr = wined3d_texture_map(texture->wined3d_texture, sub_resource_idx,
-            &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type))))
+            &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type))))
     {
         mapped_texture->pData = wined3d_map_desc.data;
         mapped_texture->RowPitch = wined3d_map_desc.row_pitch;
diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c
index 9bf3ada..31dffa3 100644
--- a/dlls/d3d11/utils.c
+++ b/dlls/d3d11/utils.c
@@ -546,20 +546,20 @@ struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *re
     }
 }
 
-DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type)
+DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type)
 {
     switch (map_type)
     {
-        case D3D10_MAP_READ_WRITE:
+        case D3D11_MAP_READ_WRITE:
             return 0;
 
-        case D3D10_MAP_READ:
+        case D3D11_MAP_READ:
             return WINED3D_MAP_READONLY;
 
-        case D3D10_MAP_WRITE_DISCARD:
+        case D3D11_MAP_WRITE_DISCARD:
             return WINED3D_MAP_DISCARD;
 
-        case D3D10_MAP_WRITE_NO_OVERWRITE:
+        case D3D11_MAP_WRITE_NO_OVERWRITE:
             return WINED3D_MAP_NOOVERWRITE;
 
         default:
-- 
2.4.10




More information about the wine-patches mailing list