diff options
author | Grigori Goronzy <[email protected]> | 2017-08-03 20:07:58 +0200 |
---|---|---|
committer | Adam Jackson <[email protected]> | 2019-03-12 19:12:21 -0400 |
commit | acfd88204e886e671da97b895fd2d1ee39b61256 (patch) | |
tree | 811416e4fb64af31378e621ba06ee9e37d299378 /src/glx/dri_common.c | |
parent | ae77f1236862e73c1ac250898924c648d481bda4 (diff) |
glx: add support for GLX_ARB_create_context_no_error (v3)
v2: Only reject no-error contexts for too-old GL if we're actually
trying to create a no-error context (Adam Jackson)
v3: Fix share contexts (Adam Jackson)
Reviewed-by: Adam Jackson <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glx/dri_common.c')
-rw-r--r-- | src/glx/dri_common.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index fb8a29f0993..2db29fd6abb 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -427,6 +427,7 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, { unsigned i; bool got_profile = false; + int no_error = 0; uint32_t profile; *major_ver = 1; @@ -459,6 +460,9 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, case GLX_CONTEXT_FLAGS_ARB: *flags = attribs[i * 2 + 1]; break; + case GLX_CONTEXT_OPENGL_NO_ERROR_ARB: + no_error = attribs[i * 2 + 1]; + break; case GLX_CONTEXT_PROFILE_MASK_ARB: profile = attribs[i * 2 + 1]; got_profile = true; @@ -500,6 +504,10 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, } } + if (no_error) { + *flags |= __DRI_CTX_FLAG_NO_ERROR; + } + if (!got_profile) { if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2)) *api = __DRI_API_OPENGL_CORE; @@ -540,7 +548,8 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, /* Unknown flag value. */ if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE - | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)) { + | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS + | __DRI_CTX_FLAG_NO_ERROR)) { *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; return false; } @@ -565,4 +574,45 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, return true; } +_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; + } + + /* The GLX_ARB_create_context_no_error specs say: + * + * BadMatch is generated if the GLX_CONTEXT_OPENGL_NO_ERROR_ARB is TRUE at + * 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; + } + + return true; +} + #endif /* GLX_DIRECT_RENDERING */ |