From eac95d30b66609c5c924ec36b6049e680c63015f Mon Sep 17 00:00:00 2001 From: Riccardo Bortolato Date: Tue, 6 Oct 2015 10:36:48 +0200 Subject: [PATCH] wined3d: Introduce new wined3d_texture_(un)map functions. Initial usage in d3d11. Also removed wined3d_volume_from_resource. Signed-off-by: Henri Verbeet --- dlls/d3d11/texture.c | 28 +++----------------- dlls/wined3d/texture.c | 47 ++++++++++++++++++++++++++++++++++ dlls/wined3d/volume.c | 5 ---- dlls/wined3d/wined3d.spec | 3 ++- dlls/wined3d/wined3d_private.h | 3 +++ include/wine/wined3d.h | 4 ++- 6 files changed, 59 insertions(+), 31 deletions(-) diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 85d001f5847..cd6b2fdb524 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 fdce24de2c4..d5f959198a6 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(surface_from_resource(sub_resource), map_desc, box, flags); +} + +static HRESULT texture2d_sub_resource_unmap(struct wined3d_resource *sub_resource) +{ + return wined3d_surface_unmap(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(volume_from_resource(sub_resource), map_desc, box, flags); +} + +static HRESULT texture3d_sub_resource_unmap(struct wined3d_resource *sub_resource) +{ + return wined3d_volume_unmap(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/volume.c b/dlls/wined3d/volume.c index 2daa55e2c48..45a2fee2dff 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -676,11 +676,6 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, return WINED3D_OK; } -struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource) -{ - return volume_from_resource(resource); -} - HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) { TRACE("volume %p.\n", volume); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 9531dd3fc20..dbe078f3422 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) @@ -281,7 +283,6 @@ @ cdecl wined3d_vertex_declaration_get_parent(ptr) @ cdecl wined3d_vertex_declaration_incref(ptr) -@ cdecl wined3d_volume_from_resource(ptr) @ cdecl wined3d_volume_get_resource(ptr) @ cdecl wined3d_volume_map(ptr ptr ptr long) @ cdecl wined3d_volume_unmap(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d3c362bebe1..1d57899da86 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2219,6 +2219,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 1fa8e524d00..7dc51ae496b 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2549,6 +2549,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, @@ -2564,7 +2567,6 @@ ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaratio void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration); ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration); -struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);