From 2abf1dd3238de2be3405472d40169603a3776b15 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 29 Jan 2018 21:10:23 +0330 Subject: [PATCH] wined3d: Get rid of WINED3D_POOL_SCRATCH. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/buffer.c | 38 +++++++++++++++++++++++++++++--------- dlls/d3d8/d3d8_private.h | 12 ++++++++++++ dlls/d3d8/device.c | 6 ++++++ dlls/d3d8/surface.c | 4 ++-- dlls/d3d8/texture.c | 30 ++++++++++++++++++++++++------ dlls/d3d8/volume.c | 4 ++-- dlls/d3d9/buffer.c | 40 ++++++++++++++++++++++++++++++---------- dlls/d3d9/d3d9_private.h | 12 ++++++++++++ dlls/d3d9/device.c | 6 ++++++ dlls/d3d9/surface.c | 4 ++-- dlls/d3d9/texture.c | 30 ++++++++++++++++++++++++------ dlls/d3d9/volume.c | 4 ++-- dlls/wined3d/buffer.c | 4 ++-- dlls/wined3d/device.c | 4 ++-- dlls/wined3d/resource.c | 10 ++++++++-- dlls/wined3d/surface.c | 4 ++-- dlls/wined3d/texture.c | 6 +++--- dlls/wined3d/utils.c | 1 - include/wine/wined3d.h | 2 +- 19 files changed, 169 insertions(+), 52 deletions(-) diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 8116c1b87b8..d0eaf8308f4 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -227,12 +227,12 @@ static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_mutex_unlock(); + desc->Format = D3DFMT_VERTEXDATA; desc->Type = D3DRTYPE_VERTEXBUFFER; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; - desc->Format = D3DFMT_VERTEXDATA; return D3D_OK; } @@ -273,15 +273,25 @@ static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops = HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, DWORD fvf, D3DPOOL pool) { + enum wined3d_pool wined3d_pool; + DWORD wined3d_usage; HRESULT hr; + wined3d_pool = pool; + wined3d_usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_SCRATCH) + { + wined3d_pool = WINED3D_POOL_SYSTEM_MEM; + wined3d_usage |= WINED3DUSAGE_SCRATCH; + } + buffer->IDirect3DVertexBuffer8_iface.lpVtbl = &Direct3DVertexBuffer8_Vtbl; d3d8_resource_init(&buffer->resource); buffer->fvf = fvf; wined3d_mutex_lock(); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create_vb(device->wined3d_device, size, wined3d_usage, wined3d_pool, + buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { @@ -512,8 +522,8 @@ static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, desc->Format = d3dformat_from_wined3dformat(buffer->format); desc->Type = D3DRTYPE_INDEXBUFFER; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; return D3D_OK; @@ -555,15 +565,25 @@ static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops = HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) { + enum wined3d_pool wined3d_pool; + DWORD wined3d_usage; HRESULT hr; + wined3d_pool = pool; + wined3d_usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_SCRATCH) + { + wined3d_pool = WINED3D_POOL_SYSTEM_MEM; + wined3d_usage |= WINED3DUSAGE_SCRATCH; + } + buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl; d3d8_resource_init(&buffer->resource); buffer->format = wined3dformat_from_d3dformat(format); wined3d_mutex_lock(); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create_ib(device->wined3d_device, size, wined3d_usage, wined3d_pool, + buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index e7dea353715..bb739a35c5a 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -275,4 +275,16 @@ enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_H void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader) DECLSPEC_HIDDEN; size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN; +static inline DWORD d3dusage_from_wined3dusage(unsigned int usage) +{ + return usage & WINED3DUSAGE_MASK; +} + +static inline D3DPOOL d3dpool_from_wined3dpool(enum wined3d_pool pool, unsigned int usage) +{ + if (pool == WINED3D_POOL_SYSTEM_MEM && usage & WINED3DUSAGE_SCRATCH) + return D3DPOOL_SCRATCH; + return pool; +} + #endif /* __WINE_D3DX8_PRIVATE_H */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e7577d70786..60e6e3131d5 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1027,6 +1027,12 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width 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, diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 9b6b425fc9e..f71f4c3be75 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -191,8 +191,8 @@ static HRESULT WINAPI d3d8_surface_GetDesc(IDirect3DSurface8 *iface, D3DSURFACE_ desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index cb877dc61d5..7be4046ad82 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -253,8 +253,8 @@ static HRESULT WINAPI d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8 *iface, UIN { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; @@ -600,8 +600,8 @@ static HRESULT WINAPI d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; desc->Width = wined3d_desc.width; @@ -945,8 +945,8 @@ static HRESULT WINAPI d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; @@ -1114,6 +1114,12 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, 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,6 +1165,12 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic 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; @@ -1203,6 +1215,12 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev 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; diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index fb3afb3edfa..ad78ea720c6 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -125,8 +125,8 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DES desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index dc52d93f23c..422dda0fab9 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -229,10 +229,10 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, wined3d_mutex_unlock(); desc->Format = D3DFMT_VERTEXDATA; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; - desc->Size = wined3d_desc.size; desc->Type = D3DRTYPE_VERTEXBUFFER; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); + desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; return D3D_OK; @@ -274,15 +274,25 @@ static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops = HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *device, UINT size, UINT usage, DWORD fvf, D3DPOOL pool) { + enum wined3d_pool wined3d_pool; + DWORD wined3d_usage; HRESULT hr; + wined3d_pool = pool; + wined3d_usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_SCRATCH) + { + wined3d_pool = WINED3D_POOL_SYSTEM_MEM; + wined3d_usage |= WINED3DUSAGE_SCRATCH; + } + buffer->IDirect3DVertexBuffer9_iface.lpVtbl = &d3d9_vertexbuffer_vtbl; buffer->fvf = fvf; d3d9_resource_init(&buffer->resource); wined3d_mutex_lock(); - hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create_vb(device->wined3d_device, size, wined3d_usage, wined3d_pool, + buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { @@ -510,10 +520,10 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3D wined3d_mutex_unlock(); desc->Format = d3dformat_from_wined3dformat(buffer->format); - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; - desc->Size = wined3d_desc.size; desc->Type = D3DRTYPE_INDEXBUFFER; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); + desc->Size = wined3d_desc.size; return D3D_OK; } @@ -554,15 +564,25 @@ static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops = HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device, UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) { + enum wined3d_pool wined3d_pool; + DWORD wined3d_usage; HRESULT hr; + wined3d_pool = pool; + wined3d_usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_SCRATCH) + { + wined3d_pool = WINED3D_POOL_SYSTEM_MEM; + wined3d_usage |= WINED3DUSAGE_SCRATCH; + } + buffer->IDirect3DIndexBuffer9_iface.lpVtbl = &d3d9_indexbuffer_vtbl; buffer->format = wined3dformat_from_d3dformat(format); d3d9_resource_init(&buffer->resource); wined3d_mutex_lock(); - hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK, - (enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); + hr = wined3d_buffer_create_ib(device->wined3d_device, size, wined3d_usage, wined3d_pool, + buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer); wined3d_mutex_unlock(); if (FAILED(hr)) { diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 7cbb5405595..aade88024c7 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -278,4 +278,16 @@ static inline struct d3d9_device *impl_from_IDirect3DDevice9Ex(IDirect3DDevice9E return CONTAINING_RECORD(iface, struct d3d9_device, IDirect3DDevice9Ex_iface); } +static inline DWORD d3dusage_from_wined3dusage(unsigned int usage) +{ + return usage & WINED3DUSAGE_MASK; +} + +static inline D3DPOOL d3dpool_from_wined3dpool(enum wined3d_pool pool, unsigned int usage) +{ + if (pool == WINED3D_POOL_SYSTEM_MEM && usage & WINED3DUSAGE_SCRATCH) + return D3DPOOL_SCRATCH; + return pool; +} + #endif /* __WINE_D3D9_PRIVATE_H */ diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 0a76227f6dd..c5348a4c404 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1283,6 +1283,12 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width 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; diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 3c01efc5891..a5b1b081e37 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -223,8 +223,8 @@ static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_ desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 96c8bc37bd0..bdbaa25edca 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -289,8 +289,8 @@ static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UIN { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; @@ -676,8 +676,8 @@ static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; desc->Width = wined3d_desc.width; @@ -1059,8 +1059,8 @@ static HRESULT WINAPI d3d9_texture_3d_GetLevelDesc(IDirect3DVolumeTexture9 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; @@ -1226,6 +1226,12 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, 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,6 +1285,12 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic 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; @@ -1331,6 +1343,12 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev 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) diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 0346f98ebaf..795da2fd4e5 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -126,8 +126,8 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DES desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; - desc->Pool = wined3d_desc.pool; + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Pool = d3dpool_from_wined3dpool(wined3d_desc.pool, wined3d_desc.usage); desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index e953e9ad215..49b189eb0c1 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1453,11 +1453,11 @@ HRESULT CDECL wined3d_buffer_create_vb(struct wined3d_device *device, UINT size, TRACE("device %p, size %u, usage %#x, pool %#x, parent %p, parent_ops %p, buffer %p.\n", device, size, usage, pool, parent, parent_ops, buffer); - if (pool == WINED3D_POOL_SCRATCH) + if (usage & WINED3DUSAGE_SCRATCH) { /* The d3d9 tests shows that this is not allowed. It doesn't make much * sense anyway, SCRATCH buffers wouldn't be usable anywhere. */ - WARN("Vertex buffer in WINED3D_POOL_SCRATCH requested, returning WINED3DERR_INVALIDCALL.\n"); + WARN("Vertex buffer with WINED3DUSAGE_SCRATCH requested, returning WINED3DERR_INVALIDCALL.\n"); *buffer = NULL; return WINED3DERR_INVALIDCALL; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5bd8804c17d..67c185563f5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3427,7 +3427,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device, return WINED3D_OK; } - if (texture && texture->resource.pool == WINED3D_POOL_SCRATCH) + if (texture && texture->resource.usage & WINED3DUSAGE_SCRATCH) { WARN("Rejecting attempt to set scratch texture.\n"); return WINED3DERR_INVALIDCALL; @@ -3768,7 +3768,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device, return WINED3DERR_INVALIDCALL; } - if (src_texture->resource.pool != WINED3D_POOL_SYSTEM_MEM) + if (src_texture->resource.pool != WINED3D_POOL_SYSTEM_MEM || src_texture->resource.usage & WINED3DUSAGE_SCRATCH) { WARN("Source texture not in WINED3D_POOL_SYSTEM_MEM, returning WINED3DERR_INVALIDCALL.\n"); return WINED3DERR_INVALIDCALL; diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 7817f85c98f..cf01f933727 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -38,7 +38,6 @@ static DWORD resource_access_from_pool(enum wined3d_pool pool) case WINED3D_POOL_MANAGED: return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP; - case WINED3D_POOL_SCRATCH: case WINED3D_POOL_SYSTEM_MEM: return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP; @@ -57,6 +56,7 @@ static void resource_check_usage(DWORD usage) | WINED3DUSAGE_AUTOGENMIPMAP | WINED3DUSAGE_STATICDECL | WINED3DUSAGE_OVERLAY + | WINED3DUSAGE_SCRATCH | WINED3DUSAGE_PRIVATE | WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; @@ -104,6 +104,12 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource_check_usage(usage); + if (usage & WINED3DUSAGE_SCRATCH && pool != WINED3D_POOL_SYSTEM_MEM) + { + ERR("WINED3DUSAGE_SCRATCH used with pool %s.\n", debug_d3dpool(pool)); + return WINED3DERR_INVALIDCALL; + } + for (i = 0; i < ARRAY_SIZE(resource_types); ++i) { if (resource_types[i].type != type @@ -157,7 +163,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * * Use 2D textures, the texture code will pad to a power of 2 size. */ gl_type = WINED3D_GL_RES_TYPE_TEX_2D; } - else if (pool == WINED3D_POOL_SCRATCH) + else if (usage & WINED3DUSAGE_SCRATCH) { /* Needed for proper format information. */ gl_type = base_type; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 2a90c12353a..4e5940a5d55 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1317,8 +1317,8 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr desc.format = dst_format->id; desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = WINED3DUSAGE_PRIVATE; - desc.pool = WINED3D_POOL_SCRATCH; + desc.usage = WINED3DUSAGE_SCRATCH | WINED3DUSAGE_PRIVATE; + desc.pool = WINED3D_POOL_SYSTEM_MEM; 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; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 36d46ad917a..101f9ad660f 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2078,7 +2078,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 /* level_count == 0 returns an error as well. */ if (level_count != 1 || layer_count != 1) { - if (desc->pool != WINED3D_POOL_SCRATCH) + if (!(desc->usage & WINED3DUSAGE_SCRATCH)) { WARN("Attempted to create a mipmapped/cube/array NPOT texture without unconditional NPOT support.\n"); return WINED3DERR_INVALIDCALL; @@ -2595,7 +2595,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct } if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->pool == WINED3D_POOL_MANAGED - || desc->pool == WINED3D_POOL_SCRATCH)) + || desc->usage & WINED3DUSAGE_SCRATCH)) { WARN("Attempted to create a DYNAMIC texture in pool %s.\n", debug_d3dpool(desc->pool)); return WINED3DERR_INVALIDCALL; @@ -2616,7 +2616,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct if (pow2_w != desc->width || pow2_h != desc->height || pow2_d != desc->depth) { - if (desc->pool == WINED3D_POOL_SCRATCH) + if (desc->usage & WINED3DUSAGE_SCRATCH) { WARN("Creating a scratch NPOT volume texture despite lack of HW support.\n"); } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 8a96a20c117..bd8aa067823 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4654,7 +4654,6 @@ const char *debug_d3dpool(enum wined3d_pool pool) POOL_TO_STR(WINED3D_POOL_DEFAULT); POOL_TO_STR(WINED3D_POOL_MANAGED); POOL_TO_STR(WINED3D_POOL_SYSTEM_MEM); - POOL_TO_STR(WINED3D_POOL_SCRATCH); #undef POOL_TO_STR default: FIXME("Unrecognized pool %#x.\n", pool); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 8c274926e0a..02c168ed237 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -681,7 +681,6 @@ enum wined3d_pool WINED3D_POOL_DEFAULT = 0, WINED3D_POOL_MANAGED = 1, WINED3D_POOL_SYSTEM_MEM = 2, - WINED3D_POOL_SCRATCH = 3, }; enum wined3d_query_type @@ -896,6 +895,7 @@ enum wined3d_shader_byte_code_format #define WINED3DUSAGE_TEXTAPI 0x10000000 #define WINED3DUSAGE_MASK 0x10007fff +#define WINED3DUSAGE_SCRATCH 0x00200000 #define WINED3DUSAGE_PRIVATE 0x00400000 #define WINED3DUSAGE_LEGACY_CUBEMAP 0x00800000 #define WINED3DUSAGE_TEXTURE 0x01000000