[PATCH 2/7] wined3d: Introduce wined3d_resource_unmap().
Józef Kucia
jkucia at codeweavers.com
Mon Nov 2 10:12:26 CST 2015
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
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 1af11ac..ba4ed5d 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 34d8509..d466764 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 b0d99be..c3ab307 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 68354b1..4380e5f 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 b0e3336..0231c23 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 a021471..7067e08 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 3cd6d4c..99b025c 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 c6ddbe1..353f785 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,
--
2.4.10
More information about the wine-patches
mailing list