From 790f8208a4873a5d172d7c11a36477e9a6b8e7aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Sun, 17 Nov 2013 18:44:48 +0100
Subject: wined3d: Invalidate containers via callback.

---
 dlls/wined3d/buffer.c          |  6 ++++++
 dlls/wined3d/resource.c        |  2 ++
 dlls/wined3d/surface.c         |  6 ++++++
 dlls/wined3d/texture.c         |  6 ++++++
 dlls/wined3d/volume.c          | 12 +++++++++---
 dlls/wined3d/wined3d_private.h |  1 +
 6 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 1e66cae..8aac5cb 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1188,6 +1188,11 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
     return WINED3D_OK;
 }
 
+static void wined3d_buffer_location_invalidated(struct wined3d_resource *resource, DWORD location)
+{
+    ERR("Not yet implemented.\n");
+}
+
 static const struct wined3d_resource_ops buffer_resource_ops =
 {
     buffer_resource_incref,
@@ -1195,6 +1200,7 @@ static const struct wined3d_resource_ops buffer_resource_ops =
     buffer_unload,
     buffer_resource_sub_resource_map,
     buffer_resource_sub_resource_unmap,
+    wined3d_buffer_location_invalidated,
 };
 
 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 c4a3a7b..39346b5 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -484,4 +484,6 @@ void wined3d_resource_invalidate_location(struct wined3d_resource *resource, DWO
     TRACE("Resource %p, setting %s.\n", resource, wined3d_debug_location(location));
     resource->locations &= ~location;
     TRACE("new location flags are %s.\n", wined3d_debug_location(resource->locations));
+
+    resource->resource_ops->resource_location_invalidated(resource, location);
 }
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index e286384..c4b9cac 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1222,6 +1222,11 @@ static HRESULT surface_resource_sub_resource_unmap(struct wined3d_resource *reso
     return WINED3DERR_INVALIDCALL;
 }
 
+static void wined3d_surface_location_invalidated(struct wined3d_resource *resource, DWORD location)
+{
+    ERR("Not yet implemented.\n");
+}
+
 static const struct wined3d_resource_ops surface_resource_ops =
 {
     surface_resource_incref,
@@ -1229,6 +1234,7 @@ static const struct wined3d_resource_ops surface_resource_ops =
     surface_unload,
     surface_resource_sub_resource_map,
     surface_resource_sub_resource_unmap,
+    wined3d_surface_location_invalidated,
 };
 
 static const struct wined3d_surface_ops surface_ops =
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 72f00fd..82ddeeb 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -938,6 +938,11 @@ static HRESULT texture2d_resource_sub_resource_unmap(struct wined3d_resource *re
     return wined3d_surface_unmap(surface_from_resource(sub_resource));
 }
 
+static void wined3d_texture_load_location_invalidated(struct wined3d_resource *resource, DWORD location)
+{
+    ERR("Should not be called on textures.\n");
+}
+
 static const struct wined3d_resource_ops texture2d_resource_ops =
 {
     texture_resource_incref,
@@ -945,6 +950,7 @@ static const struct wined3d_resource_ops texture2d_resource_ops =
     wined3d_texture_unload,
     texture2d_resource_sub_resource_map,
     texture2d_resource_sub_resource_unmap,
+    wined3d_texture_load_location_invalidated,
 };
 
 static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index b3b2fe2..00b9814 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -601,10 +601,7 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
     }
 
     if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY)))
-    {
-        wined3d_texture_set_dirty(volume->container);
         wined3d_resource_invalidate_location(&volume->resource, ~volume->resource.map_binding);
-    }
 
     volume->resource.map_count++;
 
@@ -672,6 +669,14 @@ static HRESULT volume_resource_sub_resource_unmap(struct wined3d_resource *resou
     return WINED3DERR_INVALIDCALL;
 }
 
+static void wined3d_volume_location_invalidated(struct wined3d_resource *resource, DWORD location)
+{
+    struct wined3d_volume *volume = volume_from_resource(resource);
+
+    if (location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
+        wined3d_texture_set_dirty(volume->container);
+}
+
 static const struct wined3d_resource_ops volume_resource_ops =
 {
     volume_resource_incref,
@@ -679,6 +684,7 @@ static const struct wined3d_resource_ops volume_resource_ops =
     volume_unload,
     volume_resource_sub_resource_map,
     volume_resource_sub_resource_unmap,
+    wined3d_volume_location_invalidated,
 };
 
 static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a282b95..dc24c36 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2250,6 +2250,7 @@ struct wined3d_resource_ops
     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);
+    void (*resource_location_invalidated)(struct wined3d_resource *resource, DWORD location);
 };
 
 struct wined3d_resource
-- 
2.7.0

