Mesa (10.4): glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA

Emil Velikov evelikov at kemper.freedesktop.org
Wed Mar 4 02:02:53 UTC 2015


Module: Mesa
Branch: 10.4
Commit: 0a51529a2880947f0e954b0fe20d854734782d22
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a51529a2880947f0e954b0fe20d854734782d22

Author: Andreas Boll <andreas.boll.dev at gmail.com>
Date:   Tue Feb 24 20:01:30 2015 +0100

glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA

If the renderer supports the core profile the query returned incorrectly
0x8 as value, because it was using (1U << __DRI_API_OPENGL_CORE) for the
returned value.

The same happened with the compatibility profile. It returned 0x1
(1U << __DRI_API_OPENGL) instead of 0x2.

Internal DRI defines:
   dri_interface.h: #define __DRI_API_OPENGL       0
   dri_interface.h: #define __DRI_API_OPENGL_CORE  3

Those two bits are supposed for internal usage only and should be
translated to GLX_CONTEXT_CORE_PROFILE_BIT_ARB (0x1) for a preferred
core context profile and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB (0x2)
for a preferred compatibility context profile.

This patch implements the above translation in the glx module.

v2: Fix the incorrect behavior in the glx module

Cc: "10.3 10.4 10.5" <mesa-stable at lists.freedesktop.org>
Signed-off-by: Andreas Boll <andreas.boll.dev at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
(cherry picked from commit 6d164f65c5a794164d07bc66c1f8f87280514e8c)

---

 src/glx/dri_common_query_renderer.c |   36 +++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/glx/dri_common_query_renderer.c b/src/glx/dri_common_query_renderer.c
index d598b12..b3e107d 100644
--- a/src/glx/dri_common_query_renderer.c
+++ b/src/glx/dri_common_query_renderer.c
@@ -65,10 +65,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
@@ -81,8 +94,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
@@ -108,6 +124,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
@@ -120,8 +137,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
@@ -147,6 +167,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
@@ -159,8 +180,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




More information about the mesa-commit mailing list