From 29b9724a14b8e57689bd7a9d2c84ff4edae71e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 25 Jan 2018 10:33:29 +0100 Subject: [PATCH] d3d11: Use proper bind flags for swapchain textures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d10core/tests/device.c | 4 ++-- dlls/d3d11/d3d11_private.h | 1 + dlls/d3d11/device.c | 9 +++------ dlls/d3d11/tests/d3d11.c | 4 ++-- dlls/d3d11/utils.c | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index ca0fd8be499..86a8f43d4e9 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -8758,13 +8758,13 @@ static void test_swapchain_flip(void) ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); ID3D10Texture2D_GetDesc(backbuffer_0, &texture_desc); - todo_wine ok((texture_desc.BindFlags & (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE)) + ok((texture_desc.BindFlags & (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE)) == (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE), "Got unexpected bind flags %x.\n", texture_desc.BindFlags); ok(texture_desc.Usage == D3D10_USAGE_DEFAULT, "Got unexpected usage %u.\n", texture_desc.Usage); ID3D10Texture2D_GetDesc(backbuffer_1, &texture_desc); - todo_wine ok((texture_desc.BindFlags & (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE)) + ok((texture_desc.BindFlags & (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE)) == (D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE), "Got unexpected bind flags %x.\n", texture_desc.BindFlags); ok(texture_desc.Usage == D3D10_USAGE_DEFAULT, "Got unexpected usage %u.\n", texture_desc.Usage); diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index a184b9377a0..9089398e5df 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -67,6 +67,7 @@ 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; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 86778f31335..cde5b3cc57b 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -5771,11 +5771,8 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic D3D11_TEXTURE2D_DESC desc; HRESULT hr; - FIXME("device_parent %p, container_parent %p, wined3d_desc %p, texture flags %#x, " - "wined3d_texture %p partial stub!\n", device_parent, container_parent, - wined3d_desc, texture_flags, wined3d_texture); - - FIXME("Implement DXGI<->wined3d usage conversion.\n"); + TRACE("device_parent %p, container_parent %p, wined3d_desc %p, texture_flags %#x, wined3d_texture %p.\n", + device_parent, container_parent, wined3d_desc, texture_flags, wined3d_texture); desc.Width = wined3d_desc->width; desc.Height = wined3d_desc->height; @@ -5785,7 +5782,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_RENDER_TARGET; + desc.BindFlags = d3d11_bind_flags_from_wined3d_usage(wined3d_desc->usage); desc.CPUAccessFlags = 0; desc.MiscFlags = 0; diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 19e428c2f5b..ca71718c4e9 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -11265,13 +11265,13 @@ static void test_swapchain_flip(void) ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); ID3D11Texture2D_GetDesc(backbuffer_0, &texture_desc); - todo_wine ok((texture_desc.BindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)) + ok((texture_desc.BindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)) == (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE), "Got unexpected bind flags %x.\n", texture_desc.BindFlags); ok(texture_desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected usage %u.\n", texture_desc.Usage); ID3D11Texture2D_GetDesc(backbuffer_1, &texture_desc); - todo_wine ok((texture_desc.BindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)) + ok((texture_desc.BindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)) == (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE), "Got unexpected bind flags %x.\n", texture_desc.BindFlags); ok(texture_desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected usage %u.\n", texture_desc.Usage); diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c index c72216def53..ae761f448b7 100644 --- a/dlls/d3d11/utils.c +++ b/dlls/d3d11/utils.c @@ -438,6 +438,21 @@ 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