From 94a0ddf05dac9f43cd682a1a4eee8abd83564d26 Mon Sep 17 00:00:00 2001 From: jsg Date: Wed, 18 Mar 2015 05:30:10 +0000 Subject: [PATCH] Backport a Mesa fix from Andreas Boll. glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA --- dist/Mesa/src/glx/dri2_query_renderer.c | 36 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/dist/Mesa/src/glx/dri2_query_renderer.c b/dist/Mesa/src/glx/dri2_query_renderer.c index 247ec1ca6..f614a30d3 100644 --- a/dist/Mesa/src/glx/dri2_query_renderer.c +++ b/dist/Mesa/src/glx/dri2_query_renderer.c @@ -66,10 +66,23 @@ dri2_convert_glx_query_renderer_attribs(int attribute) return -1; } +/* Convert internal dri context profile bits into GLX context profile bits */ +static inline void +dri_convert_context_profile_bits(int attribute, unsigned int *value) +{ + if (attribute == GLX_RENDERER_PREFERRED_PROFILE_MESA) { + if (value[0] == (1U << __DRI_API_OPENGL_CORE)) + value[0] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + else if (value[0] == (1U << __DRI_API_OPENGL)) + value[0] = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } +} + _X_HIDDEN int dri2_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct dri2_screen *const psc = (struct dri2_screen *) base; /* Even though there are invalid values (and @@ -82,8 +95,11 @@ dri2_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int @@ -109,6 +125,7 @@ _X_HIDDEN int dri3_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct dri3_screen *const psc = (struct dri3_screen *) base; /* Even though there are invalid values (and @@ -121,8 +138,11 @@ dri3_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int @@ -148,6 +168,7 @@ _X_HIDDEN int drisw_query_renderer_integer(struct glx_screen *base, int attribute, unsigned int *value) { + int ret; struct drisw_screen *const psc = (struct drisw_screen *) base; /* Even though there are invalid values (and @@ -160,8 +181,11 @@ drisw_query_renderer_integer(struct glx_screen *base, int attribute, if (psc->rendererQuery == NULL) return -1; - return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, - value); + ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute, + value); + dri_convert_context_profile_bits(attribute, value); + + return ret; } _X_HIDDEN int