diff --git a/patches/api-ms-win-Stub_DLLs/0027-uiautomationcore-Add-dll-and-stub-some-functions.patch b/patches/api-ms-win-Stub_DLLs/0027-uiautomationcore-Add-dll-and-stub-some-functions.patch index 08fce623..37d6c0f4 100644 --- a/patches/api-ms-win-Stub_DLLs/0027-uiautomationcore-Add-dll-and-stub-some-functions.patch +++ b/patches/api-ms-win-Stub_DLLs/0027-uiautomationcore-Add-dll-and-stub-some-functions.patch @@ -1,4 +1,4 @@ -From 988abb92ab5dc363b9ea734e256959eb542391e2 Mon Sep 17 00:00:00 2001 +From 0c9c23711c9608551eebd1d60159e2fe523347f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Tue, 12 Apr 2016 01:02:34 +0200 Subject: uiautomationcore: Add dll and stub some functions. @@ -11,7 +11,7 @@ Subject: uiautomationcore: Add dll and stub some functions. 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/dlls/uiautomationcore/Makefile.in b/dlls/uiautomationcore/Makefile.in -index 78d6254a01..029fc2e499 100644 +index 78d6254a015..029fc2e4995 100644 --- a/dlls/uiautomationcore/Makefile.in +++ b/dlls/uiautomationcore/Makefile.in @@ -1,4 +1,5 @@ @@ -21,7 +21,7 @@ index 78d6254a01..029fc2e499 100644 C_SRCS = \ uia_main.c diff --git a/dlls/uiautomationcore/uia_main.c b/dlls/uiautomationcore/uia_main.c -index 6e795ab88f..37c56dacd5 100644 +index 31b7d3e7aa1..ff0506dc7d9 100644 --- a/dlls/uiautomationcore/uia_main.c +++ b/dlls/uiautomationcore/uia_main.c @@ -1,4 +1,5 @@ @@ -124,7 +124,7 @@ index 6e795ab88f..37c56dacd5 100644 return 1; } -@@ -81,6 +122,6 @@ int WINAPI UiaLookupId(enum AutomationIdentifierType type, const GUID *guid) +@@ -81,7 +122,7 @@ int WINAPI UiaLookupId(enum AutomationIdentifierType type, const GUID *guid) LRESULT WINAPI UiaReturnRawElementProvider(HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *elprov) { @@ -132,8 +132,9 @@ index 6e795ab88f..37c56dacd5 100644 + FIXME("(%p, %lx, %lx, %p): stub!\n", hwnd, wParam, lParam, elprov); return 0; } + diff --git a/dlls/uiautomationcore/uiautomationcore.spec b/dlls/uiautomationcore/uiautomationcore.spec -index bff1303eda..221711c41d 100644 +index 48a06b2fdad..8e676adaae1 100644 --- a/dlls/uiautomationcore/uiautomationcore.spec +++ b/dlls/uiautomationcore/uiautomationcore.spec @@ -53,6 +53,8 @@ @@ -160,7 +161,7 @@ index bff1303eda..221711c41d 100644 +@ stub UiaProviderForNonClient +@ stub UiaProviderFromIAccessible @ stub UiaRaiseAsyncContentLoadedEvent - @ stub UiaRaiseAutomationEvent + @ stdcall UiaRaiseAutomationEvent(ptr long) @ stub UiaRaiseAutomationPropertyChangedEvent @ stub UiaRaiseStructureChangedEvent +@ stub UiaRaiseTextEditTextChangedEvent @@ -168,7 +169,7 @@ index bff1303eda..221711c41d 100644 @ stub UiaRemoveEvent @ stdcall UiaReturnRawElementProvider(long long long ptr) diff --git a/include/uiautomationcoreapi.h b/include/uiautomationcoreapi.h -index 6c1752ec64..1a844d0cb7 100644 +index 12c509fbec8..5ddf4b67e3d 100644 --- a/include/uiautomationcoreapi.h +++ b/include/uiautomationcoreapi.h @@ -39,18 +39,19 @@ DECLARE_HANDLE(HUIAPATTERNOBJECT); @@ -193,8 +194,8 @@ index 6c1752ec64..1a844d0cb7 100644 -int WINAPI UiaLookupId(enum AutomationIdentifierType type, const GUID *guid); +int WINAPI UiaLookupId(AutomationIdentifierType type, const GUID *guid); BOOL WINAPI UiaPatternRelease(HUIAPATTERNOBJECT hobj); + HRESULT WINAPI UiaRaiseAutomationEvent(IRawElementProviderSimple *provider, EVENTID id); LRESULT WINAPI UiaReturnRawElementProvider(HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *elprov); - BOOL WINAPI UiaTextRangeRelease(HUIATEXTRANGE hobj); -- -2.11.0 +2.12.2 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 17486995..3dcef0c0 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "3f01ab4c39ffa50e26916a5f33d82dec1a2e42dc" + echo "b8a8e1bde9382897927945ec0b58b8a2fcfcfe59" } # Show version information @@ -8868,9 +8868,8 @@ fi # | * [#11674] Support for CSMT (command stream) to increase graphic performance # | # | Modified files: -# | * dlls/wined3d/buffer.c, dlls/wined3d/cs.c, dlls/wined3d/device.c, dlls/wined3d/resource.c, dlls/wined3d/surface.c, -# | dlls/wined3d/swapchain.c, dlls/wined3d/texture.c, dlls/wined3d/view.c, dlls/wined3d/wined3d_main.c, -# | dlls/wined3d/wined3d_private.h +# | * dlls/wined3d/buffer.c, dlls/wined3d/cs.c, dlls/wined3d/device.c, dlls/wined3d/surface.c, dlls/wined3d/swapchain.c, +# | dlls/wined3d/texture.c, dlls/wined3d/view.c, dlls/wined3d/wined3d_main.c, dlls/wined3d/wined3d_private.h # | if test "$enable_wined3d_CSMT_Main" -eq 1; then patch_apply wined3d-CSMT_Main/9999-IfDefined.patch @@ -8878,8 +8877,6 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Add additional synchronization CS ops.", 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' '+ { "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 },'; 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 4d2ef941..92811383 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 ee2d4cc10c524a813e4eefcf3935c63479bb84be Mon Sep 17 00:00:00 2001 +From 443951f5ef3359b18334b50d72724f99ce77f72e 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. @@ -11,10 +11,10 @@ between surface_blt and surface_blt_ugly isn't particularly nice. 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index cbb0406dccf..613df2077a5 100644 +index cf446c7cd17..b3fea23c821 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -4199,16 +4199,17 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4241,16 +4241,17 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } @@ -31,7 +31,7 @@ index cbb0406dccf..613df2077a5 100644 - WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx); - return WINED3DERR_INVALIDCALL; + struct wined3d_device *device = dst_texture->resource.device; -+ device->cs->ops->finish(device->cs); ++ device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || + src_texture->sub_resources[src_sub_resource_idx].map_count) + { @@ -42,7 +42,7 @@ index cbb0406dccf..613df2077a5 100644 if (!src_box) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c -index ebc317bd43d..d43ee068a30 100644 +index a77c9835bbb..55cc49be5e0 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -3231,8 +3231,14 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned @@ -52,7 +52,7 @@ index ebc317bd43d..d43ee068a30 100644 - WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n"); - return WINEDDERR_SURFACEBUSY; + struct wined3d_device *device = dst_texture->resource.device; -+ device->cs->ops->finish(device->cs); ++ device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count + || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count)) + { 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 deleted file mode 100644 index a6cbc3e9..00000000 --- a/patches/wined3d-CSMT_Main/0031-wined3d-Introduce-a-separate-priority-queue.patch +++ /dev/null @@ -1,672 +0,0 @@ -From 8903436b5d2dfc6a358191002a3d5eacd6a784f6 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 | 135 ++++++++++++++++++++++++----------------- - dlls/wined3d/device.c | 6 +- - dlls/wined3d/swapchain.c | 4 +- - dlls/wined3d/texture.c | 2 +- - dlls/wined3d/wined3d_private.h | 7 ++- - 5 files changed, 89 insertions(+), 65 deletions(-) - -diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 9d6cf3676b6..10664a5cc50 100644 ---- a/dlls/wined3d/cs.c -+++ b/dlls/wined3d/cs.c -@@ -427,6 +427,17 @@ 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), 0); -+ op->opcode = WINED3D_CS_OP_NOP; -+ -+ cs->ops->submit(cs); -+ cs->ops->finish(cs); -+} -+ - static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - { - const struct wined3d_cs_present *op = data; -@@ -454,7 +465,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - unsigned int i; - LONG pending; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_PRESENT; - op->dst_window_override = dst_window_override; - op->swapchain = swapchain; -@@ -515,7 +526,7 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * - struct wined3d_cs_clear *op; - unsigned int i; - -- op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[rect_count])); -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[rect_count]), 0); - op->opcode = WINED3D_CS_OP_CLEAR; - op->flags = flags; - op->rt_count = rt_count; -@@ -551,7 +562,7 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined - struct wined3d_fb_state fb; - } *extra; - -- op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(*extra)); -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(*extra), 0); - extra = (void *)&op->rects[1]; - extra->fb.render_targets = &extra->rt; - op->fb = &extra->fb; -@@ -707,7 +718,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, - const struct wined3d_state *state = &cs->device->state; - struct wined3d_cs_dispatch *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_DISPATCH; - op->group_count_x = group_count_x; - op->group_count_y = group_count_y; -@@ -781,7 +792,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned - struct wined3d_cs_draw *op; - unsigned int i; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_DRAW; - op->primitive_type = primitive_type; - op->patch_vertex_count = patch_vertex_count; -@@ -836,7 +847,7 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) - { - struct wined3d_cs_flush *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_FLUSH; - - cs->ops->submit(cs); -@@ -854,7 +865,7 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query - { - struct wined3d_cs_set_predication *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_PREDICATION; - op->predicate = predicate; - op->value = value; -@@ -874,7 +885,7 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi - { - struct wined3d_cs_set_viewport *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_VIEWPORT; - op->viewport = *viewport; - -@@ -893,7 +904,7 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) - { - struct wined3d_cs_set_scissor_rect *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECT; - op->rect = *rect; - -@@ -913,7 +924,7 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v - { - struct wined3d_cs_set_rendertarget_view *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW; - op->view_idx = view_idx; - op->view = view; -@@ -962,7 +973,7 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 - { - struct wined3d_cs_set_depth_stencil_view *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; - op->view = view; - -@@ -981,7 +992,7 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 - { - struct wined3d_cs_set_vertex_declaration *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION; - op->declaration = declaration; - -@@ -1013,7 +1024,7 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, - { - struct wined3d_cs_set_stream_source *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE; - op->stream_idx = stream_idx; - op->buffer = buffer; -@@ -1039,7 +1050,7 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i - { - struct wined3d_cs_set_stream_source_freq *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ; - op->stream_idx = stream_idx; - op->frequency = frequency; -@@ -1072,7 +1083,7 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, - { - struct wined3d_cs_set_stream_output *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT; - op->stream_idx = stream_idx; - op->buffer = buffer; -@@ -1104,7 +1115,7 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff - { - struct wined3d_cs_set_index_buffer *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_INDEX_BUFFER; - op->buffer = buffer; - op->format_id = format_id; -@@ -1134,7 +1145,7 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha - { - struct wined3d_cs_set_constant_buffer *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER; - op->type = type; - op->cb_idx = cb_idx; -@@ -1226,7 +1237,7 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined - { - struct wined3d_cs_set_texture *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_TEXTURE; - op->stage = stage; - op->texture = texture; -@@ -1258,7 +1269,7 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 - { - struct wined3d_cs_set_shader_resource_view *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; - op->type = type; - op->view_idx = view_idx; -@@ -1288,7 +1299,7 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined - { - struct wined3d_cs_set_unordered_access_view *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW; - op->pipeline = pipeline; - op->view_idx = view_idx; -@@ -1313,7 +1324,7 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type - { - struct wined3d_cs_set_sampler *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_SAMPLER; - op->type = type; - op->sampler_idx = sampler_idx; -@@ -1338,7 +1349,7 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type - { - struct wined3d_cs_set_shader *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_SHADER; - op->type = type; - op->shader = shader; -@@ -1359,7 +1370,7 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, - { - struct wined3d_cs_set_rasterizer_state *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE; - op->state = rasterizer_state; - -@@ -1378,7 +1389,7 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render - { - struct wined3d_cs_set_render_state *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_RENDER_STATE; - op->state = state; - op->value = value; -@@ -1399,7 +1410,7 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, - { - struct wined3d_cs_set_texture_state *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_TEXTURE_STATE; - op->stage = stage; - op->state = state; -@@ -1421,7 +1432,7 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, - { - struct wined3d_cs_set_sampler_state *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE; - op->sampler_idx = sampler_idx; - op->state = state; -@@ -1444,7 +1455,7 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform - { - struct wined3d_cs_set_transform *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_TRANSFORM; - op->state = state; - op->matrix = *matrix; -@@ -1464,7 +1475,7 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const - { - struct wined3d_cs_set_clip_plane *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; - op->plane_idx = plane_idx; - op->plane = *plane; -@@ -1540,7 +1551,7 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture - { - struct wined3d_cs_set_color_key *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_COLOR_KEY; - op->texture = texture; - op->flags = flags; -@@ -1567,7 +1578,7 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma - { - struct wined3d_cs_set_material *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_MATERIAL; - op->material = *material; - -@@ -1615,7 +1626,7 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light - { - struct wined3d_cs_set_light *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_LIGHT; - op->light = *light; - -@@ -1648,7 +1659,7 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B - { - struct wined3d_cs_set_light_enable *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE; - op->idx = idx; - op->enable = enable; -@@ -1713,7 +1724,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; -- op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_push_constants, constants[size])); -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_push_constants, constants[size]), 0); - op->opcode = WINED3D_CS_OP_PUSH_CONSTANTS; - op->type = p; - op->start_idx = start_idx; -@@ -1737,7 +1748,7 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) - { - struct wined3d_cs_reset_state *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_RESET_STATE; - - cs->ops->submit(cs); -@@ -1754,7 +1765,7 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi - { - struct wined3d_cs_callback *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_CALLBACK; - op->callback = callback; - op->object = object; -@@ -1815,7 +1826,7 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu - { - struct wined3d_cs_query_issue *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_QUERY_ISSUE; - op->query = query; - op->flags = flags; -@@ -1836,7 +1847,7 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso - { - struct wined3d_cs_preload_resource *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_PRELOAD_RESOURCE; - op->resource = resource; - -@@ -1858,7 +1869,7 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou - { - struct wined3d_cs_unload_resource *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE; - op->resource = resource; - -@@ -1886,7 +1897,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; -@@ -1916,7 +1927,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; -@@ -2056,7 +2067,7 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso - { - struct wined3d_cs_blt_sub_resource *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_BLT_SUB_RESOURCE; - op->dst_resource = dst_resource; - op->dst_sub_resource_idx = dst_sub_resource_idx; -@@ -2136,7 +2147,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r - { - struct wined3d_cs_update_sub_resource *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; -@@ -2179,7 +2190,7 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, - { - struct wined3d_cs_add_dirty_texture_region *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION; - op->texture = texture; - op->layer = layer; -@@ -2207,7 +2218,7 @@ void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs, - { - struct wined3d_cs_clear_unordered_access_view *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW; - op->view = view; - op->clear_value = *clear_value; -@@ -2221,11 +2232,10 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) - { - struct wined3d_cs_stop *op; - -- op = cs->ops->require_space(cs, sizeof(*op)); -+ op = cs->ops->require_space(cs, sizeof(*op), 0); - op->opcode = WINED3D_CS_OP_STOP; - - cs->ops->submit(cs); -- cs->ops->finish(cs); - } - - static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = -@@ -2276,7 +2286,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void - /* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view, - }; - --static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) -+static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, int priority) - { - if (size > (cs->data_size - cs->end)) - { -@@ -2342,7 +2352,7 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) - - static void wined3d_cs_mt_submit(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; - -@@ -2357,15 +2367,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) -+static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, int priority) - { -- struct wined3d_cs_queue *queue = &cs->queue; -+ struct wined3d_cs_queue *queue = priority ? &cs->prio_queue : &cs->norm_queue; - size_t queue_size = ARRAY_SIZE(queue->data); - size_t header_size, packet_size, remaining; - struct wined3d_cs_packet *packet; - - if (cs->thread_id == GetCurrentThreadId()) -- return wined3d_cs_st_require_space(cs, size); -+ return wined3d_cs_st_require_space(cs, size, priority); - - header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); - size = (size + header_size - 1) & ~(header_size - 1); -@@ -2386,7 +2396,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); - -- nop = wined3d_cs_mt_require_space(cs, nop_size); -+ nop = wined3d_cs_mt_require_space(cs, nop_size, priority); - if (nop_size) - nop->opcode = WINED3D_CS_OP_NOP; - -@@ -2417,6 +2427,7 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) - head, tail, (unsigned long)packet_size); - } - -+ cs->queue = queue; - packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; - packet->size = size; - return packet->data; -@@ -2424,11 +2435,15 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) - - static void wined3d_cs_mt_finish(struct wined3d_cs *cs) - { -+ struct wined3d_cs_queue *queue = cs->queue; -+ - 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(queue)) - wined3d_pause(); -+ -+ cs->queue = NULL; - } - - static const struct wined3d_cs_ops wined3d_cs_mt_ops = -@@ -2454,6 +2469,13 @@ static void poll_queries(struct wined3d_cs *cs) - } - } - -+static struct wined3d_cs_queue *wined3d_cs_get_queue(struct wined3d_cs *cs) -+{ -+ if (!wined3d_cs_queue_is_empty(&cs->prio_queue)) return &cs->prio_queue; -+ if (!wined3d_cs_queue_is_empty(&cs->norm_queue)) return &cs->norm_queue; -+ return NULL; -+} -+ - static void wined3d_cs_wait_event(struct wined3d_cs *cs) - { - InterlockedExchange(&cs->waiting_for_event, TRUE); -@@ -2465,7 +2487,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(). */ -- if (!wined3d_cs_queue_is_empty(&cs->queue) -+ if (wined3d_cs_get_queue(cs) - && InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) - return; - -@@ -2484,7 +2506,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - - TRACE("Started.\n"); - -- queue = &cs->queue; - list_init(&cs->query_poll_list); - cs->thread_id = GetCurrentThreadId(); - for (;;) -@@ -2495,7 +2516,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - poll = 0; - } - -- if (wined3d_cs_queue_is_empty(queue)) -+ if (!(queue = wined3d_cs_get_queue(cs))) - { - if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list)) - wined3d_cs_wait_event(cs); -@@ -2524,7 +2545,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - InterlockedExchange(&queue->tail, tail); - } - -- queue->tail = queue->head = 0; - TRACE("Stopped.\n"); - FreeLibraryAndExitThread(cs->wined3d_module, 0); - } -@@ -2598,6 +2618,7 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) - if (cs->thread) - { - wined3d_cs_emit_stop(cs); -+ WaitForSingleObject(cs->thread, INFINITE); - CloseHandle(cs->thread); - if (!CloseHandle(cs->event)) - ERR("Closing event failed.\n"); -diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index eaa6c6b58ea..aee47263144 100644 ---- a/dlls/wined3d/device.c -+++ b/dlls/wined3d/device.c -@@ -1213,7 +1213,7 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) - if (!device->d3d_initialized) - return WINED3DERR_INVALIDCALL; - -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(device->cs); - - if (device->logo_texture) - wined3d_texture_decref(device->logo_texture); -@@ -4245,7 +4245,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev - src_texture->sub_resources[src_sub_resource_idx].map_count) - { - struct wined3d_device *device = dst_texture->resource.device; -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(device->cs); - if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || - src_texture->sub_resources[src_sub_resource_idx].map_count) - { -@@ -4741,7 +4741,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, - TRACE("device %p, swapchain_desc %p, mode %p, callback %p, reset_state %#x.\n", - device, swapchain_desc, mode, callback, reset_state); - -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(device->cs); - - if (!(swapchain = wined3d_device_get_swapchain(device, 0))) - { -diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c -index 4bb8cb15b80..371294aac24 100644 ---- a/dlls/wined3d/swapchain.c -+++ b/dlls/wined3d/swapchain.c -@@ -116,7 +116,7 @@ ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain) - { - struct wined3d_device *device = swapchain->device; - -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(device->cs); - - swapchain_cleanup(swapchain); - swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent); -@@ -1208,7 +1208,7 @@ 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"); - -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(device->cs); - - if (!width || !height) - { -diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c -index 01a29e605ac..3bd438f64d6 100644 ---- a/dlls/wined3d/texture.c -+++ b/dlls/wined3d/texture.c -@@ -3225,7 +3225,7 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned - || src_texture->sub_resources[src_sub_resource_idx].map_count) - { - struct wined3d_device *device = dst_texture->resource.device; -- device->cs->ops->finish(device->cs); -+ wined3d_cs_emit_sync(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)) - { -diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index e1d18ee9b83..550c0d367a7 100644 ---- a/dlls/wined3d/wined3d_private.h -+++ b/dlls/wined3d/wined3d_private.h -@@ -3285,7 +3285,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 (*finish)(struct wined3d_cs *cs); - void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p, -@@ -3302,7 +3302,9 @@ struct wined3d_cs - HANDLE thread; - DWORD thread_id; - -- struct wined3d_cs_queue queue; -+ struct wined3d_cs_queue *queue; -+ struct wined3d_cs_queue norm_queue; -+ struct wined3d_cs_queue prio_queue; - size_t data_size, start, end; - void *data; - struct list query_poll_list; -@@ -3385,6 +3387,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) DECLSPEC_HIDDEN; - 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/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch b/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch deleted file mode 100644 index 92b4cb4b..00000000 --- a/patches/wined3d-CSMT_Main/0032-wined3d-Use-priority-queue-for-maps-unmaps.patch +++ /dev/null @@ -1,59 +0,0 @@ -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. - ---- - dlls/wined3d/cs.c | 4 ++-- - dlls/wined3d/resource.c | 6 ++++++ - 2 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index c74fd1749ca..cb49f38acd3 100644 ---- a/dlls/wined3d/cs.c -+++ b/dlls/wined3d/cs.c -@@ -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; -@@ -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); - op->opcode = WINED3D_CS_OP_UNMAP; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; -diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c -index e343067f943..fffa6fbf25c 100644 ---- a/dlls/wined3d/resource.c -+++ b/dlls/wined3d/resource.c -@@ -363,6 +363,9 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i - - flags = wined3d_resource_sanitise_map_flags(resource, flags); - -+ if (wined3d_settings.cs_multithreaded) -+ wined3d_resource_wait_idle(resource); -+ - return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags); - } - -@@ -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); - -+ if (wined3d_settings.cs_multithreaded) -+ wined3d_resource_wait_idle(resource); -+ - return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx); - } - --- -2.12.2 - diff --git a/patches/wined3d-CSMT_Main/0039-wined3d-Use-priority-queue-for-update_sub_resource.patch b/patches/wined3d-CSMT_Main/0039-wined3d-Use-priority-queue-for-update_sub_resource.patch index 4d6e9816..e79845cf 100644 --- a/patches/wined3d-CSMT_Main/0039-wined3d-Use-priority-queue-for-update_sub_resource.patch +++ b/patches/wined3d-CSMT_Main/0039-wined3d-Use-priority-queue-for-update_sub_resource.patch @@ -1,31 +1,44 @@ -From 9316955f860efa52c6b58edb4998c120bd43c377 Mon Sep 17 00:00:00 2001 +From 606dbb843b9fc141ba8c904798d542696d82af32 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 12 Feb 2017 00:08:28 +0100 Subject: wined3d: Use priority queue for update_sub_resource. --- - dlls/wined3d/cs.c | 2 +- + dlls/wined3d/cs.c | 6 +++--- dlls/wined3d/device.c | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index f146cbe4633..8dea530b413 100644 +index 6bd6f3ed056..b20008d55e7 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -2143,7 +2143,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2139,7 +2139,7 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r { struct wined3d_cs_update_sub_resource *op; -- op = cs->ops->require_space(cs, sizeof(*op), 0); -+ op = cs->ops->require_space(cs, sizeof(*op), 1); +- op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); ++ op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; op->resource = resource; op->sub_resource_idx = sub_resource_idx; +@@ -2150,10 +2150,10 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r + + wined3d_resource_acquire(resource); + +- cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); ++ cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP); + /* The data pointer may go away, so we need to wait until it is read. + * Copying the data may be faster if it's small. */ +- cs->ops->finish(cs, WINED3D_CS_QUEUE_DEFAULT); ++ cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP); + } + + static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index 07d5970e4b3..56d52952a10 100644 +index d3b9a1b55b1..24bc2ba54b2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -4286,6 +4286,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str +@@ -4297,6 +4297,8 @@ 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); 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 5ede52b5..8288ab0d 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,19 +1,19 @@ -From 6c606d8f44420417fc8cbb248f57556a26125d0b Mon Sep 17 00:00:00 2001 +From cd32330bc6d35331524eb1deef302fa8f5f6d4de 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. --- - dlls/wined3d/cs.c | 68 ++++++++++++++++++++++++++++++++++++++++++ + dlls/wined3d/cs.c | 74 ++++++++++++++++++++++++++++++++++++++++-- dlls/wined3d/device.c | 2 -- dlls/wined3d/wined3d_private.h | 1 + - 3 files changed, 69 insertions(+), 2 deletions(-) + 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c -index 8dea530b413..fc67672fff2 100644 +index b20008d55e7..aa83a546e87 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c -@@ -401,6 +401,7 @@ struct wined3d_cs_update_sub_resource +@@ -402,6 +402,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 8dea530b413..fc67672fff2 100644 }; struct wined3d_cs_add_dirty_texture_region -@@ -2142,6 +2143,49 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2138,6 +2139,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; @@ -48,10 +48,10 @@ index 8dea530b413..fc67672fff2 100644 + } + + size = FIELD_OFFSET(struct wined3d_cs_update_sub_resource, copy_data[data_size]); -+ if (!cs->ops->check_space(cs, size, 0)) ++ if (!cs->ops->check_space(cs, size, WINED3D_CS_QUEUE_DEFAULT)) + goto no_async; + -+ op = cs->ops->require_space(cs, size, 0); ++ op = cs->ops->require_space(cs, size, WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; + op->resource = resource; + op->sub_resource_idx = sub_resource_idx; @@ -63,27 +63,36 @@ index 8dea530b413..fc67672fff2 100644 + + wined3d_resource_acquire(resource); + -+ cs->ops->submit(cs); ++ cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); + return; + +no_async: + wined3d_resource_wait_idle(resource); - op = cs->ops->require_space(cs, sizeof(*op), 1); + op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; -@@ -2282,6 +2326,11 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void +@@ -2151,8 +2195,6 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r + wined3d_resource_acquire(resource); + + cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP); +- /* The data pointer may go away, so we need to wait until it is read. +- * Copying the data may be faster if it's small. */ + cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP); + } + +@@ -2279,6 +2321,11 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view, }; -+static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, int priority) ++static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) +{ + return TRUE; +} + - static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, int priority) + static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) { if (size > (cs->data_size - cs->end)) -@@ -2335,6 +2384,7 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs) +@@ -2332,6 +2379,7 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id static const struct wined3d_cs_ops wined3d_cs_st_ops = { @@ -91,19 +100,15 @@ index 8dea530b413..fc67672fff2 100644 wined3d_cs_st_require_space, wined3d_cs_st_submit, wined3d_cs_st_finish, -@@ -2363,6 +2413,23 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - SetEvent(cs->event); +@@ -2364,6 +2412,19 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id + wined3d_cs_queue_submit(&cs->queue[queue_id], cs); } -+static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, int priority) ++static BOOL wined3d_cs_queue_check_space(struct wined3d_cs_queue *queue, size_t size) +{ -+ struct wined3d_cs_queue *queue = priority ? &cs->prio_queue : &cs->norm_queue; + size_t queue_size = ARRAY_SIZE(queue->data); + size_t header_size, packet_size, remaining; + -+ if (cs->thread_id == GetCurrentThreadId()) -+ return wined3d_cs_st_check_space(cs, size, priority); -+ + header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); + size = (size + header_size - 1) & ~(header_size - 1); + packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]); @@ -112,10 +117,25 @@ index 8dea530b413..fc67672fff2 100644 + return (remaining >= packet_size); +} + - static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, int priority) + static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs) { - struct wined3d_cs_queue *queue = priority ? &cs->prio_queue : &cs->norm_queue; -@@ -2444,6 +2511,7 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs) + size_t queue_size = ARRAY_SIZE(queue->data); +@@ -2425,6 +2486,14 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size + return packet->data; + } + ++static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) ++{ ++ if (cs->thread_id == GetCurrentThreadId()) ++ return wined3d_cs_st_check_space(cs, size, queue_id); ++ ++ return wined3d_cs_queue_check_space(&cs->queue[queue_id], size); ++} ++ + static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) + { + if (cs->thread_id == GetCurrentThreadId()) +@@ -2444,6 +2513,7 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id static const struct wined3d_cs_ops wined3d_cs_mt_ops = { @@ -124,10 +144,10 @@ index 8dea530b413..fc67672fff2 100644 wined3d_cs_mt_submit, wined3d_cs_mt_finish, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index 1e17106cddc..adf6ded131f 100644 +index fa01f8a15e0..0a638ecf19a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -4287,8 +4287,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str +@@ -4298,8 +4298,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 +157,17 @@ index 1e17106cddc..adf6ded131f 100644 { if (sub_resource_idx > 0) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index b647f4e23b4..093f33eee77 100644 +index 6920b29329f..b6f0dd3a90c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h -@@ -3267,6 +3267,7 @@ struct wined3d_cs_queue +@@ -3318,6 +3318,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 (*finish)(struct wined3d_cs *cs); ++ BOOL (*check_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id); + void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id); + void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id); + void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id); -- 2.12.2 diff --git a/patches/wined3d-CSMT_Main/9999-IfDefined.patch b/patches/wined3d-CSMT_Main/9999-IfDefined.patch index 2092ff06..e21d8d16 100644 --- a/patches/wined3d-CSMT_Main/9999-IfDefined.patch +++ b/patches/wined3d-CSMT_Main/9999-IfDefined.patch @@ -47,525 +47,13 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c }; struct wined3d_cs_add_dirty_texture_region -@@ -427,6 +430,19 @@ 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(cs); -+ cs->ops->finish(cs); -+} -+ -+#endif /* STAGING_CSMT */ - static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) - { - const struct wined3d_cs_present *op = data; -@@ -454,7 +470,11 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw - unsigned int i; - LONG pending; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ 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; -@@ -515,7 +535,11 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * - struct wined3d_cs_clear *op; - unsigned int i; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[rect_count])); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[rect_count]), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_CLEAR; - op->flags = flags; - op->rt_count = rt_count; -@@ -551,7 +575,11 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined - struct wined3d_fb_state fb; - } *extra; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(*extra)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(*extra), 0); -+#endif /* STAGING_CSMT */ - extra = (void *)&op->rects[1]; - extra->fb.render_targets = &extra->rt; - op->fb = &extra->fb; -@@ -707,7 +735,11 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, - const struct wined3d_state *state = &cs->device->state; - struct wined3d_cs_dispatch *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_DISPATCH; - op->group_count_x = group_count_x; - op->group_count_y = group_count_y; -@@ -781,7 +813,11 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned - struct wined3d_cs_draw *op; - unsigned int i; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_DRAW; - op->primitive_type = primitive_type; - op->patch_vertex_count = patch_vertex_count; -@@ -836,7 +872,11 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) - { - struct wined3d_cs_flush *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_FLUSH; - - cs->ops->submit(cs); -@@ -854,7 +894,11 @@ void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query - { - struct wined3d_cs_set_predication *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_PREDICATION; - op->predicate = predicate; - op->value = value; -@@ -874,7 +918,11 @@ void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_vi - { - struct wined3d_cs_set_viewport *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_VIEWPORT; - op->viewport = *viewport; - -@@ -893,7 +941,11 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) - { - struct wined3d_cs_set_scissor_rect *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECT; - op->rect = *rect; - -@@ -913,7 +965,11 @@ void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int v - { - struct wined3d_cs_set_rendertarget_view *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_RENDERTARGET_VIEW; - op->view_idx = view_idx; - op->view = view; -@@ -962,7 +1018,11 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3 - { - struct wined3d_cs_set_depth_stencil_view *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; - op->view = view; - -@@ -981,7 +1041,11 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs, struct wined3 - { - struct wined3d_cs_set_vertex_declaration *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_VERTEX_DECLARATION; - op->declaration = declaration; - -@@ -1013,7 +1077,11 @@ void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx, - { - struct wined3d_cs_set_stream_source *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE; - op->stream_idx = stream_idx; - op->buffer = buffer; -@@ -1039,7 +1107,11 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i - { - struct wined3d_cs_set_stream_source_freq *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ; - op->stream_idx = stream_idx; - op->frequency = frequency; -@@ -1072,7 +1144,11 @@ void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx, - { - struct wined3d_cs_set_stream_output *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT; - op->stream_idx = stream_idx; - op->buffer = buffer; -@@ -1104,7 +1180,11 @@ void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buff - { - struct wined3d_cs_set_index_buffer *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_INDEX_BUFFER; - op->buffer = buffer; - op->format_id = format_id; -@@ -1134,7 +1214,11 @@ void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_sha - { - struct wined3d_cs_set_constant_buffer *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER; - op->type = type; - op->cb_idx = cb_idx; -@@ -1226,7 +1310,11 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined - { - struct wined3d_cs_set_texture *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_TEXTURE; - op->stage = stage; - op->texture = texture; -@@ -1258,7 +1346,11 @@ void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3 - { - struct wined3d_cs_set_shader_resource_view *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; - op->type = type; - op->view_idx = view_idx; -@@ -1288,7 +1380,11 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined - { - struct wined3d_cs_set_unordered_access_view *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW; - op->pipeline = pipeline; - op->view_idx = view_idx; -@@ -1313,7 +1409,11 @@ void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type - { - struct wined3d_cs_set_sampler *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_SAMPLER; - op->type = type; - op->sampler_idx = sampler_idx; -@@ -1338,7 +1438,11 @@ void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type - { - struct wined3d_cs_set_shader *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_SHADER; - op->type = type; - op->shader = shader; -@@ -1359,7 +1463,11 @@ void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs, - { - struct wined3d_cs_set_rasterizer_state *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE; - op->state = rasterizer_state; - -@@ -1378,7 +1486,11 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs, enum wined3d_render - { - struct wined3d_cs_set_render_state *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_RENDER_STATE; - op->state = state; - op->value = value; -@@ -1399,7 +1511,11 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage, - { - struct wined3d_cs_set_texture_state *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_TEXTURE_STATE; - op->stage = stage; - op->state = state; -@@ -1421,7 +1537,11 @@ void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, - { - struct wined3d_cs_set_sampler_state *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE; - op->sampler_idx = sampler_idx; - op->state = state; -@@ -1444,7 +1564,11 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform - { - struct wined3d_cs_set_transform *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_TRANSFORM; - op->state = state; - op->matrix = *matrix; -@@ -1464,7 +1588,11 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const - { - struct wined3d_cs_set_clip_plane *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; - op->plane_idx = plane_idx; - op->plane = *plane; -@@ -1540,7 +1668,11 @@ void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture - { - struct wined3d_cs_set_color_key *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_COLOR_KEY; - op->texture = texture; - op->flags = flags; -@@ -1567,7 +1699,11 @@ void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_ma - { - struct wined3d_cs_set_material *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_MATERIAL; - op->material = *material; - -@@ -1615,7 +1751,11 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light - { - struct wined3d_cs_set_light *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_LIGHT; - op->light = *light; - -@@ -1648,7 +1788,11 @@ void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, B - { - struct wined3d_cs_set_light_enable *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE; - op->idx = idx; - op->enable = enable; -@@ -1713,7 +1857,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; -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_push_constants, constants[size])); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_push_constants, constants[size]), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_PUSH_CONSTANTS; - op->type = p; - op->start_idx = start_idx; -@@ -1737,7 +1885,11 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) - { - struct wined3d_cs_reset_state *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_RESET_STATE; - - cs->ops->submit(cs); -@@ -1754,7 +1906,11 @@ static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(voi - { - struct wined3d_cs_callback *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_CALLBACK; - op->callback = callback; - op->object = object; -@@ -1815,7 +1971,11 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu - { - struct wined3d_cs_query_issue *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_QUERY_ISSUE; - op->query = query; - op->flags = flags; -@@ -1836,7 +1996,11 @@ void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_reso - { - struct wined3d_cs_preload_resource *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_PRELOAD_RESOURCE; - op->resource = resource; - -@@ -1858,7 +2022,11 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou - { - struct wined3d_cs_unload_resource *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE; - op->resource = resource; - -@@ -1886,7 +2054,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)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 1); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_MAP; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; -@@ -1916,7 +2088,11 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc - - wined3d_not_from_cs(cs); - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 1); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_UNMAP; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; -@@ -2056,7 +2232,11 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso - { - struct wined3d_cs_blt_sub_resource *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_BLT_SUB_RESOURCE; - op->dst_resource = dst_resource; - op->dst_sub_resource_idx = dst_sub_resource_idx; -@@ -2135,8 +2315,56 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r +@@ -2138,22 +2141,78 @@ 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; +#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); + op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); +#else /* STAGING_CSMT */ + size_t data_size, size; + @@ -590,92 +78,69 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c + } + + size = FIELD_OFFSET(struct wined3d_cs_update_sub_resource, copy_data[data_size]); -+ if (!cs->ops->check_space(cs, size, 0)) ++ if (!cs->ops->check_space(cs, size, WINED3D_CS_QUEUE_DEFAULT)) + goto no_async; + -+ op = cs->ops->require_space(cs, size, 0); ++ op = cs->ops->require_space(cs, size, WINED3D_CS_QUEUE_DEFAULT); ++#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, WINED3D_CS_QUEUE_DEFAULT); ++#if !defined(STAGING_CSMT) + /* The data pointer may go away, so we need to wait until it is read. + * Copying the data may be faster if it's small. */ + cs->ops->finish(cs, WINED3D_CS_QUEUE_DEFAULT); ++#else /* STAGING_CSMT */ ++ return; ++ ++no_async: ++ wined3d_resource_wait_idle(resource); ++ ++ op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP); + 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 = op->copy_data; -+ memcpy(op->copy_data, data, data_size); ++ op->data.data = data; + + wined3d_resource_acquire(resource); + -+ cs->ops->submit(cs); -+ return; -+ -+no_async: -+ wined3d_resource_wait_idle(resource); -+ -+ op = cs->ops->require_space(cs, sizeof(*op), 1); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; -@@ -2179,7 +2407,11 @@ void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, - { - struct wined3d_cs_add_dirty_texture_region *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION; - op->texture = texture; - op->layer = layer; -@@ -2207,7 +2439,11 @@ void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs, - { - struct wined3d_cs_clear_unordered_access_view *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW; - op->view = view; - op->clear_value = *clear_value; -@@ -2221,11 +2457,17 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs) - { - struct wined3d_cs_stop *op; - -+#if !defined(STAGING_CSMT) - op = cs->ops->require_space(cs, sizeof(*op)); -+#else /* STAGING_CSMT */ -+ op = cs->ops->require_space(cs, sizeof(*op), 0); -+#endif /* STAGING_CSMT */ - op->opcode = WINED3D_CS_OP_STOP; - - cs->ops->submit(cs); -+#if !defined(STAGING_CSMT) - cs->ops->finish(cs); ++ cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP); ++ cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP); +#endif /* STAGING_CSMT */ } - static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = -@@ -2276,7 +2518,16 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void + static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data) +@@ -2279,6 +2338,13 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view, }; -+#if !defined(STAGING_CSMT) - static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) -+#else /* STAGING_CSMT */ -+static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, int priority) ++#if defined(STAGING_CSMT) ++static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) +{ + return TRUE; +} + -+static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, int priority) +#endif /* STAGING_CSMT */ + static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) { if (size > (cs->data_size - cs->end)) - { -@@ -2329,6 +2580,9 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs) +@@ -2332,6 +2398,9 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id static const struct wined3d_cs_ops wined3d_cs_st_ops = { @@ -685,36 +150,16 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c wined3d_cs_st_require_space, wined3d_cs_st_submit, wined3d_cs_st_finish, -@@ -2342,7 +2596,11 @@ static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs_queue *queue) - - static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - { -+#if !defined(STAGING_CSMT) - struct wined3d_cs_queue *queue = &cs->queue; -+#else /* STAGING_CSMT */ -+ struct wined3d_cs_queue *queue = cs->queue; -+#endif /* STAGING_CSMT */ - struct wined3d_cs_packet *packet; - size_t packet_size; - -@@ -2357,15 +2615,42 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs) - SetEvent(cs->event); +@@ -2364,6 +2433,21 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id + wined3d_cs_queue_submit(&cs->queue[queue_id], cs); } -+#if !defined(STAGING_CSMT) - static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) - { - struct wined3d_cs_queue *queue = &cs->queue; -+#else /* STAGING_CSMT */ -+static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, int priority) ++#if defined(STAGING_CSMT) ++static BOOL wined3d_cs_queue_check_space(struct wined3d_cs_queue *queue, size_t size) +{ -+ struct wined3d_cs_queue *queue = priority ? &cs->prio_queue : &cs->norm_queue; + size_t queue_size = ARRAY_SIZE(queue->data); + size_t header_size, packet_size, remaining; + -+ if (cs->thread_id == GetCurrentThreadId()) -+ return wined3d_cs_st_check_space(cs, size, priority); -+ + header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); + size = (size + header_size - 1) & ~(header_size - 1); + packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]); @@ -723,67 +168,29 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c + return (remaining >= packet_size); +} + -+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; +#endif /* STAGING_CSMT */ - size_t queue_size = ARRAY_SIZE(queue->data); - size_t header_size, packet_size, remaining; - struct wined3d_cs_packet *packet; - - if (cs->thread_id == GetCurrentThreadId()) -+#if !defined(STAGING_CSMT) - return wined3d_cs_st_require_space(cs, size); -+#else /* STAGING_CSMT */ -+ return wined3d_cs_st_require_space(cs, size, priority); -+#endif /* STAGING_CSMT */ - - header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); - size = (size + header_size - 1) & ~(header_size - 1); -@@ -2386,7 +2671,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); - -+#if !defined(STAGING_CSMT) - nop = wined3d_cs_mt_require_space(cs, nop_size); -+#else /* STAGING_CSMT */ -+ nop = wined3d_cs_mt_require_space(cs, nop_size, priority); -+#endif /* STAGING_CSMT */ - if (nop_size) - nop->opcode = WINED3D_CS_OP_NOP; - -@@ -2417,6 +2706,9 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) - head, tail, (unsigned long)packet_size); - } - -+#if defined(STAGING_CSMT) -+ cs->queue = queue; -+#endif /* STAGING_CSMT */ - packet = (struct wined3d_cs_packet *)&queue->data[queue->head]; - packet->size = size; - return packet->data; -@@ -2424,15 +2716,29 @@ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size) - - static void wined3d_cs_mt_finish(struct wined3d_cs *cs) + static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs) { -+#if defined(STAGING_CSMT) -+ struct wined3d_cs_queue *queue = cs->queue; -+ -+#endif /* STAGING_CSMT */ - if (cs->thread_id == GetCurrentThreadId()) - return wined3d_cs_st_finish(cs); - -+#if !defined(STAGING_CSMT) - while (!wined3d_cs_queue_is_empty(&cs->queue)) - wined3d_pause(); -+#else /* STAGING_CSMT */ -+ while (!wined3d_cs_queue_is_empty(queue)) -+ wined3d_pause(); -+ -+ cs->queue = NULL; -+#endif /* STAGING_CSMT */ + size_t queue_size = ARRAY_SIZE(queue->data); +@@ -2425,6 +2509,16 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size + return packet->data; } ++#if defined(STAGING_CSMT) ++static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) ++{ ++ if (cs->thread_id == GetCurrentThreadId()) ++ return wined3d_cs_st_check_space(cs, size, queue_id); ++ ++ return wined3d_cs_queue_check_space(&cs->queue[queue_id], size); ++} ++ ++#endif /* STAGING_CSMT */ + static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) + { + if (cs->thread_id == GetCurrentThreadId()) +@@ -2444,6 +2538,9 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id + static const struct wined3d_cs_ops wined3d_cs_mt_ops = { +#if defined(STAGING_CSMT) @@ -792,92 +199,10 @@ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c wined3d_cs_mt_require_space, wined3d_cs_mt_submit, wined3d_cs_mt_finish, -@@ -2454,6 +2760,15 @@ static void poll_queries(struct wined3d_cs *cs) - } - } - -+#if defined(STAGING_CSMT) -+static struct wined3d_cs_queue *wined3d_cs_get_queue(struct wined3d_cs *cs) -+{ -+ if (!wined3d_cs_queue_is_empty(&cs->prio_queue)) return &cs->prio_queue; -+ if (!wined3d_cs_queue_is_empty(&cs->norm_queue)) return &cs->norm_queue; -+ return NULL; -+} -+ -+#endif /* STAGING_CSMT */ - static void wined3d_cs_wait_event(struct wined3d_cs *cs) - { - InterlockedExchange(&cs->waiting_for_event, TRUE); -@@ -2465,7 +2780,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(). */ -+#if !defined(STAGING_CSMT) - if (!wined3d_cs_queue_is_empty(&cs->queue) -+#else /* STAGING_CSMT */ -+ if (wined3d_cs_get_queue(cs) -+#endif /* STAGING_CSMT */ - && InterlockedCompareExchange(&cs->waiting_for_event, FALSE, TRUE)) - return; - -@@ -2484,7 +2803,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - - TRACE("Started.\n"); - -+#if !defined(STAGING_CSMT) - queue = &cs->queue; -+#endif /* STAGING_CSMT */ - list_init(&cs->query_poll_list); - cs->thread_id = GetCurrentThreadId(); - for (;;) -@@ -2495,7 +2816,11 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - poll = 0; - } - -+#if !defined(STAGING_CSMT) - if (wined3d_cs_queue_is_empty(queue)) -+#else /* STAGING_CSMT */ -+ if (!(queue = wined3d_cs_get_queue(cs))) -+#endif /* STAGING_CSMT */ - { - if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list)) - wined3d_cs_wait_event(cs); -@@ -2524,7 +2849,9 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) - InterlockedExchange(&queue->tail, tail); - } - -+#if !defined(STAGING_CSMT) - queue->tail = queue->head = 0; -+#endif /* STAGING_CSMT */ - TRACE("Stopped.\n"); - FreeLibraryAndExitThread(cs->wined3d_module, 0); - } -@@ -2598,6 +2925,9 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) - if (cs->thread) - { - wined3d_cs_emit_stop(cs); -+#if defined(STAGING_CSMT) -+ WaitForSingleObject(cs->thread, INFINITE); -+#endif /* STAGING_CSMT */ - CloseHandle(cs->thread); - if (!CloseHandle(cs->event)) - ERR("Closing event failed.\n"); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -1213,7 +1213,11 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) - if (!device->d3d_initialized) - return WINED3DERR_INVALIDCALL; - -+#if !defined(STAGING_CSMT) - device->cs->ops->finish(device->cs); -+#else /* STAGING_CSMT */ -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - - if (device->logo_texture) - wined3d_texture_decref(device->logo_texture); -@@ -1224,6 +1228,9 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) +@@ -1224,6 +1224,9 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) wine_rb_clear(&device->samplers, device_free_sampler, NULL); @@ -887,7 +212,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c wined3d_device_delete_opengl_contexts(device); if (device->fb.depth_stencil) -@@ -4241,6 +4248,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4241,6 +4244,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } @@ -895,7 +220,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); -@@ -4251,6 +4259,19 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev +@@ -4251,6 +4255,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; @@ -904,7 +229,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c + src_texture->sub_resources[src_sub_resource_idx].map_count) + { + struct wined3d_device *device = dst_texture->resource.device; -+ wined3d_cs_emit_sync(device->cs); ++ device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || + src_texture->sub_resources[src_sub_resource_idx].map_count) + { @@ -915,19 +240,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c } if (!src_box) -@@ -4740,7 +4761,11 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, - TRACE("device %p, swapchain_desc %p, mode %p, callback %p, reset_state %#x.\n", - device, swapchain_desc, mode, callback, reset_state); - -+#if !defined(STAGING_CSMT) - device->cs->ops->finish(device->cs); -+#else /* STAGING_CSMT */ -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - - if (!(swapchain = wined3d_device_get_swapchain(device, 0))) - { -@@ -5292,3 +5317,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL +@@ -5292,3 +5309,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL else return CallWindowProcA(proc, window, message, wparam, lparam); } @@ -986,37 +299,10 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c + wined3d_device_destroy_bo(device, context, bo); +} +#endif /* STAGING_CSMT */ -diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c ---- a/dlls/wined3d/resource.c -+++ b/dlls/wined3d/resource.c -@@ -363,6 +363,11 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i - - flags = wined3d_resource_sanitise_map_flags(resource, flags); - -+#if defined(STAGING_CSMT) -+ if (wined3d_settings.cs_multithreaded) -+ wined3d_resource_wait_idle(resource); -+ -+#endif /* STAGING_CSMT */ - return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags); - } - -@@ -378,6 +383,11 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned - { - TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); - -+#if defined(STAGING_CSMT) -+ if (wined3d_settings.cs_multithreaded) -+ wined3d_resource_wait_idle(resource); -+ -+#endif /* STAGING_CSMT */ - return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx); - } - diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c -@@ -2416,7 +2416,11 @@ static BOOL surface_load_texture(struct wined3d_surface *surface, +@@ -2411,7 +2411,11 @@ static BOOL surface_load_texture(struct wined3d_surface *surface, /* Don't use PBOs for converted surfaces. During PBO conversion we look at * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is * getting called. */ @@ -1031,19 +317,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 -@@ -116,7 +116,11 @@ ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain) - { - struct wined3d_device *device = swapchain->device; - -+#if !defined(STAGING_CSMT) - device->cs->ops->finish(device->cs); -+#else /* STAGING_CSMT */ -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - - swapchain_cleanup(swapchain); - swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent); -@@ -482,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); } @@ -1055,18 +329,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 */ -@@ -1208,7 +1216,11 @@ 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) - device->cs->ops->finish(device->cs); -+#else /* STAGING_CSMT */ -+ wined3d_cs_emit_sync(device->cs); -+#endif /* STAGING_CSMT */ - - if (!width || !height) - { diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1286,7 +548,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c return WINEDDERR_SURFACEBUSY; +#else /* STAGING_CSMT */ + struct wined3d_device *device = dst_texture->resource.device; -+ wined3d_cs_emit_sync(device->cs); ++ device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); + if (dst_texture->sub_resources[dst_sub_resource_idx].map_count + || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count)) + { @@ -1360,7 +622,7 @@ diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h -@@ -2668,6 +2668,16 @@ struct wined3d_state +@@ -2694,6 +2694,16 @@ struct wined3d_state struct wined3d_rasterizer_state *rasterizer_state; }; @@ -1377,7 +639,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h #define WINED3D_UNMAPPED_STAGE ~0u /* Multithreaded flag. Removed from the public header to signal that -@@ -2779,6 +2789,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL +@@ -2805,6 +2815,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN; @@ -1390,7 +652,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state) { -@@ -2965,7 +2981,11 @@ struct wined3d_texture +@@ -2991,7 +3007,11 @@ struct wined3d_texture unsigned int map_count; DWORD locations; @@ -1402,40 +664,13 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h } sub_resources[1]; }; -@@ -3273,7 +3293,12 @@ struct wined3d_cs_queue +@@ -3306,6 +3326,9 @@ struct wined3d_cs_queue struct wined3d_cs_ops { -+#if !defined(STAGING_CSMT) - void *(*require_space)(struct wined3d_cs *cs, size_t size); -+#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); -+#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, -@@ -3290,7 +3315,13 @@ struct wined3d_cs - HANDLE thread; - DWORD thread_id; - -+#if !defined(STAGING_CSMT) - struct wined3d_cs_queue queue; -+#else /* STAGING_CSMT */ -+ struct wined3d_cs_queue *queue; -+ struct wined3d_cs_queue norm_queue; -+ struct wined3d_cs_queue prio_queue; -+#endif /* STAGING_CSMT */ - size_t data_size, start, end; - void *data; - struct list query_poll_list; -@@ -3373,6 +3404,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) DECLSPEC_HIDDEN; ++ BOOL (*check_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id); +#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, + void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id); + void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id); + void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);