Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3d11/buffer.c | 2 +- dlls/d3d11/d3d11_private.h | 11 ++++++++++- dlls/d3d11/device.c | 2 +- dlls/d3d11/texture.c | 3 +++ dlls/d3d11/utils.c | 15 --------------- dlls/d3d8/buffer.c | 4 ++-- dlls/d3d8/d3d8_private.h | 21 +++++++++++++++++++-- dlls/d3d8/device.c | 1 + dlls/d3d8/surface.c | 2 +- dlls/d3d8/texture.c | 9 ++++++--- dlls/d3d8/volume.c | 2 +- dlls/d3d9/buffer.c | 4 ++-- dlls/d3d9/d3d9_private.h | 21 +++++++++++++++++++-- dlls/d3d9/device.c | 1 + dlls/d3d9/surface.c | 2 +- dlls/d3d9/texture.c | 3 +++ dlls/d3d9/volume.c | 2 +- dlls/ddraw/surface.c | 10 ++++++++++ dlls/dxgi/device.c | 5 +++++ dlls/wined3d/arb_program_shader.c | 1 + dlls/wined3d/device.c | 3 +++ dlls/wined3d/glsl_shader.c | 1 + dlls/wined3d/resource.c | 1 + dlls/wined3d/surface.c | 2 ++ dlls/wined3d/swapchain.c | 7 +++++++ dlls/wined3d/texture.c | 3 ++- include/wine/wined3d.h | 2 ++ 27 files changed, 106 insertions(+), 34 deletions(-)
diff --git a/dlls/d3d11/buffer.c b/dlls/d3d11/buffer.c index 2221a8fdd5a..fb5b8177516 100644 --- a/dlls/d3d11/buffer.c +++ b/dlls/d3d11/buffer.c @@ -451,7 +451,7 @@ static HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *dev
wined3d_desc.byte_width = buffer->desc.ByteWidth; wined3d_desc.usage = wined3d_usage_from_d3d11(0, buffer->desc.Usage); - wined3d_desc.bind_flags = buffer->desc.BindFlags; + wined3d_desc.bind_flags = wined3d_bind_flags_from_d3d11(buffer->desc.BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(buffer->desc.Usage, buffer->desc.CPUAccessFlags); wined3d_desc.misc_flags = buffer->desc.MiscFlags; wined3d_desc.structure_byte_stride = buffer->desc.StructureByteStride; diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 787fe87b5a9..e3261a57c94 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -65,7 +65,6 @@ void d3d11_primitive_topology_from_wined3d_primitive_type(enum wined3d_primitive void wined3d_primitive_type_from_d3d11_primitive_topology(D3D11_PRIMITIVE_TOPOLOGY topology, enum wined3d_primitive_type *type, unsigned int *patch_vertex_count) DECLSPEC_HIDDEN; unsigned int wined3d_getdata_flags_from_d3d11_async_getdata_flags(unsigned int d3d11_flags) DECLSPEC_HIDDEN; -UINT d3d11_bind_flags_from_wined3d_usage(DWORD wined3d_usage) DECLSPEC_HIDDEN; DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) DECLSPEC_HIDDEN; struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *resource) DECLSPEC_HIDDEN; struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN; @@ -93,6 +92,16 @@ HRESULT d3d_set_private_data(struct wined3d_private_store *store, HRESULT d3d_set_private_data_interface(struct wined3d_private_store *store, REFGUID guid, const IUnknown *object) DECLSPEC_HIDDEN;
+static inline unsigned int wined3d_bind_flags_from_d3d11(UINT bind_flags) +{ + return bind_flags; +} + +static inline UINT d3d11_bind_flags_from_wined3d(unsigned int bind_flags) +{ + return bind_flags; +} + static inline void read_dword(const char **ptr, DWORD *d) { memcpy(d, *ptr, sizeof(*d)); diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index e4c2c80e00b..8c40cf8b475 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -6070,7 +6070,7 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1; desc.SampleDesc.Quality = wined3d_desc->multisample_quality; desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = d3d11_bind_flags_from_wined3d_usage(wined3d_desc->usage); + desc.BindFlags = d3d11_bind_flags_from_wined3d(wined3d_desc->bind_flags); desc.CPUAccessFlags = 0; desc.MiscFlags = 0;
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 36d97415a25..9df8bae00c8 100644 --- a/dlls/d3d11/texture.c +++ b/dlls/d3d11/texture.c @@ -457,6 +457,7 @@ HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DE 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.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); wined3d_desc.width = desc->Width; @@ -1010,6 +1011,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.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); wined3d_desc.width = desc->Width; @@ -1468,6 +1470,7 @@ 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.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); wined3d_desc.width = desc->Width; diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c index 8fdb00518ff..c7c682ba6c8 100644 --- a/dlls/d3d11/utils.c +++ b/dlls/d3d11/utils.c @@ -441,21 +441,6 @@ unsigned int wined3d_getdata_flags_from_d3d11_async_getdata_flags(unsigned int d return WINED3DGETDATA_FLUSH; }
-UINT d3d11_bind_flags_from_wined3d_usage(DWORD wined3d_usage) -{ - UINT bind_flags = 0; - - if (wined3d_usage & WINED3DUSAGE_TEXTURE) - bind_flags |= D3D11_BIND_SHADER_RESOURCE; - if (wined3d_usage & WINED3DUSAGE_RENDERTARGET) - bind_flags |= D3D11_BIND_RENDER_TARGET; - - wined3d_usage &= ~(WINED3DUSAGE_TEXTURE | WINED3DUSAGE_RENDERTARGET); - if (wined3d_usage) - FIXME("Unhandled wined3d usage %#x.\n", wined3d_usage); - return bind_flags; -} - DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) { static const DWORD handled = D3D11_BIND_SHADER_RESOURCE diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index fb6b7bc1e92..9534c33932d 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -229,7 +229,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->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; @@ -527,7 +527,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->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size;
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 40a0f0a38d4..7f6049df574 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -278,9 +278,14 @@ unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDE 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) +static inline DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsigned int bind_flags) { - return usage & WINED3DUSAGE_MASK; + DWORD usage = wined3d_usage & WINED3DUSAGE_MASK; + if (bind_flags & WINED3D_BIND_RENDER_TARGET) + usage |= D3DUSAGE_RENDERTARGET; + if (bind_flags & WINED3D_BIND_DEPTH_STENCIL) + usage |= D3DUSAGE_DEPTHSTENCIL; + return usage; }
static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage) @@ -318,4 +323,16 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int } }
+static inline unsigned int wined3d_bind_flags_from_d3d8_usage(DWORD usage) +{ + unsigned int bind_flags = 0; + + if (usage & D3DUSAGE_RENDERTARGET) + bind_flags |= WINED3D_BIND_RENDER_TARGET; + if (usage & D3DUSAGE_DEPTHSTENCIL) + bind_flags |= WINED3D_BIND_DEPTH_STENCIL; + + return bind_flags; +} + #endif /* __WINE_D3DX8_PRIVATE_H */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 12d02538351..a09a72b4051 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1165,6 +1165,7 @@ 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; + 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; desc.width = width; diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index fff47f5ca15..eab9cb369af 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -191,7 +191,7 @@ static HRESULT WINAPI d3d8_surface_GetDesc(IDirect3DSurface8 *iface, D3DSURFACE_
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index f7ccdc7e34b..c952579ce61 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -253,7 +253,7 @@ static HRESULT WINAPI d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8 *iface, UIN { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; @@ -600,7 +600,7 @@ static HRESULT WINAPI d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->MultiSampleType = wined3d_desc.multisample_type; @@ -945,7 +945,7 @@ static HRESULT WINAPI d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8 *ifac { desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; @@ -1110,6 +1110,7 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + 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; desc.width = width; @@ -1158,6 +1159,7 @@ 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; + 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; desc.width = edge_length; @@ -1205,6 +1207,7 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + desc.bind_flags = wined3d_bind_flags_from_d3d8_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index 89aa84fdb50..29eab6a6900 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -125,7 +125,7 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DES
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->Width = wined3d_desc.width; diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 36a6ae3f902..ea98ef4242f 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -230,7 +230,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->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size; desc->FVF = buffer->fvf; @@ -526,7 +526,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->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Size = wined3d_desc.size;
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index fc6e4af6501..d6155eba60b 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -291,9 +291,14 @@ 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) +static inline DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsigned int bind_flags) { - return usage & WINED3DUSAGE_MASK; + DWORD usage = wined3d_usage & WINED3DUSAGE_MASK; + if (bind_flags & WINED3D_BIND_RENDER_TARGET) + usage |= D3DUSAGE_RENDERTARGET; + if (bind_flags & WINED3D_BIND_DEPTH_STENCIL) + usage |= D3DUSAGE_DEPTHSTENCIL; + return usage; }
static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage) @@ -331,6 +336,18 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int } }
+static inline unsigned int wined3d_bind_flags_from_d3d9_usage(DWORD usage) +{ + unsigned int bind_flags = 0; + + if (usage & D3DUSAGE_RENDERTARGET) + bind_flags |= WINED3D_BIND_RENDER_TARGET; + if (usage & D3DUSAGE_DEPTHSTENCIL) + bind_flags |= WINED3D_BIND_DEPTH_STENCIL; + + return bind_flags; +} + static inline DWORD wined3dusage_from_d3dusage(unsigned int usage) { return usage & WINED3DUSAGE_MASK; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index a3f410a7b97..fd92b563356 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1392,6 +1392,7 @@ 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; + 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; desc.width = width; diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 0605e7142a3..50c035d93c7 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -223,7 +223,7 @@ static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_SURFACE; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->MultiSampleType = wined3d_desc.multisample_type; desc->MultiSampleQuality = wined3d_desc.multisample_quality; diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 0858be99220..a87bef45025 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1314,6 +1314,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + 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; desc.width = width; @@ -1399,6 +1400,7 @@ 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; + 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; desc.width = edge_length; @@ -1470,6 +1472,7 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + desc.bind_flags = wined3d_bind_flags_from_d3d9_usage(usage) | WINED3D_BIND_SHADER_RESOURCE; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index f4c43bc589a..cb0485cd7f4 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -126,7 +126,7 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DES
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = D3DRTYPE_VOLUME; - desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage); + desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage, wined3d_desc.bind_flags); desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage); desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index d201d9d4146..0afc9ab4beb 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6065,6 +6065,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.bind_flags = 0; wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; wined3d_desc.width = desc->dwWidth; wined3d_desc.height = desc->dwHeight; @@ -6163,11 +6164,20 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(ddraw->flags & DDRAW_NO3D)) { if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE) + { wined3d_desc.usage |= WINED3DUSAGE_TEXTURE; + wined3d_desc.bind_flags |= WINED3D_BIND_SHADER_RESOURCE; + } if (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) + { wined3d_desc.usage |= WINED3DUSAGE_DEPTHSTENCIL; + wined3d_desc.bind_flags |= WINED3D_BIND_DEPTH_STENCIL; + } else if (desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) + { wined3d_desc.usage |= WINED3DUSAGE_RENDERTARGET; + wined3d_desc.bind_flags |= WINED3D_BIND_RENDER_TARGET; + } }
if (desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 51773e9c005..2c459ca2469 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -187,6 +187,11 @@ 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.bind_flags = 0; + if (surface_desc.usage & WINED3DUSAGE_RENDERTARGET) + surface_desc.bind_flags |= WINED3D_BIND_RENDER_TARGET; + if (surface_desc.usage & WINED3DUSAGE_TEXTURE) + surface_desc.bind_flags |= WINED3D_BIND_SHADER_RESOURCE; surface_desc.access = WINED3D_RESOURCE_ACCESS_GPU; surface_desc.width = desc->Width; surface_desc.height = desc->Height; diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 62118fe0c6d..4dafb3442e6 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7820,6 +7820,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; desc.usage = WINED3DUSAGE_PRIVATE; + desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); desc.height = wined3d_texture_get_level_height(src_texture, src_level); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8b202fce0cf..83b8bea9696 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -576,6 +576,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.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = bm.bmWidth; desc.height = bm.bmHeight; @@ -4548,6 +4549,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.bind_flags = 0; 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); @@ -4897,6 +4899,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.bind_flags = WINED3D_BIND_DEPTH_STENCIL; texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU; texture_desc.width = swapchain->desc.backbuffer_width; texture_desc.height = swapchain->desc.backbuffer_height; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 37d2aab20bc..545e1bff9f5 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -13213,6 +13213,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; desc.usage = WINED3DUSAGE_PRIVATE; + desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); desc.height = wined3d_texture_get_level_height(src_texture, src_level); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index a1b2cbd2a0f..320d54c731d 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -289,6 +289,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->bind_flags = resource->bind_flags; desc->access = resource->access; desc->width = resource->width; desc->height = resource->height; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 21375dd026f..122c643150f 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -634,6 +634,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.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = wined3d_texture_get_level_width(src_texture, texture_level); desc.height = wined3d_texture_get_level_height(src_texture, texture_level); @@ -2146,6 +2147,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; desc.usage = WINED3DUSAGE_PRIVATE; + desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); desc.height = wined3d_texture_get_level_height(src_texture, src_level); diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 8de88714d10..768d27fd674 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -836,6 +836,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 texture_desc.usage = 0; if (device->wined3d->flags & WINED3D_NO3D) texture_desc.usage |= WINED3DUSAGE_OWNDC; + texture_desc.bind_flags = 0; texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU; texture_desc.width = swapchain->desc.backbuffer_width; texture_desc.height = swapchain->desc.backbuffer_height; @@ -919,6 +920,11 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 texture_desc.usage = swapchain->desc.backbuffer_usage; if (device->wined3d->flags & WINED3D_NO3D) texture_desc.usage |= WINED3DUSAGE_OWNDC; + texture_desc.bind_flags = 0; + if (texture_desc.usage & WINED3DUSAGE_RENDERTARGET) + texture_desc.bind_flags |= WINED3D_BIND_RENDER_TARGET; + if (texture_desc.usage & WINED3DUSAGE_TEXTURE) + texture_desc.bind_flags |= WINED3D_BIND_SHADER_RESOURCE; for (i = 0; i < swapchain->desc.backbuffer_count; ++i) { TRACE("Creating back buffer %u.\n", i); @@ -944,6 +950,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
texture_desc.format = swapchain->desc.auto_depth_stencil_format; texture_desc.usage = WINED3DUSAGE_DEPTHSTENCIL; + texture_desc.bind_flags = WINED3D_BIND_DEPTH_STENCIL;
if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent, device->device_parent, &texture_desc, texture_flags, &ds))) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 87998d5552e..a98c0af231b 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2996,7 +2996,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, 0, desc->access, + desc->multisample_type, desc->multisample_quality, desc->usage, desc->bind_flags, desc->access, desc->width, desc->height, desc->depth, offset, parent, parent_ops, &texture_resource_ops))) { static unsigned int once; @@ -3512,6 +3512,7 @@ HRESULT CDECL wined3d_texture_get_sub_resource_desc(const struct wined3d_texture desc->multisample_type = resource->multisample_type; desc->multisample_quality = resource->multisample_quality; desc->usage = resource->usage; + desc->bind_flags = resource->bind_flags; desc->access = resource->access;
level_idx = sub_resource_idx % texture->level_count; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 1b3a46e6567..7dc47e63d5a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1767,6 +1767,7 @@ struct wined3d_resource_desc enum wined3d_multisample_type multisample_type; unsigned int multisample_quality; unsigned int usage; + unsigned int bind_flags; unsigned int access; unsigned int width; unsigned int height; @@ -1780,6 +1781,7 @@ struct wined3d_sub_resource_desc enum wined3d_multisample_type multisample_type; unsigned int multisample_quality; unsigned int usage; + unsigned int bind_flags; unsigned int access; unsigned int width; unsigned int height;