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 priority,
- 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 = 0;
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 (flags & __DRI_CTX_FLAG_NO_ERROR)
+ if (ctx_config->flags & __DRI_CTX_FLAG_NO_ERROR)
attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
if (sharedContextPrivate) {
boolean
dri_create_context(gl_api api,
- const struct gl_config * visual,
- __DRIcontext * driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
- unsigned *error,
- void *sharedContextPrivate);
+ const struct gl_config * visual,
+ __DRIcontext * driContextPriv,
+ const struct __DriverContextConfig *ctx_config,
+ unsigned *error,
+ void *sharedContextPrivate);
#endif
const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
gl_api mesa_api;
- unsigned major_version = 1;
- unsigned minor_version = 0;
- uint32_t flags = 0;
- bool notify_reset = false;
- unsigned priority = __DRI_CTX_PRIORITY_MEDIUM;
+ struct __DriverContextConfig ctx_config;
+
+ ctx_config.major_version = 1;
+ ctx_config.minor_version = 0;
+ ctx_config.flags = 0;
+ ctx_config.attribute_mask = 0;
+ ctx_config.priority = __DRI_CTX_PRIORITY_MEDIUM;
assert((num_attribs == 0) || (attribs != NULL));
for (unsigned i = 0; i < num_attribs; i++) {
switch (attribs[i * 2]) {
case __DRI_CTX_ATTRIB_MAJOR_VERSION:
- major_version = attribs[i * 2 + 1];
+ ctx_config.major_version = attribs[i * 2 + 1];
break;
case __DRI_CTX_ATTRIB_MINOR_VERSION:
- minor_version = attribs[i * 2 + 1];
+ ctx_config.minor_version = attribs[i * 2 + 1];
break;
case __DRI_CTX_ATTRIB_FLAGS:
- flags = attribs[i * 2 + 1];
+ ctx_config.flags = attribs[i * 2 + 1];
break;
case __DRI_CTX_ATTRIB_RESET_STRATEGY:
- notify_reset = (attribs[i * 2 + 1]
- != __DRI_CTX_RESET_NO_NOTIFICATION);
+ if (attribs[i * 2 + 1] != __DRI_CTX_RESET_NO_NOTIFICATION) {
+ ctx_config.attribute_mask |=
+ __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
+ ctx_config.reset_strategy = attribs[i * 2 + 1];
+ } else {
+ ctx_config.attribute_mask &=
+ ~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
+ }
break;
case __DRI_CTX_ATTRIB_PRIORITY:
- priority = attribs[i * 2 + 1];
+ ctx_config.attribute_mask |= __DRIVER_CONTEXT_ATTRIB_PRIORITY;
+ ctx_config.priority = attribs[i * 2 + 1];
break;
default:
/* We can't create a context that satisfies the requirements of an
* compatibility profile. This means that we treat a API_OPENGL_COMPAT 3.1 as
* API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
*/
- if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1)
+ if (mesa_api == API_OPENGL_COMPAT &&
+ ctx_config.major_version == 3 && ctx_config.minor_version == 1)
mesa_api = API_OPENGL_CORE;
if (mesa_api == API_OPENGL_COMPAT
- && ((major_version > 3)
- || (major_version == 3 && minor_version >= 2))) {
+ && ((ctx_config.major_version > 3)
+ || (ctx_config.major_version == 3 &&
+ ctx_config.minor_version >= 2))) {
*error = __DRI_CTX_ERROR_BAD_API;
return NULL;
}
*/
if (mesa_api != API_OPENGL_COMPAT
&& mesa_api != API_OPENGL_CORE
- && (flags & ~(__DRI_CTX_FLAG_DEBUG |
- __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS |
- __DRI_CTX_FLAG_NO_ERROR))) {
+ && (ctx_config.flags & ~(__DRI_CTX_FLAG_DEBUG |
+ __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS |
+ __DRI_CTX_FLAG_NO_ERROR))) {
*error = __DRI_CTX_ERROR_BAD_FLAG;
return NULL;
}
*
* In Mesa, a debug context is the same as a regular context.
*/
- if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
+ if ((ctx_config.flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
mesa_api = API_OPENGL_CORE;
}
| __DRI_CTX_FLAG_FORWARD_COMPATIBLE
| __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS
| __DRI_CTX_FLAG_NO_ERROR);
- if (flags & ~allowed_flags) {
+ if (ctx_config.flags & ~allowed_flags) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return NULL;
}
if (!validate_context_version(screen, mesa_api,
- major_version, minor_version, error))
+ ctx_config.major_version,
+ ctx_config.minor_version,
+ error))
return NULL;
context = calloc(1, sizeof *context);
context->driReadablePriv = NULL;
if (!screen->driver->CreateContext(mesa_api, modes, context,
- major_version, minor_version,
- flags, notify_reset, priority,
- error, shareCtx)) {
+ &ctx_config, error, shareCtx)) {
free(context);
return NULL;
}
extern const __DRIdri2Extension driDRI2Extension;
extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+
+/**
+ * Description of the attributes used to create a config.
+ *
+ * This is passed as the context_config parameter to CreateContext. The idea
+ * with this struct is that it can be extended without having to modify all of
+ * the drivers. The first three members (major/minor_version and flags) are
+ * always valid, but the remaining members are only valid if the corresponding
+ * flag is set for the attribute. If the flag is not set then the default
+ * value should be assumed. That way the driver can quickly check if any
+ * attributes were set that it doesn't understand and report an error.
+ */
+struct __DriverContextConfig {
+ /* These members are always valid */
+ unsigned major_version;
+ unsigned minor_version;
+ uint32_t flags;
+
+ /* Flags describing which of the remaining members are valid */
+ uint32_t attribute_mask;
+
+ /* Only valid if __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY is set */
+ int reset_strategy;
+
+ /* Only valid if __DRIVER_CONTEXT_PRIORITY is set */
+ unsigned priority;
+};
+
+#define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY (1 << 0)
+#define __DRIVER_CONTEXT_ATTRIB_PRIORITY (1 << 1)
+
/**
* Driver callback functions.
*
GLboolean (*CreateContext)(gl_api api,
const struct gl_config *glVis,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate);
intelCreateContext(gl_api api,
const struct gl_config * mesaVis,
__DRIcontext * driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate)
{
__DRIscreen *sPriv = driContextPriv->driScreenPriv;
struct intel_screen *intelScreen = sPriv->driverPrivate;
- if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
+ if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
- if (notify_reset) {
+ if (ctx_config->attribute_mask) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
if (IS_GEN3(intelScreen->deviceID)) {
success = i915CreateContext(api, mesaVis, driContextPriv,
- major_version, minor_version, flags,
+ ctx_config->major_version,
+ ctx_config->minor_version,
+ ctx_config->flags,
error, sharedContextPrivate);
} else {
intelScreen->no_vbo = true;
success = i830CreateContext(api, mesaVis, driContextPriv,
- major_version, minor_version, flags,
+ ctx_config->major_version,
+ ctx_config->minor_version,
+ ctx_config->flags,
error, sharedContextPrivate);
}
brwCreateContext(gl_api api,
const struct gl_config *mesaVis,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *dri_ctx_error,
void *sharedContextPrivate)
{
if (screen->has_context_reset_notification)
allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
- if (flags & ~allowed_flags) {
+ if (ctx_config->flags & ~allowed_flags) {
*dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
+ if (ctx_config->attribute_mask & ~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) {
+ *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
+
+ bool notify_reset =
+ ((ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) &&
+ ctx_config->reset_strategy != __DRI_CTX_RESET_NO_NOTIFICATION);
+
struct brw_context *brw = rzalloc(NULL, struct brw_context);
if (!brw) {
fprintf(stderr, "%s: failed to alloc context\n", __func__);
return false;
}
- driContextSetFlags(ctx, flags);
+ driContextSetFlags(ctx, ctx_config->flags);
/* Initialize the software rasterizer and helper modules.
*
}
int hw_priority = BRW_CONTEXT_MEDIUM_PRIORITY;
- switch (priority) {
- case __DRI_CTX_PRIORITY_LOW:
- hw_priority = BRW_CONTEXT_LOW_PRIORITY;
- break;
- case __DRI_CTX_PRIORITY_HIGH:
- hw_priority = BRW_CONTEXT_HIGH_PRIORITY;
- break;
+ if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) {
+ switch (ctx_config->priority) {
+ case __DRI_CTX_PRIORITY_LOW:
+ hw_priority = BRW_CONTEXT_LOW_PRIORITY;
+ break;
+ case __DRI_CTX_PRIORITY_HIGH:
+ hw_priority = BRW_CONTEXT_HIGH_PRIORITY;
+ break;
+ }
}
if (hw_priority != I915_CONTEXT_DEFAULT_PRIORITY &&
brw_hw_context_set_priority(brw->bufmgr, brw->hw_ctx, hw_priority)) {
fprintf(stderr,
"Failed to set priority [%d:%d] for hardware context.\n",
- priority, hw_priority);
+ ctx_config->priority, hw_priority);
intelDestroyContext(driContextPriv);
return false;
}
brw_draw_init( brw );
- if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
+ if ((ctx_config->flags & __DRI_CTX_FLAG_DEBUG) != 0) {
/* Turn on some extra GL_ARB_debug_output generation. */
brw->perf_debug = true;
}
- if ((flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0) {
+ if ((ctx_config->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0) {
ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
ctx->Const.RobustAccess = GL_TRUE;
}
GLboolean brwCreateContext(gl_api api,
const struct gl_config *mesaVis,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate);
GLboolean
nouveau_context_create(gl_api api,
const struct gl_config *visual, __DRIcontext *dri_ctx,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *share_ctx)
{
struct nouveau_context *nctx;
struct gl_context *ctx;
- if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
+ if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
- if (notify_reset) {
+ if (ctx_config->attribute_mask) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
return GL_FALSE;
}
- driContextSetFlags(ctx, flags);
+ driContextSetFlags(ctx, ctx_config->flags);
nctx = to_nouveau_context(ctx);
nctx->dri_context = dri_ctx;
dri_ctx->driverPrivate = ctx;
_mesa_compute_version(ctx);
- if (ctx->Version < major_version * 10 + minor_version) {
+ if (ctx->Version < (ctx_config->major_version * 10 +
+ ctx_config->minor_version)) {
nouveau_context_destroy(dri_ctx);
*error = __DRI_CTX_ERROR_BAD_VERSION;
return GL_FALSE;
GLboolean
nouveau_context_create(gl_api api,
const struct gl_config *visual, __DRIcontext *dri_ctx,
- unsigned major_version, unsigned minor_version,
- uint32_t flags, bool notify_reset, unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error, void *share_ctx);
GLboolean
GLboolean r200CreateContext( gl_api api,
const struct gl_config *glVisual,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate)
{
int i;
int tcl_mode;
- if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
+ if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
- if (notify_reset) {
+ if (ctx_config->attribute_mask) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
ctx = &rmesa->radeon.glCtx;
- driContextSetFlags(ctx, flags);
+ driContextSetFlags(ctx, ctx_config->flags);
/* Initialize the software rasterizer and helper modules.
*/
extern GLboolean r200CreateContext( gl_api api,
const struct gl_config *glVisual,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *
+ ctx_config,
unsigned *error,
void *sharedContextPrivate);
extern GLboolean r200MakeCurrent( __DRIcontext *driContextPriv,
r100CreateContext( gl_api api,
const struct gl_config *glVisual,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate)
{
int i;
int tcl_mode, fthrottle_mode;
- if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
+ if (ctx_config->flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_NO_ERROR)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
- if (notify_reset) {
+ if (ctx_config->attribute_mask) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
ctx = &rmesa->radeon.glCtx;
- driContextSetFlags(ctx, flags);
+ driContextSetFlags(ctx, ctx_config->flags);
/* Initialize the software rasterizer and helper modules.
*/
extern GLboolean r100CreateContext( gl_api api,
const struct gl_config *glVisual,
__DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
- unsigned priority,
+ const struct __DriverContextConfig *
+ ctx_config,
unsigned *error,
void *sharedContextPrivate);
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 priority,
+ const struct __DriverContextConfig *ctx_config,
unsigned *error,
void *sharedContextPrivate)
{
/* Flag filtering is handled in dri2CreateContextAttribs.
*/
- (void) flags;
+ (void) ctx_config->flags;
+
+ /* The swrast driver doesn't understand any of the attributes */
+ if (ctx_config->attribute_mask != 0) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
ctx = CALLOC_STRUCT(dri_context);
if (ctx == NULL) {
goto context_fail;
}
- driContextSetFlags(mesaCtx, flags);
+ driContextSetFlags(mesaCtx, ctx_config->flags);
/* create module contexts */
_swrast_CreateContext( mesaCtx );