Module: wine Branch: master Commit: d6a511e0220c5cb2c2b1c18d9698d46d342affb2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d6a511e0220c5cb2c2b1c18d96...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Oct 9 11:50:45 2014 +0200
wined3d: Track system memory pinning per-texture.
---
dlls/wined3d/surface.c | 23 ++++++++++++----------- dlls/wined3d/texture.c | 23 +++++++++++++---------- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 527601f..3339c5b 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -592,8 +592,8 @@ static void surface_evict_sysmem(struct wined3d_surface *surface) * SFLAG_DYNLOCK: Avoid freeing the data for performance * SFLAG_CLIENT: OpenGL uses our memory as backup */ if (surface->resource.map_count - || surface->flags & (SFLAG_DYNLOCK | SFLAG_CLIENT | SFLAG_PIN_SYSMEM) - || surface->container->flags & WINED3D_TEXTURE_CONVERTED) + || surface->flags & (SFLAG_DYNLOCK | SFLAG_CLIENT) + || surface->container->flags & (WINED3D_TEXTURE_CONVERTED | WINED3D_TEXTURE_PIN_SYSMEM)) return;
wined3d_resource_free_sysmem(&surface->resource); @@ -625,12 +625,14 @@ static void surface_release_client_storage(struct wined3d_surface *surface) static BOOL surface_use_pbo(const struct wined3d_surface *surface) { const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info; + struct wined3d_texture *texture = surface->container;
- return surface->resource.pool == WINED3D_POOL_DEFAULT + return texture->resource.pool == WINED3D_POOL_DEFAULT && surface->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] - && !surface->resource.format->convert - && !(surface->flags & (SFLAG_NONPOW2 | SFLAG_PIN_SYSMEM)); + && !texture->resource.format->convert + && !(texture->flags & WINED3D_TEXTURE_PIN_SYSMEM) + && !(surface->flags & SFLAG_NONPOW2); }
static HRESULT surface_private_setup(struct wined3d_surface *surface) @@ -1481,8 +1483,8 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
if (surface->resource.map_count) { - WARN("Uploading a surface that is currently mapped, setting SFLAG_PIN_SYSMEM.\n"); - surface->flags |= SFLAG_PIN_SYSMEM; + WARN("Uploading a surface that is currently mapped, setting WINED3D_TEXTURE_PIN_SYSMEM.\n"); + surface->container->flags |= WINED3D_TEXTURE_PIN_SYSMEM; }
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE) @@ -2742,7 +2744,7 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc) if (FAILED(hr)) return WINED3DERR_INVALIDCALL; if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY - || surface->flags & SFLAG_PIN_SYSMEM + || surface->container->flags & WINED3D_TEXTURE_PIN_SYSMEM || surface->pbo)) surface->resource.map_binding = WINED3D_LOCATION_DIB; } @@ -2776,7 +2778,8 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc) surface->resource.map_count--; surface->flags &= ~SFLAG_DCINUSE;
- if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM + if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY + || (surface->container->flags & WINED3D_TEXTURE_PIN_SYSMEM && surface->resource.map_binding != WINED3D_LOCATION_DIB)) { /* The game Salammbo modifies the surface contents without mapping the surface between @@ -5546,8 +5549,6 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text surface->flags |= SFLAG_NORMCOORD; if (flags & WINED3D_SURFACE_DISCARD) surface->flags |= SFLAG_DISCARD; - if (flags & WINED3D_SURFACE_PIN_SYSMEM) - surface->flags |= SFLAG_PIN_SYSMEM; if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE) surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index fb0f0e8..420355b 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -28,19 +28,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); WINE_DECLARE_DEBUG_CHANNEL(winediag);
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, - UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, struct wined3d_device *device, - void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops) + UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD surface_flags, + struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, + const struct wined3d_resource_ops *resource_ops) { const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, desc->format); HRESULT hr;
TRACE("texture %p, texture_ops %p, layer_count %u, level_count %u, resource_type %s, format %s, " "multisample_type %#x, multisample_quality %#x, usage %s, pool %s, width %u, height %u, depth %u, " - "device %p, parent %p, parent_ops %p, resource_ops %p.\n", + "surface_flags %#x, device %p, parent %p, parent_ops %p, resource_ops %p.\n", texture, texture_ops, layer_count, level_count, debug_d3dresourcetype(desc->resource_type), debug_d3dformat(desc->format), desc->multisample_type, desc->multisample_quality, debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth, - device, parent, parent_ops, resource_ops); + surface_flags, device, parent, parent_ops, resource_ops);
if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY)) == WINED3DFMT_FLAG_BLOCKS) { @@ -81,6 +82,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc texture->filter_type = (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3D_TEXF_LINEAR : WINED3D_TEXF_NONE; texture->lod = 0; texture->flags = WINED3D_TEXTURE_POW2_MAT_IDENT; + if (surface_flags & WINED3D_SURFACE_PIN_SYSMEM) + texture->flags |= WINED3D_TEXTURE_PIN_SYSMEM;
if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING) { @@ -1053,8 +1056,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi } }
- if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels, - desc, device, parent, parent_ops, &texture_resource_ops))) + if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels, desc, + surface_flags, device, parent, parent_ops, &texture_resource_ops))) { WARN("Failed to initialize texture, returning %#x\n", hr); return hr; @@ -1178,8 +1181,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 TRACE("Calculated levels = %u.\n", levels); }
- if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, - desc, device, parent, parent_ops, &texture_resource_ops))) + if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, desc, + surface_flags, device, parent, parent_ops, &texture_resource_ops))) { WARN("Failed to initialize texture, returning %#x.\n", hr); return hr; @@ -1404,8 +1407,8 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct } }
- if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels, - desc, device, parent, parent_ops, &texture_resource_ops))) + if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels, desc, + 0, device, parent, parent_ops, &texture_resource_ops))) { WARN("Failed to initialize texture, returning %#x.\n", hr); return hr; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 810da0f..dd4668e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2129,6 +2129,7 @@ struct wined3d_texture_ops #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000020 #define WINED3D_TEXTURE_SRGB_VALID 0x00000040 #define WINED3D_TEXTURE_CONVERTED 0x00000080 +#define WINED3D_TEXTURE_PIN_SYSMEM 0x00000100
struct wined3d_texture { @@ -2351,11 +2352,10 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D #define SFLAG_NONPOW2 0x00000004 /* Surface sizes are not a power of 2 */ #define SFLAG_NORMCOORD 0x00000008 /* Set if GL texture coordinates are normalized (non-texture rectangle). */ #define SFLAG_DYNLOCK 0x00000010 /* Surface is often locked by the application. */ -#define SFLAG_PIN_SYSMEM 0x00000020 /* Keep the surface in sysmem, at the same address. */ +#define SFLAG_CLIENT 0x00000020 /* GL_APPLE_client_storage is used with this surface. */ #define SFLAG_DCINUSE 0x00000040 /* Set between GetDC and ReleaseDC calls. */ #define SFLAG_LOST 0x00000080 /* Surface lost flag for ddraw. */ #define SFLAG_GLCKEY 0x00000100 /* The GL texture was created with a color key. */ -#define SFLAG_CLIENT 0x00000200 /* GL_APPLE_client_storage is used with this surface. */
struct wined3d_sampler {