#include "state_tracker/drm_driver.h"
#include "pipe/p_context.h"
+#include "pipe-loader/pipe_loader.h"
#include "state_tracker/st_context.h"
GLboolean
dri_create_context(gl_api api, const struct gl_config * visual,
- __DRIcontext * cPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned *error,
- void *sharedContextPrivate)
+ __DRIcontext * cPriv,
+ const struct __DriverContextConfig *ctx_config,
+ unsigned *error,
+ void *sharedContextPrivate)
{
__DRIscreen *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
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;
const __DRIbackgroundCallableExtension *backgroundCallable =
screen->sPriv->dri2.backgroundCallable;
- if (screen->has_reset_status_query)
+ if (screen->has_reset_status_query) {
allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
+ allowed_attribs |= __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
+ }
- if (flags & ~allowed_flags) {
+ if (ctx_config->flags & ~allowed_flags) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
goto fail;
}
- if (!screen->has_reset_status_query && notify_reset) {
+ if (ctx_config->attribute_mask & ~allowed_attribs) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
goto fail;
}
case API_OPENGL_CORE:
attribs.profile = api == API_OPENGL_COMPAT ? ST_PROFILE_DEFAULT
: ST_PROFILE_OPENGL_CORE;
- attribs.major = major_version;
- attribs.minor = minor_version;
+ attribs.major = ctx_config->major_version;
+ attribs.minor = ctx_config->minor_version;
- if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+ if ((ctx_config->flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
break;
default:
goto fail;
}
- if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+ if ((ctx_config->flags & __DRI_CTX_FLAG_DEBUG) != 0)
attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
- if (flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)
+ if (ctx_config->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)
attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
- if (notify_reset)
- attribs.flags |= ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED;
+ if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY)
+ if (ctx_config->reset_strategy != __DRI_CTX_RESET_NO_NOTIFICATION)
+ attribs.flags |= ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED;
+
+ if (ctx_config->flags & __DRI_CTX_FLAG_NO_ERROR)
+ attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
+
+ 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;
if (sharedContextPrivate) {
st_share = ((struct dri_context *)sharedContextPrivate)->st;
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
+ if (driQueryOptionb(&screen->dev->option_cache, "mesa_no_error"))
+ attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
+
attribs.options = screen->options;
dri_fill_st_visual(&attribs.visual, screen, visual);
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
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);
}
/* Do this last. */
if (ctx->st->start_thread &&
- driQueryOptionb(&screen->optionCache, "mesa_glthread")) {
+ driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
if (backgroundCallable && backgroundCallable->base.version >= 2 &&
backgroundCallable->isThreadSafe) {
/* 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);
+
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;