[PATCH 2/7] wined3d: Introduce wined3d_device_unmap_sub_resource().
Józef Kucia
jkucia at codeweavers.com
Sun Nov 1 21:17:03 CST 2015
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/buffer.c | 7 +++++++
dlls/wined3d/device.c | 17 +++++++++++++++++
dlls/wined3d/surface.c | 6 ++++++
dlls/wined3d/texture.c | 21 ++++++++-------------
dlls/wined3d/volume.c | 6 ++++++
dlls/wined3d/wined3d.spec | 1 +
dlls/wined3d/wined3d_private.h | 2 +-
include/wine/wined3d.h | 2 ++
8 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 6a6156b..92cb9cd 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1143,12 +1143,19 @@ static HRESULT buffer_resource_map(struct wined3d_resource *resource, struct win
return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags);
}
+static HRESULT buffer_resource_unmap(struct wined3d_resource *resource)
+{
+ 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_map,
+ buffer_resource_unmap,
};
static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1c63444..886ccfb 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4037,6 +4037,23 @@ HRESULT CDECL wined3d_device_map_sub_resource(struct wined3d_device *device,
return sub_resource->resource_ops->resource_map(sub_resource, map_desc, box, flags);
}
+HRESULT CDECL wined3d_device_unmap_sub_resource(struct wined3d_device *device,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx)
+{
+ struct wined3d_resource *sub_resource;
+
+ TRACE("device %p, resource %p, sub_resource_idx %u.\n",
+ device, resource, sub_resource_idx);
+
+ if (!(sub_resource = sub_resource_from_resource(resource, sub_resource_idx)))
+ {
+ WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
+ return E_INVALIDARG;
+ }
+
+ return sub_resource->resource_ops->resource_unmap(sub_resource);
+}
+
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color)
{
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9322b01..021f9e4 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1206,12 +1206,18 @@ static HRESULT surface_resource_map(struct wined3d_resource *resource, struct wi
return wined3d_surface_map(surface_from_resource(resource), map_desc, box, flags);
}
+static HRESULT surface_resource_unmap(struct wined3d_resource *resource)
+{
+ return wined3d_surface_unmap(surface_from_resource(resource));
+}
+
static const struct wined3d_resource_ops surface_resource_ops =
{
surface_resource_incref,
surface_resource_decref,
surface_unload,
surface_resource_map,
+ surface_resource_unmap,
};
static const struct wined3d_surface_ops surface_ops =
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 8a77b89..d4c7ea0 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,
};
@@ -972,12 +966,19 @@ static HRESULT texture_resource_map(struct wined3d_resource *resource, struct wi
return WINED3DERR_INVALIDCALL;
}
+static HRESULT texture_resource_unmap(struct wined3d_resource *resource)
+{
+ ERR("Texture resource cannot be unmapped.\n");
+ return WINED3DERR_INVALIDCALL;
+}
+
static const struct wined3d_resource_ops texture_resource_ops =
{
texture_resource_incref,
texture_resource_decref,
wined3d_texture_unload,
texture_resource_map,
+ texture_resource_unmap,
};
static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
@@ -1308,11 +1309,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,
@@ -1321,7 +1317,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,
};
@@ -1537,7 +1532,7 @@ HRESULT CDECL wined3d_texture_unmap(struct wined3d_texture *texture, unsigned in
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 sub_resource->resource_ops->resource_unmap(sub_resource);
}
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 d0a7e25..b9cdcc1 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -706,12 +706,18 @@ static HRESULT volume_resource_map(struct wined3d_resource *resource, struct win
return wined3d_volume_map(volume_from_resource(resource), map_desc, box, flags);
}
+static HRESULT volume_resource_unmap(struct wined3d_resource *resource)
+{
+ return wined3d_volume_unmap(volume_from_resource(resource));
+}
+
static const struct wined3d_resource_ops volume_resource_ops =
{
volume_resource_incref,
volume_resource_decref,
volume_unload,
volume_resource_map,
+ volume_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 fcf2f71..a48bfd2 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -157,6 +157,7 @@
@ cdecl wined3d_device_set_vs_sampler(ptr long ptr)
@ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long)
@ cdecl wined3d_device_show_cursor(ptr long)
+@ cdecl wined3d_device_unmap_sub_resource(ptr ptr long)
@ cdecl wined3d_device_uninit_3d(ptr)
@ cdecl wined3d_device_uninit_gdi(ptr)
@ cdecl wined3d_device_update_sub_resource(ptr ptr long ptr ptr long long)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index fb296b1..c22209c 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_map)(struct wined3d_resource *resource, struct wined3d_map_desc *map_desc,
const struct wined3d_box *box, DWORD flags);
+ HRESULT (*resource_unmap)(struct wined3d_resource *resource);
};
struct wined3d_resource
@@ -2240,7 +2241,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 ebb839c..127101a 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2318,6 +2318,8 @@ void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *devic
BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show);
HRESULT __cdecl wined3d_device_uninit_3d(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_uninit_gdi(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_unmap_sub_resource(struct wined3d_device *device,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx);
void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
unsigned int depth_pitch);
--
2.4.10
More information about the wine-patches
mailing list