Module: wine
Branch: master
Commit: bc24fbf6d64d23b1ab0961de3d5bb86a53cb3d79
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bc24fbf6d64d23b1ab0961de3…
Author: Henri Verbeet <hverbeet(a)codeweavers.com>
Date: Wed Mar 9 16:21:53 2016 +0100
wined3d: Keep track of the download count in the texture.
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/wined3d/surface.c | 35 +++++++++--------------------------
dlls/wined3d/volume.c | 10 ++++++----
dlls/wined3d/wined3d_private.h | 6 ++----
3 files changed, 17 insertions(+), 34 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 1bdeecf..487fd3f 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -507,11 +507,10 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
static void surface_evict_sysmem(struct wined3d_surface *surface)
{
- /* In some conditions the surface memory must not be freed:
- * WINED3D_TEXTURE_CONVERTED: Converting the data back would take too long
- * WINED3D_TEXTURE_DYNAMIC_MAP: Avoid freeing the data for performance */
- if (surface->resource.map_count || surface->container->flags & (WINED3D_TEXTURE_CONVERTED
- | WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_DYNAMIC_MAP))
+ struct wined3d_texture *texture = surface->container;
+
+ if (surface->resource.map_count || texture->download_count > MAXLOCKCOUNT
+ || texture->flags & (WINED3D_TEXTURE_CONVERTED | WINED3D_TEXTURE_PIN_SYSMEM))
return;
wined3d_resource_free_sysmem(&surface->resource);
@@ -1259,11 +1258,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
* standard texture with a non-power2 width instead of a texture boxed up to be a power2 texture.
*
* internally the texture is still stored in a boxed format so any references to textureName will
- * get a boxed texture with width pow2width and not a texture of width resource.width.
- *
- * Performance should not be an issue, because applications normally do not lock the surfaces when
- * rendering. If an app does, the WINED3D_TEXTURE_DYNAMIC_MAP flag will kick in and the memory copy
- * won't be released, and doesn't have to be re-read. */
+ * get a boxed texture with width pow2width and not a texture of width resource.width. */
src_data = mem;
dst_data = data.addr;
TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
@@ -2169,21 +2164,6 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
if (!(surface->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU))
WARN("Trying to lock unlockable surface.\n");
- /* Performance optimization: Count how often a surface is mapped, if it is
- * mapped regularly do not throw away the system memory copy. This avoids
- * the need to download the surface from OpenGL all the time. The surface
- * is still downloaded if the OpenGL texture is changed. Note that this
- * only really makes sense for managed textures.*/
- if (!(texture->flags & WINED3D_TEXTURE_DYNAMIC_MAP)
- && surface->resource.map_binding == WINED3D_LOCATION_SYSMEM)
- {
- if (++surface->lockCount > MAXLOCKCOUNT)
- {
- TRACE("Surface is mapped regularly, not freeing the system memory copy any more.\n");
- texture->flags |= WINED3D_TEXTURE_DYNAMIC_MAP;
- }
- }
-
flags = wined3d_resource_sanitize_map_flags(&texture->resource, flags);
if (device->d3d_initialized)
@@ -3475,9 +3455,12 @@ static void surface_load_sysmem(struct wined3d_surface *surface,
/* Download the surface to system memory. */
if (surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
- wined3d_texture_bind_and_dirtify(surface->container, context,
+ struct wined3d_texture *texture = surface->container;
+
+ wined3d_texture_bind_and_dirtify(texture, context,
!(surface->locations & WINED3D_LOCATION_TEXTURE_RGB));
surface_download_data(surface, gl_info, dst_location);
+ ++texture->download_count;
return;
}
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index f70b50b..6eb7622 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -234,11 +234,13 @@ static void wined3d_volume_srgb_transfer(struct wined3d_volume *volume,
static BOOL wined3d_volume_can_evict(const struct wined3d_volume *volume)
{
- if (volume->resource.pool != WINED3D_POOL_MANAGED)
+ struct wined3d_texture *texture = volume->container;
+
+ if (texture->resource.pool != WINED3D_POOL_MANAGED)
return FALSE;
- if (volume->download_count >= 10)
+ if (texture->download_count >= 10)
return FALSE;
- if (volume->resource.format->convert)
+ if (texture->resource.format->convert)
return FALSE;
return TRUE;
@@ -324,8 +326,8 @@ static BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- volume->download_count++;
wined3d_volume_download_data(volume, context, &data);
+ ++texture->download_count;
}
else
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 61cc3a3..64a4d88 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2352,8 +2352,7 @@ struct wined3d_texture_ops
#define WINED3D_TEXTURE_SRGB_VALID 0x00000080
#define WINED3D_TEXTURE_CONVERTED 0x00000100
#define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
-#define WINED3D_TEXTURE_DYNAMIC_MAP 0x00000400
-#define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000800
+#define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
#define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
@@ -2365,6 +2364,7 @@ struct wined3d_texture
struct wined3d_swapchain *swapchain;
UINT layer_count;
UINT level_count;
+ unsigned int download_count;
float pow2_matrix[16];
UINT lod;
enum wined3d_texture_filter_type filter_type;
@@ -2457,7 +2457,6 @@ struct wined3d_volume
DWORD locations;
GLint texture_level;
- DWORD download_count;
};
static inline struct wined3d_volume *volume_from_resource(struct wined3d_resource *resource)
@@ -2537,7 +2536,6 @@ struct wined3d_surface
GLenum texture_target;
unsigned int texture_level;
unsigned int texture_layer;
- int lockCount;
/* For GetDC */
struct wined3d_surface_dib dib;