[Mesa-dev] [PATCH 07/10] dri, i965: Add an extension for sharing the drm bufmgr
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Fri Apr 4 01:36:25 PDT 2014
From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
If the fd used by the DRI driver is going to be shared with something
else, like gbm, this lets the loader pass the bufmgr struct so it is
shared too.
---
include/GL/internal/dri_interface.h | 11 +++++++++++
src/egl/drivers/dri2/egl_dri2.h | 3 ++-
src/mesa/drivers/dri/common/dri_util.c | 2 ++
src/mesa/drivers/dri/common/dri_util.h | 1 +
src/mesa/drivers/dri/i965/intel_screen.c | 9 +++++++--
5 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index d028d05..6c2312a 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1424,4 +1424,15 @@ struct __DRIimageDriverExtensionRec {
__DRIgetAPIMaskFunc getAPIMask;
};
+/**
+ * Allows the DRI screen to share a low-level (drm) bufmgr with gbm.
+ */
+#define __DRI_SHARED_BUFMGR "DRI_SHARED_BUFMGR"
+#define __DRI_SHARED_BUFMGR_VERSION 1
+
+typedef struct __DRIsharedBufmgrExtensionRec {
+ __DRIextension base;
+ void *bufmgr;
+} __DRIsharedBufmgrExtension;
+
#endif
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 990b246..7c19f5e 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -175,7 +175,8 @@ struct dri2_egl_display
__DRIdri2LoaderExtension dri2_loader_extension;
__DRIswrastLoaderExtension swrast_loader_extension;
- const __DRIextension *extensions[5];
+ __DRIsharedBufmgrExtension shared_bufmgr_extension;
+ const __DRIextension *extensions[6];
const __DRIextension **driver_extensions;
#ifdef HAVE_X11_PLATFORM
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index aed73c7..3046d60 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -81,6 +81,8 @@ setupLoaderExtensions(__DRIscreen *psp,
psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_IMAGE_LOADER) == 0)
psp->image.loader = (__DRIimageLoaderExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_SHARED_BUFMGR) == 0)
+ psp->dri2.bufmgr = (__DRIsharedBufmgrExtension *) extensions[i];
}
}
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index a37a0bb..49c380c 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -177,6 +177,7 @@ struct __DRIscreenRec {
__DRIdri2LoaderExtension *loader;
__DRIimageLookupExtension *image;
__DRIuseInvalidateExtension *useInvalidate;
+ __DRIsharedBufmgrExtension *bufmgr;
} dri2;
struct {
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 8cb1260..8ffbf17 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -952,8 +952,10 @@ static void
intelDestroyScreen(__DRIscreen * sPriv)
{
struct intel_screen *intelScreen = sPriv->driverPrivate;
+ __DRIscreen *spriv = intelScreen->driScrnPriv;
- dri_bufmgr_destroy(intelScreen->bufmgr);
+ if (!spriv->dri2.bufmgr)
+ dri_bufmgr_destroy(intelScreen->bufmgr);
driDestroyOptionInfo(&intelScreen->optionCache);
ralloc_free(intelScreen);
@@ -1074,7 +1076,10 @@ intel_init_bufmgr(struct intel_screen *intelScreen)
intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
- intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
+ if (spriv->dri2.bufmgr)
+ intelScreen->bufmgr = spriv->dri2.bufmgr->bufmgr;
+ else
+ intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
if (intelScreen->bufmgr == NULL) {
fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
__func__, __LINE__);
--
1.8.3.2
More information about the mesa-dev
mailing list