Added patch to implement vsync handling for d3d10/d3d11.

This commit is contained in:
Sebastian Lackner 2017-10-02 14:44:37 +02:00
parent b67879cfb2
commit 65acc06d90
4 changed files with 276 additions and 9 deletions

View File

@ -473,6 +473,7 @@ patch_enable_all ()
enable_wined3d_WINED3D_RS_COLORWRITEENABLE="$1"
enable_wined3d_buffer_create="$1"
enable_wined3d_draw_primitive_arrays="$1"
enable_wined3d_dxgi_swapchain_Present="$1"
enable_wined3d_sample_c_lz="$1"
enable_wined3d_wined3d_guess_gl_vendor="$1"
enable_winedbg_Process_Arguments="$1"
@ -1703,6 +1704,9 @@ patch_enable ()
wined3d-draw_primitive_arrays)
enable_wined3d_draw_primitive_arrays="$2"
;;
wined3d-dxgi_swapchain_Present)
enable_wined3d_dxgi_swapchain_Present="$2"
;;
wined3d-sample_c_lz)
enable_wined3d_sample_c_lz="$2"
;;
@ -2253,6 +2257,21 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then
enable_wined3d_CSMT_Helper=1
fi
if test "$enable_wined3d_dxgi_swapchain_Present" -eq 1; then
if test "$enable_dxgi_DXGI_PRESENT_TEST" -gt 1; then
abort "Patchset dxgi-DXGI_PRESENT_TEST disabled, but wined3d-dxgi_swapchain_Present depends on that."
fi
if test "$enable_wined3d_DrawIndirect" -gt 1; then
abort "Patchset wined3d-DrawIndirect disabled, but wined3d-dxgi_swapchain_Present depends on that."
fi
if test "$enable_wined3d_Silence_FIXMEs" -gt 1; then
abort "Patchset wined3d-Silence_FIXMEs disabled, but wined3d-dxgi_swapchain_Present depends on that."
fi
enable_dxgi_DXGI_PRESENT_TEST=1
enable_wined3d_DrawIndirect=1
enable_wined3d_Silence_FIXMEs=1
fi
if test "$enable_wined3d_Indexed_Vertex_Blending" -eq 1; then
if test "$enable_wined3d_DrawIndirect" -gt 1; then
abort "Patchset wined3d-DrawIndirect disabled, but wined3d-Indexed_Vertex_Blending depends on that."
@ -10020,6 +10039,23 @@ if test "$enable_wined3d_buffer_create" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-dxgi_swapchain_Present
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * dxgi-DXGI_PRESENT_TEST, wined3d-draw_primitive_arrays, wined3d-DrawIndirect, wined3d-Silence_FIXMEs
# |
# | Modified files:
# | * dlls/d3d8/swapchain.c, dlls/d3d9/device.c, dlls/d3d9/swapchain.c, dlls/dxgi/swapchain.c, dlls/wined3d/cs.c,
# | dlls/wined3d/surface.c, dlls/wined3d/swapchain.c, dlls/wined3d/wined3d.spec, dlls/wined3d/wined3d_private.h,
# | include/wine/wined3d.h
# |
if test "$enable_wined3d_dxgi_swapchain_Present" -eq 1; then
patch_apply wined3d-dxgi_swapchain_Present/0001-wined3d-Implement-updating-swap-interval-through-win.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Implement updating swap interval through wined3d_swapchain_present.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-sample_c_lz
# |
# | This patchset fixes the following Wine bugs:

View File

