From 798504700b9a6122740d243fc51478b37b82cfae Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 29 Jan 2018 21:10:22 +0330 Subject: [PATCH] wined3d: Introduce WINED3D_RESOURCE_ACCESS_MAP. In order to distinguish between resources that exist purely in CPU memory and resources that exist in GPU memory but can be mapped. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/resource.c | 8 ++++---- dlls/wined3d/texture.c | 10 +++++----- dlls/wined3d/wined3d_private.h | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index dcaa0727075..7817f85c98f 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -36,11 +36,11 @@ static DWORD resource_access_from_pool(enum wined3d_pool pool) return WINED3D_RESOURCE_ACCESS_GPU; case WINED3D_POOL_MANAGED: - return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU; + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP; case WINED3D_POOL_SCRATCH: case WINED3D_POOL_SYSTEM_MEM: - return WINED3D_RESOURCE_ACCESS_CPU; + return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP; default: FIXME("Unhandled pool %#x.\n", pool); @@ -191,9 +191,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource->multisample_quality = multisample_quality; resource->usage = usage; resource->pool = pool; - resource->access_flags = resource_access_from_pool(pool); + resource->access = resource_access_from_pool(pool); if (usage & WINED3DUSAGE_DYNAMIC) - resource->access_flags |= WINED3D_RESOURCE_ACCESS_CPU; + resource->access |= WINED3D_RESOURCE_ACCESS_MAP; resource->width = width; resource->height = height; resource->depth = depth; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 4dc739cc4c0..36d46ad917a 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -33,7 +33,7 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag); static BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) { return texture->resource.pool == WINED3D_POOL_DEFAULT - && texture->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU + && texture->resource.access & WINED3D_RESOURCE_ACCESS_MAP && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && !texture->resource.format->conv_byte_count && !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED)); @@ -243,9 +243,9 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture, if (WARN_ON(d3d)) { DWORD required_access = wined3d_resource_access_from_location(location); - if ((texture->resource.access_flags & required_access) != required_access) + if ((texture->resource.access & required_access) != required_access) WARN("Operation requires %#x access, but texture only has %#x.\n", - required_access, texture->resource.access_flags); + required_access, texture->resource.access); } if (current & WINED3D_LOCATION_DISCARDED) @@ -369,7 +369,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc } wined3d_resource_update_draw_binding(&texture->resource); if ((flags & WINED3D_TEXTURE_CREATE_MAPPABLE) || desc->format == WINED3DFMT_D16_LOCKABLE) - texture->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU; + texture->resource.access |= WINED3D_RESOURCE_ACCESS_MAP; texture->texture_ops = texture_ops; @@ -1874,7 +1874,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour return WINED3DERR_INVALIDCALL; } - if (!(resource->access_flags & WINED3D_RESOURCE_ACCESS_CPU)) + if (!(resource->access & WINED3D_RESOURCE_ACCESS_MAP)) { WARN("Trying to map unmappable texture.\n"); if (resource->type != WINED3D_RTYPE_TEXTURE_2D) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9f68b0ad30f..082c1ecc4af 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2961,8 +2961,9 @@ static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD sta return context->isStateDirty[idx] & (1u << shift); } -#define WINED3D_RESOURCE_ACCESS_GPU 0x1 -#define WINED3D_RESOURCE_ACCESS_CPU 0x2 +#define WINED3D_RESOURCE_ACCESS_GPU 0x1u +#define WINED3D_RESOURCE_ACCESS_CPU 0x2u +#define WINED3D_RESOURCE_ACCESS_MAP 0x4u struct wined3d_resource_ops { @@ -2990,7 +2991,7 @@ struct wined3d_resource UINT multisample_quality; DWORD usage; enum wined3d_pool pool; - DWORD access_flags; + unsigned int access; WORD draw_binding; WORD map_binding; UINT width;