Commit 9275b06c authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Replace the pool in struct wined3d_resource_desc with resource access flags.

parent 916c13c6
......@@ -520,7 +520,7 @@ HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DE
wined3d_desc.multisample_type = desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = desc->SampleDesc.Quality;
wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage);
wined3d_desc.pool = WINED3D_POOL_DEFAULT;
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
wined3d_desc.width = desc->Width;
wined3d_desc.height = desc->Height;
wined3d_desc.depth = 1;
......@@ -977,7 +977,9 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = 0;
wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage);
wined3d_desc.pool = desc->Usage == D3D11_USAGE_STAGING ? WINED3D_POOL_MANAGED : WINED3D_POOL_DEFAULT;
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
if (desc->Usage == D3D11_USAGE_STAGING)
wined3d_desc.access |= WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
wined3d_desc.width = desc->Width;
wined3d_desc.height = desc->Height;
wined3d_desc.depth = desc->Depth;
......
......@@ -230,7 +230,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface,
desc->Format = D3DFMT_VERTEXDATA;
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->FVF = buffer->fvf;
......@@ -523,7 +523,7 @@ static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface,
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
return D3D_OK;
......
......@@ -296,11 +296,20 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i
}
}
static inline D3DPOOL d3dpool_from_wined3dpool(enum wined3d_pool pool, unsigned int usage)
static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool)
{
if (pool == WINED3D_POOL_SYSTEM_MEM && usage & WINED3DUSAGE_SCRATCH)
return D3DPOOL_SCRATCH;
return pool;
switch (pool)
{
case D3DPOOL_DEFAULT:
return WINED3D_RESOURCE_ACCESS_GPU;
case D3DPOOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
case D3DPOOL_SYSTEMMEM:
case D3DPOOL_SCRATCH:
return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
default:
return 0;
}
}
#endif /* __WINE_D3DX8_PRIVATE_H */
......@@ -686,7 +686,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc);
if (desc.pool != WINED3D_POOL_DEFAULT)
if (desc.access & WINED3D_RESOURCE_ACCESS_CPU)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
......@@ -1021,18 +1021,14 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
desc.multisample_type = multisample_type;
desc.multisample_quality = multisample_quality;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
wined3d_mutex_lock();
if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &desc,
......
......@@ -1108,18 +1108,14 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device,
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
flags |= WINED3D_TEXTURE_CREATE_MAPPABLE;
......@@ -1159,18 +1155,14 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = edge_length;
desc.height = edge_length;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
flags |= WINED3D_TEXTURE_CREATE_MAPPABLE;
......@@ -1209,18 +1201,14 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = depth;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (!levels)
levels = wined3d_log2i(max(max(width, height), depth)) + 1;
......
......@@ -231,7 +231,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface,
desc->Format = D3DFMT_VERTEXDATA;
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
desc->FVF = buffer->fvf;
......@@ -522,7 +522,7 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3D
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage);
desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
desc->Size = wined3d_desc.size;
return D3D_OK;
......
......@@ -299,11 +299,20 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i
}
}
static inline D3DPOOL d3dpool_from_wined3dpool(enum wined3d_pool pool, unsigned int usage)
static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool)
{
if (pool == WINED3D_POOL_SYSTEM_MEM && usage & WINED3DUSAGE_SCRATCH)
return D3DPOOL_SCRATCH;
return pool;
switch (pool)
{
case D3DPOOL_DEFAULT:
return WINED3D_RESOURCE_ACCESS_GPU;
case D3DPOOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
case D3DPOOL_SYSTEMMEM:
case D3DPOOL_SCRATCH:
return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
default:
return 0;
}
}
#endif /* __WINE_D3D9_PRIVATE_H */
......@@ -766,7 +766,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc);
if (desc.pool != WINED3D_POOL_DEFAULT)
if (desc.access & WINED3D_RESOURCE_ACCESS_CPU)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
......@@ -1277,18 +1277,14 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
desc.multisample_type = multisample_type;
desc.multisample_quality = multisample_quality;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (is_gdi_compat_wined3dformat(desc.format))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
......
......@@ -1220,18 +1220,14 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
flags |= WINED3D_TEXTURE_CREATE_MAPPABLE;
......@@ -1279,18 +1275,14 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = edge_length;
desc.height = edge_length;
desc.depth = 1;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
flags |= WINED3D_TEXTURE_CREATE_MAPPABLE;
......@@ -1337,18 +1329,14 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev
desc.multisample_quality = 0;
desc.usage = usage & WINED3DUSAGE_MASK;
desc.usage |= WINED3DUSAGE_TEXTURE;
desc.pool = pool;
if (pool == D3DPOOL_SCRATCH)
desc.usage |= WINED3DUSAGE_SCRATCH;
desc.access = wined3daccess_from_d3dpool(pool);
desc.width = width;
desc.height = height;
desc.depth = depth;
desc.size = 0;
if (pool == D3DPOOL_SCRATCH)
{
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.usage |= WINED3DUSAGE_SCRATCH;
}
if (!levels)
{
if (usage & D3DUSAGE_AUTOGENMIPMAP)
......
......@@ -6011,7 +6011,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = 0;
wined3d_desc.usage = 0;
wined3d_desc.pool = WINED3D_POOL_DEFAULT;
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
wined3d_desc.width = desc->dwWidth;
wined3d_desc.height = desc->dwHeight;
wined3d_desc.depth = 1;
......@@ -6100,7 +6100,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
{
wined3d_desc.pool = WINED3D_POOL_SYSTEM_MEM;
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
}
else
{
......@@ -6113,7 +6113,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
if (desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE))
{
wined3d_desc.pool = WINED3D_POOL_MANAGED;
wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU
| WINED3D_RESOURCE_ACCESS_MAP;
/* Managed textures have the system memory flag set. */
desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
}
......@@ -6128,9 +6129,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
if (desc->dwFlags & DDSD_LPSURFACE)
{
if (wined3d_desc.pool != WINED3D_POOL_SYSTEM_MEM)
if (wined3d_desc.access & WINED3D_RESOURCE_ACCESS_GPU)
{
WARN("User memory surfaces should be in the system memory pool.\n");
WARN("User memory surfaces should not be GPU accessible.\n");
HeapFree(GetProcessHeap(), 0, texture);
return DDERR_INVALIDCAPS;
}
......
......@@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
wined3d_sample_desc_from_dxgi(&surface_desc.multisample_type,
&surface_desc.multisample_quality, &desc->SampleDesc);
surface_desc.usage = wined3d_usage_from_dxgi_usage(usage);
surface_desc.pool = WINED3D_POOL_DEFAULT;
surface_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
surface_desc.width = desc->Width;
surface_desc.height = desc->Height;
surface_desc.depth = 1;
......
......@@ -1324,7 +1324,7 @@ static GLenum buffer_type_hint_from_bind_flags(const struct wined3d_gl_info *gl_
}
static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device,
UINT size, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, unsigned int bind_flags,
UINT size, DWORD usage, enum wined3d_format_id format_id, unsigned int access, unsigned int bind_flags,
const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
......@@ -1350,9 +1350,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
return E_INVALIDARG;
}
hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, format,
WINED3D_MULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size, parent, parent_ops, &buffer_resource_ops);
if (FAILED(hr))
if (FAILED(hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, format, WINED3D_MULTISAMPLE_NONE,
0, usage, access, size, 1, 1, size, parent, parent_ops, &buffer_resource_ops)))
{
WARN("Failed to initialize resource, hr %#x.\n", hr);
return hr;
......@@ -1366,7 +1365,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING
|| wined3d_resource_access_is_managed(buffer->resource.access))
|| wined3d_resource_access_is_managed(access))
{
/* SWvp and managed buffers always return the same pointer in buffer
* maps and retain data in DISCARD maps. Keep a system memory copy of
......@@ -1384,7 +1383,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
{
TRACE("Not creating a BO because GL_ARB_vertex_buffer is not supported.\n");
}
else if (!(buffer->resource.access & WINED3D_RESOURCE_ACCESS_GPU))
else if (!(access & WINED3D_RESOURCE_ACCESS_GPU))
{
TRACE("Not creating a BO because the buffer is not GPU accessible.\n");
}
......@@ -1430,7 +1429,8 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
FIXME("Ignoring access flags (pool).\n");
if (FAILED(hr = buffer_init(object, device, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
WINED3D_POOL_MANAGED, desc->bind_flags, data, parent, parent_ops)))
WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP,
desc->bind_flags, data, parent, parent_ops)))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......@@ -1445,6 +1445,25 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
return WINED3D_OK;
}
static DWORD resource_access_from_pool(enum wined3d_pool pool)
{
switch (pool)
{
case WINED3D_POOL_DEFAULT:
return WINED3D_RESOURCE_ACCESS_GPU;
case WINED3D_POOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
case WINED3D_POOL_SYSTEM_MEM:
return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
default:
FIXME("Unhandled pool %#x.\n", pool);
return 0;
}
}
HRESULT CDECL wined3d_buffer_create_vb(struct wined3d_device *device, UINT size, DWORD usage, enum wined3d_pool pool,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
{
......@@ -1470,9 +1489,8 @@ HRESULT CDECL wined3d_buffer_create_vb(struct wined3d_device *device, UINT size,
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = buffer_init(object, device, size, usage, WINED3DFMT_UNKNOWN,
pool, WINED3D_BIND_VERTEX_BUFFER, NULL, parent, parent_ops);
if (FAILED(hr))
if (FAILED(hr = buffer_init(object, device, size, usage, WINED3DFMT_UNKNOWN,
resource_access_from_pool(pool), WINED3D_BIND_VERTEX_BUFFER, NULL, parent, parent_ops)))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......@@ -1501,10 +1519,8 @@ HRESULT CDECL wined3d_buffer_create_ib(struct wined3d_device *device, UINT size,
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = buffer_init(object, device, size, usage | WINED3DUSAGE_STATICDECL,
WINED3DFMT_UNKNOWN, pool, WINED3D_BIND_INDEX_BUFFER, NULL,
parent, parent_ops);
if (FAILED(hr))
if (FAILED(hr = buffer_init(object, device, size, usage | WINED3DUSAGE_STATICDECL, WINED3DFMT_UNKNOWN,
resource_access_from_pool(pool), WINED3D_BIND_INDEX_BUFFER, NULL, parent, parent_ops)))
{
WARN("Failed to initialize buffer, hr %#x\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......
......@@ -570,7 +570,7 @@ static void device_load_logo(struct wined3d_device *device, const char *filename
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
desc.usage = WINED3DUSAGE_DYNAMIC;
desc.pool = WINED3D_POOL_DEFAULT;
desc.access = WINED3D_RESOURCE_ACCESS_GPU;
desc.width = bm.bmWidth;
desc.height = bm.bmHeight;
desc.depth = 1;
......@@ -4457,7 +4457,7 @@ static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
desc.usage = WINED3DUSAGE_DYNAMIC;
desc.pool = WINED3D_POOL_DEFAULT;
desc.access = WINED3D_RESOURCE_ACCESS_GPU;
desc.width = wined3d_texture_get_level_width(cursor_image, texture_level);
desc.height = wined3d_texture_get_level_height(cursor_image, texture_level);
desc.depth = 1;
......@@ -4805,7 +4805,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
texture_desc.multisample_type = swapchain->desc.multisample_type;
texture_desc.multisample_quality = swapchain->desc.multisample_quality;
texture_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
texture_desc.pool = WINED3D_POOL_DEFAULT;
texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
texture_desc.width = swapchain->desc.backbuffer_width;
texture_desc.height = swapchain->desc.backbuffer_height;
texture_desc.depth = 1;
......
......@@ -28,25 +28,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
static DWORD resource_access_from_pool(enum wined3d_pool pool)
{
switch (pool)
{
case WINED3D_POOL_DEFAULT:
return WINED3D_RESOURCE_ACCESS_GPU;
case WINED3D_POOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
case WINED3D_POOL_SYSTEM_MEM:
return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
default:
FIXME("Unhandled pool %#x.\n", pool);
return 0;
}
}
static void resource_check_usage(DWORD usage)
{
static const DWORD handled = WINED3DUSAGE_RENDERTARGET
......@@ -75,15 +56,14 @@ static void resource_check_usage(DWORD usage)
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
enum wined3d_resource_type type, const struct wined3d_format *format,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
void *parent, const struct wined3d_parent_ops *parent_ops,
enum wined3d_multisample_type multisample_type, unsigned int multisample_quality,
unsigned int usage, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops)
{
enum wined3d_gl_resource_type base_type = WINED3D_GL_RES_TYPE_COUNT;
enum wined3d_gl_resource_type gl_type = WINED3D_GL_RES_TYPE_COUNT;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
DWORD access = resource_access_from_pool(pool);
BOOL tex_2d_ok = FALSE;
unsigned int i;
......@@ -198,7 +178,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource->multisample_type = multisample_type;
resource->multisample_quality = multisample_quality;
resource->usage = usage;
resource->pool = pool;
if (usage & WINED3DUSAGE_DYNAMIC)
access |= WINED3D_RESOURCE_ACCESS_MAP;
resource->access = access;
......@@ -319,7 +298,7 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
desc->multisample_type = resource->multisample_type;
desc->multisample_quality = resource->multisample_quality;
desc->usage = resource->usage;
desc->pool = resource->pool;
desc->access = resource->access;
desc->width = resource->width;
desc->height = resource->height;
desc->depth = resource->depth;
......
......@@ -1321,7 +1321,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
desc.multisample_quality = 0;
desc.usage = WINED3DUSAGE_SCRATCH | WINED3DUSAGE_PRIVATE;
desc.pool = WINED3D_POOL_SYSTEM_MEM;
desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP;
desc.width = wined3d_texture_get_level_width(src_texture, texture_level);
desc.height = wined3d_texture_get_level_height(src_texture, texture_level);
desc.depth = 1;
......
......@@ -839,7 +839,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
texture_desc.multisample_type = swapchain->desc.multisample_type;
texture_desc.multisample_quality = swapchain->desc.multisample_quality;
texture_desc.usage = 0;
texture_desc.pool = WINED3D_POOL_DEFAULT;
texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
texture_desc.width = swapchain->desc.backbuffer_width;
texture_desc.height = swapchain->desc.backbuffer_height;
texture_desc.depth = 1;
......
......@@ -321,12 +321,12 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
HRESULT hr;
TRACE("texture %p, texture_ops %p, layer_count %u, level_count %u, resource_type %s, format %s, "
"multisample_type %#x, multisample_quality %#x, usage %s, pool %s, width %u, height %u, depth %u, "
"multisample_type %#x, multisample_quality %#x, usage %s, access %s, width %u, height %u, depth %u, "
"flags %#x, device %p, parent %p, parent_ops %p, resource_ops %p.\n",
texture, texture_ops, layer_count, level_count, debug_d3dresourcetype(desc->resource_type),
debug_d3dformat(desc->format), desc->multisample_type, desc->multisample_quality,
debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth,
flags, device, parent, parent_ops, resource_ops);
debug_d3dusage(desc->usage), wined3d_debug_resource_access(desc->access),
desc->width, desc->height, desc->depth, flags, device, parent, parent_ops, resource_ops);
if (!desc->width || !desc->height || !desc->depth)
return WINED3DERR_INVALIDCALL;
......@@ -352,7 +352,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
return WINED3DERR_INVALIDCALL;
if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, format,
desc->multisample_type, desc->multisample_quality, desc->usage, desc->pool,
desc->multisample_type, desc->multisample_quality, desc->usage, desc->access,
desc->width, desc->height, desc->depth, offset, parent, parent_ops, resource_ops)))
{
static unsigned int once;
......@@ -2065,13 +2065,13 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
return WINED3DERR_INVALIDCALL;
}
if (desc->usage & WINED3DUSAGE_DYNAMIC && desc->pool == WINED3D_POOL_MANAGED)
if (desc->usage & WINED3DUSAGE_DYNAMIC && wined3d_resource_access_is_managed(desc->access))
FIXME("Trying to create a managed texture with dynamic usage.\n");
if (!(desc->usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))
&& (flags & WINED3D_TEXTURE_CREATE_MAPPABLE))
WARN("Creating a mappable texture in the default pool that doesn't specify dynamic usage.\n");
if (desc->usage & WINED3DUSAGE_RENDERTARGET && desc->pool != WINED3D_POOL_DEFAULT)
FIXME("Trying to create a render target that isn't in the default pool.\n");
WARN("Creating a mappable texture that doesn't specify dynamic usage.\n");
if (desc->usage & WINED3DUSAGE_RENDERTARGET && desc->access & WINED3D_RESOURCE_ACCESS_CPU)
FIXME("Trying to create a CPU accessible render target.\n");
pow2_width = desc->width;
pow2_height = desc->height;
......@@ -2129,7 +2129,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
* Blts. Some apps (e.g. Swat 3) create textures with a height of
* 16 and a width > 3000 and blt 16x16 letter areas from them to
* the render target. */
if (desc->pool == WINED3D_POOL_DEFAULT || desc->pool == WINED3D_POOL_MANAGED)
if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
{
WARN("Dimensions (%ux%u) exceed the maximum texture size.\n", pow2_width, pow2_height);
return WINED3DERR_NOTAVAILABLE;
......@@ -2597,10 +2597,11 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
}
}
if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->pool == WINED3D_POOL_MANAGED
if (desc->usage & WINED3DUSAGE_DYNAMIC && (wined3d_resource_access_is_managed(desc->access)
|| desc->usage & WINED3DUSAGE_SCRATCH))
{
WARN("Attempted to create a DYNAMIC texture in pool %s.\n", debug_d3dpool(desc->pool));
WARN("Attempted to create a DYNAMIC texture with access %s.\n",
wined3d_debug_resource_access(desc->access));
return WINED3DERR_INVALIDCALL;
}
......
......@@ -4662,21 +4662,6 @@ const char *debug_d3dstate(DWORD state)
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
}
const char *debug_d3dpool(enum wined3d_pool pool)
{
switch (pool)
{
#define POOL_TO_STR(p) case p: return #p
POOL_TO_STR(WINED3D_POOL_DEFAULT);
POOL_TO_STR(WINED3D_POOL_MANAGED);
POOL_TO_STR(WINED3D_POOL_SYSTEM_MEM);
#undef POOL_TO_STR
default:
FIXME("Unrecognized pool %#x.\n", pool);
return "unrecognized";
}
}
const char *debug_fboattachment(GLenum attachment)
{
switch(attachment)
......
......@@ -2993,7 +2993,6 @@ struct wined3d_resource
enum wined3d_multisample_type multisample_type;
UINT multisample_quality;
DWORD usage;
enum wined3d_pool pool;
unsigned int access;
WORD draw_binding;
WORD map_binding;
......@@ -3034,9 +3033,9 @@ static inline void wined3d_resource_release(struct wined3d_resource *resource)
void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
enum wined3d_resource_type type, const struct wined3d_format *format,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
void *parent, const struct wined3d_parent_ops *parent_ops,
enum wined3d_multisample_type multisample_type, unsigned int multisample_quality,
unsigned int usage, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
......@@ -3809,7 +3808,6 @@ const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_t
const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
const char *debug_d3dpool(enum wined3d_pool pool) DECLSPEC_HIDDEN;
const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
......
......@@ -1735,13 +1735,13 @@ struct wined3d_resource_desc
enum wined3d_resource_type resource_type;
enum wined3d_format_id format;
enum wined3d_multisample_type multisample_type;
UINT multisample_quality;
DWORD usage;
enum wined3d_pool pool;
UINT width;
UINT height;
UINT depth;
UINT size;
unsigned int multisample_quality;
unsigned int usage;
unsigned int access;
unsigned int width;
unsigned int height;
unsigned int depth;
unsigned int size;
};
struct wined3d_sub_resource_desc
......
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