wined3d: Use the resource access flags in resource_init().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-01-31 18:49:36 +03:30 committed by Alexandre Julliard
parent 1d732b4751
commit 7ef8b31965
3 changed files with 25 additions and 5 deletions

View File

@ -83,6 +83,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
enum wined3d_gl_resource_type base_type = WINED3D_GL_RES_TYPE_COUNT;
enum wined3d_gl_resource_type gl_type = WINED3D_GL_RES_TYPE_COUNT;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
DWORD access = resource_access_from_pool(pool);
BOOL tex_2d_ok = FALSE;
unsigned int i;
@ -104,9 +105,10 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource_check_usage(usage);
if (usage & WINED3DUSAGE_SCRATCH && pool != WINED3D_POOL_SYSTEM_MEM)
if (usage & WINED3DUSAGE_SCRATCH && access & WINED3D_RESOURCE_ACCESS_GPU)
{
ERR("WINED3DUSAGE_SCRATCH used with pool %s.\n", debug_d3dpool(pool));
ERR("Trying to create a scratch resource with access flags %s.\n",
wined3d_debug_resource_access(access));
return WINED3DERR_INVALIDCALL;
}
@ -197,9 +199,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource->multisample_quality = multisample_quality;
resource->usage = usage;
resource->pool = pool;
resource->access = resource_access_from_pool(pool);
if (usage & WINED3DUSAGE_DYNAMIC)
resource->access |= WINED3D_RESOURCE_ACCESS_MAP;
access |= WINED3D_RESOURCE_ACCESS_MAP;
resource->access = access;
resource->width = width;
resource->height = height;
resource->depth = depth;
@ -226,7 +228,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
if (!(usage & WINED3DUSAGE_PRIVATE))
{
/* Check that we have enough video ram left */
if (pool == WINED3D_POOL_DEFAULT && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
if (!(access & WINED3D_RESOURCE_ACCESS_CPU) && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
{
if (size > wined3d_device_get_available_texture_mem(device))
{

View File

@ -4129,6 +4129,22 @@ const char *debug_d3ddevicetype(enum wined3d_device_type device_type)
}
}
const char *wined3d_debug_resource_access(DWORD access)
{
char buf[91];
buf[0] = '\0';
#define ACCESS_TO_STR(x) if (access & x) { strcat(buf, " | "#x); access &= ~x; }
ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_GPU);
ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_CPU);
ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_MAP);
#undef ACCESS_TO_STR
if (access)
FIXME("Unrecognised access flag(s) %#x.\n", access);
return buf[0] ? wine_dbg_sprintf("%s", &buf[3]) : "0";
}
const char *debug_d3dusage(DWORD usage)
{
char buf[552];

View File

@ -2965,6 +2965,8 @@ static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD sta
#define WINED3D_RESOURCE_ACCESS_CPU 0x2u
#define WINED3D_RESOURCE_ACCESS_MAP 0x4u
const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
{
return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));