diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 7c3537e466e..3ecaa9017d0 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -30,7 +30,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); #define WINED3D_BUFFER_HASDESC 0x01 /* A vertex description has been found. */ #define WINED3D_BUFFER_USE_BO 0x02 /* Use a buffer object for this buffer. */ -#define WINED3D_BUFFER_PIN_SYSMEM 0x04 /* Keep a system memory copy for this buffer. */ #define VB_MAXDECLCHANGES 100 /* After that number of decl changes we stop converting */ #define VB_RESETDECLCHANGE 1000 /* Reset the decl changecount after that number of draws */ @@ -47,7 +46,7 @@ struct wined3d_buffer_ops static void wined3d_buffer_evict_sysmem(struct wined3d_buffer *buffer) { - if (buffer->flags & WINED3D_BUFFER_PIN_SYSMEM) + if (buffer->resource.pin_sysmem) { TRACE("Not evicting system memory for buffer %p.\n", buffer); return; @@ -513,7 +512,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined ERR("Failed to load system memory.\n"); return; } - buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM; + buffer->resource.pin_sysmem = 1; /* Now for each vertex in the buffer that needs conversion. */ vertex_count = buffer->resource.size / buffer->stride; @@ -666,7 +665,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) { if (wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM)) - buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM; + buffer->resource.pin_sysmem = 1; return buffer->resource.heap_memory; } @@ -966,7 +965,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc if (((flags & WINED3D_MAP_WRITE) && !(flags & (WINED3D_MAP_NOOVERWRITE | WINED3D_MAP_DISCARD))) || (!(flags & WINED3D_MAP_WRITE) && (buffer->locations & WINED3D_LOCATION_SYSMEM)) - || buffer->flags & WINED3D_BUFFER_PIN_SYSMEM + || buffer->resource.pin_sysmem || !(buffer->flags & WINED3D_BUFFER_USE_BO)) { if (!(buffer->locations & WINED3D_LOCATION_SYSMEM)) @@ -1036,7 +1035,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc { TRACE("Falling back to doublebuffered operation.\n"); wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM); - buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM; + buffer->resource.pin_sysmem = 1; } TRACE("New pointer is %p.\n", resource->heap_memory); } @@ -1302,7 +1301,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d * maps and retain data in DISCARD maps. Keep a system memory copy of * the buffer to provide the same behavior to the application. */ TRACE("Pinning system memory.\n"); - buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM; + buffer->resource.pin_sysmem = 1; buffer->locations = WINED3D_LOCATION_SYSMEM; } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index b1fd1e7bde2..1323d533eff 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -48,8 +48,8 @@ struct wined3d_rect_f BOOL wined3d_texture_can_use_pbo(const struct wined3d_texture *texture, const struct wined3d_d3d_info *d3d_info) { - if (!d3d_info->pbo || texture->resource.format->conv_byte_count - || (texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED))) + if (!d3d_info->pbo || texture->resource.format->conv_byte_count || texture->resource.pin_sysmem + || (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)) return FALSE; return TRUE; @@ -666,7 +666,8 @@ static void wined3d_texture_evict_sysmem(struct wined3d_texture *texture) struct wined3d_texture_sub_resource *sub_resource; unsigned int i, sub_count; - if (texture->flags & (WINED3D_TEXTURE_CONVERTED | WINED3D_TEXTURE_PIN_SYSMEM) + if ((texture->flags & WINED3D_TEXTURE_CONVERTED) + || texture->resource.pin_sysmem || texture->download_count > WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD) { TRACE("Not evicting system memory for texture %p.\n", texture); @@ -2462,8 +2463,8 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context, if (dst_texture->sub_resources[dst_sub_resource_idx].map_count) { - WARN("Uploading a texture that is currently mapped, setting WINED3D_TEXTURE_PIN_SYSMEM.\n"); - dst_texture->flags |= WINED3D_TEXTURE_PIN_SYSMEM; + WARN("Uploading a texture that is currently mapped, pinning sysmem.\n"); + dst_texture->resource.pin_sysmem = 1; } if (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE) @@ -3825,7 +3826,10 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc texture->flags |= WINED3D_TEXTURE_POW2_MAT_IDENT | WINED3D_TEXTURE_NORMALIZED_COORDS | WINED3D_TEXTURE_DOWNLOADABLE; if (flags & WINED3D_TEXTURE_CREATE_GET_DC_LENIENT) - texture->flags |= WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_GET_DC_LENIENT; + { + texture->flags |= WINED3D_TEXTURE_GET_DC_LENIENT; + texture->resource.pin_sysmem = 1; + } if (flags & (WINED3D_TEXTURE_CREATE_GET_DC | WINED3D_TEXTURE_CREATE_GET_DC_LENIENT)) texture->flags |= WINED3D_TEXTURE_GET_DC; if (flags & WINED3D_TEXTURE_CREATE_DISCARD) @@ -5744,7 +5748,7 @@ static bool blitter_use_cpu_clear(struct wined3d_rendertarget_view *view) locations = texture->sub_resources[view->sub_resource_idx].locations; if (locations & (resource->map_binding | WINED3D_LOCATION_DISCARDED)) return !(resource->access & WINED3D_RESOURCE_ACCESS_GPU) - || (texture->flags & WINED3D_TEXTURE_PIN_SYSMEM); + || texture->resource.pin_sysmem; return !(resource->access & WINED3D_RESOURCE_ACCESS_GPU) && !(texture->flags & WINED3D_TEXTURE_CONVERTED); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c8c9bb7c8c6..e190fc4285e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4332,6 +4332,8 @@ struct wined3d_resource DWORD priority; void *heap_memory; + uint32_t pin_sysmem : 1; + struct wined3d_client_resource client; void *parent; @@ -4450,7 +4452,6 @@ struct wined3d_texture_ops #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080 #define WINED3D_TEXTURE_CONVERTED 0x00000100 -#define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000