Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/context.c | 29 ++++++++++++++--------------- dlls/wined3d/wined3d_main.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index fb393395258..80124c17dbe 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1255,13 +1255,13 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context if (context_gl->c.destroyed || !swapchain) { FIXME("Unable to get backup dc for destroyed context %p.\n", context_gl); - context_set_current(NULL); + wined3d_context_gl_set_current(NULL); return FALSE; }
if (!(context_gl->dc = swapchain_get_backup_dc(swapchain))) { - context_set_current(NULL); + wined3d_context_gl_set_current(NULL); return FALSE; }
@@ -1272,7 +1272,7 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context { ERR("Failed to set pixel format %d on device context %p.\n", context_gl->pixel_format, context_gl->dc); - context_set_current(NULL); + wined3d_context_gl_set_current(NULL); return FALSE; }
@@ -1280,7 +1280,7 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context { ERR("Fallback to backup window (dc %p) failed too, last error %#x.\n", context_gl->dc, GetLastError()); - context_set_current(NULL); + wined3d_context_gl_set_current(NULL); return FALSE; }
@@ -1297,7 +1297,7 @@ static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HD { ERR("Failed to restore GL context %p on device context %p, last error %#x.\n", gl_ctx, dc, GetLastError()); - context_set_current(NULL); + wined3d_context_gl_set_current(NULL); } }
@@ -1508,13 +1508,14 @@ struct wined3d_context *context_get_current(void) return TlsGetValue(wined3d_context_tls_idx); }
-BOOL context_set_current(struct wined3d_context *ctx) +BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) { + struct wined3d_context *ctx = context_gl ? &context_gl->c : NULL; struct wined3d_context *old = context_get_current();
if (old == ctx) { - TRACE("Already using D3D context %p.\n", ctx); + TRACE("Already using D3D context %p.\n", context_gl); return TRUE; }
@@ -1532,20 +1533,18 @@ BOOL context_set_current(struct wined3d_context *ctx) if (wglGetCurrentContext()) { const struct wined3d_gl_info *gl_info = old->gl_info; - TRACE("Flushing context %p before switching to %p.\n", old, ctx); + TRACE("Flushing context %p before switching to %p.\n", old, context_gl); gl_info->gl_ops.gl.p_glFlush(); } old->current = 0; } }
- if (ctx) + if (context_gl) { - struct wined3d_context_gl *context_gl = wined3d_context_gl(ctx); - if (!context_gl->valid) { - ERR("Trying to make invalid context %p current\n", ctx); + ERR("Trying to make invalid context %p current.\n", context_gl); return FALSE; }
@@ -1553,7 +1552,7 @@ BOOL context_set_current(struct wined3d_context *ctx) context_gl, context_gl->gl_ctx, context_gl->dc); if (!wined3d_context_gl_set_gl_context(context_gl)) return FALSE; - ctx->current = 1; + context_gl->c.current = 1; } else if (wglGetCurrentContext()) { @@ -2146,7 +2145,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi context_gl->needs_set = 1;
/* Set up the context defaults */ - if (!context_set_current(context)) + if (!wined3d_context_gl_set_current(context_gl)) { ERR("Cannot activate context to set up defaults.\n"); context_release(context); @@ -4201,7 +4200,7 @@ static void wined3d_context_gl_activate(struct wined3d_context_gl *context_gl,
if (&context_gl->c != context_get_current()) { - if (!context_set_current(&context_gl->c)) + if (!wined3d_context_gl_set_current(context_gl)) ERR("Failed to activate the new context.\n"); } else if (context_gl->needs_set) diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 132c9782def..5d60a44ef69 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -820,7 +820,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) break;
case DLL_THREAD_DETACH: - if (!context_set_current(NULL)) + if (!wined3d_context_gl_set_current(NULL)) { ERR("Failed to clear current context.\n"); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c7d9cd74258..60c69f13d04 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2116,6 +2116,7 @@ void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN; struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; +BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN; void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl, const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN; @@ -2271,7 +2272,6 @@ void context_invalidate_state(struct wined3d_context *context, DWORD state_id) D void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN; -BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN; void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN; void context_state_drawbuf(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;