diff --git a/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch b/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch index a922a929..597ce9a0 100644 --- a/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch +++ b/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch @@ -1,66 +1,56 @@ -From 9e643b1eb9f0050b72e17665fcc803756184637d Mon Sep 17 00:00:00 2001 +From ebc82ef6a886955f8e2abff6b1b126c8b41b6515 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 29 Dec 2015 00:48:02 -0700 -Subject: ntdll: Do a device check before returning a default serial port name. +Subject: mountmgr.sys: Do a device check before returning a default serial + port name. Fixes https://bugs.winehq.org/show_bug.cgi?id=39793 - -Signed-off-by: Alex Henrie --- - dlls/ntdll/directory.c | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) + dlls/mountmgr.sys/device.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) -diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c -index f3c6aa2..046f1b9 100644 ---- a/dlls/ntdll/directory.c -+++ b/dlls/ntdll/directory.c -@@ -83,6 +83,9 @@ - #ifdef HAVE_SYS_STATFS_H - #include - #endif +diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c +index ee2599984a6..994e3676176 100644 +--- a/dlls/mountmgr.sys/device.c ++++ b/dlls/mountmgr.sys/device.c +@@ -25,6 +25,9 @@ + #include + #include + #include +#ifdef HAVE_TERMIOS_H +# include +#endif - #include - #ifdef HAVE_UNISTD_H - # include -@@ -321,6 +324,24 @@ static void flush_dir_queue(void) - } - } + #include + + #define NONAMELESSUNION +@@ -1038,6 +1041,27 @@ static BOOL create_port_device( DRIVER_OBJECT *driver, int n, const char *unix_p + if (!unix_path) + return FALSE; +#ifdef linux -+/* Serial port device files almost always exist on Linux even if the corresponding serial -+ * ports don't exist. Do a basic functionality check before advertising a serial port. */ -+static BOOL is_serial_device( const char *unix_name ) -+{ -+ struct termios tios; -+ BOOL ret = FALSE; -+ int fd; -+ -+ if ((fd = open( unix_name, O_RDONLY )) != -1) ++ /* Serial port device files almost always exist on Linux even if the corresponding serial ++ * ports don't exist. Do a basic functionality check before advertising a serial port. */ ++ if (driver == serial_driver) + { -+ ret = tcgetattr( fd, &tios ) != -1; ++ struct termios tios; ++ int fd; ++ ++ if ((fd = open( unix_path, O_RDONLY )) == -1) ++ return FALSE; ++ ++ if (tcgetattr( fd, &tios ) == -1) ++ { ++ close( fd ); ++ return FALSE; ++ } ++ + close( fd ); + } -+ -+ return ret; -+} +#endif - - /*********************************************************************** - * get_default_com_device -@@ -336,6 +357,11 @@ static char *get_default_com_device( int num ) - ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/ttyS256") ); - if (!ret) return NULL; - sprintf( ret, "/dev/ttyS%d", num - 1 ); -+ if (!is_serial_device( ret )) -+ { -+ RtlFreeHeap( GetProcessHeap(), 0, ret ); -+ ret = NULL; -+ } - #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuau256") ); - if (!ret) return NULL; ++ + /* create DOS device */ + sprintf( p, "%u", n ); + if (symlink( unix_path, dosdevices_path ) != 0) -- -2.6.4 +2.12.2 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index b81e2ce6..6caafe3c 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "7cd7f14696dc3fb7aa41ef253ad144d458304a28" + echo "b1203af6ba44ff8858ee9ca50fc05f4f3f633892" } # Show version information @@ -5774,12 +5774,12 @@ fi # | * [#39793] Do a device check before returning a default serial port name # | # | Modified files: -# | * dlls/ntdll/directory.c +# | * dlls/mountmgr.sys/device.c # | if test "$enable_ntdll_Serial_Port_Detection" -eq 1; then patch_apply ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch ( - printf '%s\n' '+ { "Alex Henrie", "ntdll: Do a device check before returning a default serial port name.", 1 },'; + printf '%s\n' '+ { "Alex Henrie", "mountmgr.sys: Do a device check before returning a default serial port name.", 1 },'; ) >> "$patchlist" fi @@ -7094,7 +7094,7 @@ fi # | * [#24721] Support for extra large and jumbo icon lists in shell32 # | # | Modified files: -# | * dlls/shell32/iconcache.c, dlls/shell32/shell32_main.h, dlls/shell32/shellord.c +# | * dlls/shell32/iconcache.c, dlls/shell32/shell32_main.h, dlls/shell32/shellord.c, dlls/shell32/tests/shelllink.c # | if test "$enable_shell32_Icons" -eq 1; then patch_apply shell32-Icons/0001-shell32-Add-support-for-extra-large-and-jumbo-icon-l.patch @@ -8642,19 +8642,14 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then patch_apply wined3d-CSMT_Main/9999-IfDefined.patch ( printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Add additional synchronization CS ops.", 1 },'; - printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Prevent the command stream from running ahead too far.", 1 },'; printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Send blits through the command stream.", 1 },'; printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Wrap GL BOs in a structure.", 1 },'; - printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Wait for the cs to finish before destroying the device.", 1 },'; - printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Add swapchain waits.", 1 },'; printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Hackily introduce a multithreaded command stream.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Run the cs asynchronously.", 1 },'; printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Introduce a separate priority queue.", 1 },'; printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Use priority queue for maps/unmaps.", 1 },'; printf '%s\n' '+ { "Stefan Dösinger", "wined3d: Don'\''t call glFinish before swapping.", 1 },'; printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Use priority queue for update_sub_resource.", 1 },'; printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Reset context before destruction.", 1 },'; - printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Synchronize before resizing swapchain context array.", 1 },'; printf '%s\n' '+ { "Michael Müller", "wined3d: Improve wined3d_cs_emit_update_sub_resource.", 1 },'; printf '%s\n' '+ { "Michael Müller", "wined3d: Discard buffer during upload when replacing complete content.", 1 },'; ) >> "$patchlist" diff --git a/patches/shell32-Icons/0001-shell32-Add-support-for-extra-large-and-jumbo-icon-l.patch b/patches/shell32-Icons/0001-shell32-Add-support-for-extra-large-and-jumbo-icon-l.patch index 8ef83844..8158f403 100644 --- a/patches/shell32-Icons/0001-shell32-Add-support-for-extra-large-and-jumbo-icon-l.patch +++ b/patches/shell32-Icons/0001-shell32-Add-support-for-extra-large-and-jumbo-icon-l.patch @@ -1,16 +1,17 @@ -From 7648652cd46e37da1dc51c3dee6d0dcd953e96a9 Mon Sep 17 00:00:00 2001 +From 4d4320e632de06b391bb6ddff4376f7aabe92d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sun, 3 Aug 2014 02:23:44 +0200 Subject: shell32: Add support for extra large and jumbo icon lists. (v2) --- - dlls/shell32/iconcache.c | 228 ++++++++++++++++++++++++++++---------------- - dlls/shell32/shell32_main.h | 3 + - dlls/shell32/shellord.c | 28 ++++-- - 3 files changed, 170 insertions(+), 89 deletions(-) + dlls/shell32/iconcache.c | 223 ++++++++++++++++++++++++++--------------- + dlls/shell32/shell32_main.h | 3 + + dlls/shell32/shellord.c | 28 ++++-- + dlls/shell32/tests/shelllink.c | 7 +- + 4 files changed, 169 insertions(+), 92 deletions(-) diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c -index 737f4d5023..9105b7ab29 100644 +index 0ea2eb9e0e8..767c90e8e71 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -62,7 +62,9 @@ typedef struct @@ -24,7 +25,7 @@ index 737f4d5023..9105b7ab29 100644 static CRITICAL_SECTION SHELL32_SicCS; static CRITICAL_SECTION_DEBUG critsect_debug = -@@ -109,7 +111,7 @@ static int SIC_LoadOverlayIcon(int icon_idx); +@@ -158,7 +160,7 @@ static int SIC_LoadOverlayIcon(int icon_idx); * Creates a new icon as a copy of the passed-in icon, overlaid with a * shortcut image. */ @@ -33,7 +34,7 @@ index 737f4d5023..9105b7ab29 100644 { ICONINFO SourceIconInfo, ShortcutIconInfo, TargetIconInfo; HICON ShortcutIcon, TargetIcon; BITMAP SourceBitmapInfo, ShortcutBitmapInfo; -@@ -139,10 +141,16 @@ static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large) +@@ -188,10 +190,16 @@ static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large) if (s_imgListIdx != -1) { @@ -54,7 +55,7 @@ index 737f4d5023..9105b7ab29 100644 } else ShortcutIcon = NULL; -@@ -258,11 +266,14 @@ fail: +@@ -307,11 +315,14 @@ fail: * NOTES * appends an icon pair to the end of the cache */ @@ -73,7 +74,7 @@ index 737f4d5023..9105b7ab29 100644 lpsice = SHAlloc(sizeof(SIC_ENTRY)); -@@ -284,13 +295,14 @@ static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallI +@@ -333,13 +344,14 @@ static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallI } else { @@ -94,7 +95,7 @@ index 737f4d5023..9105b7ab29 100644 lpsice->dwListIndex = index; ret = lpsice->dwListIndex; } -@@ -304,7 +316,7 @@ static BOOL get_imagelist_icon_size(int list, SIZE *size) +@@ -353,7 +365,7 @@ static BOOL get_imagelist_icon_size(int list, SIZE *size) HIMAGELIST image_list; if (list < SHIL_LARGE || list > SHIL_SMALL) return FALSE; @@ -103,7 +104,7 @@ index 737f4d5023..9105b7ab29 100644 return ImageList_GetIconSize( image_list, &size->cx, &size->cy ); } -@@ -317,19 +329,25 @@ static BOOL get_imagelist_icon_size(int list, SIZE *size) +@@ -366,19 +378,25 @@ static BOOL get_imagelist_icon_size(int list, SIZE *size) */ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags) { @@ -142,7 +143,7 @@ index 737f4d5023..9105b7ab29 100644 { WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall); return -1; -@@ -337,44 +355,69 @@ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags) +@@ -386,28 +404,42 @@ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags) if (0 != (dwFlags & GIL_FORSHORTCUT)) { @@ -202,9 +203,9 @@ index 737f4d5023..9105b7ab29 100644 + DestroyIcon( hiconJumbo ); + return ret; } -- - /***************************************************************************** - * SIC_Initialize [internal] + + static int get_shell_icon_size(void) +@@ -433,9 +465,11 @@ static int get_shell_icon_size(void) */ static BOOL WINAPI SIC_Initialize( INIT_ONCE *once, void *param, void **context ) { @@ -217,25 +218,23 @@ index 737f4d5023..9105b7ab29 100644 + int cx_extralarge, cy_extralarge; + int cx_jumbo, cy_jumbo; - cx_small = GetSystemMetrics(SM_CXSMICON); - cy_small = GetSystemMetrics(SM_CYSMICON); - cx_large = GetSystemMetrics(SM_CXICON); - cy_large = GetSystemMetrics(SM_CYICON); + if (!IsProcessDPIAware()) + { +@@ -451,7 +485,13 @@ static BOOL WINAPI SIC_Initialize( INIT_ONCE *once, void *param, void **context + cy_small = cy_large / 2; + } -+ /* -+ * TODO: according to -+ * http://msdn.microsoft.com/en-us/library/windows/desktop/bb762185(v=vs.85).aspx -+ * the size can be configured, but where is the value defined? -+ */ -+ cx_extralarge = 48; -+ cy_extralarge = 48; -+ cx_jumbo = 256; -+ cy_jumbo = 256; ++ cx_extralarge = (GetSystemMetrics( SM_CXICON ) * 3) / 2; ++ cy_extralarge = (GetSystemMetrics( SM_CYICON ) * 3) / 2; ++ cx_jumbo = 256; ++ cy_jumbo = 256; + - TRACE("\n"); + TRACE("large %dx%d small %dx%d\n", cx_large, cy_large, cx_small, cx_small); ++ TRACE("extra %dx%d jumbo %dx%d\n", cx_extralarge, cy_extralarge, cx_jumbo, cy_jumbo); sic_hdpa = DPA_Create(16); -@@ -384,28 +427,36 @@ static BOOL WINAPI SIC_Initialize( INIT_ONCE *once, void *param, void **context + +@@ -460,28 +500,36 @@ static BOOL WINAPI SIC_Initialize( INIT_ONCE *once, void *param, void **context return(FALSE); } @@ -292,7 +291,7 @@ index 737f4d5023..9105b7ab29 100644 return TRUE; } -@@ -429,13 +480,17 @@ void SIC_Destroy(void) +@@ -505,13 +553,17 @@ void SIC_Destroy(void) if (sic_hdpa) DPA_DestroyCallback(sic_hdpa, sic_free, NULL ); @@ -317,7 +316,7 @@ index 737f4d5023..9105b7ab29 100644 } /***************************************************************************** -@@ -549,10 +604,21 @@ BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList +@@ -625,10 +677,21 @@ BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList { TRACE("(%p,%p)\n",lpBigList,lpSmallList); InitOnceExecuteOnce( &sic_init_once, SIC_Initialize, NULL, NULL ); @@ -341,10 +340,10 @@ index 737f4d5023..9105b7ab29 100644 * PidlToSicIndex [INTERNAL] * diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h -index bdebcba0e3..fbb8e8811a 100644 +index 941ca74f321..3007bbf4539 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h -@@ -235,4 +235,7 @@ static inline WCHAR *strdupW(const WCHAR *src) +@@ -236,4 +236,7 @@ static inline WCHAR *strdupW(const WCHAR *src) return dest; } @@ -353,7 +352,7 @@ index bdebcba0e3..fbb8e8811a 100644 + #endif diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c -index f9814997da..5102bf0e47 100644 +index f9814997dae..5102bf0e475 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -2146,18 +2146,30 @@ void WINAPI SHFlushSFCache(void) @@ -395,6 +394,24 @@ index f9814997da..5102bf0e47 100644 - return HIMAGELIST_QueryInterface(hNew, riid, ppv); } +diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c +index ad254c83498..03878af46dd 100644 +--- a/dlls/shell32/tests/shelllink.c ++++ b/dlls/shell32/tests/shelllink.c +@@ -1363,10 +1363,9 @@ static void test_SHGetImageList(void) + for (i = 0; i <= SHIL_LAST; i++) + { + hr = SHGetImageList( i, &IID_IImageList, (void **)&list ); +- todo_wine_if(i == SHIL_EXTRALARGE || i == SHIL_JUMBO) +- ok( hr == S_OK || +- broken( i == SHIL_JUMBO && hr == E_INVALIDARG ), /* XP and 2003 */ +- "%d: got %08x\n", i, hr ); ++ ok( hr == S_OK || ++ broken( i == SHIL_JUMBO && hr == E_INVALIDARG ), /* XP and 2003 */ ++ "%d: got %08x\n", i, hr ); + if (FAILED(hr)) continue; + IImageList_GetIconSize( list, &width, &height ); + switch (i) -- 2.12.2 diff --git a/patches/user32-GetAutoRotationState/0001-user32-Add-semi-stub-for-GetAutoRotationState.patch b/patches/user32-GetAutoRotationState/0001-user32-Add-semi-stub-for-GetAutoRotationState.patch index 6f3622f0..6963a5bb 100644 --- a/patches/user32-GetAutoRotationState/0001-user32-Add-semi-stub-for-GetAutoRotationState.patch +++ b/patches/user32-GetAutoRotationState/0001-user32-Add-semi-stub-for-GetAutoRotationState.patch @@ -1,4 +1,4 @@ -From 856606f7a35b0ee7245a41d356d5a6dd902899b2 Mon Sep 17 00:00:00 2001 +From d505408feb9b03a117ff0476944b92df0db3fea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sun, 8 Jan 2017 18:22:30 +0100 Subject: user32: Add semi-stub for GetAutoRotationState. @@ -9,10 +9,10 @@ Subject: user32: Add semi-stub for GetAutoRotationState. 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c -index ab3d717300..27560380bd 100644 +index bec4d66edd..155dcaf6b6 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c -@@ -2919,8 +2919,15 @@ BOOL WINAPI IsProcessDPIAware(void) +@@ -2930,8 +2930,15 @@ BOOL WINAPI IsProcessDPIAware(void) */ BOOL WINAPI GetAutoRotationState( AR_STATE *state ) { @@ -31,19 +31,19 @@ index ab3d717300..27560380bd 100644 } diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c -index 96b15814d7..3fe21abb90 100644 +index b5ab784b16..673cd1c146 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c -@@ -39,6 +39,7 @@ - #endif - +@@ -41,6 +41,7 @@ static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID); + static BOOL (WINAPI *pIsProcessDPIAware)(void); + static BOOL (WINAPI *pSetProcessDPIAware)(void); +static LONG (WINAPI *pGetAutoRotationState)(PAR_STATE); static BOOL strict; static int dpi, real_dpi; -@@ -2932,6 +2933,28 @@ static void test_GetSysColorBrush(void) - win_skip("COLOR_MENUBAR unsupported\n"); +@@ -2996,6 +2997,28 @@ static void test_dpi_aware(void) + test_GetSystemMetrics(); } +static void test_GetAutoRotationState(void) @@ -71,15 +71,15 @@ index 96b15814d7..3fe21abb90 100644 START_TEST(sysparams) { int argc; -@@ -2944,6 +2967,7 @@ START_TEST(sysparams) - - hdll = GetModuleHandleA("user32.dll"); - pChangeDisplaySettingsExA=(void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA"); -+ pGetAutoRotationState=(void*)GetProcAddress(hdll, "GetAutoRotationState"); +@@ -3010,6 +3033,7 @@ START_TEST(sysparams) + pChangeDisplaySettingsExA = (void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA"); + pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware"); + pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware"); ++ pGetAutoRotationState = (void*)GetProcAddress(hdll, "GetAutoRotationState"); hInstance = GetModuleHandleA( NULL ); hdc = GetDC(0); -@@ -2965,6 +2989,7 @@ START_TEST(sysparams) +@@ -3031,6 +3055,7 @@ START_TEST(sysparams) trace("testing EnumDisplaySettings vs GetDeviceCaps\n"); test_EnumDisplaySettings( ); test_GetSysColorBrush( ); diff --git a/patches/wined3d-CSMT_Main/0001-wined3d-Add-additional-synchronization-CS-ops.patch b/patches/wined3d-CSMT_Main/0001-wined3d-Add-additional-synchronization-CS-ops.patch index fb1bf26b..aebb4e43 100644 --- a/patches/wined3d-CSMT_Main/0001-wined3d-Add-additional-synchronization-CS-ops.patch +++ b/patches/wined3d-CSMT_Main/0001-wined3d-Add-additional-synchronization-CS-ops.patch @@ -1,135 +1,18 @@ -From fdbfdf6df22ea87be4390c3d8913417b6177cbd7 Mon Sep 17 00:00:00 2001 +From caad9fff0e12134e72b964f7a9bcd2924e25709c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 19 Feb 2017 00:57:12 +0100 Subject: wined3d: Add additional synchronization CS ops. --- - dlls/wined3d/cs.c | 51 ++++++++++++++++++++++++++++++++++++------ - dlls/wined3d/device.c | 2 ++ - dlls/wined3d/swapchain.c | 2 ++ - dlls/wined3d/texture.c | 11 +++++++++ - dlls/wined3d/view.c | 6 +++++ - dlls/wined3d/wined3d_private.h | 3 +++ - 6 files changed, 68 insertions(+), 7 deletions(-) + dlls/wined3d/cs.c | 8 ++++---- + dlls/wined3d/view.c | 6 ++++++ + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index b4e819cf01..833ab4b4c1 100644 +index 7331f31dd3f..5daff0c96fd 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -31,6 +31,7 @@ enum wined3d_cs_op - WINED3D_CS_OP_CLEAR, - WINED3D_CS_OP_DISPATCH, - WINED3D_CS_OP_DRAW, -+ WINED3D_CS_OP_FINISH, - WINED3D_CS_OP_FLUSH, - WINED3D_CS_OP_SET_PREDICATION, - WINED3D_CS_OP_SET_VIEWPORT, -@@ -127,6 +128,11 @@ struct wined3d_cs_draw - BOOL indexed; - }; - -+struct wined3d_cs_finish -+{ -+ enum wined3d_cs_op opcode; -+}; -+ - struct wined3d_cs_flush - { - enum wined3d_cs_op opcode; -@@ -418,6 +424,16 @@ static void wined3d_cs_exec_nop(struct wined3d_cs *cs, const void *data) - { - } - -+void wined3d_cs_emit_sync(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_nop *op; -+ -+ op = cs->ops->require_space(cs, sizeof(*op)); -+ op->opcode = WINED3D_CS_OP_NOP; -+ -+ cs->ops->submit_and_wait(cs); -+} -+ - static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - { - const struct wined3d_cs_present *op = data; -@@ -797,6 +813,24 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base - cs->ops->submit(cs); - } - -+static void wined3d_cs_exec_finish(struct wined3d_cs *cs, const void *data) -+{ -+ struct wined3d_context *context = context_get_current(); -+ -+ if (context) -+ context->gl_info->gl_ops.gl.p_glFinish(); -+} -+ -+void wined3d_cs_emit_finish(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_finish *op; -+ -+ op = cs->ops->require_space(cs, sizeof(*op)); -+ op->opcode = WINED3D_CS_OP_FINISH; -+ -+ cs->ops->submit_and_wait(cs); -+} -+ - static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data) - { - struct wined3d_context *context; -@@ -1865,7 +1899,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, - op->flags = flags; - op->hr = &hr; - -- cs->ops->submit(cs); -+ cs->ops->submit_and_wait(cs); - - return hr; - } -@@ -1889,7 +1923,7 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc - op->sub_resource_idx = sub_resource_idx; - op->hr = &hr; - -- cs->ops->submit(cs); -+ cs->ops->submit_and_wait(cs); - - return hr; - } -@@ -2111,7 +2145,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r - - wined3d_resource_acquire(resource); - -- cs->ops->submit(cs); -+ cs->ops->submit_and_wait(cs); - } - - static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data) -@@ -2167,6 +2201,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void - /* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear, - /* WINED3D_CS_OP_DISPATCH */ wined3d_cs_exec_dispatch, - /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, -+ /* WINED3D_CS_OP_FINISH */ wined3d_cs_exec_finish, - /* WINED3D_CS_OP_FLUSH */ wined3d_cs_exec_flush, - /* WINED3D_CS_OP_SET_PREDICATION */ wined3d_cs_exec_set_predication, - /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, -@@ -2258,6 +2293,7 @@ static const struct wined3d_cs_ops wined3d_cs_st_ops = - { - wined3d_cs_st_require_space, - wined3d_cs_st_submit, -+ wined3d_cs_st_submit, - wined3d_cs_st_push_constants, - }; - -@@ -2355,6 +2391,7 @@ static const struct wined3d_cs_ops wined3d_cs_mt_ops = - { - wined3d_cs_mt_require_space, - wined3d_cs_mt_submit, -+ wined3d_cs_mt_submit, - wined3d_cs_mt_push_constants, - }; - -@@ -2504,10 +2541,6 @@ fail: +@@ -2554,10 +2554,6 @@ fail: void wined3d_cs_destroy(struct wined3d_cs *cs) { @@ -140,7 +23,7 @@ index b4e819cf01..833ab4b4c1 100644 if (cs->thread) { wined3d_cs_emit_stop(cs); -@@ -2516,5 +2549,9 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) +@@ -2566,5 +2562,9 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) ERR("Closing event failed.\n"); } @@ -150,104 +33,11 @@ index b4e819cf01..833ab4b4c1 100644 + HeapFree(GetProcessHeap(), 0, cs); } -diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index c86d243c00..22e474303b 100644 ---- a/dlls/wined3d/device.c -+++ b/dlls/wined3d/device.c -@@ -1023,6 +1023,7 @@ static void wined3d_device_delete_opengl_contexts_cs(void *object) - static void wined3d_device_delete_opengl_contexts(struct wined3d_device *device) - { - wined3d_cs_destroy_object(device->cs, wined3d_device_delete_opengl_contexts_cs, device); -+ wined3d_cs_emit_sync(device->cs); - } - - static void wined3d_device_create_primary_opengl_context_cs(void *object) -@@ -1061,6 +1062,7 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object) - static HRESULT wined3d_device_create_primary_opengl_context(struct wined3d_device *device) - { - wined3d_cs_init_object(device->cs, wined3d_device_create_primary_opengl_context_cs, device); -+ wined3d_cs_emit_sync(device->cs); - if (!device->swapchains[0]->num_contexts) - return E_FAIL; - -diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c -index 3be9a92a06..5482e3024e 100644 ---- a/dlls/wined3d/swapchain.c -+++ b/dlls/wined3d/swapchain.c -@@ -66,6 +66,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) - } - - wined3d_cs_destroy_object(swapchain->device->cs, wined3d_swapchain_destroy_object, swapchain); -+ wined3d_cs_emit_sync(swapchain->device->cs); - - /* Restore the screen resolution if we rendered in fullscreen. - * This will restore the screen resolution to what it was before creating -@@ -900,6 +901,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 - } - - wined3d_cs_init_object(device->cs, wined3d_swapchain_cs_init, swapchain); -+ wined3d_cs_emit_sync(device->cs); - - if (!swapchain->context[0]) - { -diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c -index 288ef8078a..c259bbfe8c 100644 ---- a/dlls/wined3d/texture.c -+++ b/dlls/wined3d/texture.c -@@ -1387,6 +1387,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT - if (surface->dc) - { - wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface); -+ wined3d_cs_emit_sync(device->cs); - create_dib = TRUE; - } - -@@ -1447,7 +1448,10 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT - wined3d_texture_invalidate_location(texture, 0, ~valid_location); - - if (create_dib) -+ { - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } - - return WINED3D_OK; - } -@@ -2840,6 +2844,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 - if ((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D)) - { - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+ wined3d_cs_emit_sync(device->cs); - if (!surface->dc) - { - wined3d_texture_cleanup_sync(texture); -@@ -3627,7 +3632,10 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i - return WINED3DERR_INVALIDCALL; - - if (!surface->dc) -+ { - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } - if (!surface->dc) - return WINED3DERR_INVALIDCALL; - -@@ -3671,7 +3679,10 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign - } - - if (!(texture->resource.usage & WINED3DUSAGE_OWNDC) && !(device->wined3d->flags & WINED3D_NO3D)) -+ { - wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } - - --sub_resource->map_count; - if (!--texture->resource.map_count && texture->update_map_binding) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c -index dc225f4f81..cd09c9c8ee 100644 +index 0a458803a72..0184b21cdb9 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c -@@ -632,6 +632,8 @@ static void wined3d_shader_resource_view_cs_init(void *object) +@@ -716,6 +716,8 @@ static void wined3d_shader_resource_view_cs_init(void *object) debug_d3dformat(resource->format->id), debug_d3dformat(view_format->id)); } } @@ -256,7 +46,7 @@ index dc225f4f81..cd09c9c8ee 100644 } static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_view *view, -@@ -648,6 +650,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_ +@@ -732,6 +734,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_ wined3d_resource_incref(view->resource = resource); @@ -264,7 +54,7 @@ index dc225f4f81..cd09c9c8ee 100644 wined3d_cs_init_object(resource->device->cs, wined3d_shader_resource_view_cs_init, view); return WINED3D_OK; -@@ -829,6 +832,8 @@ static void wined3d_unordered_access_view_cs_init(void *object) +@@ -898,6 +901,8 @@ static void wined3d_unordered_access_view_cs_init(void *object) desc, texture, view->format); } } @@ -273,7 +63,7 @@ index dc225f4f81..cd09c9c8ee 100644 } static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_access_view *view, -@@ -848,6 +853,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces +@@ -917,6 +922,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces wined3d_resource_incref(view->resource = resource); @@ -281,34 +71,6 @@ index dc225f4f81..cd09c9c8ee 100644 wined3d_cs_init_object(resource->device->cs, wined3d_unordered_access_view_cs_init, view); return WINED3D_OK; -diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index df8427d1b7..de832d8125 100644 ---- a/dlls/wined3d/wined3d_private.h -+++ b/dlls/wined3d/wined3d_private.h -@@ -3248,6 +3248,7 @@ struct wined3d_cs_ops - { - void *(*require_space)(struct wined3d_cs *cs, size_t size); - void (*submit)(struct wined3d_cs *cs); -+ void (*submit_and_wait)(struct wined3d_cs *cs); - void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p, - unsigned int start_idx, unsigned int count, const void *constants); - }; -@@ -3289,6 +3290,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, - void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base_vertex_idx, - unsigned int start_idx, unsigned int index_count, unsigned int start_instance, - unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN; -+void wined3d_cs_emit_finish(struct wined3d_cs *cs) 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, -@@ -3341,6 +3343,7 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined - void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, - struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN; - void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN; -+void wined3d_cs_emit_sync(struct wined3d_cs *cs); - void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN; - void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource, - unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, -- 2.12.2 diff --git a/patches/wined3d-CSMT_Main/0007-wined3d-Prevent-the-command-stream-from-running-ahea.patch b/patches/wined3d-CSMT_Main/0007-wined3d-Prevent-the-command-stream-from-running-ahea.patch deleted file mode 100644 index 413ce1fc..00000000 --- a/patches/wined3d-CSMT_Main/0007-wined3d-Prevent-the-command-stream-from-running-ahea.patch +++ /dev/null @@ -1,68 +0,0 @@ -From b53b6032e3923711099eb7aaf6d1cedbd0c3a866 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Stefan=20D=C3=B6singer?= -Date: Wed, 10 Apr 2013 19:10:41 +0200 -Subject: wined3d: Prevent the command stream from running ahead too far - ---- - dlls/wined3d/cs.c | 16 ++++++++++++++++ - dlls/wined3d/wined3d_private.h | 2 ++ - 2 files changed, 18 insertions(+) - -diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 96c88f068b..f7d8f86d5c 100644 ---- a/dlls/wined3d/cs.c -+++ b/dlls/wined3d/cs.c -@@ -445,6 +445,8 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - - swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->flags); - -+ InterlockedDecrement(&cs->pending_presents); -+ - wined3d_resource_release(&swapchain->front_buffer->resource); - for (i = 0; i < swapchain->desc.backbuffer_count; ++i) - { -@@ -457,6 +459,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - { - struct wined3d_cs_present *op; - unsigned int i; -+ LONG pending; - - op = cs->ops->require_space(cs, sizeof(*op)); - op->opcode = WINED3D_CS_OP_PRESENT; -@@ -472,7 +475,20 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - wined3d_resource_acquire(&swapchain->back_buffers[i]->resource); - } - -+ pending = InterlockedIncrement(&cs->pending_presents); -+ - cs->ops->submit(cs); -+ -+ /* D3D10 documentation suggests that Windows allows the game to run -+ * 3 frames ahead of the GPU. Increasing this above 1 causes uneven -+ * animation in some games, most notably StarCraft II. The framerates -+ * don't show this problem. The issue is more noticable with vsync -+ * on, but also happens with vsync off. -+ * -+ * In Counter-Strike: Source a frame difference of 3 causes noticable -+ * input delay that makes the game unplayable. */ -+ while (pending > 1) -+ pending = InterlockedCompareExchange(&cs->pending_presents, 0, 0); - } - - static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data) -diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index de832d8125..0001cffc12 100644 ---- a/dlls/wined3d/wined3d_private.h -+++ b/dlls/wined3d/wined3d_private.h -@@ -3269,6 +3269,8 @@ struct wined3d_cs - - HANDLE event; - BOOL waiting_for_event; -+ -+ LONG pending_presents; - }; - - struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN; --- -2.12.2 - diff --git a/patches/wined3d-CSMT_Main/0008-wined3d-Send-blits-through-the-command-stream.patch b/patches/wined3d-CSMT_Main/0008-wined3d-Send-blits-through-the-command-stream.patch index a5f56243..4d2ef941 100644 --- a/patches/wined3d-CSMT_Main/0008-wined3d-Send-blits-through-the-command-stream.patch +++ b/patches/wined3d-CSMT_Main/0008-wined3d-Send-blits-through-the-command-stream.patch @@ -1,4 +1,4 @@ -From bc0a87c3b6553fae719b2181bc878e8b9e59838c Mon Sep 17 00:00:00 2001 +From ee2d4cc10c524a813e4eefcf3935c63479bb84be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 29 Apr 2013 18:49:53 +0200 Subject: wined3d: Send blits through the command stream. @@ -6,15 +6,15 @@ Subject: wined3d: Send blits through the command stream. This needs more work. This patch breaks error handling, and the split between surface_blt and surface_blt_ugly isn't particularly nice. --- - dlls/wined3d/device.c | 18 +++++++++--------- - dlls/wined3d/texture.c | 9 +++++++-- - 2 files changed, 16 insertions(+), 11 deletions(-) + dlls/wined3d/device.c | 19 ++++++++++--------- + dlls/wined3d/texture.c | 10 ++++++++-- + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index 8fced7ece3..9dc893bfeb 100644 +index cbb0406dccf..613df2077a5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -4148,16 +4148,16 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4199,16 +4199,17 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } @@ -30,7 +30,8 @@ index 8fced7ece3..9dc893bfeb 100644 - { - WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx); - return WINED3DERR_INVALIDCALL; -+ wined3d_cs_emit_sync(dst_texture->resource.device->cs); ++ struct wined3d_device *device = dst_texture->resource.device; ++ device->cs->ops->finish(device->cs); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || + src_texture->sub_resources[src_sub_resource_idx].map_count) + { @@ -41,16 +42,17 @@ index 8fced7ece3..9dc893bfeb 100644 if (!src_box) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c -index 8a92a77872..2b249c26c0 100644 +index ebc317bd43d..d43ee068a30 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c -@@ -3301,8 +3301,13 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned +@@ -3231,8 +3231,14 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || src_texture->sub_resources[src_sub_resource_idx].map_count) { - WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n"); - return WINEDDERR_SURFACEBUSY; -+ wined3d_cs_emit_sync(dst_texture->resource.device->cs); ++ struct wined3d_device *device = dst_texture->resource.device; ++ device->cs->ops->finish(device->cs); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count + || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count)) + { @@ -61,5 +63,5 @@ index 8a92a77872..2b249c26c0 100644 if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) -- -2.11.0 +2.12.2 diff --git a/patches/wined3d-CSMT_Main/0027-wined3d-Wait-for-the-cs-to-finish-before-destroying-.patch b/patches/wined3d-CSMT_Main/0027-wined3d-Wait-for-the-cs-to-finish-before-destroying-.patch deleted file mode 100644 index 0d297cf2..00000000 --- a/patches/wined3d-CSMT_Main/0027-wined3d-Wait-for-the-cs-to-finish-before-destroying-.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 35fd800789c10045216d6649ce568264f0cf68da Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Stefan=20D=C3=B6singer?= -Date: Wed, 10 Apr 2013 20:09:55 +0200 -Subject: wined3d: Wait for the cs to finish before destroying the device - ---- - dlls/wined3d/device.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index cd0ffbe32f7..61c862de138 100644 ---- a/dlls/wined3d/device.c -+++ b/dlls/wined3d/device.c -@@ -1183,6 +1183,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) - if (!device->d3d_initialized) - return WINED3DERR_INVALIDCALL; - -+ wined3d_cs_emit_sync(device->cs); -+ - if (device->logo_texture) - wined3d_texture_decref(device->logo_texture); - if (device->cursor_texture) --- -2.11.0 - diff --git a/patches/wined3d-CSMT_Main/0028-wined3d-Add-swapchain-waits.patch b/patches/wined3d-CSMT_Main/0028-wined3d-Add-swapchain-waits.patch deleted file mode 100644 index 4194c9bd..00000000 --- a/patches/wined3d-CSMT_Main/0028-wined3d-Add-swapchain-waits.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 994f9e8861db01f02f2dc8724a27ee0e7eea5100 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Stefan=20D=C3=B6singer?= -Date: Thu, 5 Nov 2015 17:46:50 +0100 -Subject: wined3d: Add swapchain waits. - ---- - dlls/wined3d/swapchain.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c -index 592cbd96db4..1566d21a944 100644 ---- a/dlls/wined3d/swapchain.c -+++ b/dlls/wined3d/swapchain.c -@@ -112,6 +112,10 @@ ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain) - - if (!refcount) - { -+ struct wined3d_device *device = swapchain->device; -+ -+ wined3d_cs_emit_sync(device->cs); -+ - swapchain_cleanup(swapchain); - swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent); - HeapFree(GetProcessHeap(), 0, swapchain); -@@ -1307,6 +1311,7 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha - enum wined3d_multisample_type multisample_type, unsigned int multisample_quality) - { - BOOL update_desc = FALSE; -+ struct wined3d_device *device = swapchain->device; - - TRACE("swapchain %p, buffer_count %u, width %u, height %u, format %s, " - "multisample_type %#x, multisample_quality %#x.\n", -@@ -1318,6 +1323,8 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha - if (buffer_count && buffer_count != swapchain->desc.backbuffer_count) - FIXME("Cannot change the back buffer count yet.\n"); - -+ wined3d_cs_emit_sync(device->cs); -+ - if (!width || !height) - { - /* The application is requesting that either the swapchain width or --- -2.11.0 - diff --git a/patches/wined3d-CSMT_Main/0030-wined3d-Run-the-cs-asynchronously.patch b/patches/wined3d-CSMT_Main/0030-wined3d-Run-the-cs-asynchronously.patch deleted file mode 100644 index d3bcd0ec..00000000 --- a/patches/wined3d-CSMT_Main/0030-wined3d-Run-the-cs-asynchronously.patch +++ /dev/null @@ -1,49 +0,0 @@ -From f37495b98b6c9ddd4624326dfb5658e184978917 Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Sun, 19 Feb 2017 07:01:45 +0100 -Subject: wined3d: Run the cs asynchronously. - ---- - dlls/wined3d/cs.c | 19 ++++++++++++++++++- - 1 file changed, 18 insertions(+), 1 deletion(-) - -diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 659cfdf7c3..73d5c48e86 100644 ---- a/dlls/wined3d/cs.c -+++ b/dlls/wined3d/cs.c -@@ -2333,6 +2333,23 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - - if (InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) - SetEvent(cs->event); -+} -+ -+static void wined3d_cs_mt_submit_and_wait(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_queue *queue = &cs->queue; -+ struct wined3d_cs_packet *packet; -+ size_t packet_size; -+ -+ if (cs->thread_id == GetCurrentThreadId()) -+ return wined3d_cs_st_submit(cs); -+ -+ packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; -+ packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[packet->size]); -+ InterlockedExchange(&queue->head, (queue->head + packet_size) & (WINED3D_CS_QUEUE_SIZE - 1)); -+ -+ if (InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) -+ SetEvent(cs->event); - - while (!wined3d_cs_queue_is_empty(queue)) - wined3d_pause(); -@@ -2407,7 +2424,7 @@ static const struct wined3d_cs_ops wined3d_cs_mt_ops = - { - wined3d_cs_mt_require_space, - wined3d_cs_mt_submit, -- wined3d_cs_mt_submit, -+ wined3d_cs_mt_submit_and_wait, - wined3d_cs_mt_push_constants, - }; - --- -2.12.2 - diff --git a/patches/wined3d-CSMT_Main/0031-wined3d-Introduce-a-separate-priority-queue.patch b/patches/wined3d-CSMT_Main/0031-wined3d-Introduce-a-separate-priority-queue.patch index 19446b02..ab617e5f 100644 --- a/patches/wined3d-CSMT_Main/0031-wined3d-Introduce-a-separate-priority-queue.patch +++ b/patches/wined3d-CSMT_Main/0031-wined3d-Introduce-a-separate-priority-queue.patch @@ -1,27 +1,18 @@ -From 66e6b4de0d88527f5b0efb4d6a1658fbe2fcb84b Mon Sep 17 00:00:00 2001 +From b1c1a512a1c51790d0359279014ae616b86238a6 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 8 Feb 2017 00:12:31 +0100 Subject: wined3d: Introduce a separate priority queue. --- - dlls/wined3d/cs.c | 120 +++++++++++++++++++++-------------------- + dlls/wined3d/cs.c | 119 ++++++++++++++++++++++------------------- dlls/wined3d/wined3d_private.h | 6 ++- - 2 files changed, 67 insertions(+), 59 deletions(-) + 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 7dc00ef5d9..9a05359fec 100644 +index 5c444b29bc7..c74fd1749ca 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -428,7 +428,7 @@ void wined3d_cs_emit_sync(struct wined3d_cs *cs) - { - struct wined3d_cs_nop *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_NOP; - - cs->ops->submit_and_wait(cs); -@@ -461,7 +461,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw +@@ -445,7 +445,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw unsigned int i; LONG pending; @@ -30,7 +21,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_PRESENT; op->dst_window_override = dst_window_override; op->swapchain = swapchain; -@@ -524,7 +524,7 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * +@@ -506,7 +506,7 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * struct wined3d_cs_clear *op; unsigned int i; @@ -39,7 +30,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_CLEAR; op->flags = flags; op->rt_count = rt_count; -@@ -560,7 +560,7 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined +@@ -542,7 +542,7 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined struct wined3d_fb_state fb; } *extra; @@ -48,7 +39,7 @@ index 7dc00ef5d9..9a05359fec 100644 extra = (void *)&op->rects[1]; extra->fb.render_targets = &extra->rt; op->fb = &extra->fb; -@@ -716,7 +716,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, +@@ -698,7 +698,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, const struct wined3d_state *state = &cs->device->state; struct wined3d_cs_dispatch *op; @@ -57,7 +48,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_DISPATCH; op->group_count_x = group_count_x; op->group_count_y = group_count_y; -@@ -788,7 +788,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base +@@ -770,7 +770,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base struct wined3d_cs_draw *op; unsigned int i; @@ -66,16 +57,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_DRAW; op->primitive_type = primitive_type; op->base_vertex_idx = base_vertex_idx; -@@ -841,7 +841,7 @@ void wined3d_cs_emit_finish(struct wined3d_cs *cs) - { - struct wined3d_cs_finish *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_FINISH; - - cs->ops->submit_and_wait(cs); -@@ -860,7 +860,7 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) +@@ -824,7 +824,7 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) { struct wined3d_cs_flush *op; @@ -84,7 +66,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_FLUSH; cs->ops->submit(cs); -@@ -878,7 +878,7 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query +@@ -842,7 +842,7 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query { struct wined3d_cs_set_predication *op; @@ -93,7 +75,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_PREDICATION; op->predicate = predicate; op->value = value; -@@ -898,7 +898,7 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi +@@ -862,7 +862,7 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi { struct wined3d_cs_set_viewport *op; @@ -102,7 +84,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_VIEWPORT; op->viewport = *viewport; -@@ -917,7 +917,7 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) +@@ -881,7 +881,7 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) { struct wined3d_cs_set_scissor_rect *op; @@ -111,7 +93,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECT; op->rect = *rect; -@@ -937,7 +937,7 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v +@@ -901,7 +901,7 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v { struct wined3d_cs_set_rendertarget_view *op; @@ -120,7 +102,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW; op->view_idx = view_idx; op->view = view; -@@ -986,7 +986,7 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 +@@ -950,7 +950,7 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 { struct wined3d_cs_set_depth_stencil_view *op; @@ -129,7 +111,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; op->view = view; -@@ -1005,7 +1005,7 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 +@@ -969,7 +969,7 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 { struct wined3d_cs_set_vertex_declaration *op; @@ -138,7 +120,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION; op->declaration = declaration; -@@ -1037,7 +1037,7 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, +@@ -1001,7 +1001,7 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, { struct wined3d_cs_set_stream_source *op; @@ -147,7 +129,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE; op->stream_idx = stream_idx; op->buffer = buffer; -@@ -1063,7 +1063,7 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i +@@ -1027,7 +1027,7 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i { struct wined3d_cs_set_stream_source_freq *op; @@ -156,7 +138,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ; op->stream_idx = stream_idx; op->frequency = frequency; -@@ -1096,7 +1096,7 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, +@@ -1060,7 +1060,7 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, { struct wined3d_cs_set_stream_output *op; @@ -165,7 +147,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT; op->stream_idx = stream_idx; op->buffer = buffer; -@@ -1128,7 +1128,7 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff +@@ -1092,7 +1092,7 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff { struct wined3d_cs_set_index_buffer *op; @@ -174,7 +156,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_INDEX_BUFFER; op->buffer = buffer; op->format_id = format_id; -@@ -1158,7 +1158,7 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha +@@ -1122,7 +1122,7 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha { struct wined3d_cs_set_constant_buffer *op; @@ -183,7 +165,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER; op->type = type; op->cb_idx = cb_idx; -@@ -1250,7 +1250,7 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined +@@ -1214,7 +1214,7 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined { struct wined3d_cs_set_texture *op; @@ -192,7 +174,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_TEXTURE; op->stage = stage; op->texture = texture; -@@ -1282,7 +1282,7 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 +@@ -1246,7 +1246,7 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 { struct wined3d_cs_set_shader_resource_view *op; @@ -201,7 +183,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; op->type = type; op->view_idx = view_idx; -@@ -1312,7 +1312,7 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined +@@ -1276,7 +1276,7 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined { struct wined3d_cs_set_unordered_access_view *op; @@ -210,7 +192,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW; op->pipeline = pipeline; op->view_idx = view_idx; -@@ -1337,7 +1337,7 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type +@@ -1301,7 +1301,7 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type { struct wined3d_cs_set_sampler *op; @@ -219,7 +201,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_SAMPLER; op->type = type; op->sampler_idx = sampler_idx; -@@ -1362,7 +1362,7 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type +@@ -1326,7 +1326,7 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type { struct wined3d_cs_set_shader *op; @@ -228,7 +210,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_SHADER; op->type = type; op->shader = shader; -@@ -1383,7 +1383,7 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, +@@ -1347,7 +1347,7 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, { struct wined3d_cs_set_rasterizer_state *op; @@ -237,7 +219,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE; op->state = rasterizer_state; -@@ -1402,7 +1402,7 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render +@@ -1366,7 +1366,7 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render { struct wined3d_cs_set_render_state *op; @@ -246,7 +228,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_RENDER_STATE; op->state = state; op->value = value; -@@ -1423,7 +1423,7 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, +@@ -1387,7 +1387,7 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, { struct wined3d_cs_set_texture_state *op; @@ -255,7 +237,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_TEXTURE_STATE; op->stage = stage; op->state = state; -@@ -1445,7 +1445,7 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, +@@ -1409,7 +1409,7 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, { struct wined3d_cs_set_sampler_state *op; @@ -264,7 +246,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE; op->sampler_idx = sampler_idx; op->state = state; -@@ -1468,7 +1468,7 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform +@@ -1432,7 +1432,7 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform { struct wined3d_cs_set_transform *op; @@ -273,7 +255,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_TRANSFORM; op->state = state; op->matrix = *matrix; -@@ -1488,7 +1488,7 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const +@@ -1452,7 +1452,7 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const { struct wined3d_cs_set_clip_plane *op; @@ -282,7 +264,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; op->plane_idx = plane_idx; op->plane = *plane; -@@ -1564,7 +1564,7 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture +@@ -1528,7 +1528,7 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture { struct wined3d_cs_set_color_key *op; @@ -291,7 +273,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_COLOR_KEY; op->texture = texture; op->flags = flags; -@@ -1591,7 +1591,7 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma +@@ -1555,7 +1555,7 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma { struct wined3d_cs_set_material *op; @@ -300,7 +282,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_MATERIAL; op->material = *material; -@@ -1639,7 +1639,7 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light +@@ -1603,7 +1603,7 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light { struct wined3d_cs_set_light *op; @@ -309,7 +291,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_LIGHT; op->light = *light; -@@ -1672,7 +1672,7 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B +@@ -1636,7 +1636,7 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B { struct wined3d_cs_set_light_enable *op; @@ -318,7 +300,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE; op->idx = idx; op->enable = enable; -@@ -1737,7 +1737,7 @@ static void wined3d_cs_mt_push_constants(struct wined3d_cs *cs, enum wined3d_pus +@@ -1701,7 +1701,7 @@ static void wined3d_cs_mt_push_constants(struct wined3d_cs *cs, enum wined3d_pus size_t size; size = count * wined3d_cs_push_constant_info[p].size; @@ -327,7 +309,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_PUSH_CONSTANTS; op->type = p; op->start_idx = start_idx; -@@ -1761,7 +1761,7 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) +@@ -1725,7 +1725,7 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) { struct wined3d_cs_reset_state *op; @@ -336,7 +318,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_RESET_STATE; cs->ops->submit(cs); -@@ -1778,7 +1778,7 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi +@@ -1742,7 +1742,7 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi { struct wined3d_cs_callback *op; @@ -345,7 +327,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_CALLBACK; op->callback = callback; op->object = object; -@@ -1839,7 +1839,7 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu +@@ -1803,7 +1803,7 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu { struct wined3d_cs_query_issue *op; @@ -354,7 +336,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_QUERY_ISSUE; op->query = query; op->flags = flags; -@@ -1860,7 +1860,7 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso +@@ -1824,7 +1824,7 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso { struct wined3d_cs_preload_resource *op; @@ -363,7 +345,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_PRELOAD_RESOURCE; op->resource = resource; -@@ -1882,7 +1882,7 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou +@@ -1846,7 +1846,7 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou { struct wined3d_cs_unload_resource *op; @@ -372,25 +354,25 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE; op->resource = resource; -@@ -1906,7 +1906,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, - struct wined3d_cs_map *op; - HRESULT hr; +@@ -1874,7 +1874,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, + * increasing the map count would be visible to applications. */ + wined3d_not_from_cs(cs); - op = cs->ops->require_space(cs, sizeof(*op)); + op = cs->ops->require_space(cs, sizeof(*op), 0); op->opcode = WINED3D_CS_OP_MAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; -@@ -1933,7 +1933,7 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc - struct wined3d_cs_unmap *op; - HRESULT hr; +@@ -1904,7 +1904,7 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc + + wined3d_not_from_cs(cs); - op = cs->ops->require_space(cs, sizeof(*op)); + op = cs->ops->require_space(cs, sizeof(*op), 0); op->opcode = WINED3D_CS_OP_UNMAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; -@@ -2072,7 +2072,7 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso +@@ -2044,7 +2044,7 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso { struct wined3d_cs_blt_sub_resource *op; @@ -399,7 +381,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_BLT_SUB_RESOURCE; op->dst_resource = dst_resource; op->dst_sub_resource_idx = dst_sub_resource_idx; -@@ -2150,7 +2150,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2124,7 +2124,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r { struct wined3d_cs_update_sub_resource *op; @@ -408,7 +390,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; op->resource = resource; op->sub_resource_idx = sub_resource_idx; -@@ -2190,7 +2190,7 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, +@@ -2167,7 +2167,7 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, { struct wined3d_cs_add_dirty_texture_region *op; @@ -417,7 +399,7 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION; op->texture = texture; op->layer = layer; -@@ -2204,7 +2204,7 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) +@@ -2181,11 +2181,10 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) { struct wined3d_cs_stop *op; @@ -426,7 +408,11 @@ index 7dc00ef5d9..9a05359fec 100644 op->opcode = WINED3D_CS_OP_STOP; cs->ops->submit(cs); -@@ -2258,7 +2258,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void +- cs->ops->finish(cs); + } + + static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = +@@ -2235,7 +2234,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region, }; @@ -435,7 +421,7 @@ index 7dc00ef5d9..9a05359fec 100644 { if (size > (cs->data_size - cs->end)) { -@@ -2320,7 +2320,7 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) +@@ -2301,7 +2300,7 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) static void wined3d_cs_mt_submit(struct wined3d_cs *cs) { @@ -444,17 +430,8 @@ index 7dc00ef5d9..9a05359fec 100644 struct wined3d_cs_packet *packet; size_t packet_size; -@@ -2337,7 +2337,7 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - - static void wined3d_cs_mt_submit_and_wait(struct wined3d_cs *cs) - { -- struct wined3d_cs_queue *queue = &cs->queue; -+ struct wined3d_cs_queue *queue = cs->queue; - struct wined3d_cs_packet *packet; - size_t packet_size; - -@@ -2355,15 +2355,15 @@ static void wined3d_cs_mt_submit_and_wait(struct wined3d_cs *cs) - wined3d_pause(); +@@ -2316,15 +2315,15 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) + SetEvent(cs->event); } -static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) @@ -472,7 +449,7 @@ index 7dc00ef5d9..9a05359fec 100644 header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); size = (size + header_size - 1) & ~(header_size - 1); -@@ -2384,7 +2384,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) +@@ -2345,7 +2344,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) TRACE("Inserting a nop for %lu + %lu bytes.\n", (unsigned long)header_size, (unsigned long)nop_size); @@ -481,7 +458,7 @@ index 7dc00ef5d9..9a05359fec 100644 if (nop_size) nop->opcode = WINED3D_CS_OP_NOP; -@@ -2415,6 +2415,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) +@@ -2376,6 +2375,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) head, tail, (unsigned long)packet_size); } @@ -489,7 +466,18 @@ index 7dc00ef5d9..9a05359fec 100644 packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; packet->size = size; return packet->data; -@@ -2443,6 +2444,13 @@ static void poll_queries(struct wined3d_cs *cs) +@@ -2386,7 +2386,9 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs) + if (cs->thread_id == GetCurrentThreadId()) + return wined3d_cs_st_finish(cs); + +- while (!wined3d_cs_queue_is_empty(&cs->queue)) ++ while (!wined3d_cs_queue_is_empty(&cs->prio_queue)) ++ wined3d_pause(); ++ while (!wined3d_cs_queue_is_empty(&cs->norm_queue)) + wined3d_pause(); + } + +@@ -2413,6 +2415,13 @@ static void poll_queries(struct wined3d_cs *cs) } } @@ -503,7 +491,7 @@ index 7dc00ef5d9..9a05359fec 100644 static void wined3d_cs_wait_event(struct wined3d_cs *cs) { InterlockedExchange(&cs->waiting_for_event, TRUE); -@@ -2454,7 +2462,7 @@ static void wined3d_cs_wait_event(struct wined3d_cs *cs) +@@ -2424,7 +2433,7 @@ static void wined3d_cs_wait_event(struct wined3d_cs *cs) * Likewise, we can race with the main thread when resetting * "waiting_for_event", in which case we would need to call * WaitForSingleObject() because the main thread called SetEvent(). */ @@ -512,7 +500,7 @@ index 7dc00ef5d9..9a05359fec 100644 && InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) return; -@@ -2473,7 +2481,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2443,7 +2452,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) TRACE("Started.\n"); @@ -520,7 +508,7 @@ index 7dc00ef5d9..9a05359fec 100644 list_init(&cs->query_poll_list); cs->thread_id = GetCurrentThreadId(); for (;;) -@@ -2484,7 +2491,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2454,7 +2462,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) poll = 0; } @@ -529,7 +517,7 @@ index 7dc00ef5d9..9a05359fec 100644 { if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list)) wined3d_cs_wait_event(cs); -@@ -2513,7 +2520,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2483,7 +2491,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) InterlockedExchange(&queue->tail, tail); } @@ -538,19 +526,19 @@ index 7dc00ef5d9..9a05359fec 100644 FreeLibraryAndExitThread(cs->wined3d_module, 0); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index 9bb7a791e6..5aef1a9b06 100644 +index 9ef6c9ea692..eca14c4a819 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h -@@ -3259,7 +3259,7 @@ struct wined3d_cs_queue +@@ -3265,7 +3265,7 @@ struct wined3d_cs_queue struct wined3d_cs_ops { - void *(*require_space)(struct wined3d_cs *cs, size_t size); + void *(*require_space)(struct wined3d_cs *cs, size_t size, int priority); void (*submit)(struct wined3d_cs *cs); - void (*submit_and_wait)(struct wined3d_cs *cs); + void (*finish)(struct wined3d_cs *cs); void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p, -@@ -3276,7 +3276,9 @@ struct wined3d_cs +@@ -3282,7 +3282,9 @@ struct wined3d_cs HANDLE thread; DWORD thread_id; diff --git a/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch b/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch index df43216c..92b4cb4b 100644 --- a/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch +++ b/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch @@ -1,4 +1,4 @@ -From 4dfea261298432bd9f02c415e99ba770c9c3fe21 Mon Sep 17 00:00:00 2001 +From 1ad08ef9f2b5f2830990b179bb38041212b3459e Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 8 Feb 2017 00:21:56 +0100 Subject: wined3d: Use priority queue for maps/unmaps. @@ -9,21 +9,21 @@ Subject: wined3d: Use priority queue for maps/unmaps. 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index b874b1f41f2..3e7defdeb1b 100644 +index c74fd1749ca..cb49f38acd3 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -1800,7 +1800,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, - struct wined3d_cs_map *op; - HRESULT hr; +@@ -1874,7 +1874,7 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, + * increasing the map count would be visible to applications. */ + wined3d_not_from_cs(cs); - op = cs->ops->require_space(cs, sizeof(*op), 0); + op = cs->ops->require_space(cs, sizeof(*op), 1); op->opcode = WINED3D_CS_OP_MAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; -@@ -1829,7 +1829,7 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc - struct wined3d_cs_unmap *op; - HRESULT hr; +@@ -1904,7 +1904,7 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc + + wined3d_not_from_cs(cs); - op = cs->ops->require_space(cs, sizeof(*op), 0); + op = cs->ops->require_space(cs, sizeof(*op), 1); @@ -31,10 +31,10 @@ index b874b1f41f2..3e7defdeb1b 100644 op->resource = resource; op->sub_resource_idx = sub_resource_idx; diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c -index 1f465fa1f2f..b64147aa437 100644 +index e343067f943..fffa6fbf25c 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c -@@ -356,6 +356,9 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i +@@ -363,6 +363,9 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i flags = wined3d_resource_sanitise_map_flags(resource, flags); @@ -44,7 +44,7 @@ index 1f465fa1f2f..b64147aa437 100644 return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags); } -@@ -371,6 +374,9 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned +@@ -378,6 +381,9 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned { TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); @@ -55,5 +55,5 @@ index 1f465fa1f2f..b64147aa437 100644 } -- -2.11.0 +2.12.2 diff --git a/patches/wined3d-CSMT_Main/0043-wined3d-Synchronize-before-resizing-swapchain-contex.patch b/patches/wined3d-CSMT_Main/0043-wined3d-Synchronize-before-resizing-swapchain-contex.patch deleted file mode 100644 index 965d2001..00000000 --- a/patches/wined3d-CSMT_Main/0043-wined3d-Synchronize-before-resizing-swapchain-contex.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 8f135be1edd72169ffdf5f1e500909bc75661823 Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Sun, 19 Feb 2017 08:30:44 +0100 -Subject: wined3d: Synchronize before resizing swapchain context array. - ---- - dlls/wined3d/swapchain.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c -index 5963d7222f2..f7acf81bde2 100644 ---- a/dlls/wined3d/swapchain.c -+++ b/dlls/wined3d/swapchain.c -@@ -1125,6 +1125,8 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain - - TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId()); - -+ wined3d_cs_emit_sync(swapchain->device->cs); -+ - if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format))) - { - ERR("Failed to create a new context for the swapchain\n"); --- -2.11.0 - diff --git a/patches/wined3d-CSMT_Main/0045-wined3d-Improve-wined3d_cs_emit_update_sub_resource.patch b/patches/wined3d-CSMT_Main/0045-wined3d-Improve-wined3d_cs_emit_update_sub_resource.patch index 74f45384..9a4ef6d2 100644 --- a/patches/wined3d-CSMT_Main/0045-wined3d-Improve-wined3d_cs_emit_update_sub_resource.patch +++ b/patches/wined3d-CSMT_Main/0045-wined3d-Improve-wined3d_cs_emit_update_sub_resource.patch @@ -1,4 +1,4 @@ -From 10c158a6010bc2aa8699701626fbba3945e50611 Mon Sep 17 00:00:00 2001 +From e17eeff3044b2a6417c3232b3e8a5fe4e28b059e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Mon, 20 Feb 2017 00:27:25 +0100 Subject: wined3d: Improve wined3d_cs_emit_update_sub_resource. @@ -10,10 +10,10 @@ Subject: wined3d: Improve wined3d_cs_emit_update_sub_resource. 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 1d5e221292..cf3ea9f9ab 100644 +index c8bd8adc82e..7a380905179 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -406,6 +406,7 @@ struct wined3d_cs_update_sub_resource +@@ -400,6 +400,7 @@ struct wined3d_cs_update_sub_resource unsigned int sub_resource_idx; struct wined3d_box box; struct wined3d_sub_resource_data data; @@ -21,7 +21,7 @@ index 1d5e221292..cf3ea9f9ab 100644 }; struct wined3d_cs_add_dirty_texture_region -@@ -2149,6 +2150,49 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2123,6 +2124,49 @@ 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; @@ -71,7 +71,7 @@ index 1d5e221292..cf3ea9f9ab 100644 op = cs->ops->require_space(cs, sizeof(*op), 1); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; -@@ -2258,6 +2302,11 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void +@@ -2234,6 +2278,11 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region, }; @@ -83,16 +83,16 @@ index 1d5e221292..cf3ea9f9ab 100644 static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, int priority) { if (size > (cs->data_size - cs->end)) -@@ -2307,6 +2356,7 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs) +@@ -2287,6 +2336,7 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs) static const struct wined3d_cs_ops wined3d_cs_st_ops = { + wined3d_cs_st_check_space, wined3d_cs_st_require_space, wined3d_cs_st_submit, - wined3d_cs_st_submit, -@@ -2355,6 +2405,23 @@ static void wined3d_cs_mt_submit_and_wait(struct wined3d_cs *cs) - wined3d_pause(); + wined3d_cs_st_finish, +@@ -2315,6 +2365,23 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) + SetEvent(cs->event); } +static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, int priority) @@ -115,19 +115,19 @@ index 1d5e221292..cf3ea9f9ab 100644 static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, int priority) { struct wined3d_cs_queue *queue = priority ? &cs->prio_queue : &cs->norm_queue; -@@ -2423,6 +2490,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, int +@@ -2394,6 +2461,7 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs) static const struct wined3d_cs_ops wined3d_cs_mt_ops = { + wined3d_cs_mt_check_space, wined3d_cs_mt_require_space, wined3d_cs_mt_submit, - wined3d_cs_mt_submit_and_wait, + wined3d_cs_mt_finish, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index e3fd896e39..5fceafdb13 100644 +index 26872ec5ec5..44e9a18fd22 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -4119,8 +4119,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str +@@ -4256,8 +4256,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str TRACE("device %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, depth_pitch %u.\n", device, resource, sub_resource_idx, debug_box(box), data, row_pitch, depth_pitch); @@ -137,17 +137,17 @@ index e3fd896e39..5fceafdb13 100644 { if (sub_resource_idx > 0) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index 8f6d720902..f0b07a6a64 100644 +index eca14c4a819..bde0e9f47b9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h -@@ -3258,6 +3258,7 @@ struct wined3d_cs_queue +@@ -3265,6 +3265,7 @@ struct wined3d_cs_queue struct wined3d_cs_ops { + BOOL (*check_space)(struct wined3d_cs *cs, size_t size, int priority); void *(*require_space)(struct wined3d_cs *cs, size_t size, int priority); void (*submit)(struct wined3d_cs *cs); - void (*submit_and_wait)(struct wined3d_cs *cs); + void (*finish)(struct wined3d_cs *cs); -- 2.12.2 diff --git a/patches/wined3d-CSMT_Main/9999-IfDefined.patch b/patches/wined3d-CSMT_Main/9999-IfDefined.patch index ea65fa6f..0013c222 100644 --- a/patches/wined3d-CSMT_Main/9999-IfDefined.patch +++ b/patches/wined3d-CSMT_Main/9999-IfDefined.patch @@ -37,31 +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 -@@ -31,6 +31,9 @@ enum wined3d_cs_op - WINED3D_CS_OP_CLEAR, - WINED3D_CS_OP_DISPATCH, - WINED3D_CS_OP_DRAW, -+#if defined(STAGING_CSMT) -+ WINED3D_CS_OP_FINISH, -+#endif /* STAGING_CSMT */ - WINED3D_CS_OP_FLUSH, - WINED3D_CS_OP_SET_PREDICATION, - WINED3D_CS_OP_SET_VIEWPORT, -@@ -127,6 +130,13 @@ struct wined3d_cs_draw - BOOL indexed; - }; - -+#if defined(STAGING_CSMT) -+struct wined3d_cs_finish -+{ -+ enum wined3d_cs_op opcode; -+}; -+ -+#endif /* STAGING_CSMT */ - struct wined3d_cs_flush - { - enum wined3d_cs_op opcode; -@@ -400,6 +410,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; @@ -71,77 +47,19 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c }; struct wined3d_cs_add_dirty_texture_region -@@ -418,6 +431,18 @@ static void wined3d_cs_exec_nop(struct wined3d_cs *cs, const void *data) - { - } - -+#if defined(STAGING_CSMT) -+void wined3d_cs_emit_sync(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_nop *op; -+ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+ op->opcode = WINED3D_CS_OP_NOP; -+ -+ cs->ops->submit_and_wait(cs); -+} -+ -+#endif /* STAGING_CSMT */ - static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - { - const struct wined3d_cs_present *op = data; -@@ -429,6 +454,10 @@ static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - - swapchain->swapchain_ops->swapchain_present(swapchain, &op->src_rect, &op->dst_rect, op->flags); - -+#if defined(STAGING_CSMT) -+ InterlockedDecrement(&cs->pending_presents); -+ -+#endif /* STAGING_CSMT */ - wined3d_resource_release(&swapchain->front_buffer->resource); - for (i = 0; i < swapchain->desc.backbuffer_count; ++i) - { -@@ -441,8 +470,14 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - { - struct wined3d_cs_present *op; +@@ -445,7 +448,11 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw unsigned int i; -+#if !defined(STAGING_CSMT) + LONG pending; ++#if !defined(STAGING_CSMT) op = cs->ops->require_space(cs, sizeof(*op)); +#else /* STAGING_CSMT */ -+ LONG pending; -+ + op = cs->ops->require_space(cs, sizeof(*op), 0); +#endif /* STAGING_CSMT */ op->opcode = WINED3D_CS_OP_PRESENT; op->dst_window_override = dst_window_override; op->swapchain = swapchain; -@@ -456,7 +491,24 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - wined3d_resource_acquire(&swapchain->back_buffers[i]->resource); - } - -+#if !defined(STAGING_CSMT) - cs->ops->submit(cs); -+#else /* STAGING_CSMT */ -+ pending = InterlockedIncrement(&cs->pending_presents); -+ -+ cs->ops->submit(cs); -+ -+ /* D3D10 documentation suggests that Windows allows the game to run -+ * 3 frames ahead of the GPU. Increasing this above 1 causes uneven -+ * animation in some games, most notably StarCraft II. The framerates -+ * don't show this problem. The issue is more noticable with vsync -+ * on, but also happens with vsync off. -+ * -+ * In Counter-Strike: Source a frame difference of 3 causes noticable -+ * input delay that makes the game unplayable. */ -+ while (pending > 1) -+ pending = InterlockedCompareExchange(&cs->pending_presents, 0, 0); -+#endif /* STAGING_CSMT */ - } - - static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data) -@@ -492,7 +544,11 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * +@@ -506,7 +513,11 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * struct wined3d_cs_clear *op; unsigned int i; @@ -153,7 +71,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_CLEAR; op->flags = flags; op->rt_count = rt_count; -@@ -528,7 +584,11 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined +@@ -542,7 +553,11 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined struct wined3d_fb_state fb; } *extra; @@ -165,7 +83,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c extra = (void *)&op->rects[1]; extra->fb.render_targets = &extra->rt; op->fb = &extra->fb; -@@ -684,7 +744,11 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, +@@ -698,7 +713,11 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, const struct wined3d_state *state = &cs->device->state; struct wined3d_cs_dispatch *op; @@ -177,7 +95,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_DISPATCH; op->group_count_x = group_count_x; op->group_count_y = group_count_y; -@@ -756,7 +820,11 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base +@@ -770,7 +789,11 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base struct wined3d_cs_draw *op; unsigned int i; @@ -189,34 +107,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_DRAW; op->primitive_type = primitive_type; op->base_vertex_idx = base_vertex_idx; -@@ -797,6 +865,26 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base - cs->ops->submit(cs); - } - -+#if defined(STAGING_CSMT) -+static void wined3d_cs_exec_finish(struct wined3d_cs *cs, const void *data) -+{ -+ struct wined3d_context *context = context_get_current(); -+ -+ if (context) -+ context->gl_info->gl_ops.gl.p_glFinish(); -+} -+ -+void wined3d_cs_emit_finish(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_finish *op; -+ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+ op->opcode = WINED3D_CS_OP_FINISH; -+ -+ cs->ops->submit_and_wait(cs); -+} -+ -+#endif /* STAGING_CSMT */ - static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data) - { - struct wined3d_context *context; -@@ -810,7 +898,11 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) +@@ -824,7 +847,11 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) { struct wined3d_cs_flush *op; @@ -228,7 +119,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_FLUSH; cs->ops->submit(cs); -@@ -828,7 +920,11 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query +@@ -842,7 +869,11 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query { struct wined3d_cs_set_predication *op; @@ -240,7 +131,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_PREDICATION; op->predicate = predicate; op->value = value; -@@ -848,7 +944,11 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi +@@ -862,7 +893,11 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi { struct wined3d_cs_set_viewport *op; @@ -252,7 +143,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_VIEWPORT; op->viewport = *viewport; -@@ -867,7 +967,11 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) +@@ -881,7 +916,11 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) { struct wined3d_cs_set_scissor_rect *op; @@ -264,7 +155,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECT; op->rect = *rect; -@@ -887,7 +991,11 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v +@@ -901,7 +940,11 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v { struct wined3d_cs_set_rendertarget_view *op; @@ -276,7 +167,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW; op->view_idx = view_idx; op->view = view; -@@ -936,7 +1044,11 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 +@@ -950,7 +993,11 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 { struct wined3d_cs_set_depth_stencil_view *op; @@ -288,7 +179,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; op->view = view; -@@ -955,7 +1067,11 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 +@@ -969,7 +1016,11 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 { struct wined3d_cs_set_vertex_declaration *op; @@ -300,7 +191,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION; op->declaration = declaration; -@@ -987,7 +1103,11 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, +@@ -1001,7 +1052,11 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, { struct wined3d_cs_set_stream_source *op; @@ -312,7 +203,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE; op->stream_idx = stream_idx; op->buffer = buffer; -@@ -1013,7 +1133,11 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i +@@ -1027,7 +1082,11 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i { struct wined3d_cs_set_stream_source_freq *op; @@ -324,7 +215,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ; op->stream_idx = stream_idx; op->frequency = frequency; -@@ -1046,7 +1170,11 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, +@@ -1060,7 +1119,11 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, { struct wined3d_cs_set_stream_output *op; @@ -336,7 +227,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT; op->stream_idx = stream_idx; op->buffer = buffer; -@@ -1078,7 +1206,11 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff +@@ -1092,7 +1155,11 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff { struct wined3d_cs_set_index_buffer *op; @@ -348,7 +239,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_INDEX_BUFFER; op->buffer = buffer; op->format_id = format_id; -@@ -1108,7 +1240,11 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha +@@ -1122,7 +1189,11 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha { struct wined3d_cs_set_constant_buffer *op; @@ -360,7 +251,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER; op->type = type; op->cb_idx = cb_idx; -@@ -1200,7 +1336,11 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined +@@ -1214,7 +1285,11 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined { struct wined3d_cs_set_texture *op; @@ -372,7 +263,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_TEXTURE; op->stage = stage; op->texture = texture; -@@ -1232,7 +1372,11 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 +@@ -1246,7 +1321,11 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 { struct wined3d_cs_set_shader_resource_view *op; @@ -384,7 +275,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; op->type = type; op->view_idx = view_idx; -@@ -1262,7 +1406,11 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined +@@ -1276,7 +1355,11 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined { struct wined3d_cs_set_unordered_access_view *op; @@ -396,7 +287,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW; op->pipeline = pipeline; op->view_idx = view_idx; -@@ -1287,7 +1435,11 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type +@@ -1301,7 +1384,11 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type { struct wined3d_cs_set_sampler *op; @@ -408,7 +299,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_SAMPLER; op->type = type; op->sampler_idx = sampler_idx; -@@ -1312,7 +1464,11 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type +@@ -1326,7 +1413,11 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type { struct wined3d_cs_set_shader *op; @@ -420,7 +311,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_SHADER; op->type = type; op->shader = shader; -@@ -1333,7 +1489,11 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, +@@ -1347,7 +1438,11 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, { struct wined3d_cs_set_rasterizer_state *op; @@ -432,7 +323,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE; op->state = rasterizer_state; -@@ -1352,7 +1512,11 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render +@@ -1366,7 +1461,11 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render { struct wined3d_cs_set_render_state *op; @@ -444,7 +335,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_RENDER_STATE; op->state = state; op->value = value; -@@ -1373,7 +1537,11 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, +@@ -1387,7 +1486,11 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, { struct wined3d_cs_set_texture_state *op; @@ -456,7 +347,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_TEXTURE_STATE; op->stage = stage; op->state = state; -@@ -1395,7 +1563,11 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, +@@ -1409,7 +1512,11 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, { struct wined3d_cs_set_sampler_state *op; @@ -468,7 +359,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE; op->sampler_idx = sampler_idx; op->state = state; -@@ -1418,7 +1590,11 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform +@@ -1432,7 +1539,11 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform { struct wined3d_cs_set_transform *op; @@ -480,7 +371,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_TRANSFORM; op->state = state; op->matrix = *matrix; -@@ -1438,7 +1614,11 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const +@@ -1452,7 +1563,11 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const { struct wined3d_cs_set_clip_plane *op; @@ -492,7 +383,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; op->plane_idx = plane_idx; op->plane = *plane; -@@ -1514,7 +1694,11 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture +@@ -1528,7 +1643,11 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture { struct wined3d_cs_set_color_key *op; @@ -504,7 +395,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_COLOR_KEY; op->texture = texture; op->flags = flags; -@@ -1541,7 +1725,11 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma +@@ -1555,7 +1674,11 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma { struct wined3d_cs_set_material *op; @@ -516,7 +407,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_MATERIAL; op->material = *material; -@@ -1589,7 +1777,11 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light +@@ -1603,7 +1726,11 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light { struct wined3d_cs_set_light *op; @@ -528,7 +419,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_LIGHT; op->light = *light; -@@ -1622,7 +1814,11 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B +@@ -1636,7 +1763,11 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B { struct wined3d_cs_set_light_enable *op; @@ -540,7 +431,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE; op->idx = idx; op->enable = enable; -@@ -1687,7 +1883,11 @@ static void wined3d_cs_mt_push_constants(struct wined3d_cs *cs, enum wined3d_pus +@@ -1701,7 +1832,11 @@ static void wined3d_cs_mt_push_constants(struct wined3d_cs *cs, enum wined3d_pus size_t size; size = count * wined3d_cs_push_constant_info[p].size; @@ -552,7 +443,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_PUSH_CONSTANTS; op->type = p; op->start_idx = start_idx; -@@ -1711,7 +1911,11 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) +@@ -1725,7 +1860,11 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) { struct wined3d_cs_reset_state *op; @@ -564,7 +455,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_RESET_STATE; cs->ops->submit(cs); -@@ -1728,7 +1932,11 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi +@@ -1742,7 +1881,11 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi { struct wined3d_cs_callback *op; @@ -576,7 +467,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_CALLBACK; op->callback = callback; op->object = object; -@@ -1789,7 +1997,11 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu +@@ -1803,7 +1946,11 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu { struct wined3d_cs_query_issue *op; @@ -588,7 +479,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_QUERY_ISSUE; op->query = query; op->flags = flags; -@@ -1810,7 +2022,11 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso +@@ -1824,7 +1971,11 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso { struct wined3d_cs_preload_resource *op; @@ -600,7 +491,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_PRELOAD_RESOURCE; op->resource = resource; -@@ -1832,7 +2048,11 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou +@@ -1846,7 +1997,11 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou { struct wined3d_cs_unload_resource *op; @@ -612,9 +503,9 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE; op->resource = resource; -@@ -1856,7 +2076,11 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, - struct wined3d_cs_map *op; - HRESULT hr; +@@ -1874,7 +2029,11 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, + * increasing the map count would be visible to applications. */ + wined3d_not_from_cs(cs); +#if !defined(STAGING_CSMT) op = cs->ops->require_space(cs, sizeof(*op)); @@ -624,21 +515,9 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_MAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; -@@ -1865,7 +2089,11 @@ HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, - op->flags = flags; - op->hr = &hr; +@@ -1904,7 +2063,11 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc -+#if !defined(STAGING_CSMT) - cs->ops->submit(cs); -+#else /* STAGING_CSMT */ -+ cs->ops->submit_and_wait(cs); -+#endif /* STAGING_CSMT */ - - return hr; - } -@@ -1883,13 +2111,21 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc - struct wined3d_cs_unmap *op; - HRESULT hr; + wined3d_not_from_cs(cs); +#if !defined(STAGING_CSMT) op = cs->ops->require_space(cs, sizeof(*op)); @@ -648,17 +527,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_UNMAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; - op->hr = &hr; - -+#if !defined(STAGING_CSMT) - cs->ops->submit(cs); -+#else /* STAGING_CSMT */ -+ cs->ops->submit_and_wait(cs); -+#endif /* STAGING_CSMT */ - - return hr; - } -@@ -2022,7 +2258,11 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso +@@ -2044,7 +2207,11 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso { struct wined3d_cs_blt_sub_resource *op; @@ -670,7 +539,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_BLT_SUB_RESOURCE; op->dst_resource = dst_resource; op->dst_sub_resource_idx = dst_sub_resource_idx; -@@ -2099,19 +2339,73 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2123,8 +2290,56 @@ 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; @@ -705,46 +574,29 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c + goto no_async; + + op = cs->ops->require_space(cs, size, 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; - op->box = *box; - op->data.row_pitch = row_pitch; - op->data.slice_pitch = slice_pitch; -+#if !defined(STAGING_CSMT) - op->data.data = data; -+#else /* STAGING_CSMT */ -+ op->data.data = op->copy_data; -+ memcpy(op->copy_data, data, data_size); -+#endif /* STAGING_CSMT */ - - wined3d_resource_acquire(resource); - - cs->ops->submit(cs); -+#if defined(STAGING_CSMT) -+ return; -+ -+no_async: -+ wined3d_resource_wait_idle(resource); -+ -+ op = cs->ops->require_space(cs, sizeof(*op), 1); + op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; + op->resource = resource; + op->sub_resource_idx = sub_resource_idx; + op->box = *box; + op->data.row_pitch = row_pitch; + op->data.slice_pitch = slice_pitch; -+ op->data.data = data; ++ op->data.data = op->copy_data; ++ memcpy(op->copy_data, data, data_size); + + wined3d_resource_acquire(resource); + -+ cs->ops->submit_and_wait(cs); ++ cs->ops->submit(cs); ++ return; ++ ++no_async: ++ wined3d_resource_wait_idle(resource); ++ ++ op = cs->ops->require_space(cs, sizeof(*op), 1); +#endif /* STAGING_CSMT */ - } - - static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data) -@@ -2140,7 +2434,11 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, + op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; + op->resource = resource; + op->sub_resource_idx = sub_resource_idx; +@@ -2167,7 +2382,11 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, { struct wined3d_cs_add_dirty_texture_region *op; @@ -756,7 +608,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION; op->texture = texture; op->layer = layer; -@@ -2154,7 +2452,11 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) +@@ -2181,11 +2400,17 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) { struct wined3d_cs_stop *op; @@ -768,17 +620,13 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c op->opcode = WINED3D_CS_OP_STOP; cs->ops->submit(cs); -@@ -2167,6 +2469,9 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void - /* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear, - /* WINED3D_CS_OP_DISPATCH */ wined3d_cs_exec_dispatch, - /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, -+#if defined(STAGING_CSMT) -+ /* WINED3D_CS_OP_FINISH */ wined3d_cs_exec_finish, ++#if !defined(STAGING_CSMT) + cs->ops->finish(cs); +#endif /* STAGING_CSMT */ - /* WINED3D_CS_OP_FLUSH */ wined3d_cs_exec_flush, - /* WINED3D_CS_OP_SET_PREDICATION */ wined3d_cs_exec_set_predication, - /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, -@@ -2207,7 +2512,16 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void + } + + static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = +@@ -2235,7 +2460,16 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region, }; @@ -795,21 +643,17 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c { if (size > (cs->data_size - cs->end)) { -@@ -2256,7 +2570,13 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs) +@@ -2288,6 +2522,9 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs) static const struct wined3d_cs_ops wined3d_cs_st_ops = { -+#if !defined(STAGING_CSMT) - wined3d_cs_st_require_space, -+#else /* STAGING_CSMT */ ++#if defined(STAGING_CSMT) + wined3d_cs_st_check_space, -+ wined3d_cs_st_require_space, -+ wined3d_cs_st_submit, +#endif /* STAGING_CSMT */ + wined3d_cs_st_require_space, wined3d_cs_st_submit, - wined3d_cs_st_push_constants, - }; -@@ -2268,7 +2588,28 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) + wined3d_cs_st_finish, +@@ -2301,7 +2538,11 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) static void wined3d_cs_mt_submit(struct wined3d_cs *cs) { @@ -817,29 +661,12 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c struct wined3d_cs_queue *queue = &cs->queue; +#else /* STAGING_CSMT */ + struct wined3d_cs_queue *queue = cs->queue; -+ struct wined3d_cs_packet *packet; -+ size_t packet_size; -+ -+ if (cs->thread_id == GetCurrentThreadId()) -+ return wined3d_cs_st_submit(cs); -+ -+ packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; -+ packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[packet->size]); -+ InterlockedExchange(&queue->head, (queue->head + packet_size) & (WINED3D_CS_QUEUE_SIZE - 1)); -+ -+ if (InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) -+ SetEvent(cs->event); -+} -+ -+static void wined3d_cs_mt_submit_and_wait(struct wined3d_cs *cs) -+{ -+ struct wined3d_cs_queue *queue = cs->queue; +#endif /* STAGING_CSMT */ struct wined3d_cs_packet *packet; size_t packet_size; -@@ -2286,15 +2627,42 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - wined3d_pause(); +@@ -2316,15 +2557,42 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) + SetEvent(cs->event); } +#if !defined(STAGING_CSMT) @@ -881,7 +708,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); size = (size + header_size - 1) & ~(header_size - 1); -@@ -2315,7 +2683,11 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) +@@ -2345,7 +2613,11 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) TRACE("Inserting a nop for %lu + %lu bytes.\n", (unsigned long)header_size, (unsigned long)nop_size); @@ -893,7 +720,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c if (nop_size) nop->opcode = WINED3D_CS_OP_NOP; -@@ -2346,6 +2718,9 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) +@@ -2376,6 +2648,9 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) head, tail, (unsigned long)packet_size); } @@ -903,23 +730,29 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; packet->size = size; return packet->data; -@@ -2353,8 +2728,15 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) +@@ -2386,12 +2661,21 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs) + if (cs->thread_id == GetCurrentThreadId()) + return wined3d_cs_st_finish(cs); + ++#if !defined(STAGING_CSMT) + while (!wined3d_cs_queue_is_empty(&cs->queue)) ++#else /* STAGING_CSMT */ ++ while (!wined3d_cs_queue_is_empty(&cs->prio_queue)) ++ wined3d_pause(); ++ while (!wined3d_cs_queue_is_empty(&cs->norm_queue)) ++#endif /* STAGING_CSMT */ + wined3d_pause(); + } static const struct wined3d_cs_ops wined3d_cs_mt_ops = { -+#if !defined(STAGING_CSMT) -+ wined3d_cs_mt_require_space, -+ wined3d_cs_mt_submit, -+#else /* STAGING_CSMT */ ++#if defined(STAGING_CSMT) + wined3d_cs_mt_check_space, ++#endif /* STAGING_CSMT */ wined3d_cs_mt_require_space, wined3d_cs_mt_submit, -+ wined3d_cs_mt_submit_and_wait, -+#endif /* STAGING_CSMT */ - wined3d_cs_mt_push_constants, - }; - -@@ -2373,6 +2755,15 @@ static void poll_queries(struct wined3d_cs *cs) + wined3d_cs_mt_finish, +@@ -2413,6 +2697,15 @@ static void poll_queries(struct wined3d_cs *cs) } } @@ -935,7 +768,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c static void wined3d_cs_wait_event(struct wined3d_cs *cs) { InterlockedExchange(&cs->waiting_for_event, TRUE); -@@ -2384,7 +2775,11 @@ static void wined3d_cs_wait_event(struct wined3d_cs *cs) +@@ -2424,7 +2717,11 @@ static void wined3d_cs_wait_event(struct wined3d_cs *cs) * Likewise, we can race with the main thread when resetting * "waiting_for_event", in which case we would need to call * WaitForSingleObject() because the main thread called SetEvent(). */ @@ -947,7 +780,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c && InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) return; -@@ -2403,7 +2798,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2443,7 +2740,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) TRACE("Started.\n"); @@ -957,7 +790,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c list_init(&cs->query_poll_list); cs->thread_id = GetCurrentThreadId(); for (;;) -@@ -2414,7 +2811,11 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2454,7 +2753,11 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) poll = 0; } @@ -969,7 +802,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c { if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list)) wined3d_cs_wait_event(cs); -@@ -2443,7 +2844,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) +@@ -2483,7 +2786,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) InterlockedExchange(&queue->tail, tail); } @@ -979,7 +812,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c TRACE("Stopped.\n"); FreeLibraryAndExitThread(cs->wined3d_module, 0); } -@@ -2514,17 +2917,28 @@ fail: +@@ -2554,17 +2859,28 @@ fail: void wined3d_cs_destroy(struct wined3d_cs *cs) { @@ -1011,38 +844,7 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -1023,6 +1023,9 @@ static void wined3d_device_delete_opengl_contexts_cs(void *object) - static void wined3d_device_delete_opengl_contexts(struct wined3d_device *device) - { - wined3d_cs_destroy_object(device->cs, wined3d_device_delete_opengl_contexts_cs, device); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - } - - static void wined3d_device_create_primary_opengl_context_cs(void *object) -@@ -1061,6 +1064,9 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object) - static HRESULT wined3d_device_create_primary_opengl_context(struct wined3d_device *device) - { - wined3d_cs_init_object(device->cs, wined3d_device_create_primary_opengl_context_cs, device); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - if (!device->swapchains[0]->num_contexts) - return E_FAIL; - -@@ -1205,6 +1211,10 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) - if (!device->d3d_initialized) - return WINED3DERR_INVALIDCALL; - -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+ -+#endif /* STAGING_CSMT */ - if (device->logo_texture) - wined3d_texture_decref(device->logo_texture); - if (device->cursor_texture) -@@ -1214,6 +1224,9 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) +@@ -1218,6 +1218,9 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) wine_rb_clear(&device->samplers, device_free_sampler, NULL); @@ -1052,7 +854,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c wined3d_device_delete_opengl_contexts(device); if (device->fb.depth_stencil) -@@ -4195,6 +4208,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4199,6 +4202,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } @@ -1060,7 +862,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c if (dst_texture->sub_resources[dst_sub_resource_idx].map_count) { WARN("Destination sub-resource %u is mapped.\n", dst_sub_resource_idx); -@@ -4205,6 +4219,18 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4209,6 +4213,19 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev { WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx); return WINED3DERR_INVALIDCALL; @@ -1068,7 +870,8 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || + src_texture->sub_resources[src_sub_resource_idx].map_count) + { -+ wined3d_cs_emit_sync(dst_texture->resource.device->cs); ++ struct wined3d_device *device = dst_texture->resource.device; ++ device->cs->ops->finish(device->cs); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || + src_texture->sub_resources[src_sub_resource_idx].map_count) + { @@ -1079,7 +882,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c } if (!src_box) -@@ -5236,3 +5262,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL +@@ -5242,3 +5259,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL else return CallWindowProcA(proc, window, message, wparam, lparam); } @@ -1183,30 +986,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 -@@ -66,6 +66,9 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) - } - - wined3d_cs_destroy_object(swapchain->device->cs, wined3d_swapchain_destroy_object, swapchain); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(swapchain->device->cs); -+#endif /* STAGING_CSMT */ - - /* Restore the screen resolution if we rendered in fullscreen. - * This will restore the screen resolution to what it was before creating -@@ -113,6 +116,12 @@ ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain) - - if (!refcount) - { -+#if defined(STAGING_CSMT) -+ struct wined3d_device *device = swapchain->device; -+ -+ wined3d_cs_emit_sync(device->cs); -+ -+#endif /* STAGING_CSMT */ - swapchain_cleanup(swapchain); - swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent); - HeapFree(GetProcessHeap(), 0, swapchain); -@@ -477,7 +486,11 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, +@@ -482,7 +482,11 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, swapchain_blit(swapchain, context, src_rect, dst_rect); } @@ -1218,48 +998,6 @@ diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c gl_info->gl_ops.gl.p_glFinish(); /* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */ -@@ -900,6 +913,9 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 - } - - wined3d_cs_init_object(device->cs, wined3d_swapchain_cs_init, swapchain); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - - if (!swapchain->context[0]) - { -@@ -1040,6 +1056,10 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain - - TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId()); - -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(swapchain->device->cs); -+ -+#endif /* STAGING_CSMT */ - if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format))) - { - ERR("Failed to create a new context for the swapchain\n"); -@@ -1189,6 +1209,9 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha - enum wined3d_multisample_type multisample_type, unsigned int multisample_quality) - { - BOOL update_desc = FALSE; -+#if defined(STAGING_CSMT) -+ struct wined3d_device *device = swapchain->device; -+#endif /* STAGING_CSMT */ - - TRACE("swapchain %p, buffer_count %u, width %u, height %u, format %s, " - "multisample_type %#x, multisample_quality %#x.\n", -@@ -1200,6 +1223,10 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha - if (buffer_count && buffer_count != swapchain->desc.backbuffer_count) - FIXME("Cannot change the back buffer count yet.\n"); - -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+ -+#endif /* STAGING_CSMT */ - if (!width || !height) - { - /* The application is requesting that either the swapchain width or diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1362,31 +1100,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c } if (context) context_release(context); -@@ -1338,6 +1378,9 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT - if (surface->dc) - { - wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - create_dib = TRUE; - } - -@@ -1398,18 +1441,30 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT - wined3d_texture_invalidate_location(texture, 0, ~valid_location); - - if (create_dib) -+#if !defined(STAGING_CSMT) - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+#else /* STAGING_CSMT */ -+ { -+ wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } -+#endif /* STAGING_CSMT */ - - return WINED3D_OK; - } +@@ -1409,11 +1449,16 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT /* Context activation is done by the caller. */ static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture, @@ -1403,7 +1117,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c if (sub_resource->buffer_object) return; -@@ -1421,6 +1476,16 @@ static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *textur +@@ -1425,6 +1470,16 @@ static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *textur TRACE("Created buffer object %u for texture %p, sub-resource %u.\n", sub_resource->buffer_object, texture, sub_resource_idx); @@ -1420,7 +1134,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c } static void wined3d_texture_force_reload(struct wined3d_texture *texture) -@@ -1546,7 +1611,11 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned +@@ -1550,7 +1605,11 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned return TRUE; case WINED3D_LOCATION_BUFFER: @@ -1432,7 +1146,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c return TRUE; case WINED3D_LOCATION_TEXTURE_RGB: -@@ -1847,7 +1916,11 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in +@@ -1851,7 +1910,11 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in } else if (sub_resource->locations & WINED3D_LOCATION_BUFFER) { @@ -1444,7 +1158,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch); -@@ -1892,7 +1965,11 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in +@@ -1896,7 +1959,11 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in case WINED3D_LOCATION_BUFFER: if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) { @@ -1456,7 +1170,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) wined3d_texture_bind_and_dirtify(texture, context, FALSE); -@@ -2186,8 +2263,13 @@ static void wined3d_texture_unload(struct wined3d_resource *resource) +@@ -2190,8 +2257,13 @@ static void wined3d_texture_unload(struct wined3d_resource *resource) wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_DISCARDED); } @@ -1470,17 +1184,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c if (resource->type == WINED3D_RTYPE_TEXTURE_2D) { -@@ -2782,6 +2864,9 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 - if ((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D)) - { - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+#if defined(STAGING_CSMT) -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - if (!surface->dc) - { - wined3d_texture_cleanup_sync(texture); -@@ -2962,7 +3047,11 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in +@@ -2967,7 +3039,11 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in } else if (sub_resource->locations & WINED3D_LOCATION_BUFFER) { @@ -1492,7 +1196,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); -@@ -3008,7 +3097,11 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in +@@ -3013,7 +3089,11 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in case WINED3D_LOCATION_BUFFER: if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) { @@ -1504,7 +1208,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) wined3d_texture_bind_and_dirtify(texture, context, FALSE); -@@ -3226,8 +3319,18 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned +@@ -3231,8 +3311,19 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || src_texture->sub_resources[src_sub_resource_idx].map_count) { @@ -1512,7 +1216,8 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n"); return WINEDDERR_SURFACEBUSY; +#else /* STAGING_CSMT */ -+ wined3d_cs_emit_sync(dst_texture->resource.device->cs); ++ struct wined3d_device *device = dst_texture->resource.device; ++ device->cs->ops->finish(device->cs); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count + || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count)) + { @@ -1523,36 +1228,6 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c } if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) -@@ -3569,7 +3672,14 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i - return WINED3DERR_INVALIDCALL; - - if (!surface->dc) -+#if !defined(STAGING_CSMT) - wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+#else /* STAGING_CSMT */ -+ { -+ wined3d_cs_init_object(device->cs, texture2d_create_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } -+#endif /* STAGING_CSMT */ - if (!surface->dc) - return WINED3DERR_INVALIDCALL; - -@@ -3613,7 +3723,14 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign - } - - if (!(texture->resource.usage & WINED3DUSAGE_OWNDC) && !(device->wined3d->flags & WINED3D_NO3D)) -+#if !defined(STAGING_CSMT) - wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface); -+#else /* STAGING_CSMT */ -+ { -+ wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface); -+ wined3d_cs_emit_sync(device->cs); -+ } -+#endif /* STAGING_CSMT */ - - --sub_resource->map_count; - if (!--texture->resource.map_count && texture->update_map_binding) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1658,23 +1333,20 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h } sub_resources[1]; }; -@@ -3253,8 +3273,15 @@ struct wined3d_cs_queue +@@ -3253,7 +3273,12 @@ struct wined3d_cs_queue struct wined3d_cs_ops { +#if !defined(STAGING_CSMT) void *(*require_space)(struct wined3d_cs *cs, size_t size); - void (*submit)(struct wined3d_cs *cs); +#else /* STAGING_CSMT */ + BOOL (*check_space)(struct wined3d_cs *cs, size_t size, int priority); + void *(*require_space)(struct wined3d_cs *cs, size_t size, int priority); -+ void (*submit)(struct wined3d_cs *cs); -+ void (*submit_and_wait)(struct wined3d_cs *cs); +#endif /* STAGING_CSMT */ + void (*submit)(struct wined3d_cs *cs); + void (*finish)(struct wined3d_cs *cs); void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p, - unsigned int start_idx, unsigned int count, const void *constants); - }; -@@ -3269,13 +3296,23 @@ struct wined3d_cs +@@ -3270,7 +3295,13 @@ struct wined3d_cs HANDLE thread; DWORD thread_id; @@ -1688,33 +1360,3 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h size_t data_size, start, end; void *data; struct list query_poll_list; - - HANDLE event; - BOOL waiting_for_event; -+#if defined(STAGING_CSMT) -+ -+ LONG pending_presents; -+#endif /* STAGING_CSMT */ - }; - - struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN; -@@ -3297,6 +3334,9 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, - void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, int base_vertex_idx, - unsigned int start_idx, unsigned int index_count, unsigned int start_instance, - unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN; -+#if defined(STAGING_CSMT) -+void wined3d_cs_emit_finish(struct wined3d_cs *cs) DECLSPEC_HIDDEN; -+#endif /* STAGING_CSMT */ - 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, -@@ -3349,6 +3389,9 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined - void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, - struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN; - void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN; -+#if defined(STAGING_CSMT) -+void wined3d_cs_emit_sync(struct wined3d_cs *cs); -+#endif /* STAGING_CSMT */ - void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN; - void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource, - unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,