[PATCH 3/3] dxgi: Added support for DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE
Nikolay Sivov
nsivov at codeweavers.com
Wed Feb 8 02:26:27 CST 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d3d11/device.c | 4 ++--
dlls/d3d8/device.c | 3 ++-
dlls/d3d9/device.c | 3 ++-
dlls/ddraw/ddraw.c | 3 ++-
dlls/dxgi/device.c | 2 +-
dlls/dxgi/tests/device.c | 1 -
dlls/dxgi/utils.c | 12 ++++++++++++
dlls/wined3d/device.c | 6 +++++-
dlls/wined3d/swapchain.c | 10 +++++++---
include/wine/wined3d.h | 3 ++-
10 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 85f84fe719..b47f4f6513 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -5275,7 +5275,7 @@ static HRESULT CDECL device_parent_sub_resource_created(struct wined3d_device_pa
}
static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
- void *container_parent, const struct wined3d_resource_desc *wined3d_desc,
+ void *container_parent, const struct wined3d_resource_desc *wined3d_desc, DWORD texture_flags,
struct wined3d_texture **wined3d_texture)
{
struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
@@ -5299,7 +5299,7 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic
desc.Usage = D3D10_USAGE_DEFAULT;
desc.BindFlags = D3D10_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0;
- desc.MiscFlags = 0;
+ desc.MiscFlags = texture_flags & WINED3D_TEXTURE_CREATE_GET_DC ? D3D10_RESOURCE_MISC_GDI_COMPATIBLE: 0;
if (FAILED(hr = d3d10_device_CreateTexture2D(&device->ID3D10Device1_iface,
&desc, NULL, &texture_iface)))
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 805694b853..bf6653a42b 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -3036,7 +3036,8 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *
}
static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
- void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_texture **texture)
+ void *container_parent, const struct wined3d_resource_desc *desc, DWORD texture_flags,
+ struct wined3d_texture **texture)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_surface *d3d_surface;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index e646cb76c7..923ced55b4 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3746,7 +3746,8 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *
}
static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
- void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_texture **texture)
+ void *container_parent, const struct wined3d_resource_desc *desc, DWORD texture_flags,
+ struct wined3d_texture **texture)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
DWORD flags = WINED3D_TEXTURE_CREATE_MAPPABLE;
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index a0865c0c96..57d18f09c3 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -4877,7 +4877,8 @@ static const struct wined3d_parent_ops ddraw_frontbuffer_parent_ops =
};
static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
- void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_texture **texture)
+ void *container_parent, const struct wined3d_resource_desc *desc, DWORD texture_flags,
+ struct wined3d_texture **texture)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
HRESULT hr;
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index f548ca2ce6..268b6f08be 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -201,7 +201,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
IUnknown *parent;
if (FAILED(hr = device_parent->ops->create_swapchain_texture(device_parent,
- NULL, &surface_desc, &wined3d_texture)))
+ NULL, &surface_desc, 0, &wined3d_texture)))
{
ERR("Failed to create surface, hr %#x.\n", hr);
goto fail;
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c
index b092d5eff1..2bc0ff4071 100644
--- a/dlls/dxgi/tests/device.c
+++ b/dlls/dxgi/tests/device.c
@@ -1039,7 +1039,6 @@ static void test_create_swapchain(void)
ok(SUCCEEDED(hr), "Failed to get front buffer, hr %#x.\n", hr);
hr = IDXGISurface1_GetDC(surface, FALSE, &hdc);
- todo_wine
ok(SUCCEEDED(hr), "Expected GetDC() to succeed, %#x\n", hr);
IDXGISurface1_ReleaseDC(surface, NULL);
diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c
index f41b0a89c7..db74a487f2 100644
--- a/dlls/dxgi/utils.c
+++ b/dlls/dxgi/utils.c
@@ -468,6 +468,12 @@ unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags)
flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
}
+ if (wined3d_flags & WINED3D_SWAPCHAIN_GDI_COMPATIBLE)
+ {
+ wined3d_flags &= ~WINED3D_SWAPCHAIN_GDI_COMPATIBLE;
+ flags |= DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE;
+ }
+
if (wined3d_flags)
FIXME("Unhandled flags %#x.\n", flags);
@@ -484,6 +490,12 @@ unsigned int wined3d_swapchain_flags_from_dxgi(unsigned int flags)
wined3d_flags |= WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
}
+ if (flags & DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE)
+ {
+ flags &= ~DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE;
+ wined3d_flags |= WINED3D_SWAPCHAIN_GDI_COMPATIBLE;
+ }
+
if (flags)
FIXME("Unhandled flags %#x.\n", flags);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 0e969be247..381fac4172 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4749,6 +4749,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{
struct wined3d_resource_desc texture_desc;
struct wined3d_texture *texture;
+ DWORD flags = 0;
TRACE("Creating the depth stencil buffer.\n");
@@ -4763,8 +4764,11 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
texture_desc.depth = 1;
texture_desc.size = 0;
+ if (swapchain_desc->flags & WINED3D_SWAPCHAIN_GDI_COMPATIBLE)
+ flags |= WINED3D_TEXTURE_CREATE_GET_DC;
+
if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
- device->device_parent, &texture_desc, &texture)))
+ device->device_parent, &texture_desc, flags, &texture)))
{
ERR("Failed to create the auto depth/stencil surface, hr %#x.\n", hr);
return WINED3DERR_INVALIDCALL;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 62589c1410..56646e7b14 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -784,6 +784,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
const struct wined3d_adapter *adapter = device->adapter;
struct wined3d_resource_desc texture_desc;
BOOL displaymode_set = FALSE;
+ DWORD texture_flags = 0;
RECT client_rect;
HWND window;
HRESULT hr;
@@ -856,8 +857,11 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
texture_desc.depth = 1;
texture_desc.size = 0;
+ if (swapchain->desc.flags & WINED3D_SWAPCHAIN_GDI_COMPATIBLE)
+ texture_flags |= WINED3D_TEXTURE_CREATE_GET_DC;
+
if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
- parent, &texture_desc, &swapchain->front_buffer)))
+ parent, &texture_desc, texture_flags, &swapchain->front_buffer)))
{
WARN("Failed to create front buffer, hr %#x.\n", hr);
goto err;
@@ -972,7 +976,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
{
TRACE("Creating back buffer %u.\n", i);
if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
- parent, &texture_desc, &swapchain->back_buffers[i])))
+ parent, &texture_desc, texture_flags, &swapchain->back_buffers[i])))
{
WARN("Failed to create back buffer %u, hr %#x.\n", i, hr);
swapchain->desc.backbuffer_count = i;
@@ -995,7 +999,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
texture_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
- device->device_parent, &texture_desc, &ds)))
+ device->device_parent, &texture_desc, texture_flags, &ds)))
{
WARN("Failed to create the auto depth/stencil surface, hr %#x.\n", hr);
goto err;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 8b8305bff3..ea3cffd9e9 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -830,6 +830,7 @@ enum wined3d_display_rotation
#define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH 0x00001000u
#define WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE 0x00002000u
#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT 0x00004000u
+#define WINED3D_SWAPCHAIN_GDI_COMPATIBLE 0x00008000u
#define WINED3DDP_MAXTEXCOORD 8
@@ -2026,7 +2027,7 @@ struct wined3d_device_parent_ops
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent,
- const struct wined3d_resource_desc *desc, struct wined3d_texture **texture);
+ const struct wined3d_resource_desc *desc, DWORD texture_flags, struct wined3d_texture **texture);
HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain);
};
--
2.11.0
More information about the wine-patches
mailing list