From: Riccardo Bortolato Subject: [PATCH 06/12] wined3d: introduce new wined3d_texture_(un)map functions Message-Id: <1442996856-32611-6-git-send-email-rikyz619@gmail.com> Date: Wed, 23 Sep 2015 10:27:30 +0200 initial usage in d3d11 --- dlls/d3d11/texture.c | 28 ++++--------------------- dlls/wined3d/texture.c | 47 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 2 ++ dlls/wined3d/wined3d_private.h | 3 +++ include/wine/wined3d.h | 3 +++ 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 85d001f..cd6b2fd 100644 --- a/dlls/d3d11/texture.c +++ b/dlls/d3d11/texture.c @@ -357,7 +357,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN { struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface); struct wined3d_map_desc wined3d_map_desc; - struct wined3d_resource *sub_resource; HRESULT hr; TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n", @@ -367,9 +366,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN FIXME("Ignoring map_flags %#x.\n", map_flags); wined3d_mutex_lock(); - 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), + 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)))) { mapped_texture->pData = wined3d_map_desc.data; @@ -383,18 +380,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN static void STDMETHODCALLTYPE d3d10_texture2d_Unmap(ID3D10Texture2D *iface, UINT sub_resource_idx) { struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface); - struct wined3d_resource *sub_resource; TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx); wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - { - wined3d_mutex_unlock(); - return; - } - - wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource)); + wined3d_texture_unmap(texture->wined3d_texture, sub_resource_idx); wined3d_mutex_unlock(); } @@ -824,7 +814,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN { struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct wined3d_map_desc wined3d_map_desc; - struct wined3d_resource *sub_resource; HRESULT hr; TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n", @@ -834,9 +823,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN FIXME("Ignoring map_flags %#x.\n", map_flags); wined3d_mutex_lock(); - 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), + 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)))) { mapped_texture->pData = wined3d_map_desc.data; @@ -851,18 +838,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN static void STDMETHODCALLTYPE d3d10_texture3d_Unmap(ID3D10Texture3D *iface, UINT sub_resource_idx) { struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); - struct wined3d_resource *sub_resource; TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx); wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - { - wined3d_mutex_unlock(); - return; - } - - wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource)); + wined3d_texture_unmap(texture->wined3d_texture, sub_resource_idx); wined3d_mutex_unlock(); } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index b369809..9d9e1a5 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -915,6 +915,17 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi } } +static HRESULT texture2d_sub_resource_map(struct wined3d_resource *sub_resource, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) +{ + return wined3d_surface_map(wined3d_surface_from_resource(sub_resource), map_desc, box, flags); +} + +static HRESULT texture2d_sub_resource_unmap(struct wined3d_resource *sub_resource) +{ + return wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource)); +} + static const struct wined3d_texture_ops texture2d_ops = { texture2d_sub_resource_load, @@ -923,6 +934,8 @@ static const struct wined3d_texture_ops texture2d_ops = texture2d_sub_resource_invalidate_location, texture2d_sub_resource_validate_location, texture2d_sub_resource_upload_data, + texture2d_sub_resource_map, + texture2d_sub_resource_unmap, texture2d_prepare_texture, }; @@ -1290,6 +1303,17 @@ static void texture3d_prepare_texture(struct wined3d_texture *texture, struct wi } } +static HRESULT texture3d_sub_resource_map(struct wined3d_resource *sub_resource, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) +{ + return wined3d_volume_map(wined3d_volume_from_resource(sub_resource), map_desc, box, flags); +} + +static HRESULT texture3d_sub_resource_unmap(struct wined3d_resource *sub_resource) +{ + return wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource)); +} + static const struct wined3d_texture_ops texture3d_ops = { texture3d_sub_resource_load, @@ -1298,6 +1322,8 @@ static const struct wined3d_texture_ops texture3d_ops = texture3d_sub_resource_invalidate_location, texture3d_sub_resource_validate_location, texture3d_sub_resource_upload_data, + texture3d_sub_resource_map, + texture3d_sub_resource_unmap, texture3d_prepare_texture, }; @@ -1465,3 +1491,24 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct return WINED3D_OK; } + +HRESULT CDECL wined3d_texture_map(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) +{ + struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx); + + if (!sub_resource) + return WINED3DERR_INVALIDCALL; + + return texture->texture_ops->texture_sub_resource_map(sub_resource, map_desc, box, flags); +} + +HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx) +{ + struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx); + + if (!sub_resource) + return WINED3DERR_INVALIDCALL; + + return texture->texture_ops->texture_sub_resource_unmap(sub_resource); +} diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 9531dd3..a39d946 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -273,6 +273,8 @@ @ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_color_key(ptr long ptr) @ cdecl wined3d_texture_set_lod(ptr long) +@ cdecl wined3d_texture_map(ptr long ptr ptr long) +@ cdecl wined3d_texture_unmap(ptr long) @ cdecl wined3d_texture_update_desc(ptr long long long long long ptr long) @ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 758af54..eb4a0fc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2218,6 +2218,9 @@ struct wined3d_texture_ops void (*texture_sub_resource_validate_location)(struct wined3d_resource *sub_resource, DWORD location); void (*texture_sub_resource_upload_data)(struct wined3d_resource *sub_resource, const struct wined3d_context *context, const struct wined3d_sub_resource_data *data); + HRESULT (*texture_sub_resource_map)(struct wined3d_resource *sub_resource, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); + HRESULT (*texture_sub_resource_unmap)(struct wined3d_resource *sub_resource); void (*texture_prepare_texture)(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb); }; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 4425d08..e9e72eb 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2551,6 +2551,9 @@ HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture * HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key); DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod); +HRESULT __cdecl wined3d_texture_map(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); +HRESULT __cdecl wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx); HRESULT __cdecl wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, UINT multisample_quality, -- 1.9.1