[PATCH 3/4] glx: Implement GLX_EXT_create_context_es2_profile

Dave Airlie airlied at gmail.com
Sun Jun 10 11:12:13 PDT 2012


On Fri, Jun 8, 2012 at 9:10 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> This patch builds on the infrastucture put in place for
> GLX_ARB_create_context_profile.  If GLX_CONTEXT_ES2_PROFILE_BIT_EXT is
> specified and the requested version is 2.0, create a context with the
> __DRI_API_GLES2 API.
>
> This change assumes that any DRI2 driver can handle (possibly by saying "no
> seeing an API setting other than __DRI_API_OPENGL or __DRI_API_OPENGL_CORE.
> This allows enabling the extension any time GLX_ARB_create_context (and
> GLX_ARB_create_context_profile) is enabled.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>

I'm no ES2 expert, so maybe one of the mesa ES guys could chime in,
but the patch
seems to fit the commit message.

Reviewed-by: Dave Airlie <airlied at redhat.com>
> ---
>  glx/createcontext.c    |   37 +++++++++++++++++++++++++++++++++++++
>  glx/extension_string.c |    1 +
>  glx/extension_string.h |    1 +
>  glx/glxdri2.c          |    7 +++++++
>  4 files changed, 46 insertions(+), 0 deletions(-)
>
> diff --git a/glx/createcontext.c b/glx/createcontext.c
> index 6f580f0..8f7dc05 100644
> --- a/glx/createcontext.c
> +++ b/glx/createcontext.c
> @@ -229,6 +229,43 @@ __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc)
>     case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
>     case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
>         break;
> +    case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
> +        /* The GLX_EXT_create_context_es2_profile spec says:
> +         *
> +         *     "... If the version requested is 2.0, and the
> +         *     GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
> +         *     GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the
> +         *     context returned will implement OpenGL ES 2.0."
> +         *
> +         * It also says:
> +         *
> +         *     "* If attribute GLX_CONTEXT_PROFILE_MASK_ARB has no bits set;
> +         *        has any bits set other than
> +         *        GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
> +         *        GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, or
> +         *        GLX_CONTEXT_ES2_PROFILE_BIT_EXT; has more than one of these
> +         *        bits set; or if the implementation does not supported the
> +         *        requested profile, then GLXBadProfileARB is generated."
> +         *
> +         * However, it does not say what is supposed to happen if
> +         * GLX_CONTEXT_ES2_PROFILE_BIT_EXT is set but the version requested is
> +         * not 2.0.
> +         *
> +         * We choose to generate GLXBadProfileARB.
> +         *
> +         * Other options include:
> +         *
> +         *    * Generate BadMatch.
> +         *
> +         *    * Ignore the version and create an ES2 context.
> +         *
> +         *    * Ignore GLX_CONTEXT_ES2_PROFILE_BIT_EXT and create a context
> +         *      with the specified version and the default profile for that
> +         *      version.
> +         */
> +        if (major_version != 2 || minor_version != 0)
> +            return __glXError(GLXBadProfileARB);
> +        break;
>     default:
>         return __glXError(GLXBadProfileARB);
>     }
> diff --git a/glx/extension_string.c b/glx/extension_string.c
> index 6a1a6c6..2d550a9 100644
> --- a/glx/extension_string.c
> +++ b/glx/extension_string.c
> @@ -72,6 +72,7 @@ static const struct extension_info known_glx_extensions[] = {
>     { GLX(ARB_create_context_profile),  VER(0,0), N, },
>     { GLX(ARB_multisample),             VER(1,4), Y, },
>
> +    { GLX(EXT_create_context_es2_profile), VER(0,0), N, },
>     { GLX(EXT_import_context),          VER(0,0), Y, },
>     { GLX(EXT_texture_from_pixmap),     VER(0,0), Y, },
>     { GLX(EXT_visual_info),             VER(0,0), Y, },
> diff --git a/glx/extension_string.h b/glx/extension_string.h
> index 947bf89..1704696 100644
> --- a/glx/extension_string.h
> +++ b/glx/extension_string.h
> @@ -39,6 +39,7 @@ enum {
>     ARB_create_context_bit = 0,
>     ARB_create_context_profile_bit,
>     ARB_multisample_bit,
> +    EXT_create_context_es2_profile_bit,
>     EXT_import_context_bit,
>     EXT_texture_from_pixmap_bit,
>     EXT_visual_info_bit,
> diff --git a/glx/glxdri2.c b/glx/glxdri2.c
> index 2827326..e61b13a 100644
> --- a/glx/glxdri2.c
> +++ b/glx/glxdri2.c
> @@ -417,6 +417,9 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
>             case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
>                 *api = __DRI_API_OPENGL;
>                 break;
> +            case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
> +                *api = __DRI_API_GLES2;
> +                break;
>             default:
>                 *error = __glXError(GLXBadProfileARB);
>                 return False;
> @@ -814,8 +817,12 @@ initializeExtensions(__GLXDRIscreen * screen)
>                              "GLX_ARB_create_context");
>         __glXEnableExtension(screen->glx_enable_bits,
>                              "GLX_ARB_create_context_profile");
> +        __glXEnableExtension(screen->glx_enable_bits,
> +                             "GLX_EXT_create_context_es2_profile");
>         LogMessage(X_INFO, "AIGLX: enabled GLX_ARB_create_context\n");
>         LogMessage(X_INFO, "AIGLX: enabled GLX_ARB_create_context_profile\n");
> +        LogMessage(X_INFO,
> +                   "AIGLX: enabled GLX_EXT_create_context_es2_profile\n");
>     }
>  #endif
>
> --
> 1.7.6.5
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list