From bc240cf9d9401914b2685b66f21af86aca21bccb 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 ba4ed5d..638c9b9 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1161,6 +1161,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,
@@ -1168,6 +1173,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 2a42535..c259eba 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -474,4 +474,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 0d95db3..f5bc72c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1220,6 +1220,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,
@@ -1227,6 +1232,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 2e5276a..520647d 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -978,6 +978,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,
@@ -985,6 +990,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 cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index eefdb06..f150795 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -604,10 +604,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++;
 
@@ -675,6 +672,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,
@@ -682,6 +687,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 429a093..53e9fe9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2159,6 +2159,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.6.2

