Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/cs.c | 18 ++++++++++++++++++ dlls/wined3d/wined3d_main.c | 15 +++++++++++++++ dlls/wined3d/wined3d_private.h | 4 ++++ 3 files changed, 37 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 48b73a71fe4..4b71f910048 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -21,6 +21,7 @@ #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); +WINE_DECLARE_DEBUG_CHANNEL(d3d_synchronous); WINE_DECLARE_DEBUG_CHANNEL(fps);
#define WINED3D_INITIAL_CS_SIZE 4096 @@ -2866,6 +2867,18 @@ static void wined3d_cs_wait_event(struct wined3d_cs *cs) WaitForSingleObject(cs->event, INFINITE); }
+static void wined3d_cs_adapter_lock(const struct wined3d_cs *cs) +{ + if (cs->serialize_adapter) + EnterCriticalSection(&wined3d_adapter_cs); +} + +static void wined3d_cs_adapter_unlock(const struct wined3d_cs *cs) +{ + if (cs->serialize_adapter) + LeaveCriticalSection(&wined3d_adapter_cs); +} + static DWORD WINAPI wined3d_cs_run(void *ctx) { struct wined3d_cs_packet *packet; @@ -2889,7 +2902,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) { if (++poll == WINED3D_CS_QUERY_POLL_INTERVAL) { + wined3d_cs_adapter_lock(cs); poll_queries(cs); + wined3d_cs_adapter_unlock(cs); poll = 0; }
@@ -2920,7 +2935,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) break; }
+ wined3d_cs_adapter_lock(cs); wined3d_cs_op_handlers[opcode](cs, packet->data); + wined3d_cs_adapter_unlock(cs); TRACE("%s executed.\n", debug_cs_op(opcode)); }
@@ -2945,6 +2962,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
cs->ops = &wined3d_cs_st_ops; cs->device = device; + cs->serialize_adapter = TRACE_ON(d3d_synchronous) || wined3d_settings.serialize_adapter;
state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index e1ed86e80ed..43653d6dbc1 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -96,6 +96,16 @@ static CRITICAL_SECTION_DEBUG wined3d_wndproc_cs_debug = }; static CRITICAL_SECTION wined3d_wndproc_cs = {&wined3d_wndproc_cs_debug, -1, 0, 0, 0, 0};
+CRITICAL_SECTION wined3d_adapter_cs; +static CRITICAL_SECTION_DEBUG wined3d_adapter_cs_debug = +{ + 0, 0, &wined3d_adapter_cs, + {&wined3d_adapter_cs_debug.ProcessLocksList, + &wined3d_adapter_cs_debug.ProcessLocksList}, + 0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_adapter_cs")} +}; +CRITICAL_SECTION wined3d_adapter_cs = {&wined3d_adapter_cs_debug, -1, 0, 0, 0, 0}; + /* When updating default value here, make sure to update winecfg as well, * where appropriate. */ struct wined3d_settings wined3d_settings = @@ -111,6 +121,7 @@ struct wined3d_settings wined3d_settings = ~0u, /* Don't force a specific sample count by default. */ FALSE, /* Don't range check relative addressing indices in float constants. */ FALSE, /* No strict shader math by default. */ + FALSE, /* Don't synchronize adapter commands by default. */ ~0U, /* No VS shader model limit by default. */ ~0U, /* No HS shader model limit by default. */ ~0U, /* No DS shader model limit by default. */ @@ -392,6 +403,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) wined3d_settings.renderer = WINED3D_RENDERER_NO3D; } } + if (!get_config_key_dword(hkey, appkey, "serialize_adapter", &wined3d_settings.serialize_adapter)) + ERR_(winediag)("Setting serialize_adapter to %#x.\n", wined3d_settings.serialize_adapter); }
if (appkey) RegCloseKey( appkey ); @@ -436,6 +449,8 @@ static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL) heap_free(wined3d_settings.logo); UnregisterClassA(WINED3D_OPENGL_WINDOW_CLASS_NAME, hInstDLL);
+ DeleteCriticalSection(&wined3d_adapter_cs); + DeleteCriticalSection(&wined3d_wndproc_cs); DeleteCriticalSection(&wined3d_cs); return TRUE; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ab2543e52eb..6ed8d3c2d7d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -434,6 +434,7 @@ struct wined3d_settings unsigned int sample_count; BOOL check_float_constants; unsigned int strict_shader_math; + unsigned int serialize_adapter; unsigned int max_sm_vs; unsigned int max_sm_hs; unsigned int max_sm_ds; @@ -4640,6 +4641,7 @@ struct wined3d_cs HMODULE wined3d_module; HANDLE thread; DWORD thread_id; + BOOL serialize_adapter;
struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT]; size_t data_size, start, end; @@ -6323,4 +6325,6 @@ static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl *co /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */ #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
+extern CRITICAL_SECTION wined3d_adapter_cs; + #endif