All pastes #1926561 Raw Edit

[PATCH] dri: Really enable EGL_

public text v1 · immutable
#1926561 ·published 2010-08-27 06:24 UTC
rendered paste body
From 9a80f823c981e0ca0fb646b5aae00b76624d59b7 Mon Sep 17 00:00:00 2001
From: nobled <nobled@dreamwidth.org>
Date: Fri, 27 Aug 2010 02:33:06 +0000
Subject: [PATCH] dri: Really enable EGL_KHR_surfaceless_* extensions

The dri2 code would segfault if passed a NULL __DRIconfig
(what the egl_dri2 code was doing).

Also, the code should pass mesa_api to CreateContext and
abort early if it doesn't recognize the requested API.
---
 src/mesa/drivers/dri/common/dri_util.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index b1a7b3e..cb6109c 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -636,6 +636,7 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     __DRIcontext *context;
     void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
     gl_api mesa_api;
+    __GLcontextModes *modes = (config != NULL) ? &config->modes : NULL;
 
     if (!(screen->api_mask & (1 << api)))
 	return NULL;
@@ -650,8 +651,18 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     case __DRI_API_GLES2:
 	    mesa_api = API_OPENGLES2;
 	    break;
+    default:
+	    return NULL;
     }
 
+    /* TODO: Add a __DRInoDrawableExtension that we can check for
+       to see whether the driver even supports surfaceless contexts
+       for EGL_KHR_surfaceless_{opengl,gles1,gles2} */
+#if 0
+    if (!modes && !noDrawableExtension())
+        return NULL;
+#endif
+
     context = malloc(sizeof *context);
     if (!context)
 	return NULL;
@@ -659,8 +670,8 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     context->driScreenPriv = screen;
     context->driDrawablePriv = NULL;
     context->loaderPrivate = data;
-    
-    if (!(*screen->DriverAPI.CreateContext)(api, &config->modes,
+
+    if (!(*screen->DriverAPI.CreateContext)(mesa_api, modes,
 					    context, shareCtx) ) {
         free(context);
         return NULL;
-- 
1.5.4.3