d3d8: Don't allow map read access to D3DUSAGE_WRITEONLY buffers.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2019-01-31 13:17:22 +01:00 committed by Alexandre Julliard
parent 07c20ef0c9
commit 10061d591e
2 changed files with 21 additions and 11 deletions

View File

@ -303,8 +303,7 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *
desc.byte_width = size;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.bind_flags = 0;
desc.access = wined3daccess_from_d3dpool(pool, usage)
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage);
desc.misc_flags = 0;
desc.structure_byte_stride = 0;
@ -618,8 +617,7 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de
desc.byte_width = size;
desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
desc.bind_flags = 0;
desc.access = wined3daccess_from_d3dpool(pool, usage)
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage);
desc.misc_flags = 0;
desc.structure_byte_stride = 0;

View File

@ -313,23 +313,35 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i
}
}
static inline unsigned int map_access_from_usage(unsigned int usage)
{
if (usage & D3DUSAGE_WRITEONLY)
return WINED3D_RESOURCE_ACCESS_MAP_W;
return WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
}
static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
{
unsigned int access;
switch (pool)
{
case D3DPOOL_DEFAULT:
if (usage & D3DUSAGE_DYNAMIC)
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
return WINED3D_RESOURCE_ACCESS_GPU;
access = WINED3D_RESOURCE_ACCESS_GPU;
break;
case D3DPOOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU;
break;
case D3DPOOL_SYSTEMMEM:
case D3DPOOL_SCRATCH:
return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
access = WINED3D_RESOURCE_ACCESS_CPU;
break;
default:
return 0;
access = 0;
}
if (pool != D3DPOOL_DEFAULT || usage & D3DUSAGE_DYNAMIC)
access |= map_access_from_usage(usage);
return access;
}
static inline unsigned int wined3d_bind_flags_from_d3d8_usage(DWORD usage)