Signed-off-by: Matteo Bruni <mbruni(a)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
--
2.18.1