glx: Use the new no-error driver interface
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12474>
This commit is contained in:
@@ -198,10 +198,6 @@ dri2_create_context_attribs(struct glx_screen *base,
|
||||
if (*error != __DRI_CTX_ERROR_SUCCESS)
|
||||
goto error_exit;
|
||||
|
||||
if (!dri2_check_no_error(dca.flags, shareList, dca.major_ver, error)) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
/* Check the renderType value */
|
||||
if (!validate_renderType_against_config(config_base, dca.render_type))
|
||||
goto error_exit;
|
||||
@@ -211,6 +207,17 @@ dri2_create_context_attribs(struct glx_screen *base,
|
||||
if (!shareList->isDirect)
|
||||
return NULL;
|
||||
|
||||
/* The GLX_ARB_create_context_no_error specs say:
|
||||
*
|
||||
* BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
|
||||
* used to create <share_context> does not match the value of
|
||||
* GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
|
||||
*/
|
||||
if (!!shareList->noError != !!dca.no_error) {
|
||||
*error = __DRI_CTX_ERROR_BAD_FLAG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp_shared = (struct dri2_context *) shareList;
|
||||
shared = pcp_shared->driContext;
|
||||
}
|
||||
@@ -243,12 +250,14 @@ dri2_create_context_attribs(struct glx_screen *base,
|
||||
ctx_attribs[num_ctx_attribs++] = dca.release;
|
||||
}
|
||||
|
||||
if (dca.no_error) {
|
||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
||||
pcp->base.noError = GL_TRUE;
|
||||
}
|
||||
|
||||
if (dca.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++] = dca.flags;
|
||||
}
|
||||
|
||||
@@ -257,9 +266,6 @@ dri2_create_context_attribs(struct glx_screen *base,
|
||||
*/
|
||||
pcp->base.renderType = dca.render_type;
|
||||
|
||||
if (dca.flags & __DRI_CTX_FLAG_NO_ERROR)
|
||||
pcp->base.noError = GL_TRUE;
|
||||
|
||||
pcp->driContext =
|
||||
(*psc->dri2->createContextAttribs) (psc->driScreen,
|
||||
dca.api,
|
||||
@@ -1096,13 +1102,15 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_robustness");
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_NO_ERROR) == 0)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
|
||||
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
|
||||
unsigned int no_error = 0;
|
||||
if (psc->rendererQuery->queryInteger(psc->driScreen,
|
||||
__DRI2_RENDERER_HAS_NO_ERROR_CONTEXT,
|
||||
&no_error) == 0 && no_error)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
}
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0)
|
||||
|
@@ -249,10 +249,6 @@ dri3_create_context_attribs(struct glx_screen *base,
|
||||
if (*error != __DRI_CTX_ERROR_SUCCESS)
|
||||
goto error_exit;
|
||||
|
||||
if (!dri2_check_no_error(dca.flags, shareList, dca.major_ver, error)) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
/* Check the renderType value */
|
||||
if (!validate_renderType_against_config(config_base, dca.render_type))
|
||||
goto error_exit;
|
||||
@@ -262,6 +258,17 @@ dri3_create_context_attribs(struct glx_screen *base,
|
||||
if (!shareList->isDirect)
|
||||
return NULL;
|
||||
|
||||
/* The GLX_ARB_create_context_no_error specs say:
|
||||
*
|
||||
* BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
|
||||
* used to create <share_context> does not match the value of
|
||||
* GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
|
||||
*/
|
||||
if (!!shareList->noError != !!dca.no_error) {
|
||||
*error = __DRI_CTX_ERROR_BAD_FLAG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp_shared = (struct dri3_context *) shareList;
|
||||
shared = pcp_shared->driContext;
|
||||
}
|
||||
@@ -294,16 +301,15 @@ dri3_create_context_attribs(struct glx_screen *base,
|
||||
ctx_attribs[num_ctx_attribs++] = dca.release;
|
||||
}
|
||||
|
||||
if (dca.no_error) {
|
||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||
ctx_attribs[num_ctx_attribs++] = dca.no_error;
|
||||
pcp->base.noError = GL_TRUE;
|
||||
}
|
||||
|
||||
if (dca.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++] = dca.flags;
|
||||
|
||||
if (dca.flags & __DRI_CTX_FLAG_NO_ERROR)
|
||||
pcp->base.noError = GL_TRUE;
|
||||
}
|
||||
|
||||
pcp->base.renderType = dca.render_type;
|
||||
@@ -793,13 +799,15 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_robustness");
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_NO_ERROR) == 0)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
|
||||
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
|
||||
unsigned int no_error = 0;
|
||||
if (psc->rendererQuery->queryInteger(psc->driScreen,
|
||||
__DRI2_RENDERER_HAS_NO_ERROR_CONTEXT,
|
||||
&no_error) == 0 && no_error)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
}
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0)
|
||||
|
@@ -460,7 +460,6 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
struct dri_ctx_attribs *dca)
|
||||
{
|
||||
unsigned i;
|
||||
int no_error = 0;
|
||||
uint32_t profile = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
|
||||
dca->major_ver = 1;
|
||||
@@ -470,6 +469,7 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
dca->release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
|
||||
dca->flags = 0;
|
||||
dca->api = __DRI_API_OPENGL;
|
||||
dca->no_error = 0;
|
||||
|
||||
if (num_attribs == 0)
|
||||
return __DRI_CTX_ERROR_SUCCESS;
|
||||
@@ -490,7 +490,7 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
dca->flags = attribs[i * 2 + 1];
|
||||
break;
|
||||
case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
|
||||
no_error = attribs[i * 2 + 1];
|
||||
dca->no_error = attribs[i * 2 + 1];
|
||||
break;
|
||||
case GLX_CONTEXT_PROFILE_MASK_ARB:
|
||||
profile = attribs[i * 2 + 1];
|
||||
@@ -533,10 +533,6 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
}
|
||||
}
|
||||
|
||||
if (no_error) {
|
||||
dca->flags |= __DRI_CTX_FLAG_NO_ERROR;
|
||||
}
|
||||
|
||||
switch (profile) {
|
||||
case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
|
||||
/* This is the default value, but there are no profiles before OpenGL
|
||||
@@ -571,7 +567,7 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
if (dca->flags & ~(__DRI_CTX_FLAG_DEBUG |
|
||||
__DRI_CTX_FLAG_FORWARD_COMPATIBLE |
|
||||
__DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS |
|
||||
__DRI_CTX_FLAG_NO_ERROR))
|
||||
__DRI_CTX_FLAG_RESET_ISOLATION))
|
||||
return __DRI_CTX_ERROR_UNKNOWN_FLAG;
|
||||
|
||||
/* There are no forward-compatible contexts before OpenGL 3.0. The
|
||||
@@ -586,34 +582,12 @@ dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
if (dca->major_ver >= 3 && dca->render_type == GLX_COLOR_INDEX_TYPE)
|
||||
return __DRI_CTX_ERROR_BAD_FLAG;
|
||||
|
||||
return __DRI_CTX_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
_X_HIDDEN bool
|
||||
dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
|
||||
int major, unsigned *error)
|
||||
{
|
||||
Bool noError = flags & __DRI_CTX_FLAG_NO_ERROR;
|
||||
|
||||
/* The KHR_no_error specs say:
|
||||
*
|
||||
* Requires OpenGL ES 2.0 or OpenGL 2.0.
|
||||
*/
|
||||
if (noError && major < 2) {
|
||||
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The GLX_ARB_create_context_no_error specs say:
|
||||
*
|
||||
* BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
|
||||
* used to create <share_context> does not match the value of
|
||||
* GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
|
||||
*/
|
||||
if (share_context && !!share_context->noError != !!noError) {
|
||||
*error = __DRI_CTX_ERROR_BAD_FLAG;
|
||||
return false;
|
||||
}
|
||||
if (dca->no_error && dca->major_ver < 2)
|
||||
return __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
|
||||
|
||||
/* The GLX_ARB_create_context_no_error specs say:
|
||||
*
|
||||
@@ -621,13 +595,11 @@ dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
|
||||
* the same time as a debug or robustness context is specified.
|
||||
*
|
||||
*/
|
||||
if (noError && ((flags & __DRI_CTX_FLAG_DEBUG) ||
|
||||
(flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS))) {
|
||||
*error = __DRI_CTX_ERROR_BAD_FLAG;
|
||||
return false;
|
||||
}
|
||||
if (dca->no_error && ((dca->flags & __DRI_CTX_FLAG_DEBUG) ||
|
||||
(dca->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)))
|
||||
return __DRI_CTX_ERROR_BAD_FLAG;
|
||||
|
||||
return true;
|
||||
return __DRI_CTX_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
struct glx_context *
|
||||
|
@@ -74,17 +74,13 @@ struct dri_ctx_attribs {
|
||||
unsigned api;
|
||||
int reset;
|
||||
int release;
|
||||
int no_error;
|
||||
};
|
||||
|
||||
extern int
|
||||
dri_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
|
||||
struct dri_ctx_attribs *dca);
|
||||
|
||||
extern bool
|
||||
dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
|
||||
int major, unsigned *error);
|
||||
|
||||
|
||||
extern struct glx_context *
|
||||
dri_common_create_context(struct glx_screen *base,
|
||||
struct glx_config *config_base,
|
||||
|
@@ -523,9 +523,6 @@ drisw_create_context_attribs(struct glx_screen *base,
|
||||
if (*error != __DRI_CTX_ERROR_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
if (!dri2_check_no_error(dca.flags, shareList, dca.major_ver, error))
|
||||
return NULL;
|
||||
|
||||
/* Check the renderType value */
|
||||
if (!validate_renderType_against_config(config_base, dca.render_type)) {
|
||||
return NULL;
|
||||
@@ -536,6 +533,17 @@ drisw_create_context_attribs(struct glx_screen *base,
|
||||
if (!shareList->isDirect)
|
||||
return NULL;
|
||||
|
||||
/* The GLX_ARB_create_context_no_error specs say:
|
||||
*
|
||||
* BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
|
||||
* used to create <share_context> does not match the value of
|
||||
* GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
|
||||
*/
|
||||
if (!!shareList->noError != !!dca.no_error) {
|
||||
*error = __DRI_CTX_ERROR_BAD_FLAG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp_shared = (struct drisw_context *) shareList;
|
||||
shared = pcp_shared->driContext;
|
||||
}
|
||||
@@ -557,17 +565,15 @@ drisw_create_context_attribs(struct glx_screen *base,
|
||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR;
|
||||
ctx_attribs[num_ctx_attribs++] = dca.release;
|
||||
}
|
||||
if (dca.no_error) {
|
||||
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_NO_ERROR;
|
||||
ctx_attribs[num_ctx_attribs++] = GL_TRUE;
|
||||
pcp->base.noError = GL_TRUE;
|
||||
}
|
||||
|
||||
if (dca.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++] = dca.flags;
|
||||
|
||||
if (dca.flags & __DRI_CTX_FLAG_NO_ERROR)
|
||||
pcp->base.noError = GL_TRUE;
|
||||
}
|
||||
|
||||
pcp->base.renderType = dca.render_type;
|
||||
@@ -768,6 +774,12 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
|
||||
&& strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
|
||||
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
|
||||
unsigned int no_error = 0;
|
||||
if (psc->rendererQuery->queryInteger(psc->driScreen,
|
||||
__DRI2_RENDERER_HAS_NO_ERROR_CONTEXT,
|
||||
&no_error) == 0 && no_error)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
}
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0)
|
||||
@@ -778,10 +790,6 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_context_flush_control");
|
||||
}
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI2_NO_ERROR) == 0)
|
||||
__glXEnableDirectExtension(&psc->base,
|
||||
"GLX_ARB_create_context_no_error");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user