Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/buffer.c | 6 ++---- dlls/d3d9/d3d9_private.h | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 83cf4010450..dcd7e287264 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -310,8 +310,7 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_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;
@@ -629,8 +628,7 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_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;
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index e520b604e9a..1032f8e8e9c 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -325,23 +325,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_d3d9_usage(DWORD usage)