From 7b9d06b49409a48c04bda3523de0ecc752a4bf9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 2 Nov 2015 17:12:26 +0100 Subject: [PATCH] wined3d: Introduce wined3d_resource_unmap(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/buffer.c | 13 +++++++++++ dlls/wined3d/resource.c | 7 ++++++ dlls/wined3d/surface.c | 7 ++++++ dlls/wined3d/texture.c | 41 +++++++++++++++++++--------------- dlls/wined3d/volume.c | 7 ++++++ dlls/wined3d/wined3d.spec | 1 + dlls/wined3d/wined3d_private.h | 2 +- include/wine/wined3d.h | 1 + 8 files changed, 60 insertions(+), 19 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 1af11ac021a..ba4ed5d7fd5 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1149,12 +1149,25 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags); } +static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + if (sub_resource_idx) + { + WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); + return E_INVALIDARG; + } + + wined3d_buffer_unmap(buffer_from_resource(resource)); + return WINED3D_OK; +} + static const struct wined3d_resource_ops buffer_resource_ops = { buffer_resource_incref, buffer_resource_decref, buffer_unload, buffer_resource_sub_resource_map, + buffer_resource_sub_resource_unmap, }; static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device, diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 34d8509a7f2..d466764b177 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -304,6 +304,13 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i return resource->resource_ops->resource_sub_resource_map(resource, sub_resource_idx, map_desc, box, flags); } +HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); + + return resource->resource_ops->resource_sub_resource_unmap(resource, sub_resource_idx); +} + BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) { void **p; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index b0d99bee1fe..c3ab3078ac4 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1207,12 +1207,19 @@ static HRESULT surface_resource_sub_resource_map(struct wined3d_resource *resour return WINED3DERR_INVALIDCALL; } +static HRESULT surface_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + ERR("Not supported on sub-resources.\n"); + return WINED3DERR_INVALIDCALL; +} + static const struct wined3d_resource_ops surface_resource_ops = { surface_resource_incref, surface_resource_decref, surface_unload, surface_resource_sub_resource_map, + surface_resource_sub_resource_unmap, }; static const struct wined3d_surface_ops surface_ops = diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 68354b14107..4380e5f7043 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -919,11 +919,6 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi } } -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, @@ -932,7 +927,6 @@ 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_unmap, texture2d_prepare_texture, }; @@ -976,12 +970,23 @@ static HRESULT texture2d_resource_sub_resource_map(struct wined3d_resource *reso return wined3d_surface_map(surface_from_resource(sub_resource), map_desc, box, flags); } +static HRESULT texture2d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + struct wined3d_resource *sub_resource; + + if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx))) + return E_INVALIDARG; + + return wined3d_surface_unmap(surface_from_resource(sub_resource)); +} + static const struct wined3d_resource_ops texture2d_resource_ops = { texture_resource_incref, texture_resource_decref, wined3d_texture_unload, texture2d_resource_sub_resource_map, + texture2d_resource_sub_resource_unmap, }; static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, @@ -1312,11 +1317,6 @@ static void texture3d_prepare_texture(struct wined3d_texture *texture, struct wi } } -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, @@ -1325,7 +1325,6 @@ 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_unmap, texture3d_prepare_texture, }; @@ -1340,12 +1339,23 @@ static HRESULT texture3d_resource_sub_resource_map(struct wined3d_resource *reso return wined3d_volume_map(volume_from_resource(sub_resource), map_desc, box, flags); } +static HRESULT texture3d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + struct wined3d_resource *sub_resource; + + if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx))) + return E_INVALIDARG; + + return wined3d_volume_unmap(volume_from_resource(sub_resource)); +} + static const struct wined3d_resource_ops texture3d_resource_ops = { texture_resource_incref, texture_resource_decref, wined3d_texture_unload, texture3d_resource_sub_resource_map, + texture3d_resource_sub_resource_unmap, }; static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, @@ -1549,14 +1559,9 @@ HRESULT CDECL wined3d_texture_map(struct wined3d_texture *texture, unsigned int HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned int sub_resource_idx) { - struct wined3d_resource *sub_resource; - TRACE("texture %p, sub_resource_idx %u.\n", texture, sub_resource_idx); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) - return WINED3DERR_INVALIDCALL; - - return texture->texture_ops->texture_sub_resource_unmap(sub_resource); + return texture->resource.resource_ops->resource_sub_resource_unmap(&texture->resource, sub_resource_idx); } HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc) diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index b0e333642da..0231c23d4e8 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -707,12 +707,19 @@ static HRESULT volume_resource_sub_resource_map(struct wined3d_resource *resourc return WINED3DERR_INVALIDCALL; } +static HRESULT volume_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) +{ + ERR("Not supported on sub-resources.\n"); + return WINED3DERR_INVALIDCALL; +} + static const struct wined3d_resource_ops volume_resource_ops = { volume_resource_incref, volume_resource_decref, volume_unload, volume_resource_sub_resource_map, + volume_resource_sub_resource_unmap, }; static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index a021471c600..7067e080cae 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -185,6 +185,7 @@ @ cdecl wined3d_resource_map(ptr long ptr ptr long) @ cdecl wined3d_resource_set_parent(ptr ptr) @ cdecl wined3d_resource_set_priority(ptr long) +@ cdecl wined3d_resource_unmap(ptr long) @ cdecl wined3d_rendertarget_view_create(ptr ptr ptr ptr ptr) @ cdecl wined3d_rendertarget_view_create_from_surface(ptr ptr ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3cd6d4c98da..99b025c2cb7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2158,6 +2158,7 @@ struct wined3d_resource_ops void (*resource_unload)(struct wined3d_resource *resource); HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); + HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx); }; struct wined3d_resource @@ -2237,7 +2238,6 @@ 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_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 98f48c808dd..9c9258a58fb 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2426,6 +2426,7 @@ HRESULT __cdecl wined3d_resource_map(struct wined3d_resource *resource, unsigned struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent); DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority); +HRESULT __cdecl wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx); HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,