Commit 10061d59 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

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

parent 07c20ef0
...@@ -303,8 +303,7 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device * ...@@ -303,8 +303,7 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *
desc.byte_width = size; desc.byte_width = size;
desc.usage = usage & WINED3DUSAGE_MASK; desc.usage = usage & WINED3DUSAGE_MASK;
desc.bind_flags = 0; desc.bind_flags = 0;
desc.access = wined3daccess_from_d3dpool(pool, usage) desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage);
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.misc_flags = 0; desc.misc_flags = 0;
desc.structure_byte_stride = 0; desc.structure_byte_stride = 0;
...@@ -618,8 +617,7 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de ...@@ -618,8 +617,7 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de
desc.byte_width = size; desc.byte_width = size;
desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
desc.bind_flags = 0; desc.bind_flags = 0;
desc.access = wined3daccess_from_d3dpool(pool, usage) desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage);
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
desc.misc_flags = 0; desc.misc_flags = 0;
desc.structure_byte_stride = 0; desc.structure_byte_stride = 0;
......
...@@ -313,23 +313,35 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i ...@@ -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) static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
{ {
unsigned int access;
switch (pool) switch (pool)
{ {
case D3DPOOL_DEFAULT: case D3DPOOL_DEFAULT:
if (usage & D3DUSAGE_DYNAMIC) access = WINED3D_RESOURCE_ACCESS_GPU;
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; break;
return WINED3D_RESOURCE_ACCESS_GPU;
case D3DPOOL_MANAGED: case D3DPOOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU;
| WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; break;
case D3DPOOL_SYSTEMMEM: case D3DPOOL_SYSTEMMEM:
case D3DPOOL_SCRATCH: 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: 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) static inline unsigned int wined3d_bind_flags_from_d3d8_usage(DWORD usage)
......
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