Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/buffer.c | 4 ++++ dlls/d3d8/device.c | 2 ++ dlls/d3d8/texture.c | 6 ++++++ dlls/d3d9/buffer.c | 4 ++++ dlls/d3d9/device.c | 2 ++ dlls/d3d9/texture.c | 6 ++++++ dlls/ddraw/surface.c | 1 + dlls/wined3d/buffer.c | 2 +- dlls/wined3d/device.c | 2 +- dlls/wined3d/resource.c | 9 ++++++++- dlls/wined3d/texture.c | 12 +++++------- dlls/wined3d/utils.c | 2 ++ dlls/wined3d/wined3d_private.h | 5 ----- include/wine/wined3d.h | 1 + 14 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 9534c33932d..2f0d1679c22 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -288,6 +288,8 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *
desc.byte_width = size; desc.usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -577,6 +579,8 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index b05df7e2914..b60e00cce1f 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1165,6 +1165,8 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width desc.usage = usage & WINED3DUSAGE_MASK; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage); desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index c952579ce61..d9e68f87035 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -1110,6 +1110,8 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -1159,6 +1161,8 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -1207,6 +1211,8 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index ea98ef4242f..0c4a1262ff1 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -289,6 +289,8 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *
desc.byte_width = size; desc.usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -576,6 +578,8 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 1e7c0ea0f45..d641b94221e 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1392,6 +1392,8 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width desc.usage = usage & WINED3DUSAGE_MASK; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage); desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 70d35fc50c1..a4db0e9dec8 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1314,6 +1314,8 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -1401,6 +1403,8 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -1473,6 +1477,8 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 6bb92d5d399..dfa740833b7 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6191,6 +6191,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; /* Managed textures have the system memory flag set. */ desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + wined3d_desc.usage |= WINED3DUSAGE_MANAGED; } else if (desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) { diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 020116da7f6..ff81044fcff 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1393,7 +1393,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING - || wined3d_resource_access_is_managed(desc->access)) + || desc->usage & WINED3DUSAGE_MANAGED) { /* SWvp and managed buffers always return the same pointer in buffer * maps and retain data in DISCARD maps. Keep a system memory copy of diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1af76f235c8..14e2260c023 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4744,7 +4744,7 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) { TRACE("Checking resource %p for eviction.\n", resource);
- if (wined3d_resource_access_is_managed(resource->access) && !resource->map_count) + if (resource->usage & WINED3DUSAGE_MANAGED && !resource->map_count) { TRACE("Evicting %p.\n", resource); wined3d_cs_emit_unload_resource(device->cs, resource); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 58caccc7305..299202e6d31 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -36,6 +36,7 @@ static void resource_check_usage(DWORD usage) | WINED3DUSAGE_STATICDECL | WINED3DUSAGE_OVERLAY | WINED3DUSAGE_SCRATCH + | WINED3DUSAGE_MANAGED | WINED3DUSAGE_PRIVATE | WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE @@ -92,6 +93,12 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * wined3d_debug_resource_access(access)); return WINED3DERR_INVALIDCALL; } + if (usage & WINED3DUSAGE_MANAGED && ~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) + { + ERR("Trying to create a managed resource with access flags %s.\n", + wined3d_debug_resource_access(access)); + return WINED3DERR_INVALIDCALL; + }
if (!size) ERR("Attempting to create a zero-sized resource.\n"); @@ -258,7 +265,7 @@ DWORD CDECL wined3d_resource_set_priority(struct wined3d_resource *resource, DWO { DWORD prev;
- if (!wined3d_resource_access_is_managed(resource->access)) + if (~resource->usage & WINED3DUSAGE_MANAGED) { WARN("Called on non-managed resource %p, ignoring.\n", resource); return 0; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index e01becd44f8..9c19e4e9fb6 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1410,10 +1410,9 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) /* The d3d9:texture test shows that SetLOD is ignored on non-managed * textures. The call always returns 0, and GetLOD always returns 0. */ resource = &texture->resource; - if (!wined3d_resource_access_is_managed(resource->access)) + if (~resource->usage & WINED3DUSAGE_MANAGED) { - TRACE("Ignoring LOD on texture with resource access %s.\n", - wined3d_debug_resource_access(resource->access)); + TRACE("Ignoring LOD on texture with resource usage %s.\n", debug_d3dusage(resource->usage)); return 0; }
@@ -2898,11 +2897,10 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc } format = wined3d_get_format(device->adapter, desc->format, desc->bind_flags);
- if (desc->usage & WINED3DUSAGE_DYNAMIC && (wined3d_resource_access_is_managed(desc->access) - || desc->usage & WINED3DUSAGE_SCRATCH)) + if (desc->usage & WINED3DUSAGE_DYNAMIC + && desc->usage & (WINED3DUSAGE_MANAGED | WINED3DUSAGE_SCRATCH)) { - WARN("Attempted to create a dynamic texture with access %s and usage %s.\n", - wined3d_debug_resource_access(desc->access), debug_d3dusage(desc->usage)); + WARN("Attempted to create a dynamic texture with usage %s.\n", debug_d3dusage(desc->usage)); return WINED3DERR_INVALIDCALL; }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a7b1b10f9ac..5edea43c510 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4524,6 +4524,8 @@ const char *debug_d3dusage(DWORD usage) WINED3DUSAGE_TO_STR(WINED3DUSAGE_RESTRICT_SHARED_RESOURCE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_DMAP); WINED3DUSAGE_TO_STR(WINED3DUSAGE_TEXTAPI); + WINED3DUSAGE_TO_STR(WINED3DUSAGE_MANAGED); + WINED3DUSAGE_TO_STR(WINED3DUSAGE_PRIVATE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_LEGACY_CUBEMAP); WINED3DUSAGE_TO_STR(WINED3DUSAGE_TEXTURE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_OWNDC); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5b7ddfce10d..d53f0ccc192 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3083,11 +3083,6 @@ const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN; const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d, const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
-static inline BOOL wined3d_resource_access_is_managed(unsigned int access) -{ - return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)); -} - struct wined3d_resource_ops { ULONG (*resource_incref)(struct wined3d_resource *resource); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index fd907578c2d..4fd80dca27d 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -930,6 +930,7 @@ enum wined3d_shader_type #define WINED3DUSAGE_MASK 0x10007bfa
#define WINED3DUSAGE_SCRATCH 0x00200000 +#define WINED3DUSAGE_MANAGED 0x00000004 #define WINED3DUSAGE_PRIVATE 0x00400000 #define WINED3DUSAGE_LEGACY_CUBEMAP 0x00800000 #define WINED3DUSAGE_TEXTURE 0x01000000
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 14e2260c023..bf3a66114b9 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4744,7 +4744,8 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) { TRACE("Checking resource %p for eviction.\n", resource);
- if (resource->usage & WINED3DUSAGE_MANAGED && !resource->map_count) + if (!(~resource->access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) + && !resource->map_count) { TRACE("Evicting %p.\n", resource); wined3d_cs_emit_unload_resource(device->cs, resource);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index ff81044fcff..a9bce2b474e 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1393,7 +1393,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING - || desc->usage & WINED3DUSAGE_MANAGED) + || desc->access & WINED3D_RESOURCE_ACCESS_CPU) { /* SWvp and managed buffers always return the same pointer in buffer * maps and retain data in DISCARD maps. Keep a system memory copy of
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/buffer.c | 4 ++-- dlls/d3d9/d3d9_private.h | 10 ++++++++-- dlls/d3d9/device.c | 2 +- dlls/d3d9/texture.c | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 0c4a1262ff1..e4c5895b0ce 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -292,7 +292,7 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device * if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_VERTEXBUFFER) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0; @@ -581,7 +581,7 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_INDEXBUFFER) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0; diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index d6155eba60b..1144c97b9ec 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -313,11 +313,13 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i return D3DPOOL_SCRATCH; return D3DPOOL_SYSTEMMEM; case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: - return D3DPOOL_MANAGED; + if (usage & WINED3DUSAGE_MANAGED) + return D3DPOOL_MANAGED; + return D3DPOOL_SYSTEMMEM; } }
-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) { switch (pool) { @@ -329,6 +331,10 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; case D3DPOOL_SYSTEMMEM: + if (type == D3DRTYPE_VERTEXBUFFER || type == D3DRTYPE_INDEXBUFFER) + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + /* Fall-through. */ case D3DPOOL_SCRATCH: return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; default: diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index d641b94221e..dfb30e55fcd 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1395,7 +1395,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage); - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_SURFACE) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index a4db0e9dec8..d76179eab04 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1317,7 +1317,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; 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) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; @@ -1406,7 +1406,7 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; 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) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; desc.height = edge_length; @@ -1480,7 +1480,7 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; 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;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/buffer.c | 4 ++-- dlls/d3d8/d3d8_private.h | 10 ++++++++-- dlls/d3d8/device.c | 2 +- dlls/d3d8/texture.c | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 2f0d1679c22..87b24bccc60 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -291,7 +291,7 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device * if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_VERTEXBUFFER) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0; @@ -582,7 +582,7 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_INDEXBUFFER) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0; diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 7f6049df574..aab2eb97e6e 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -300,11 +300,13 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i return D3DPOOL_SCRATCH; return D3DPOOL_SYSTEMMEM; case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: - return D3DPOOL_MANAGED; + if (usage & WINED3DUSAGE_MANAGED) + return D3DPOOL_MANAGED; + return D3DPOOL_SYSTEMMEM; } }
-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) { switch (pool) { @@ -316,6 +318,10 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; case D3DPOOL_SYSTEMMEM: + if (type == D3DRTYPE_VERTEXBUFFER || type == D3DRTYPE_INDEXBUFFER) + return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + /* Fall-through. */ case D3DPOOL_SCRATCH: return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; default: diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index b60e00cce1f..67c4c7ed75d 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1168,7 +1168,7 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage); - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_SURFACE) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index d9e68f87035..f53ae562336 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -1113,7 +1113,7 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_TEXTURE) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; desc.height = height; @@ -1164,7 +1164,7 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; - desc.access = wined3daccess_from_d3dpool(pool, usage) + desc.access = wined3daccess_from_d3dpool(pool, usage, D3DRTYPE_CUBETEXTURE) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; desc.height = edge_length; @@ -1214,7 +1214,7 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = wined3d_bind_flags_from_d3d8_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;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45279 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/ddraw/vertexbuffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c index 3ad8f7e1bdd..6a1f010bd31 100644 --- a/dlls/ddraw/vertexbuffer.c +++ b/dlls/ddraw/vertexbuffer.c @@ -125,7 +125,8 @@ static HRESULT d3d_vertex_buffer_create_wined3d_buffer(struct d3d_vertex_buffer desc.usage |= WINED3DUSAGE_DYNAMIC; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; if (buffer->Caps & D3DVBCAPS_SYSTEMMEMORY) - desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; else desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0;
Hello Matteo,
What's the state on this patch series? I've been investigating bug 45279, and this solves it nicely. It's been almost a month since submission, and I'd like to see that in 4.0 - it fixes a bunch of applications. Not sure if that would be suitable during code freeze though.
Regards, Fabian Maurer