[Mesa-dev] [PATCH mesa] dri: use a supported API in driCreateNewContext

Ilia Mirkin imirkin at alum.mit.edu
Wed Feb 14 14:06:41 UTC 2018


On Feb 14, 2018 7:38 AM, "Eric Engestrom" <eric.engestrom at imgtec.com> wrote:

From: Brendan King <Brendan.King at imgtec.com>

Don't assume the screen supports OpenGL when creating a new context,
use an API that the screen supports.

Signed-off-by: Brendan King <Brendan.King at imgtec.com>
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
[Eric: rebased on current git HEAD]
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
 src/mesa/drivers/dri/common/dri_util.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c
b/src/mesa/drivers/dri/common/dri_util.c
index e6a7d2391a78c45d45a1..3f32b34132e75228e0e0 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -49,6 +49,7 @@
 #include "main/debug_output.h"
 #include "main/errors.h"
 #include "main/macros.h"
+#include "util/bitscan.h"

 const char __dri2ConfigOptions[] =
    DRI_CONF_BEGIN
@@ -325,7 +326,11 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
        mesa_api = API_OPENGLES;
        break;
     case __DRI_API_GLES2:
+       ctx_config.major_version = 2;
+       mesa_api = API_OPENGLES2;
+       break;
     case __DRI_API_GLES3:
+       ctx_config.major_version = 3;


Are you sure about this change? Doesn't seem related, and I'm about 20%
sure there was some reason for the current thing.

        mesa_api = API_OPENGLES2;
        break;
     case __DRI_API_OPENGL_CORE:
@@ -514,7 +519,14 @@ static __DRIcontext *
 driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
                     __DRIcontext *shared, void *data)
 {
-    return driCreateNewContextForAPI(screen, __DRI_API_OPENGL,
+    int apifs;
+
+    apifs = ffs(screen->api_mask);
+
+    if (!apifs)
+        return NULL;
+
+    return driCreateNewContextForAPI(screen, apifs - 1,
                                      config, shared, data);
 }

--
Cheers,
  Eric

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180214/eea69d7a/attachment-0001.html>


More information about the mesa-dev mailing list