+ pcp->base.vtable = &drisw_context_vtable;
+
+ return &pcp->base;
+}
+
+static struct glx_context *
+drisw_create_context_attribs(struct glx_screen *base,
+ struct glx_config *config_base,
+ struct glx_context *shareList,
+ unsigned num_attribs,
+ const uint32_t *attribs,
+ unsigned *error)
+{
+ struct drisw_context *pcp, *pcp_shared;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
+ struct drisw_screen *psc = (struct drisw_screen *) base;
+ __DRIcontext *shared = NULL;
+
+ uint32_t minor_ver;
+ uint32_t major_ver;
+ uint32_t renderType;
+ uint32_t flags;
+ unsigned api;
+ int reset;
+ uint32_t ctx_attribs[2 * 4];
+ unsigned num_ctx_attribs = 0;
+
+ if (!psc->base.driScreen)
+ return NULL;
+
+ if (psc->swrast->base.version < 3)
+ return NULL;
+
+ /* Remap the GLX tokens to DRI2 tokens.
+ */
+ if (!dri2_convert_glx_attribs(num_attribs, attribs,
+ &major_ver, &minor_ver, &renderType, &flags,
+ &api, &reset, error))
+ return NULL;
+
+ /* Check the renderType value */
+ if (!validate_renderType_against_config(config_base, renderType)) {
+ return NULL;
+ }
+
+ if (reset != __DRI_CTX_RESET_NO_NOTIFICATION)
+ return NULL;
+
+ if (shareList) {
+ pcp_shared = (struct drisw_context *) shareList;
+ shared = pcp_shared->driContext;
+ }
+
+ pcp = calloc(1, sizeof *pcp);
+ if (pcp == NULL)
+ return NULL;
+
+ if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
+ free(pcp);
+ return NULL;
+ }
+
+ ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
+ ctx_attribs[num_ctx_attribs++] = major_ver;
+ ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
+ ctx_attribs[num_ctx_attribs++] = minor_ver;
+
+ if (flags != 0) {
+ ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
+
+ /* The current __DRI_CTX_FLAG_* values are identical to the
+ * GLX_CONTEXT_*_BIT values.
+ */
+ ctx_attribs[num_ctx_attribs++] = flags;
+ }
+
+ pcp->base.renderType = renderType;
+
+ pcp->driContext =
+ (*psc->swrast->createContextAttribs) (psc->driScreen,
+ api,
+ config->driConfig,
+ shared,
+ num_ctx_attribs / 2,
+ ctx_attribs,
+ error,
+ pcp);
+ if (pcp->driContext == NULL) {
+ free(pcp);
+ return NULL;
+ }
+
+ pcp->base.vtable = &drisw_context_vtable;