Reduce the versioning madness required to create a DRI2 screen.
authorKristian Høgsberg <krh@redhat.com>
Tue, 26 Feb 2008 04:37:23 +0000 (23:37 -0500)
committerKristian Høgsberg <krh@redhat.com>
Fri, 29 Feb 2008 20:05:39 +0000 (15:05 -0500)
Right now the DRI2 screen constructor takes 3 different versions:
DRI, DDX and DRM.  This is mostly useless, though:

  DRI: The DRI driver doesn't actually care about the DRI protocol,
  it only talks to the loader, which in turn speaks DRI protocol.  Thus,
  the DRI protocol version is of not interest to the DRI driver, but it
  needs to know what functionality the loader provides.  At this point
  that's reflected in the __DRIinterfaceMethods struct and the
  internal_version integer.

  DDX: The DDX version number is essentially used to track extensions
  to the SAREA.  With DRI2 the SAREA consists of a number of versioned,
  self-describing blocks, so the DDX version is no longer interesting.

  DRM: We have the fd, lets just ask the kernel ourselves.

include/GL/internal/dri_interface.h
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_screen.c

index 888b91df58658f52cf44bd407baecfdad80d1c10..ed71e5698bc3e9ea5773473a62c6990de8f14978 100644 (file)
@@ -266,11 +266,8 @@ extern CREATENEWSCREENFUNC __DRI_CREATE_NEW_SCREEN;
 /* DRI2 Entry point */
 
 typedef void *(__DRI2_CREATE_NEW_SCREEN_FUNC)(int scr, __DRIscreen *psc,
-    const __DRIversion * ddx_version, const __DRIversion * dri_version,
-    const __DRIversion * drm_version, int fd,
-    unsigned int sarea_handle,
-    const __DRIinterfaceMethods * interface,
-    __GLcontextModes ** driver_modes);
+    int fd, unsigned int sarea_handle,
+    const __DRIinterfaceMethods * interface, __GLcontextModes ** driver_modes);
 #define __DRI2_CREATE_NEW_SCREEN \
     __DRI_MAKE_VERSION(__dri2CreateNewScreen, __DRI_INTERFACE_VERSION)
 
index 8e9f9167cae285a3fece4b691cfaab6565415bce..b429a824abdc431dd708b5adc8bcc5d9d4868d81 100644 (file)
@@ -872,18 +872,15 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
 
 PUBLIC void *
 __DRI2_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                        const __DRIversion * ddx_version,
-                        const __DRIversion * dri_version,
-                        const __DRIversion * drm_version,
-                        int fd, 
-                        unsigned int sarea_handle,
-                        const __DRIinterfaceMethods * interface,
-                        __GLcontextModes ** driver_modes)
+                        int fd, unsigned int sarea_handle,
+                        const __DRIinterfaceMethods *interface,
+                        __GLcontextModes **driver_modes)
 {
     __DRIscreenPrivate *psp;
     static const __DRIextension *emptyExtensionList[] = { NULL };
     dri_interface = interface;
     unsigned int *p;
+    drmVersionPtr version;
     __GLcontextModes *(*initScreen)(__DRIscreenPrivate *psc);
 
     initScreen = dlsym(NULL, "__dri2DriverInitScreen");
@@ -896,9 +893,14 @@ __DRI2_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
 
     psp->psc = psc;
 
-    psp->drm_version = *drm_version;
-    psp->ddx_version = *ddx_version;
-    psp->dri_version = *dri_version;
+    version = drmGetVersion(fd);
+    if (version) {
+       psp->drm_version.major = version->version_major;
+       psp->drm_version.minor = version->version_minor;
+       psp->drm_version.patch = version->version_patchlevel;
+       drmFreeVersion(version);
+    }
+
     psp->extensions = emptyExtensionList;
     psp->fd = fd;
     psp->myNum = scrn;
index ab615df68b12e5376ee0c0b6bf4a07153e00b8d5..e3622db5966c072c112b9f6b6c0ae2054de109de 100644 (file)
@@ -440,16 +440,22 @@ intel_init_bufmgr(struct intel_context *intel)
 {
    intelScreenPrivate *intelScreen = intel->intelScreen;
    GLboolean ttm_disable = getenv("INTEL_NO_TTM") != NULL;
+   GLboolean ttm_supported;
 
    /* If we've got a new enough DDX that's initializing TTM and giving us
     * object handles for the shared buffers, use that.
     */
    intel->ttm = GL_FALSE;
-   if (!ttm_disable &&
-       intel->intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
-       intel->intelScreen->drmMinor >= 11 &&
-       intel->intelScreen->front.bo_handle != -1)
-   {
+   if (intel->intelScreen->driScrnPriv->dri2.enabled)
+       ttm_supported = GL_TRUE;
+   else if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
+           intel->intelScreen->drmMinor >= 11 &&
+           intel->intelScreen->front.bo_handle != -1)
+       ttm_supported = GL_TRUE;
+   else
+       ttm_supported = GL_FALSE;
+
+   if (!ttm_disable && ttm_supported) {
       intel->bufmgr = intel_bufmgr_ttm_init(intel->driFd,
                                            DRM_FENCE_TYPE_EXE,
                                            DRM_FENCE_TYPE_EXE |
index 5d0bf4a1da14b81cfc54504545e6cc5b6ad4f751..7ac7240b56ade9a8df44d06913d846c85eaf0d9f 100644 (file)
@@ -829,22 +829,11 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
  */
 PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
 {
-   static const __DRIversion ddx_expected = { 1, 9, 0 };
-   static const __DRIversion dri_expected = { 4, 0, 0 };
-   static const __DRIversion drm_expected = { 1, 5, 0 };
    intelScreenPrivate *intelScreen;
    __GLcontextModes *modes, *m;
 
    psp->DriverAPI = intelAPI;
 
-   if (!driCheckDriDdxDrmVersions2("i915",
-                                   &psp->dri_version, &dri_expected,
-                                   &psp->ddx_version, &ddx_expected,
-                                   &psp->drm_version, &drm_expected)) {
-      fprintf(stderr, "bad version voodoo\n");
-      return NULL;
-   }
-
    /* Calling driInitExtensions here, with a NULL context pointer,
     * does not actually enable the extensions.  It just makes sure
     * that all the dispatch offsets for all the extensions that