@ -37,7 +37,7 @@ diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -399,6 +399,9 @@ struct wined3d_cs_update_sub_resource
@@ -400,6 +400,9 @@ struct wined3d_cs_update_sub_resource
unsigned int sub_resource_idx;
struct wined3d_box box;
struct wined3d_sub_resource_data data;
@ -47,7 +47,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
};
struct wined3d_cs_add_dirty_texture_region
@@ -2254,6 +2257,53 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
@@ -2263,6 +2266,53 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
unsigned int slice_pitch)
{
struct wined3d_cs_update_sub_resource *op;
@ -101,7 +101,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
@@ -2267,8 +2317,10 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
@@ -2276,8 +2326,10 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
wined3d_resource_acquire(resource);
cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP);
@ -112,7 +112,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP);
}
@@ -2647,6 +2699,13 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
@@ -2656,6 +2708,13 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_GENERATE_MIPS */ wined3d_cs_exec_generate_mips,
};
@ -126,7 +126,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
if (size > (cs->data_size - cs->end))
@@ -2700,6 +2759,9 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
@@ -2709,6 +2768,9 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
static const struct wined3d_cs_ops wined3d_cs_st_ops =
{
@ -136,7 +136,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
wined3d_cs_st_require_space,
wined3d_cs_st_submit,
wined3d_cs_st_finish,
@@ -2733,6 +2795,21 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id
@@ -2742,6 +2804,21 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id
wined3d_cs_queue_submit(&cs->queue[queue_id], cs);
}
@ -158,7 +158,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs)
{
size_t queue_size = ARRAY_SIZE(queue->data);
@@ -2794,6 +2871,16 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size
@@ -2803,6 +2880,16 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size
return packet->data;
}
@ -175,7 +175,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
if (cs->thread_id == GetCurrentThreadId())
@@ -2813,6 +2900,9 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
@@ -2822,6 +2909,9 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
static const struct wined3d_cs_ops wined3d_cs_mt_ops =
{
@ -314,7 +314,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -482,7 +482,11 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
@@ -483,7 +483,11 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
swapchain_blit(swapchain, context, src_rect, dst_rect);
}

View File

@ -0,0 +1,227 @@
From d76e9bb4c57cb75a29a0a59bc9ce64fa4da85626 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 1 Oct 2017 01:44:57 +0200
Subject: wined3d: Implement updating swap interval through
wined3d_swapchain_present.
---
dlls/d3d8/swapchain.c | 2 +-
dlls/d3d9/device.c | 4 ++--
dlls/d3d9/swapchain.c | 2 +-
dlls/dxgi/swapchain.c | 15 +++++++++++++--
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, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c
index 6fd30e5ba47..7e9e2c2bcd2 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 cd42cbccb37..994f85b714a 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -911,7 +911,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;
@@ -3505,7 +3505,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 8f3803ae823..c9e4fa3d6d8 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 90c8ab55094..263415f728e 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -166,11 +166,22 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface,
static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags)
{
struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface);
+ DWORD swap_interval = 0;
HRESULT hr;
TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags);
- if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
+ switch (sync_interval)
+ {
+ case 0:
+ swap_interval = WINED3DPRESENT_INTERVAL_IMMEDIATE;
+ break;
+ case 1:
+ swap_interval = WINED3DPRESENT_INTERVAL_ONE;
+ break;
+ default:
+ FIXME("Unimplemented sync interval %u.\n", sync_interval);
+ }
if (flags == DXGI_PRESENT_TEST)
{
@@ -181,7 +192,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, U
if (flags) FIXME("Unimplemented flags %#x\n", flags);
wined3d_mutex_lock();
- hr = wined3d_swapchain_present(This->wined3d_swapchain, NULL, NULL, NULL, 0);
+ hr = wined3d_swapchain_present(This->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 3a5ad441e14..1ec53fbba76 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;
};
@@ -461,6 +462,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);
@@ -473,7 +480,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;
@@ -485,6 +493,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 9d48ad8fe2d..73fa9356cfb 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3920,7 +3920,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 e3940ae4cfb..7a2e877c8e1 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)
{
static DWORD notified_flags = 0;
RECT s, d;
@@ -181,7 +182,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 22c76a49281..d537ea6f659 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -279,7 +279,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 abef3ff2479..38cbfbe1c25 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3544,8 +3544,8 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type,
struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
void wined3d_cs_emit_flush(struct wined3d_cs *cs) 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_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 5d9ff1a2812..52cd2a92495 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2668,7 +2668,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.14.1

View File

@ -0,0 +1,4 @@
Fixes: Implement vsync handling for d3d10/d3d11
Depends: wined3d-DrawIndirect
Depends: dxgi-DXGI_PRESENT_TEST
Depends: wined3d-Silence_FIXMEs