From: Józef Kucia Subject: [PATCH 1/8] wined3d: Implement updating swap interval through wined3d_swapchain_present(). Message-Id: <20180228111239.11201-1-jkucia@codeweavers.com> Date: Wed, 28 Feb 2018 12:12:32 +0100 From: Michael Müller Signed-off-by: Józef Kucia --- dlls/d3d8/swapchain.c | 2 +- dlls/d3d9/device.c | 4 ++-- dlls/d3d9/swapchain.c | 2 +- dlls/dxgi/swapchain.c | 27 ++++++++++++++++++++++++--- dlls/wined3d/cs.c | 11 ++++++++++- dlls/wined3d/surface.c | 2 +- dlls/wined3d/swapchain.c | 5 +++-- dlls/wined3d/wined3d.spec | 2 +- dlls/wined3d/wined3d_private.h | 4 ++-- include/wine/wined3d.h | 2 +- 10 files changed, 46 insertions(+), 15 deletions(-) diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c index 7003aa32dbcb..3a588b5e8c2b 100644 --- a/dlls/d3d8/swapchain.c +++ b/dlls/d3d8/swapchain.c @@ -105,7 +105,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present(IDirect3DSwapChai wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, 0); + src_rect, dst_rect, dst_window_override, 0, 0); wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index aac0961d559e..bc73699e5251 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -992,7 +992,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Present(IDirect3DDevice9Ex * for (i = 0; i < device->implicit_swapchain_count; ++i) { if (FAILED(hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, 0))) + src_rect, dst_rect, dst_window_override, 0, 0))) { wined3d_mutex_unlock(); return hr; @@ -3684,7 +3684,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_PresentEx(IDirect3DDevice9Ex for (i = 0; i < device->implicit_swapchain_count; ++i) { if (FAILED(hr = wined3d_swapchain_present(device->implicit_swapchains[i]->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, flags))) + src_rect, dst_rect, dst_window_override, 0, flags))) { wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c index 411040ad66df..dbb3f45b91d5 100644 --- a/dlls/d3d9/swapchain.c +++ b/dlls/d3d9/swapchain.c @@ -137,7 +137,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_swapchain_Present(IDirect3DSwapChai wined3d_mutex_lock(); hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, - src_rect, dst_rect, dst_window_override, flags); + src_rect, dst_rect, dst_window_override, 0, flags); wined3d_mutex_unlock(); return hr; diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 1f88d71b77a7..7ddf51c0d5c9 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -528,11 +528,34 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present1(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags, const DXGI_PRESENT_PARAMETERS *present_parameters) { struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + DWORD swap_interval; HRESULT hr; TRACE("iface %p, sync_interval %u, flags %#x, present_parameters %p.\n", iface, sync_interval, flags, present_parameters); + switch (sync_interval) + { + case 0: + swap_interval = WINED3DPRESENT_INTERVAL_IMMEDIATE; + break; + case 1: + swap_interval = WINED3DPRESENT_INTERVAL_ONE; + break; + case 2: + swap_interval = WINED3DPRESENT_INTERVAL_TWO; + break; + case 3: + swap_interval = WINED3DPRESENT_INTERVAL_THREE; + break; + case 4: + swap_interval = WINED3DPRESENT_INTERVAL_FOUR; + break; + default: + WARN("Invalid sync interval %u.\n", sync_interval); + return DXGI_ERROR_INVALID_CALL; + } + if (flags & ~DXGI_PRESENT_TEST) FIXME("Unimplemented flags %#x.\n", flags); if (flags & DXGI_PRESENT_TEST) @@ -541,13 +564,11 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present1(IDXGISwapChain1 *iface, return S_OK; } - if (sync_interval) - FIXME("Unimplemented sync interval %u.\n", sync_interval); if (present_parameters) FIXME("Ignored present parameters %p.\n", present_parameters); wined3d_mutex_lock(); - hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, NULL, NULL, NULL, 0); + hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, NULL, NULL, NULL, swap_interval, 0); wined3d_mutex_unlock(); return hr; diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 9f3ff4691d1a..d16a8997e931 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -94,6 +94,7 @@ struct wined3d_cs_present struct wined3d_swapchain *swapchain; RECT src_rect; RECT dst_rect; + DWORD swap_interval; DWORD flags; }; @@ -453,6 +454,12 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) swapchain = op->swapchain; wined3d_swapchain_set_window(swapchain, op->dst_window_override); + if (op->swap_interval && swapchain->desc.swap_interval != op->swap_interval) + { + swapchain->desc.swap_interval = op->swap_interval; + swapchain_update_swap_interval(swapchain); + } + swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->flags); wined3d_resource_release(&swapchain->front_buffer->resource); @@ -465,7 +472,8 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) } void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, - const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) + const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, + DWORD swap_interval, DWORD flags) { struct wined3d_cs_present *op; unsigned int i; @@ -477,6 +485,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw op->swapchain = swapchain; op->src_rect = *src_rect; op->dst_rect = *dst_rect; + op->swap_interval = swap_interval; op->flags = flags; pending = InterlockedIncrement(&cs->pending_presents); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index ada71938da52..d7f5fcab7d52 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -4007,7 +4007,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst /* Set the swap effect to COPY, we don't want the backbuffer to become * undefined. */ dst_swapchain->desc.swap_effect = WINED3D_SWAP_EFFECT_COPY; - wined3d_swapchain_present(dst_swapchain, NULL, NULL, dst_swapchain->win_handle, 0); + wined3d_swapchain_present(dst_swapchain, NULL, NULL, dst_swapchain->win_handle, 0, 0); dst_swapchain->desc.swap_effect = swap_effect; return WINED3D_OK; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 0d76b671717e..c7e9bf12d0b2 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -146,7 +146,8 @@ void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWN } HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain, - const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) + const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, + DWORD swap_interval, DWORD flags) { RECT s, d; @@ -177,7 +178,7 @@ HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain, } wined3d_cs_emit_present(swapchain->device->cs, swapchain, src_rect, - dst_rect, dst_window_override, flags); + dst_rect, dst_window_override, swap_interval, flags); return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index d2b6bef36340..16d22f5263ac 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -281,7 +281,7 @@ @ cdecl wined3d_swapchain_get_desc(ptr ptr) @ cdecl wined3d_swapchain_get_raster_status(ptr ptr) @ cdecl wined3d_swapchain_incref(ptr) -@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr long) +@ 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) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f085f2d8b85e..bba80df35cfd 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3548,8 +3548,8 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN; void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN; -void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, - const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) DECLSPEC_HIDDEN; +void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect, + const RECT *dst_rect, HWND dst_window_override, DWORD swap_interval, DWORD flags) DECLSPEC_HIDDEN; void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN; void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index b6a2ec38a004..96c1c25bf07c 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2656,7 +2656,7 @@ HRESULT __cdecl wined3d_swapchain_get_raster_status(const struct wined3d_swapcha struct wined3d_raster_status *raster_status); 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, DWORD flags); + const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD 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); -- 2.16.1