wined3d: Pass a wined3d_context_gl structure to context_set_current().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-08-05 17:39:54 +04:30 committed by Alexandre Julliard
parent 8003f1fd64
commit 360e1a46d8
3 changed files with 16 additions and 17 deletions

View File

@ -1255,13 +1255,13 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context
if (context_gl->c.destroyed || !swapchain) if (context_gl->c.destroyed || !swapchain)
{ {
FIXME("Unable to get backup dc for destroyed context %p.\n", context_gl); 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; return FALSE;
} }
if (!(context_gl->dc = swapchain_get_backup_dc(swapchain))) if (!(context_gl->dc = swapchain_get_backup_dc(swapchain)))
{ {
context_set_current(NULL); wined3d_context_gl_set_current(NULL);
return FALSE; 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", ERR("Failed to set pixel format %d on device context %p.\n",
context_gl->pixel_format, context_gl->dc); context_gl->pixel_format, context_gl->dc);
context_set_current(NULL); wined3d_context_gl_set_current(NULL);
return FALSE; 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", ERR("Fallback to backup window (dc %p) failed too, last error %#x.\n",
context_gl->dc, GetLastError()); context_gl->dc, GetLastError());
context_set_current(NULL); wined3d_context_gl_set_current(NULL);
return FALSE; 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", ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
gl_ctx, dc, GetLastError()); 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); 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(); struct wined3d_context *old = context_get_current();
if (old == ctx) if (old == ctx)
{ {
TRACE("Already using D3D context %p.\n", ctx); TRACE("Already using D3D context %p.\n", context_gl);
return TRUE; return TRUE;
} }
@ -1532,20 +1533,18 @@ BOOL context_set_current(struct wined3d_context *ctx)
if (wglGetCurrentContext()) if (wglGetCurrentContext())
{ {
const struct wined3d_gl_info *gl_info = old->gl_info; 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(); gl_info->gl_ops.gl.p_glFlush();
} }
old->current = 0; old->current = 0;
} }
} }
if (ctx) if (context_gl)
{ {
struct wined3d_context_gl *context_gl = wined3d_context_gl(ctx);
if (!context_gl->valid) 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; return FALSE;
} }
@ -1553,7 +1552,7 @@ BOOL context_set_current(struct wined3d_context *ctx)
context_gl, context_gl->gl_ctx, context_gl->dc); context_gl, context_gl->gl_ctx, context_gl->dc);
if (!wined3d_context_gl_set_gl_context(context_gl)) if (!wined3d_context_gl_set_gl_context(context_gl))
return FALSE; return FALSE;
ctx->current = 1; context_gl->c.current = 1;
} }
else if (wglGetCurrentContext()) 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; context_gl->needs_set = 1;
/* Set up the context defaults */ /* 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"); ERR("Cannot activate context to set up defaults.\n");
context_release(context); 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_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"); ERR("Failed to activate the new context.\n");
} }
else if (context_gl->needs_set) else if (context_gl->needs_set)

View File

@ -820,7 +820,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
if (!context_set_current(NULL)) if (!wined3d_context_gl_set_current(NULL))
{ {
ERR("Failed to clear current context.\n"); ERR("Failed to clear current context.\n");
} }

View File

@ -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; 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; 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; 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_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, void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN; 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_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
unsigned int sub_resource_idx) DECLSPEC_HIDDEN; 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_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
void context_state_drawbuf(struct wined3d_context *context, void context_state_drawbuf(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;