[Mesa-dev] [PATCH 5/8] glx: Add the GLX_ARB_flush_control extension
Ian Romanick
idr at freedesktop.org
Thu Oct 16 08:33:50 PDT 2014
On 10/01/2014 12:00 PM, Neil Roberts wrote:
> This adds the framework for the GLX flush control extension. It is advertised
> if the DRI driver implements the new __DRI2_FLUSH_CONTROL extension. The GLX
> attributes are converted to the appropriate DRI attributes.
> ---
> src/glx/dri2_glx.c | 19 +++++++++++++++++--
> src/glx/dri3_glx.c | 15 +++++++++++++--
> src/glx/dri_common.c | 16 +++++++++++++++-
> src/glx/dri_common.h | 2 +-
> src/glx/drisw_glx.c | 6 +++++-
> src/glx/glxextensions.c | 1 +
> src/glx/glxextensions.h | 1 +
> 7 files changed, 53 insertions(+), 7 deletions(-)
>
> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
> index 462d560..f39a5c9 100644
> --- a/src/glx/dri2_glx.c
> +++ b/src/glx/dri2_glx.c
> @@ -253,7 +253,8 @@ dri2_create_context_attribs(struct glx_screen *base,
> uint32_t flags;
> unsigned api;
> int reset;
> - uint32_t ctx_attribs[2 * 5];
> + int release;
> + uint32_t ctx_attribs[2 * 6];
> unsigned num_ctx_attribs = 0;
>
> if (psc->dri2->base.version < 3) {
> @@ -265,7 +266,7 @@ dri2_create_context_attribs(struct glx_screen *base,
> */
> if (!dri2_convert_glx_attribs(num_attribs, attribs,
> &major_ver, &minor_ver, &renderType, &flags,
> - &api, &reset, error))
> + &api, &reset, &release, error))
> goto error_exit;
>
> /* Check the renderType value */
> @@ -300,6 +301,11 @@ dri2_create_context_attribs(struct glx_screen *base,
> ctx_attribs[num_ctx_attribs++] = reset;
> }
>
> + if (release != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH) {
> + ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR;
> + ctx_attribs[num_ctx_attribs++] = release;
> + }
> +
> if (flags != 0) {
> ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
>
> @@ -1140,6 +1146,15 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
> psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
> __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
> }
> +
> + /* DRI2 version 3 is also required because
> + * GLX_ARB_control_flush_control requires GLX_ARB_create_context.
> + */
> + if (psc->dri2->base.version >= 3
> + && strcmp(extensions[i]->name, __DRI2_FLUSH_CONTROL) == 0)
> + __glXEnableDirectExtension(&psc->base,
> + "GLX_ARB_context_flush_control");
> +
> }
> }
>
> diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
> index e8e5c4a..9ec9ab3 100644
> --- a/src/glx/dri3_glx.c
> +++ b/src/glx/dri3_glx.c
> @@ -177,7 +177,8 @@ dri3_create_context_attribs(struct glx_screen *base,
> uint32_t flags = 0;
> unsigned api;
> int reset = __DRI_CTX_RESET_NO_NOTIFICATION;
> - uint32_t ctx_attribs[2 * 5];
> + int release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
> + uint32_t ctx_attribs[2 * 6];
> unsigned num_ctx_attribs = 0;
> uint32_t render_type;
>
> @@ -186,7 +187,7 @@ dri3_create_context_attribs(struct glx_screen *base,
> if (!dri2_convert_glx_attribs(num_attribs, attribs,
> &major_ver, &minor_ver,
> &render_type, &flags, &api,
> - &reset, error))
> + &reset, &release, error))
> goto error_exit;
>
> /* Check the renderType value */
> @@ -221,6 +222,11 @@ dri3_create_context_attribs(struct glx_screen *base,
> ctx_attribs[num_ctx_attribs++] = reset;
> }
>
> + if (release != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH) {
> + ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR;
> + ctx_attribs[num_ctx_attribs++] = release;
> + }
> +
> if (flags != 0) {
> ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
>
> @@ -1797,6 +1803,11 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
> psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
> __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
> }
> +
> + if (strcmp(extensions[i]->name, __DRI2_FLUSH_CONTROL) == 0)
> + __glXEnableDirectExtension(&psc->base,
> + "GLX_ARB_context_flush_control");
> +
> }
> }
>
> diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
> index 63c8de3..ebe7559 100644
> --- a/src/glx/dri_common.c
> +++ b/src/glx/dri_common.c
> @@ -462,7 +462,7 @@ _X_HIDDEN bool
> dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
> unsigned *major_ver, unsigned *minor_ver,
> uint32_t *render_type, uint32_t *flags, unsigned *api,
> - int *reset, unsigned *error)
> + int *reset, int *release, unsigned *error)
> {
> unsigned i;
> bool got_profile = false;
> @@ -472,6 +472,7 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
> *minor_ver = 0;
> *render_type = GLX_RGBA_TYPE;
> *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
> + *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
> *flags = 0;
> *api = __DRI_API_OPENGL;
>
> @@ -517,6 +518,19 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
> return false;
> }
> break;
> + case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
> + switch (attribs[i * 2 + 1]) {
> + case GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB:
> + *release = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
> + break;
> + case GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB:
> + *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
> + break;
> + default:
> + *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> + return false;
> + }
> + break;
> default:
> /* If an unknown attribute is received, fail.
> */
> diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
> index 6234fd8..925f8e9 100644
> --- a/src/glx/dri_common.h
> +++ b/src/glx/dri_common.h
> @@ -83,6 +83,6 @@ extern bool
> dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
> unsigned *major_ver, unsigned *minor_ver,
> uint32_t *render_type, uint32_t *flags, unsigned *api,
> - int *reset, unsigned *error);
> + int *reset, int *release, unsigned *error);
>
> #endif /* _DRI_COMMON_H */
> diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
> index 749ceb0..a07feb9 100644
> --- a/src/glx/drisw_glx.c
> +++ b/src/glx/drisw_glx.c
> @@ -409,6 +409,7 @@ drisw_create_context_attribs(struct glx_screen *base,
> uint32_t flags;
> unsigned api;
> int reset;
> + int release;
> uint32_t ctx_attribs[2 * 4];
> unsigned num_ctx_attribs = 0;
>
> @@ -422,7 +423,7 @@ drisw_create_context_attribs(struct glx_screen *base,
> */
> if (!dri2_convert_glx_attribs(num_attribs, attribs,
> &major_ver, &minor_ver, &renderType, &flags,
> - &api, &reset, error))
> + &api, &reset, &release, error))
> return NULL;
>
> /* Check the renderType value */
> @@ -433,6 +434,9 @@ drisw_create_context_attribs(struct glx_screen *base,
> if (reset != __DRI_CTX_RESET_NO_NOTIFICATION)
> return NULL;
>
> + if (release != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH)
> + return NULL;
> +
> if (shareList) {
> pcp_shared = (struct drisw_context *) shareList;
> shared = pcp_shared->driContext;
> diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
> index ce5d66d..42af217 100644
> --- a/src/glx/glxextensions.c
> +++ b/src/glx/glxextensions.c
> @@ -104,6 +104,7 @@ static const struct extension_info known_glx_extensions[] = {
> { GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N },
> { GLX(INTEL_swap_event), VER(0,0), Y, N, N, N },
> { GLX(EXT_buffer_age), VER(0,0), Y, N, N, Y },
> + { GLX(ARB_context_flush_control), VER(0,0), Y, N, N, N },
Please alphabetize. :)
> { NULL }
> };
>
> diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
> index 37e4ccc..7fbbee2 100644
> --- a/src/glx/glxextensions.h
> +++ b/src/glx/glxextensions.h
> @@ -67,6 +67,7 @@ enum
> EXT_texture_from_pixmap_bit,
> INTEL_swap_event_bit,
> EXT_buffer_age_bit,
> + ARB_context_flush_control_bit,
Same here.
> };
>
> /* From the GLX perspective, the ARB and EXT extensions are identical. Use a
>
More information about the mesa-dev
mailing list