Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/buffer.c | 6 ++---- dlls/d3d9/d3d9_private.h | 22 ++++++++++++++-------- dlls/d3d9/device.c | 2 +- dlls/d3d9/texture.c | 6 +++--- 4 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 6becf7d3af0..ca6493363f5 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -311,8 +311,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, D3DRTYPE_VERTEXBUFFER); desc.misc_flags = 0; desc.structure_byte_stride = 0;
@@ -632,8 +631,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, D3DRTYPE_INDEXBUFFER); desc.misc_flags = 0; desc.structure_byte_stride = 0;
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index c6d73d92957..3566ab91239 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -324,23 +324,29 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i } }
-static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage) +static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage, D3DRESOURCETYPE type) { + 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 (type == D3DRTYPE_VERTEXBUFFER || type == D3DRTYPE_INDEXBUFFER + || pool != D3DPOOL_DEFAULT || usage & D3DUSAGE_DYNAMIC) + access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + return access; }
static inline unsigned int wined3d_bind_flags_from_d3d9_usage(DWORD usage) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index d8e5f0fbfc3..094a87b8479 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1854,7 +1854,7 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex usage = 0; if (pool == D3DPOOL_SCRATCH) usage |= WINED3DUSAGE_SCRATCH; - access = wined3daccess_from_d3dpool(pool, usage) + access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_SURFACE) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
return d3d9_device_create_surface(device, 0, wined3dformat_from_d3dformat(format), diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 8dc1ceea698..010434d66aa 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1321,7 +1321,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; - desc.access = wined3daccess_from_d3dpool(pool, usage); + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_TEXTURE); desc.width = width; desc.height = height; desc.depth = 1; @@ -1410,7 +1410,7 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; - desc.access = wined3daccess_from_d3dpool(pool, usage); + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_CUBETEXTURE); desc.width = edge_length; desc.height = edge_length; desc.depth = 1; @@ -1487,7 +1487,7 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; - desc.access = wined3daccess_from_d3dpool(pool, usage); + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_VOLUMETEXTURE); desc.width = width; desc.height = height; desc.depth = depth;