Hi all
So at XDS we had a quick bof about adding support in dri2 for different
types of contexts. Like VG, GLES, exa and so on. This is a first quick draft
which does that. I have updated the dri interface the glx code and the
shared dri_util code imported by dri drivers. It compiles but I haven't
tested the code.
Cheers Jakob.
From ae8bb84c220308ce3ce7c70b4ad5cb215319f3ab Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz <[EMAIL PROTECTED]>
Date: Thu, 4 Sep 2008 17:12:20 +0200
Subject: [PATCH] dri2: Add different types of contexts to create
---
include/GL/internal/dri_interface.h | 69 +++++++++++++++++++++++++++++++-
src/glx/x11/dri2_glx.c | 19 +++++++--
src/glx/x11/glxclient.h | 5 ++
src/mesa/drivers/dri/common/dri_util.c | 9 +++-
4 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index e4cc16b..3a2c1fe 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -78,6 +78,10 @@ typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
typedef struct __DRIbufferRec __DRIbuffer;
typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
+typedef struct __DRIdri2GL2ExtensionRec __DRIdri2GL2Extension;
+typedef struct __DRIdri2VGExtensionRec __DRIdri2VGExtension;
+typedef struct __DRIdri2GLESv1ExtensionRec __DRIdri2GLESv1Extension;
+typedef struct __DRIdri2GLESv2ExtensionRec __DRIdri2GLESv2Extension;
/[EMAIL PROTECTED]/
@@ -663,7 +667,70 @@ struct __DRIdri2ExtensionRec {
const __DRIconfig *config,
void *loaderPrivate);
- __DRIcontext *(*createNewContext)(__DRIscreen *screen,
+};
+
+/**
+ * This extension provides GL1/GL2 compatible context
+ * constructors for DRI2.
+ */
+#define __DRI_DRI2_GL2 "DRI_DRI2_GL2"
+#define __DRI_DRI2_GL2_VERSION 1
+
+struct __DRIdri2GL2ExtensionRec {
+ __DRIextension base;
+
+ __DRIcontext *(*createNewGL2Context)(__DRIscreen *screen,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ void *loaderPrivate);
+
+};
+
+/**
+ * This extension provides a VG context
+ * constructor for DRI2.
+ */
+#define __DRI_DRI2_VG "DRI_DRI2_VG"
+#define __DRI_DRI2_VG_VERSION 1
+
+struct __DRIdri2VGExtensionRec {
+ __DRIextension base;
+
+ __DRIcontext *(*createNewVGContext)(__DRIscreen *screen,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ void *loaderPrivate);
+
+};
+
+/**
+ * This extension provides a GLESv1 context
+ * constructor for DRI2.
+ */
+#define __DRI_DRI2_GLESv1 "DRI_DRI2_GLESv1"
+#define __DRI_DRI2_GLESv1_VERSION 1
+
+struct __DRIdri2GLESv1ExtensionRec {
+ __DRIextension base;
+
+ __DRIcontext *(*createNewGLESv1Context)(__DRIscreen *screen,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ void *loaderPrivate);
+
+};
+
+/**
+ * This extension provides a GLESv2 context
+ * constructor for DRI2.
+ */
+#define __DRI_DRI2_GLESv2 "DRI_DRI2_GLESv2"
+#define __DRI_DRI2_GLESv2_VERSION 1
+
+struct __DRIdri2GLESv2ExtensionRec {
+ __DRIextension base;
+
+ __DRIcontext *(*createNewGLESv2Context)(__DRIscreen *screen,
const __DRIconfig *config,
__DRIcontext *shared,
void *loaderPrivate);
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index c56adfa..5c80c89 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -105,7 +105,7 @@ static void dri2UnbindContext(__GLXDRIcontext *context)
(*core->unbindContext)(pcp->driContext);
}
-static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
+static __GLXDRIcontext *dri2CreateGL2Context(__GLXscreenConfigs *psc,
const __GLcontextModes *mode,
GLXContext gc,
GLXContext shareList, int renderType)
@@ -119,13 +119,16 @@ static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
shared = pcp_shared->driContext;
}
+ if (psc->GL2)
+ return NULL;
+
pcp = Xmalloc(sizeof *pcp);
if (pcp == NULL)
return NULL;
pcp->psc = psc;
pcp->driContext =
- (*psc->dri2->createNewContext)(psc->__driScreen,
+ (*psc->GL2->createNewGL2Context)(psc->__driScreen,
config->driConfig, shared, pcp);
gc->__driContext = pcp->driContext;
@@ -276,9 +279,17 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_DRI2) == 0)
psc->dri2 = (__DRIdri2Extension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2_GL2) == 0)
+ psc->GL2 = (__DRIdri2GL2Extension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2_VG) == 0)
+ psc->VG = (__DRIdri2VGExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2_GLESv1) == 0)
+ psc->GLESv1 = (__DRIdri2GLESv1Extension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2_GLESv2) == 0)
+ psc->GLESv2 = (__DRIdri2GLESv2Extension *) extensions[i];
}
- if (psc->core == NULL || psc->dri2 == NULL) {
+ if (psc->core == NULL || psc->dri2 == NULL || psc->GL2 == NULL) {
ErrorMessageF("core dri or dri2 extension not found\n");
goto handle_error;
}
@@ -311,7 +322,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
psp->destroyScreen = dri2DestroyScreen;
- psp->createContext = dri2CreateContext;
+ psp->createContext = dri2CreateGL2Context;
psp->createDrawable = dri2CreateDrawable;
psp->swapBuffers = dri2SwapBuffers;
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index 4125112..1331e19 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -472,6 +472,11 @@ struct __GLXscreenConfigsRec {
const __DRIlegacyExtension *legacy;
const __DRIswrastExtension *swrast;
const __DRIdri2Extension *dri2;
+ const __DRIdri2GL2Extension *GL2;
+ const __DRIdri2VGExtension *VG;
+ const __DRIdri2GLESv1Extension *GLESv1;
+ const __DRIdri2GLESv2Extension *GLESv2;
+
__glxHashTable *drawHash;
Display *dpy;
int scr, fd;
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index ce54062..42cf2f3 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -575,7 +575,7 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
static __DRIcontext *
-dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
+dri2CreateNewGL2Context(__DRIscreen *screen, const __DRIconfig *config,
__DRIcontext *shared, void *data)
{
return driCreateNewContext(screen, config, 0, shared, 0, data);
@@ -816,7 +816,11 @@ const __DRIdri2Extension driDRI2Extension = {
{ __DRI_DRI2, __DRI_DRI2_VERSION },
dri2CreateNewScreen,
dri2CreateNewDrawable,
- dri2CreateNewContext,
+};
+
+const __DRIdri2GL2Extension driDRI2GL2Extension = {
+ { __DRI_DRI2_GL2, __DRI_DRI2_GL2_VERSION },
+ dri2CreateNewGL2Context,
};
/* This is the table of extensions that the loader will dlsym() for. */
@@ -824,6 +828,7 @@ PUBLIC const __DRIextension *__driDriverExtensions[] = {
&driCoreExtension.base,
&driLegacyExtension.base,
&driDRI2Extension.base,
+ &driDRI2GL2Extension.base,
NULL
};
--
1.5.2.5
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel