summarylogtreecommitdiffstats
path: root/0017-dri-use-a-supported-API-in-driCreateNewContext.patch
blob: 6929711886dba03f7dc69cf30f7932e215def890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From f46f7083921f1e56ce576d3fd5b822e6595ce141 Mon Sep 17 00:00:00 2001
From: Brendan King <Brendan.King@imgtec.com>
Date: Thu, 23 Nov 2017 15:50:21 +0000
Subject: [PATCH] dri: use a supported API in driCreateNewContext

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

---
 src/gallium/frontends/dri/dri_util.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/frontends/dri/dri_util.c b/src/gallium/frontends/dri/dri_util.c
index abc84a2..e22a3eb 100644
--- a/src/gallium/frontends/dri/dri_util.c
+++ b/src/gallium/frontends/dri/dri_util.c
@@ -49,6 +49,7 @@
 #include "main/version.h"
 #include "main/debug_output.h"
 #include "main/errors.h"
+#include "util/bitscan.h"
 
 driOptionDescription __dri2ConfigOptions[] = {
       DRI_CONF_SECTION_DEBUG
@@ -333,7 +334,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;
 	mesa_api = API_OPENGLES2;
 	break;
     case __DRI_API_OPENGL_CORE:
@@ -512,7 +517,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);
 }