From e872730f9d2dbdb4220860cc6ee5588860971223 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 3 Oct 2013 12:34:13 +0200
Subject: wined3d: Move validate_location to resource.c.

---
 dlls/wined3d/resource.c        |  7 +++++++
 dlls/wined3d/texture.c         |  4 +---
 dlls/wined3d/volume.c          | 19 ++++++-------------
 dlls/wined3d/wined3d_private.h |  1 +
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 8032a4c..2731f27 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -362,3 +362,10 @@ void CDECL wined3d_resource_get_pitch(const struct wined3d_resource *resource, U
 
     TRACE("Returning row pitch %u, slice pitch %u.\n", *row_pitch, *slice_pitch);
 }
+
+void wined3d_resource_validate_location(struct wined3d_resource *resource, DWORD location)
+{
+    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));
+}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 9fe7d25..92f7744 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1331,9 +1331,7 @@ static void texture3d_sub_resource_invalidate_location(struct wined3d_resource *
 
 static void texture3d_sub_resource_validate_location(struct wined3d_resource *sub_resource, DWORD location)
 {
-    struct wined3d_volume *volume = volume_from_resource(sub_resource);
-
-    wined3d_volume_validate_location(volume, location);
+    wined3d_resource_validate_location(sub_resource, location);
 }
 
 static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 62eb5ed..e1fa454 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -99,13 +99,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
     HeapFree(GetProcessHeap(), 0, converted_mem);
 }
 
-void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location)
-{
-    TRACE("Volume %p, setting %s.\n", volume, wined3d_debug_location(location));
-    volume->resource.locations |= location;
-    TRACE("new location flags are %s.\n", wined3d_debug_location(volume->resource.locations));
-}
-
 void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location)
 {
     TRACE("Volume %p, clearing %s.\n", volume, wined3d_debug_location(location));
@@ -271,7 +264,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
                 FIXME("Implement texture loading from %s.\n", wined3d_debug_location(volume->resource.locations));
                 return;
             }
-            wined3d_volume_validate_location(volume, location);
+            wined3d_resource_validate_location(&volume->resource, location);
 
             if (wined3d_volume_can_evict(volume))
                 wined3d_volume_evict_sysmem(volume);
@@ -305,7 +298,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
                         wined3d_debug_location(volume->resource.locations));
                 return;
             }
-            wined3d_volume_validate_location(volume, WINED3D_LOCATION_SYSMEM);
+            wined3d_resource_validate_location(&volume->resource, WINED3D_LOCATION_SYSMEM);
             break;
 
         case WINED3D_LOCATION_BUFFER:
@@ -334,7 +327,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
                         wined3d_debug_location(volume->resource.locations));
                 return;
             }
-            wined3d_volume_validate_location(volume, WINED3D_LOCATION_BUFFER);
+            wined3d_resource_validate_location(&volume->resource, WINED3D_LOCATION_BUFFER);
             break;
 
         default:
@@ -413,7 +406,7 @@ static void volume_unload(struct wined3d_resource *resource)
     else
     {
         ERR("Out of memory when unloading volume %p.\n", volume);
-        wined3d_volume_validate_location(volume, WINED3D_LOCATION_DISCARDED);
+        wined3d_resource_validate_location(&volume->resource, WINED3D_LOCATION_DISCARDED);
         wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_DISCARDED);
     }
 
@@ -559,7 +552,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
 
         wined3d_volume_prepare_pbo(volume, context);
         if (flags & WINED3D_MAP_DISCARD)
-            wined3d_volume_validate_location(volume, WINED3D_LOCATION_BUFFER);
+            wined3d_resource_validate_location(&volume->resource, WINED3D_LOCATION_BUFFER);
         else
             wined3d_volume_load_location(volume, context, WINED3D_LOCATION_BUFFER);
 
@@ -594,7 +587,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
 
         if (flags & WINED3D_MAP_DISCARD)
         {
-            wined3d_volume_validate_location(volume, WINED3D_LOCATION_SYSMEM);
+            wined3d_resource_validate_location(&volume->resource, WINED3D_LOCATION_SYSMEM);
         }
         else if (!(volume->resource.locations & WINED3D_LOCATION_SYSMEM))
         {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a431453..f47c2fb 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2125,6 +2125,7 @@ GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
 DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags) DECLSPEC_HIDDEN;
 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void wined3d_resource_validate_location(struct wined3d_resource *resource, DWORD location) DECLSPEC_HIDDEN;
 
 /* Tests show that the start address of resources is 32 byte aligned */
 #define RESOURCE_ALIGNMENT 16
-- 
2.2.1

