d3d10core: Add support for map_type flags D3D10_MAP_READ, D3D10_MAP_WRITE_NO_OVERWRITE and D3D10_MAP_DISCARD. (try 2)
Johannes Brandstätter
jbrandst at 2ds.eu
Wed Sep 24 10:06:47 CDT 2014
Thanks for you feedback!
This patch supersedes patch 106656.
- Implemented change as helper function in dlls/d3d10core/utils.c.
- Made additional use of the new helper function in
d3d10_texture2d_Map() and d3d10_texture3d_Map().
---
dlls/d3d10core/buffer.c | 5 ++---
dlls/d3d10core/d3d10core_private.h | 1 +
dlls/d3d10core/texture.c | 10 ++++------
dlls/d3d10core/utils.c | 23 +++++++++++++++++++++++
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d10core/buffer.c b/dlls/d3d10core/buffer.c
index b9ac6e1..c962ecb 100644
--- a/dlls/d3d10core/buffer.c
+++ b/dlls/d3d10core/buffer.c
@@ -151,15 +151,14 @@ static UINT STDMETHODCALLTYPE d3d10_buffer_GetEvictionPriority(ID3D10Buffer *ifa
static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP map_type, UINT map_flags, void **data)
{
struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
+ DWORD wine_map_flags = wined3d_map_flags_from_d3d10_map_type(map_type);
TRACE("iface %p, map_type %u, map_flags %#x, data %p.\n", iface, map_type, map_flags, data);
- if (map_type != D3D10_MAP_READ_WRITE)
- FIXME("Ignoring map_type %#x.\n", map_type);
if (map_flags)
FIXME("Ignoring map_flags %#x.\n", map_flags);
- return wined3d_buffer_map(buffer->wined3d_buffer, 0, 0, (BYTE **)data, 0);
+ return wined3d_buffer_map(buffer->wined3d_buffer, 0, 0, (BYTE **)data, wine_map_flags);
}
static void STDMETHODCALLTYPE d3d10_buffer_Unmap(ID3D10Buffer *iface)
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index 71c4dc0..30ae928 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -63,6 +63,7 @@ DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSP
enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) DECLSPEC_HIDDEN;
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
+DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type) DECLSPEC_HIDDEN;
static inline void read_dword(const char **ptr, DWORD *d)
{
diff --git a/dlls/d3d10core/texture.c b/dlls/d3d10core/texture.c
index b488f91..d7b61d7 100644
--- a/dlls/d3d10core/texture.c
+++ b/dlls/d3d10core/texture.c
@@ -172,19 +172,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_resource *sub_resource;
HRESULT hr;
+ DWORD wine_map_flags = wined3d_map_flags_from_d3d10_map_type(map_type);
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
iface, sub_resource_idx, map_type, map_flags, mapped_texture);
- if (map_type != D3D10_MAP_READ_WRITE)
- FIXME("Ignoring map_type %#x.\n", map_type);
if (map_flags)
FIXME("Ignoring map_flags %#x.\n", map_flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = E_INVALIDARG;
else if (SUCCEEDED(hr = wined3d_surface_map(wined3d_surface_from_resource(sub_resource),
- &wined3d_map_desc, NULL, 0)))
+ &wined3d_map_desc, NULL, wine_map_flags)))
{
mapped_texture->pData = wined3d_map_desc.data;
mapped_texture->RowPitch = wined3d_map_desc.row_pitch;
@@ -447,19 +446,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_resource *sub_resource;
HRESULT hr;
+ DWORD wine_map_flags = wined3d_map_flags_from_d3d10_map_type(map_type);
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
iface, sub_resource_idx, map_type, map_flags, mapped_texture);
- if (map_type != D3D10_MAP_READ_WRITE)
- FIXME("Ignoring map_type %#x.\n", map_type);
if (map_flags)
FIXME("Ignoring map_flags %#x.\n", map_flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = E_INVALIDARG;
else if (SUCCEEDED(hr = wined3d_volume_map(wined3d_volume_from_resource(sub_resource),
- &wined3d_map_desc, NULL, 0)))
+ &wined3d_map_desc, NULL, wine_map_flags)))
{
mapped_texture->pData = wined3d_map_desc.data;
mapped_texture->RowPitch = wined3d_map_desc.row_pitch;
diff --git a/dlls/d3d10core/utils.c b/dlls/d3d10core/utils.c
index d955fbb..0adde83 100644
--- a/dlls/d3d10core/utils.c
+++ b/dlls/d3d10core/utils.c
@@ -389,6 +389,29 @@ struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource
}
}
+DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type)
+{
+ switch (map_type)
+ {
+ case D3D10_MAP_READ_WRITE:
+ return 0;
+
+ case D3D10_MAP_READ:
+ return WINED3D_MAP_READONLY;
+
+ case D3D10_MAP_WRITE_DISCARD:
+ return WINED3D_MAP_DISCARD;
+
+ case D3D10_MAP_WRITE_NO_OVERWRITE:
+ return WINED3D_MAP_NOOVERWRITE;
+
+ default:
+ FIXME("Unhandled map_type %#x.\n", map_type);
+ }
+
+ return 0;
+}
+
void skip_dword_unknown(const char **ptr, unsigned int count)
{
unsigned int i;
--
2.1.0
More information about the wine-patches
mailing list