Commit d6a511e0 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Track system memory pinning per-texture.

parent 6d498018
...@@ -592,8 +592,8 @@ static void surface_evict_sysmem(struct wined3d_surface *surface) ...@@ -592,8 +592,8 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
* SFLAG_DYNLOCK: Avoid freeing the data for performance * SFLAG_DYNLOCK: Avoid freeing the data for performance
* SFLAG_CLIENT: OpenGL uses our memory as backup */ * SFLAG_CLIENT: OpenGL uses our memory as backup */
if (surface->resource.map_count if (surface->resource.map_count
|| surface->flags & (SFLAG_DYNLOCK | SFLAG_CLIENT | SFLAG_PIN_SYSMEM) || surface->flags & (SFLAG_DYNLOCK | SFLAG_CLIENT)
|| surface->container->flags & WINED3D_TEXTURE_CONVERTED) || surface->container->flags & (WINED3D_TEXTURE_CONVERTED | WINED3D_TEXTURE_PIN_SYSMEM))
return; return;
wined3d_resource_free_sysmem(&surface->resource); wined3d_resource_free_sysmem(&surface->resource);
...@@ -625,12 +625,14 @@ static void surface_release_client_storage(struct wined3d_surface *surface) ...@@ -625,12 +625,14 @@ static void surface_release_client_storage(struct wined3d_surface *surface)
static BOOL surface_use_pbo(const 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; 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 && surface->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !surface->resource.format->convert && !texture->resource.format->convert
&& !(surface->flags & (SFLAG_NONPOW2 | SFLAG_PIN_SYSMEM)); && !(texture->flags & WINED3D_TEXTURE_PIN_SYSMEM)
&& !(surface->flags & SFLAG_NONPOW2);
} }
static HRESULT surface_private_setup(struct wined3d_surface *surface) 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 ...@@ -1481,8 +1483,8 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
if (surface->resource.map_count) if (surface->resource.map_count)
{ {
WARN("Uploading a surface that is currently mapped, setting SFLAG_PIN_SYSMEM.\n"); WARN("Uploading a surface that is currently mapped, setting WINED3D_TEXTURE_PIN_SYSMEM.\n");
surface->flags |= SFLAG_PIN_SYSMEM; surface->container->flags |= WINED3D_TEXTURE_PIN_SYSMEM;
} }
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE) if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
...@@ -2742,7 +2744,7 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc) ...@@ -2742,7 +2744,7 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
if (FAILED(hr)) if (FAILED(hr))
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY
|| surface->flags & SFLAG_PIN_SYSMEM || surface->container->flags & WINED3D_TEXTURE_PIN_SYSMEM
|| surface->pbo)) || surface->pbo))
surface->resource.map_binding = WINED3D_LOCATION_DIB; surface->resource.map_binding = WINED3D_LOCATION_DIB;
} }
...@@ -2776,7 +2778,8 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc) ...@@ -2776,7 +2778,8 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
surface->resource.map_count--; surface->resource.map_count--;
surface->flags &= ~SFLAG_DCINUSE; 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)) && surface->resource.map_binding != WINED3D_LOCATION_DIB))
{ {
/* The game Salammbo modifies the surface contents without mapping the surface between /* 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 ...@@ -5546,8 +5549,6 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
surface->flags |= SFLAG_NORMCOORD; surface->flags |= SFLAG_NORMCOORD;
if (flags & WINED3D_SURFACE_DISCARD) if (flags & WINED3D_SURFACE_DISCARD)
surface->flags |= SFLAG_DISCARD; surface->flags |= SFLAG_DISCARD;
if (flags & WINED3D_SURFACE_PIN_SYSMEM)
surface->flags |= SFLAG_PIN_SYSMEM;
if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE) if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE)
surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU; surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
......
...@@ -28,19 +28,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); ...@@ -28,19 +28,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
WINE_DECLARE_DEBUG_CHANNEL(winediag); WINE_DECLARE_DEBUG_CHANNEL(winediag);
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, 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, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD surface_flags,
void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops) 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); const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, desc->format);
HRESULT hr; HRESULT hr;
TRACE("texture %p, texture_ops %p, layer_count %u, level_count %u, resource_type %s, format %s, " 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, " "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), texture, texture_ops, layer_count, level_count, debug_d3dresourcetype(desc->resource_type),
debug_d3dformat(desc->format), desc->multisample_type, desc->multisample_quality, debug_d3dformat(desc->format), desc->multisample_type, desc->multisample_quality,
debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth, 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) 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 ...@@ -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->filter_type = (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3D_TEXF_LINEAR : WINED3D_TEXF_NONE;
texture->lod = 0; texture->lod = 0;
texture->flags = WINED3D_TEXTURE_POW2_MAT_IDENT; 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) if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
{ {
...@@ -1053,8 +1056,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi ...@@ -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, if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels, desc,
desc, device, parent, parent_ops, &texture_resource_ops))) surface_flags, device, parent, parent_ops, &texture_resource_ops)))
{ {
WARN("Failed to initialize texture, returning %#x\n", hr); WARN("Failed to initialize texture, returning %#x\n", hr);
return hr; return hr;
...@@ -1178,8 +1181,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 ...@@ -1178,8 +1181,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
TRACE("Calculated levels = %u.\n", levels); TRACE("Calculated levels = %u.\n", levels);
} }
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, desc,
desc, device, parent, parent_ops, &texture_resource_ops))) surface_flags, device, parent, parent_ops, &texture_resource_ops)))
{ {
WARN("Failed to initialize texture, returning %#x.\n", hr); WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr; return hr;
...@@ -1404,8 +1407,8 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct ...@@ -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, if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels, desc,
desc, device, parent, parent_ops, &texture_resource_ops))) 0, device, parent, parent_ops, &texture_resource_ops)))
{ {
WARN("Failed to initialize texture, returning %#x.\n", hr); WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr; return hr;
......
...@@ -2129,6 +2129,7 @@ struct wined3d_texture_ops ...@@ -2129,6 +2129,7 @@ struct wined3d_texture_ops
#define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000020 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000020
#define WINED3D_TEXTURE_SRGB_VALID 0x00000040 #define WINED3D_TEXTURE_SRGB_VALID 0x00000040
#define WINED3D_TEXTURE_CONVERTED 0x00000080 #define WINED3D_TEXTURE_CONVERTED 0x00000080
#define WINED3D_TEXTURE_PIN_SYSMEM 0x00000100
struct wined3d_texture struct wined3d_texture
{ {
...@@ -2351,11 +2352,10 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D ...@@ -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_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_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_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_DCINUSE 0x00000040 /* Set between GetDC and ReleaseDC calls. */
#define SFLAG_LOST 0x00000080 /* Surface lost flag for ddraw. */ #define SFLAG_LOST 0x00000080 /* Surface lost flag for ddraw. */
#define SFLAG_GLCKEY 0x00000100 /* The GL texture was created with a color key. */ #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 struct wined3d_sampler
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment