From 9fc282d682cfef466a3ee341b901f7081c0959e0 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Thu, 14 Mar 2019 16:30:12 +0100 Subject: [PATCH] wined3d: Set display mode to a suitable adapter format. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46792 Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/swapchain.c | 16 ++++++++++++++-- dlls/wined3d/utils.c | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index f7fc05f8ef3..724ea160c96 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -762,6 +762,16 @@ void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain, const swapchain->max_frame_latency = device->max_frame_latency >= 2 ? device->max_frame_latency - 1 : 1; } +static enum wined3d_format_id adapter_format_from_backbuffer_format(struct wined3d_swapchain *swapchain, + enum wined3d_format_id format_id) +{ + const struct wined3d_adapter *adapter = swapchain->device->adapter; + const struct wined3d_format *backbuffer_format; + + backbuffer_format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET); + return pixelformat_for_depth(backbuffer_format->byte_count * CHAR_BIT); +} + static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops) { @@ -881,7 +891,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 /* Change the display settings */ swapchain->d3d_mode.width = desc->backbuffer_width; swapchain->d3d_mode.height = desc->backbuffer_height; - swapchain->d3d_mode.format_id = desc->backbuffer_format; + swapchain->d3d_mode.format_id = adapter_format_from_backbuffer_format(swapchain, + desc->backbuffer_format); swapchain->d3d_mode.refresh_rate = desc->refresh_rate; swapchain->d3d_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; @@ -1414,7 +1425,8 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha actual_mode.width = swapchain_desc->backbuffer_width; actual_mode.height = swapchain_desc->backbuffer_height; actual_mode.refresh_rate = swapchain_desc->refresh_rate; - actual_mode.format_id = swapchain_desc->backbuffer_format; + actual_mode.format_id = adapter_format_from_backbuffer_format(swapchain, + swapchain_desc->backbuffer_format); actual_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; } else diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 469ce1bdacf..a800527e222 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5672,7 +5672,6 @@ void wined3d_format_get_float_color_key(const struct wined3d_format *format, } } -/* DirectDraw stuff */ enum wined3d_format_id pixelformat_for_depth(DWORD depth) { switch (depth)