Commit 1f843165 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Introduce WINED3DUSAGE_MANAGED.

We would like to use two different textures for the CPU and GPU parts of managed textures, which means that wined3d_resource_access_is_managed() as such will no longer be useful.
parent a3c4410f
......@@ -308,6 +308,9 @@ static inline DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsig
static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
{
if (usage & WINED3DUSAGE_MANAGED)
return D3DPOOL_MANAGED;
switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU))
{
default:
......@@ -358,6 +361,8 @@ static inline unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage)
usage &= WINED3DUSAGE_MASK;
if (pool == D3DPOOL_SCRATCH)
usage |= WINED3DUSAGE_SCRATCH;
else if (pool == D3DPOOL_MANAGED)
usage |= WINED3DUSAGE_MANAGED;
return usage;
}
......
......@@ -318,6 +318,9 @@ static inline DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsig
static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
{
if (usage & WINED3DUSAGE_MANAGED)
return D3DPOOL_MANAGED;
switch (access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU))
{
default:
......@@ -378,6 +381,8 @@ static inline unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage)
usage &= WINED3DUSAGE_MASK;
if (pool == D3DPOOL_SCRATCH)
usage |= WINED3DUSAGE_SCRATCH;
else if (pool == D3DPOOL_MANAGED)
usage |= WINED3DUSAGE_MANAGED;
return usage;
}
......
......@@ -6441,6 +6441,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)
{
......
......@@ -1296,7 +1296,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
buffer, buffer->resource.size, buffer->resource.usage, buffer->resource.heap_memory);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING
|| wined3d_resource_access_is_managed(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
......
......@@ -5525,7 +5525,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);
......
......@@ -32,6 +32,7 @@ static void resource_check_usage(DWORD usage, unsigned int access)
| WINED3DUSAGE_STATICDECL
| WINED3DUSAGE_OVERLAY
| WINED3DUSAGE_SCRATCH
| WINED3DUSAGE_MANAGED
| WINED3DUSAGE_PRIVATE
| WINED3DUSAGE_LEGACY_CUBEMAP
| ~WINED3DUSAGE_MASK;
......@@ -97,8 +98,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
return WINED3DERR_INVALIDCALL;
}
/* Dynamic usage is incompatible with GPU writes. */
if (usage & WINED3DUSAGE_DYNAMIC)
/* Dynamic and managed usages are incompatible with GPU writes. */
if (usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_MANAGED))
{
WARN("Bind flags %s are incompatible with resource usage %s.\n",
wined3d_debug_bind_flags(bind_flags), debug_d3dusage(usage));
......@@ -268,7 +269,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;
......
......@@ -1736,7 +1736,7 @@ 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));
......@@ -3872,11 +3872,9 @@ 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;
}
......
......@@ -4950,6 +4950,7 @@ const char *debug_d3dusage(DWORD usage)
WINED3DUSAGE_TO_STR(WINED3DUSAGE_OWNDC);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_STATICDECL);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_OVERLAY);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_MANAGED);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_QUERY_FILTER);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_QUERY_GENMIPMAP);
WINED3DUSAGE_TO_STR(WINED3DUSAGE_QUERY_LEGACYBUMPMAP);
......
......@@ -953,6 +953,7 @@ enum wined3d_memory_segment_group
#define WINED3DUSAGE_OWNDC 0x02000000
#define WINED3DUSAGE_STATICDECL 0x04000000
#define WINED3DUSAGE_OVERLAY 0x08000000
#define WINED3DUSAGE_MANAGED 0x20000000
#define WINED3DUSAGE_QUERY_GENMIPMAP 0x00000400
#define WINED3DUSAGE_QUERY_LEGACYBUMPMAP 0x00008000
......
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