unsigned allowed_flags = __DRI_CTX_FLAG_DEBUG |
__DRI_CTX_FLAG_FORWARD_COMPATIBLE |
__DRI_CTX_FLAG_NO_ERROR;
- unsigned allowed_attribs = __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
+ unsigned allowed_attribs =
+ __DRIVER_CONTEXT_ATTRIB_PRIORITY |
+ __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
const __DRIbackgroundCallableExtension *backgroundCallable =
screen->sPriv->dri2.backgroundCallable;
+ const struct driOptionCache *optionCache = &screen->dev->option_cache;
if (screen->has_reset_status_query) {
allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
break;
case API_OPENGL_COMPAT:
case API_OPENGL_CORE:
- attribs.profile = api == API_OPENGL_COMPAT ? ST_PROFILE_DEFAULT
- : ST_PROFILE_OPENGL_CORE;
+ if (driQueryOptionb(optionCache, "force_compat_profile")) {
+ attribs.profile = ST_PROFILE_DEFAULT;
+ } else {
+ attribs.profile = api == API_OPENGL_COMPAT ? ST_PROFILE_DEFAULT
+ : ST_PROFILE_OPENGL_CORE;
+ }
+
attribs.major = ctx_config->major_version;
attribs.minor = ctx_config->minor_version;
if (ctx_config->flags & __DRI_CTX_FLAG_NO_ERROR)
attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
+ if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) {
+ switch (ctx_config->priority) {
+ case __DRI_CTX_PRIORITY_LOW:
+ attribs.flags |= ST_CONTEXT_FLAG_LOW_PRIORITY;
+ break;
+ case __DRI_CTX_PRIORITY_HIGH:
+ attribs.flags |= ST_CONTEXT_FLAG_HIGH_PRIORITY;
+ break;
+ default:
+ break;
+ }
+ }
+
if ((ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR)
&& (ctx_config->release_behavior == __DRI_CTX_RELEASE_BEHAVIOR_NONE))
attribs.flags |= ST_CONTEXT_FLAG_RELEASE_NONE;
+ struct dri_context *share_ctx = NULL;
if (sharedContextPrivate) {
- st_share = ((struct dri_context *)sharedContextPrivate)->st;
+ share_ctx = (struct dri_context *)sharedContextPrivate;
+ st_share = share_ctx->st;
}
ctx = CALLOC_STRUCT(dri_context);
if (ctx->st->cso_context) {
ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context);
- ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context);
+ ctx->hud = hud_create(ctx->st->cso_context,
+ share_ctx ? share_ctx->hud : NULL);
}
/* Do this last. */
struct dri_context *ctx = dri_context(cPriv);
if (ctx->hud) {
- hud_destroy(ctx->hud);
+ hud_destroy(ctx->hud, ctx->st->cso_context);
}
if (ctx->pp)
free(ctx);
}
+/* This is called inside MakeCurrent to unbind the context. */
GLboolean
dri_unbind_context(__DRIcontext * cPriv)
{
/* dri_util.c ensures cPriv is not null */
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
struct dri_context *ctx = dri_context(cPriv);
+ struct st_context_iface *st = ctx->st;
struct st_api *stapi = screen->st_api;
if (--ctx->bind_count == 0) {
- if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
- if (ctx->st->thread_finish)
- ctx->st->thread_finish(ctx->st);
-
- /* For conformance, unbind is supposed to flush the context.
- * However, if we do it here we might end up flushing a partially
- * destroyed context. Instead, we flush in dri_make_current and
- * in dri_destroy_context which should cover all the cases.
- */
+ if (st == stapi->get_current(stapi)) {
+ if (st->thread_finish)
+ st->thread_finish(st);
+
+ /* Record HUD queries for the duration the context was "current". */
+ if (ctx->hud)
+ hud_record_only(ctx->hud, st->pipe);
+
stapi->make_current(stapi, NULL, NULL, NULL);
}
}
struct dri_context *ctx = dri_context(cPriv);
struct dri_drawable *draw = dri_drawable(driDrawPriv);
struct dri_drawable *read = dri_drawable(driReadPriv);
- struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi);
-
- if (old_st && old_st->thread_finish)
- old_st->thread_finish(old_st);
-
- /* Flush the old context here so we don't have to flush on unbind() */
- if (old_st && old_st != ctx->st)
- old_st->flush(old_st, ST_FLUSH_FRONT, NULL);
++ctx->bind_count;