Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- This supersedes patch 167237.
dlls/dxgi/dxgi_private.h | 1 + dlls/dxgi/output.c | 8 ++++++ dlls/dxgi/swapchain.c | 14 +++++++++- dlls/wined3d/device.c | 6 ++-- dlls/wined3d/swapchain.c | 63 +++++++++++++++++++++--------------------- dlls/wined3d/wined3d.spec | 4 ++- dlls/wined3d/wined3d_main.c | 4 +-- dlls/wined3d/wined3d_private.h | 2 +- include/wine/wined3d.h | 7 +++-- 9 files changed, 67 insertions(+), 42 deletions(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 553eacee3b8..a17c4da83c1 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -148,6 +148,7 @@ struct dxgi_output };
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, struct dxgi_output **output) DECLSPEC_HIDDEN; +struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface) DECLSPEC_HIDDEN;
/* IDXGIAdapter */ struct dxgi_adapter diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c index 123dee8c99e..abe1aef950c 100644 --- a/dlls/dxgi/output.c +++ b/dlls/dxgi/output.c @@ -522,6 +522,14 @@ static const struct IDXGIOutput4Vtbl dxgi_output_vtbl = dxgi_output_CheckOverlayColorSpaceSupport, };
+struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == (IDXGIOutputVtbl *)&dxgi_output_vtbl); + return CONTAINING_RECORD(iface, struct dxgi_output, IDXGIOutput4_iface); +} + static void dxgi_output_init(struct dxgi_output *output, struct dxgi_adapter *adapter) { output->IDXGIOutput4_iface.lpVtbl = &dxgi_output_vtbl; diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 963ceee077c..6741b3d489c 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -520,7 +520,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *i const DXGI_MODE_DESC *target_mode_desc) { struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); + struct wined3d_swapchain_state *state; struct wined3d_display_mode mode; + struct dxgi_output *dxgi_output; + struct dxgi_adapter *adapter; + IDXGIOutput *output; + HRESULT hr;
TRACE("iface %p, target_mode_desc %p.\n", iface, target_mode_desc);
@@ -530,14 +535,21 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *i return DXGI_ERROR_INVALID_CALL; }
+ if (FAILED(hr = IDXGISwapChain1_GetContainingOutput(iface, &output))) + return hr; + dxgi_output = unsafe_impl_from_IDXGIOutput(output); + adapter = dxgi_output->adapter; + IDXGIOutput_Release(output); + TRACE("Mode: %s.\n", debug_dxgi_mode(target_mode_desc));
if (target_mode_desc->Scaling) FIXME("Ignoring scaling %#x.\n", target_mode_desc->Scaling);
+ state = wined3d_swapchain_get_state(swapchain->wined3d_swapchain); wined3d_display_mode_from_dxgi(&mode, target_mode_desc);
- return wined3d_swapchain_resize_target(swapchain->wined3d_swapchain, &mode); + return wined3d_swapchain_state_resize_target(state, adapter->factory->wined3d, adapter->ordinal, &mode); }
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 30307cc90c3..db1b313fcbf 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5404,7 +5404,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, TRACE("Changing the device window from %p to %p.\n", current_desc->device_window, swapchain_desc->device_window); current_desc->device_window = swapchain_desc->device_window; - swapchain->device_window = swapchain_desc->device_window; + swapchain_state->device_window = swapchain_desc->device_window; wined3d_swapchain_set_window(swapchain, NULL); }
@@ -5421,7 +5421,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, HWND focus_window = device->create_parms.focus_window;
if (!focus_window) - focus_window = swapchain->device_window; + focus_window = swapchain->state.device_window; if (FAILED(hr = wined3d_device_acquire_focus_window(device, focus_window))) { ERR("Failed to acquire focus window, hr %#x.\n", hr); @@ -5445,7 +5445,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, * up their mess. Guild Wars also loses the device during that. */ swapchain_state->style = 0; swapchain_state->exstyle = 0; - wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain->device_window, + wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain_state->device_window, swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height); swapchain_state->style = style; swapchain_state->exstyle = exstyle; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 5e207be37e5..2669207cfa3 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -86,13 +86,13 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) if (swapchain->state.desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT) { wined3d_swapchain_state_restore_from_fullscreen(&swapchain->state, - swapchain->device_window, &swapchain->original_window_rect); + swapchain->state.device_window, &swapchain->original_window_rect); wined3d_device_release_focus_window(swapchain->device); } } else { - wined3d_swapchain_state_restore_from_fullscreen(&swapchain->state, swapchain->device_window, NULL); + wined3d_swapchain_state_restore_from_fullscreen(&swapchain->state, swapchain->state.device_window, NULL); } }
@@ -152,7 +152,7 @@ void * CDECL wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapch void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window) { if (!window) - window = swapchain->device_window; + window = swapchain->state.device_window; if (window == swapchain->win_handle) return;
@@ -261,6 +261,11 @@ HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain swapchain->device->adapter->ordinal, raster_status); }
+struct wined3d_swapchain_state * CDECL wined3d_swapchain_get_state(struct wined3d_swapchain *swapchain) +{ + return &swapchain->state; +} + HRESULT CDECL wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation) { @@ -302,9 +307,9 @@ HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *s if (flags) FIXME("Ignoring flags %#x.\n", flags);
- dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE); + dc = GetDCEx(swapchain->state.device_window, 0, DCX_USESTYLE | DCX_CACHE); SetDeviceGammaRamp(dc, (void *)ramp); - ReleaseDC(swapchain->device_window, dc); + ReleaseDC(swapchain->state.device_window, dc);
return WINED3D_OK; } @@ -325,9 +330,9 @@ HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *s
TRACE("swapchain %p, ramp %p.\n", swapchain, ramp);
- dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE); + dc = GetDCEx(swapchain->state.device_window, 0, DCX_USESTYLE | DCX_CACHE); GetDeviceGammaRamp(dc, ramp); - ReleaseDC(swapchain->device_window, dc); + ReleaseDC(swapchain->state.device_window, dc);
return WINED3D_OK; } @@ -776,7 +781,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 swapchain->parent_ops = parent_ops; swapchain->ref = 1; swapchain->win_handle = window; - swapchain->device_window = window; + swapchain->state.device_window = window; swapchain->swap_interval = WINED3D_SWAP_INTERVAL_DEFAULT; swapchain_set_max_frame_latency(swapchain, device);
@@ -1150,7 +1155,7 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) { struct wined3d_device *device = swapchain->device; - HWND window = swapchain->device_window; + HWND window = swapchain->state.device_window; BOOL focus_messages, filter;
/* This code is not protected by the wined3d mutex, so it may run while @@ -1243,7 +1248,7 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha if (!desc->windowed) return WINED3DERR_INVALIDCALL;
- if (!GetClientRect(swapchain->device_window, &client_rect)) + if (!GetClientRect(swapchain->state.device_window, &client_rect)) { ERR("Failed to get client rect, last error %#x.\n", GetLastError()); return WINED3DERR_INVALIDCALL; @@ -1309,23 +1314,20 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha return WINED3D_OK; }
-static HRESULT wined3d_swapchain_set_display_mode(struct wined3d_swapchain *swapchain, - struct wined3d_display_mode *mode) +static HRESULT wined3d_swapchain_state_set_display_mode(struct wined3d_swapchain_state *state, + struct wined3d *wined3d, unsigned int adapter_idx, struct wined3d_display_mode *mode) { - struct wined3d_device *device = swapchain->device; HRESULT hr;
- if (swapchain->state.desc.flags & WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE) + if (state->desc.flags & WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE) { - if (FAILED(hr = wined3d_find_closest_matching_adapter_mode(device->wined3d, - device->adapter->ordinal, mode))) + if (FAILED(hr = wined3d_find_closest_matching_adapter_mode(wined3d, adapter_idx, mode))) { WARN("Failed to find closest matching mode, hr %#x.\n", hr); } }
- if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, - device->adapter->ordinal, mode))) + if (FAILED(hr = wined3d_set_adapter_display_mode(wined3d, adapter_idx, mode))) { WARN("Failed to set display mode, hr %#x.\n", hr); return WINED3DERR_INVALIDCALL; @@ -1334,22 +1336,19 @@ static HRESULT wined3d_swapchain_set_display_mode(struct wined3d_swapchain *swap return WINED3D_OK; }
-HRESULT CDECL wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchain, - const struct wined3d_display_mode *mode) +HRESULT CDECL wined3d_swapchain_state_resize_target(struct wined3d_swapchain_state *state, + struct wined3d *wined3d, unsigned int adapter_idx, const struct wined3d_display_mode *mode) { - struct wined3d_swapchain_state *state = &swapchain->state; struct wined3d_display_mode actual_mode; RECT original_window_rect, window_rect; - struct wined3d_device *device; HWND window; HRESULT hr;
- TRACE("swapchain %p, mode %p.\n", swapchain, mode); + TRACE("state %p, wined3d %p, adapter_idx %u, mode %p.\n", state, wined3d, adapter_idx, mode);
wined3d_mutex_lock();
- device = swapchain->device; - window = swapchain->device_window; + window = state->device_window;
if (state->desc.windowed) { @@ -1365,7 +1364,7 @@ HRESULT CDECL wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchai else if (state->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH) { actual_mode = *mode; - if (FAILED(hr = wined3d_swapchain_set_display_mode(swapchain, &actual_mode))) + if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, wined3d, adapter_idx, &actual_mode))) { wined3d_mutex_unlock(); return hr; @@ -1374,8 +1373,7 @@ HRESULT CDECL wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchai } else { - if (FAILED(hr = wined3d_get_adapter_display_mode(device->wined3d, device->adapter->ordinal, - &actual_mode, NULL))) + if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &actual_mode, NULL))) { ERR("Failed to get display mode, hr %#x.\n", hr); wined3d_mutex_unlock(); @@ -1535,7 +1533,8 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha } }
- if (FAILED(hr = wined3d_swapchain_set_display_mode(swapchain, &actual_mode))) + if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, + device->wined3d, device->adapter->ordinal, &actual_mode))) return hr; } else @@ -1560,12 +1559,12 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha { /* Switch from windowed to fullscreen */ if (FAILED(hr = wined3d_swapchain_state_setup_fullscreen(state, - swapchain->device_window, width, height))) + state->device_window, width, height))) return hr; } else { - HWND window = swapchain->device_window; + HWND window = swapchain->state.device_window; BOOL filter;
/* Fullscreen -> fullscreen mode change */ @@ -1582,7 +1581,7 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha RECT *window_rect = NULL; if (state->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT) window_rect = &swapchain->original_window_rect; - wined3d_swapchain_state_restore_from_fullscreen(state, swapchain->device_window, window_rect); + wined3d_swapchain_state_restore_from_fullscreen(state, state->device_window, window_rect); }
state->desc.windowed = swapchain_desc->windowed; diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 8b36753f458..bd91e92c683 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -269,15 +269,17 @@ @ cdecl wined3d_swapchain_get_parent(ptr) @ cdecl wined3d_swapchain_get_desc(ptr ptr) @ cdecl wined3d_swapchain_get_raster_status(ptr ptr) +@ cdecl wined3d_swapchain_get_state(ptr) @ cdecl wined3d_swapchain_incref(ptr) @ cdecl wined3d_swapchain_present(ptr ptr ptr ptr long long) @ cdecl wined3d_swapchain_resize_buffers(ptr long long long long long long) -@ cdecl wined3d_swapchain_resize_target(ptr ptr) @ cdecl wined3d_swapchain_set_fullscreen(ptr ptr ptr) @ cdecl wined3d_swapchain_set_gamma_ramp(ptr long ptr) @ cdecl wined3d_swapchain_set_palette(ptr ptr) @ cdecl wined3d_swapchain_set_window(ptr ptr)
+@ cdecl wined3d_swapchain_state_resize_target(ptr ptr long ptr) + @ cdecl wined3d_texture_add_dirty_region(ptr long ptr) @ cdecl wined3d_texture_blt(ptr long ptr ptr long ptr long ptr long) @ cdecl wined3d_texture_create(ptr ptr long long long ptr ptr ptr ptr) diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 2d74d6f9d94..360d6d51962 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -555,7 +555,7 @@ static LRESULT CALLBACK wined3d_hook_proc(int code, WPARAM wparam, LPARAM lparam { swapchain = hook_table.swapchains[i].swapchain;
- if (swapchain->device_window != msg->hwnd) + if (swapchain->state.device_window != msg->hwnd) continue;
if ((entry = wined3d_find_wndproc(msg->hwnd, swapchain->device->wined3d)) @@ -747,7 +747,7 @@ void wined3d_hook_swapchain(struct wined3d_swapchain *swapchain)
swapchain_entry = &hook_table.swapchains[hook_table.swapchain_count++]; swapchain_entry->swapchain = swapchain; - swapchain_entry->thread_id = GetWindowThreadProcessId(swapchain->device_window, NULL); + swapchain_entry->thread_id = GetWindowThreadProcessId(swapchain->state.device_window, NULL);
if ((hook = wined3d_find_hook(swapchain_entry->thread_id))) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 74f115f4f80..5ddf066878a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4181,6 +4181,7 @@ struct wined3d_swapchain_state /* Window styles to restore when switching fullscreen mode. */ LONG style; LONG exstyle; + HWND device_window; };
void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state, @@ -4222,7 +4223,6 @@ struct wined3d_swapchain
struct wined3d_swapchain_state state; HWND win_handle; - HWND device_window;
HDC backup_dc; HWND backup_wnd; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index c71bb9c54c7..bbb58ba8320 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2127,6 +2127,7 @@ struct wined3d_shader; struct wined3d_shader_resource_view; struct wined3d_stateblock; struct wined3d_swapchain; +struct wined3d_swapchain_state; struct wined3d_texture; struct wined3d_unordered_access_view; struct wined3d_vertex_declaration; @@ -2676,14 +2677,13 @@ void __cdecl wined3d_swapchain_get_desc(const struct wined3d_swapchain *swapchai struct wined3d_swapchain_desc *desc); HRESULT __cdecl wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain, struct wined3d_raster_status *raster_status); +struct wined3d_swapchain_state * __cdecl wined3d_swapchain_get_state(struct wined3d_swapchain *swapchain); ULONG __cdecl wined3d_swapchain_incref(struct wined3d_swapchain *swapchain); HRESULT __cdecl wined3d_swapchain_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags); HRESULT __cdecl wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapchain, unsigned int buffer_count, unsigned int width, unsigned int height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, unsigned int multisample_quality); -HRESULT __cdecl wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchain, - const struct wined3d_display_mode *mode); HRESULT __cdecl wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapchain, const struct wined3d_swapchain_desc *desc, const struct wined3d_display_mode *mode); HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain, @@ -2691,6 +2691,9 @@ HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain void __cdecl wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette); void __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window);
+HRESULT __cdecl wined3d_swapchain_state_resize_target(struct wined3d_swapchain_state *state, + struct wined3d *wined3d, unsigned int adapter_idx, const struct wined3d_display_mode *mode); + HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture, UINT layer, const struct wined3d_box *dirty_region); HRESULT __cdecl wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned int dst_idx, const RECT *dst_rect_in,
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=54969
Your paranoid android.
=== debian10 (build log) ===
error: patch failed: dlls/wined3d/swapchain.c:85 error: patch failed: dlls/wined3d/wined3d_private.h:4183 error: patch failed: dlls/wined3d/device.c:5404 error: patch failed: dlls/wined3d/swapchain.c:86 error: patch failed: dlls/wined3d/wined3d_private.h:4181 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/wined3d/swapchain.c:85 error: patch failed: dlls/wined3d/wined3d_private.h:4183 error: patch failed: dlls/wined3d/device.c:5404 error: patch failed: dlls/wined3d/swapchain.c:86 error: patch failed: dlls/wined3d/wined3d_private.h:4181 Task: Patch failed to apply