I'm not sure this is 100% safe (maybe limiting those blits to sysmem textures would be better like stated in the original change?)
-- v3: HACK: wined3d: Don't assert in CS thread check.
From: Aida Jonikienė aidas957@gmail.com
This is basically a revert of commit db6f95880c2631b64e48adc547d365e878ae45a6.
Testing of the problematic game in bug 45382 shows it no longer crashes with those blits enabled (even with CSMT) so I think this isn't a major issue anymore (and rejecting cross-device blits can break some games like GTA 2 where the menu is missing some textures after exiting from the game to the menu screen). --- dlls/wined3d/texture.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 2efdaf91438..8fd43311056 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -3902,12 +3902,6 @@ HRESULT CDECL wined3d_device_context_blt(struct wined3d_device_context *context, return WINED3DERR_INVALIDCALL; }
- if (dst_texture->resource.device != src_texture->resource.device) - { - FIXME("Rejecting cross-device blit.\n"); - return E_NOTIMPL; - } - wined3d_device_context_emit_blt_sub_resource(context, &dst_texture->resource, dst_sub_resource_idx, &dst_box, &src_texture->resource, src_sub_resource_idx, &src_box, flags, fx, filter);
From: Aida Jonikienė aidas957@gmail.com
--- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/device.c | 2 +- dlls/wined3d/directx.c | 4 +--- dlls/wined3d/swapchain.c | 2 +- dlls/wined3d/wined3d_private.h | 13 ++++++++++--- 5 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 6b606617f3d..af3d4326608 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2297,7 +2297,7 @@ void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
TRACE("Destroying context %p.\n", context_gl);
- wined3d_from_cs(device->cs); + if (!wined3d_from_cs(device->cs)) return;
/* We delay destroying a context when it is active. The context_release() * function invokes wined3d_context_gl_destroy() again while leaving the diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0fb71108b27..770e3cfd53a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5563,7 +5563,7 @@ void device_invalidate_state(const struct wined3d_device *device, unsigned int s unsigned int representative, i, idx, shift; struct wined3d_context *context;
- wined3d_from_cs(device->cs); + if (!wined3d_from_cs(device->cs)) return;
if (STATE_IS_COMPUTE(state_id)) { diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index f236a59f963..75644133ace 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2908,9 +2908,7 @@ static struct wined3d_context *adapter_no3d_acquire_context(struct wined3d_devic { TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
- wined3d_from_cs(device->cs); - - if (!device->context_count) + if (!wined3d_from_cs(device->cs) || !device->context_count) return NULL;
return &wined3d_device_no3d(device)->context_no3d; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 6b2ad8d6954..78abf283a22 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -1766,7 +1766,7 @@ static struct wined3d_context_gl *wined3d_swapchain_gl_create_context(struct win
TRACE("Creating a new context for swapchain %p, thread %lu.\n", swapchain_gl, GetCurrentThreadId());
- wined3d_from_cs(device->cs); + if (!wined3d_from_cs(device->cs)) return NULL;
if (!(context_gl = calloc(1, sizeof(*context_gl)))) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index eff2400fd8f..9b2b354b5d1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4660,10 +4660,17 @@ static inline void wined3d_insert_bits(uint32_t *bitstream, } }
-static inline void wined3d_from_cs(const struct wined3d_cs *cs) +static inline BOOL wined3d_from_cs(const struct wined3d_cs *cs) { if (cs->thread) - assert(cs->thread_id == GetCurrentThreadId()); + { + if (cs->thread_id == GetCurrentThreadId()) + return TRUE; + else + return FALSE; + } + + return TRUE; }
static inline void wined3d_not_from_cs(const struct wined3d_cs *cs) @@ -4730,7 +4737,7 @@ void compute_normal_matrix(struct wined3d_matrix *normal_matrix, BOOL legacy_lig static inline struct wined3d_context *context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx) { - wined3d_from_cs(device->cs); + if (!wined3d_from_cs(device->cs)) return NULL;
return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx); }