Merge branch 'master' into pipe-video
authorThomas Balling Sørensen <tball@tball-laptop.(none)>
Tue, 5 Oct 2010 10:04:08 +0000 (12:04 +0200)
committerThomas Balling Sørensen <tball@tball-laptop.(none)>
Tue, 5 Oct 2010 10:04:08 +0000 (12:04 +0200)
Conflicts:
configs/linux-dri
configure.ac
src/gallium/drivers/nvfx/Makefile
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/state_tracker/dri1_api.h
src/gallium/include/state_tracker/drm_api.h
src/gallium/tests/python/samples/tri.py
src/gallium/tests/trivial/Makefile
src/gallium/tests/unit/Makefile
src/gallium/tests/unit/SConscript
src/gallium/tests/unit/u_format_test.c
src/gallium/winsys/nouveau/drm/nouveau_drm_api.c

16 files changed:
1  2 
configs/autoconf.in
configs/linux-dri
configure.ac
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/drivers/nvfx/Makefile
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_state.h
src/gallium/drivers/softpipe/Makefile
src/gallium/drivers/softpipe/SConscript
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_format.h
src/gallium/include/pipe/p_screen.h
src/gallium/targets/dri-nouveau/Makefile
src/gallium/winsys/g3dvl/dri/XF86dri.c

Simple merge
index eca321bc6acc2e42b039cd5825ca28bc749e9a74,64fc407c42e93b8f0ce6348647ff692df0ddd3ac..9a0253f919b18def99bec183237797b84b0a0883
@@@ -58,11 -57,12 +57,12 @@@ SRC_DIRS := glx egl $(SRC_DIRS
  EGL_DRIVERS_DIRS = glx
  
  DRIVER_DIRS = dri
- GALLIUM_WINSYS_DIRS = sw sw/xlib
++
+ GALLIUM_WINSYS_DIRS = sw sw/xlib drm/vmware drm/intel drm/i965
 -GALLIUM_TARGET_DIRS = 
 -GALLIUM_STATE_TRACKERS_DIRS = egl
 +GALLIUM_TARGET_DIRS = egl-swrast
 +GALLIUM_STATE_TRACKERS_DIRS = egl vdpau
  
 -DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
 -      savage sis tdfx unichrome swrast
 +DRI_DIRS = r300 radeon swrast
  
  INTEL_LIBS = `pkg-config --libs libdrm_intel`
  INTEL_CFLAGS = `pkg-config --cflags libdrm_intel`
diff --cc configure.ac
index c5b2d6704568bfa4c92b049c61fb803253947a5e,364ee0394703c38d5ef951f1915449a250a0340f..0344be00703c598b97d190dd437adfc6d984dc2e
              HAVE_ST_XORG="yes"
              ;;
          es)
-             # mesa/es is required to build es state tracker
-             CORE_DIRS="$CORE_DIRS mesa/es"
+             AC_MSG_WARN([state tracker 'es' has been replaced by --enable-gles-overlay])
+             if test "x$enable_gles_overlay" != xyes; then
+                 if test "x$enable_gles1" != xyes -a "x$enable_gles2" != xyes; then
+                     CORE_DIRS="mapi/es1api mapi/es2api $CORE_DIRS"
+                 fi
+                 GLES_OVERLAY=1
+                 EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GLESv1_CM_LIB) $(GLESv2_LIB)'
+             fi
+           tracker=""
+             ;;
+         vega)
+             CORE_DIRS="$CORE_DIRS mapi/vgapi"
+             VG_LIB_DEPS="$VG_LIB_DEPS -lpthread"
+             EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
              ;;
 +      xorg/xvmc)
 +            # Check for xvmc?
 +            if test "x$enable_gallium_g3dvl" != xyes; then
 +                AC_MSG_ERROR([cannot build XvMC state tracker without --enable-gallium-g3dvl])
 +            fi
 +            HAVE_ST_XVMC="yes"
 +            ;;
 +        vdpau)
 +            # Check for libvdpau?
 +            if test "x$enable_gallium_g3dvl" != xyes; then
 +                AC_MSG_ERROR([cannot build vdpau state tracker without --enable-gallium-g3dvl])
 +            fi
 +            HAVE_ST_VDPAU="yes"
 +            ;;
          esac
+       if test -n "$tracker"; then
+             test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
+                 AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
+             if test -n "$state_trackers"; then
+                 state_trackers="$state_trackers $tracker"
+             else
+                 state_trackers="$tracker"
+             fi
+         fi
      done
      GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
      ;;
@@@ -1378,18 -1471,9 +1485,18 @@@ gallium_check_st() 
      if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
           GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
      fi
-     if test "x$HAVE_ST_EGL" = xyes && test "x$3" != x; then
+     if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
           GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
      fi
 +    if test "x$HAVE_ST_XORG" = xyes && test "x$4" != x; then
 +         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4"
 +    fi
 +    if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then
 +         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5"
 +    fi
 +    if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then
 +         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6"
 +    fi
  }
  
  
Simple merge
Simple merge
Simple merge
index a4d5c61b7aa3c82e34fa4c76c55bcf380f7da08a,8024800bd09dc29d8ca464856d7e323e8876aeeb..875b3a96ca693847db87a1ca8cbb51beec3256f7
@@@ -3,28 -4,16 +4,17 @@@
  #include "util/u_simple_screen.h"
  
  #include "nouveau/nouveau_screen.h"
+ #include "nouveau/nv_object.xml.h"
  #include "nvfx_context.h"
 +#include "nvfx_video_context.h"
  #include "nvfx_screen.h"
  #include "nvfx_resource.h"
+ #include "nvfx_tex.h"
  
- #define NV30TCL_CHIPSET_3X_MASK 0x00000003
- #define NV34TCL_CHIPSET_3X_MASK 0x00000010
- #define NV35TCL_CHIPSET_3X_MASK 0x000001e0
- /* FIXME: It seems I should not include directly ../../winsys/drm/nouveau/drm/nouveau_drm_api.h
- * to get the pointer to the context front buffer, so I copied nouveau_winsys here.
- * nv30_screen_surface_format_supported() can then use it to enforce creating fbo
- * with same number of bits everywhere.
- */
- struct nouveau_winsys {
-       struct pipe_winsys base;
+ #define NV30_3D_CHIPSET_3X_MASK 0x00000003
+ #define NV34_3D_CHIPSET_3X_MASK 0x00000010
+ #define NV35_3D_CHIPSET_3X_MASK 0x000001e0
  
-       struct pipe_screen *pscreen;
-       struct pipe_surface *front;
- };
  #define NV4X_GRCLASS4097_CHIPSETS 0x00000baf
  #define NV4X_GRCLASS4497_CHIPSETS 0x00005450
  #define NV6X_GRCLASS4497_CHIPSETS 0x00000088
@@@ -339,10 -430,10 +431,11 @@@ nvfx_screen_create(struct pipe_winsys *
        pscreen->winsys = ws;
        pscreen->destroy = nvfx_screen_destroy;
        pscreen->get_param = nvfx_screen_get_param;
+       pscreen->get_shader_param = nvfx_screen_get_shader_param;
        pscreen->get_paramf = nvfx_screen_get_paramf;
-       pscreen->is_format_supported = nvfx_screen_surface_format_supported;
+       pscreen->is_format_supported = nvfx_screen_is_format_supported;
        pscreen->context_create = nvfx_create;
 +      pscreen->video_context_create = nvfx_video_create;
  
        switch (dev->chipset & 0xf0) {
        case 0x30:
index 676d4fd34bbcb62dbf452736ae936f9825f30ab1,8fafca1950ccb5bc4116373dd881ef18899b7a87..15e1cbb1986703cf6202f5ca6ef76fe47b14191a
@@@ -2,9 -2,10 +2,11 @@@
  #define __NVFX_STATE_H__
  
  #include "pipe/p_state.h"
 +#include "pipe/p_video_state.h"
  #include "tgsi/tgsi_scan.h"
  #include "nouveau/nouveau_statebuf.h"
+ #include "util/u_dynarray.h"
+ #include "util/u_linkage.h"
  
  struct nvfx_vertex_program_exec {
        uint32_t data[4];
Simple merge
index 26ba7b8002a0cefabc12abe00aebd5cc0f53b6ae,8b4663742fa5bd4fcfee53b4143c197095dd6907..d2273b334a68a1865600ffedace59942498b3649
@@@ -463,32 -492,20 +492,48 @@@ enum pipe_shader_ca
  #define PIPE_REFERENCED_FOR_READ  (1 << 0)
  #define PIPE_REFERENCED_FOR_WRITE (1 << 1)
  
++
 +enum pipe_video_codec
 +{
 +   PIPE_VIDEO_CODEC_UNKNOWN = 0,
 +   PIPE_VIDEO_CODEC_MPEG12,   /**< MPEG1, MPEG2 */
 +   PIPE_VIDEO_CODEC_MPEG4,    /**< DIVX, XVID */
 +   PIPE_VIDEO_CODEC_VC1,      /**< WMV */
 +   PIPE_VIDEO_CODEC_MPEG4_AVC /**< H.264 */
 +};
 +
 +enum pipe_video_profile
 +{
 +   PIPE_VIDEO_PROFILE_UNKNOWN,
 +   PIPE_VIDEO_PROFILE_MPEG1,
 +   PIPE_VIDEO_PROFILE_MPEG2_SIMPLE,
 +   PIPE_VIDEO_PROFILE_MPEG2_MAIN,
 +   PIPE_VIDEO_PROFILE_MPEG4_SIMPLE,
 +   PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE,
 +   PIPE_VIDEO_PROFILE_VC1_SIMPLE,
 +   PIPE_VIDEO_PROFILE_VC1_MAIN,
 +   PIPE_VIDEO_PROFILE_VC1_ADVANCED,
 +   PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE,
 +   PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN,
 +   PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
 +};
 +
 +
+ /**
+  * Composite query types
+  */
+ struct pipe_query_data_so_statistics
+ {
+    uint64_t num_primitives_written;
+    uint64_t primitives_storage_needed;
+ };
+ struct pipe_query_data_timestamp_disjoint
+ {
+    uint64_t frequency;
+    boolean  disjoint;
+ };
++
  #ifdef __cplusplus
  }
  #endif
Simple merge
index 919d1628d05e206db63891ee5ef3f364de1f9779,912631242f51ba52734ee5e06b8d646838374b76..75eeaeba1f71ce70f04c441494669b2f6f26843d
@@@ -85,16 -84,17 +84,22 @@@ struct pipe_screen 
      * Query a float-valued capability/parameter/limit
      * \param param  one of PIPE_CAP_x
      */
-    float (*get_paramf)( struct pipe_screen *, int param );
+    float (*get_paramf)( struct pipe_screen *, enum pipe_cap param );
  
-    struct pipe_context * (*context_create)( struct pipe_screen *,
-                                             void *priv );
+    /**
+     * Query a per-shader-stage integer-valued capability/parameter/limit
+     * \param param  one of PIPE_CAP_x
+     */
+    int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
 -   struct pipe_context * (*context_create)( struct pipe_screen *,
 -                                          void *priv );
++   struct pipe_context * (*context_create)( struct pipe_screen *, void *priv );
 +
 +   struct pipe_video_context * (*video_context_create)( struct pipe_screen *screen,
 +                                                        enum pipe_video_profile profile,
 +                                                        enum pipe_video_chroma_format chroma_format,
 +                                                        unsigned width, unsigned height, void *priv );
 +
     /**
      * Check if the given pipe_format is supported as a texture or
      * drawing surface.
index 9b345e1d9d1928085205844866c40a5a8ff1b341,2f64f312b841cdad42c8f7120ddd8ac10fd4a5b4..9dfe86c8949cfd396eee481794ac5d6022a5fbff
@@@ -6,9 -6,10 +6,11 @@@ LIBNAME = nouveau_dri.s
  PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
        $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/rbug/librbug.a \
        $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
        $(TOP)/src/gallium/drivers/nv50/libnv50.a \
 +      $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
        $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
  
  C_SOURCES = \
index 9e359a92384b6e6861c2d82e3de166bc1d908c67,0000000000000000000000000000000000000000..831a7603396959b3cc3a71b857a5179d5d5c737a
mode 100644,000000..100644
--- /dev/null
@@@ -1,619 -1,0 +1,618 @@@
- #define NEED_REPLIES
 +/**************************************************************************
 +
 +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
 +Copyright 2000 VA Linux Systems, Inc.
 +All Rights Reserved.
 +
 +Permission is hereby granted, free of charge, to any person obtaining a
 +copy of this software and associated documentation files (the
 +"Software"), to deal in the Software without restriction, including
 +without limitation the rights to use, copy, modify, merge, publish,
 +distribute, sub license, and/or sell copies of the Software, and to
 +permit persons to whom the Software is furnished to do so, subject to
 +the following conditions:
 +
 +The above copyright notice and this permission notice (including the
 +next paragraph) shall be included in all copies or substantial portions
 +of the Software.
 +
 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 +
 +**************************************************************************/
 +
 +/*
 + * Authors:
 + *   Kevin E. Martin <martin@valinux.com>
 + *   Jens Owen <jens@tungstengraphics.com>
 + *   Rickard E. (Rik) Faith <faith@valinux.com>
 + *
 + */
 +
 +/* THIS IS NOT AN X CONSORTIUM STANDARD */
 +
 +#include <X11/Xlibint.h>
 +#include <X11/extensions/Xext.h>
 +#include <X11/extensions/extutil.h>
 +#include "xf86dristr.h"
 +
 +static XExtensionInfo _xf86dri_info_data;
 +static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
 +static char xf86dri_extension_name[] = XF86DRINAME;
 +
 +#define XF86DRICheckExtension(dpy,i,val) \
 +  XextCheckExtension (dpy, i, xf86dri_extension_name, val)
 +
 +/*****************************************************************************
 + *                                                                           *
 + *                       private utility routines                          *
 + *                                                                           *
 + *****************************************************************************/
 +
 +static int close_display(Display *dpy, XExtCodes *extCodes);
 +static /* const */ XExtensionHooks xf86dri_extension_hooks = {
 +    NULL,                             /* create_gc */
 +    NULL,                             /* copy_gc */
 +    NULL,                             /* flush_gc */
 +    NULL,                             /* free_gc */
 +    NULL,                             /* create_font */
 +    NULL,                             /* free_font */
 +    close_display,                    /* close_display */
 +    NULL,                             /* wire_to_event */
 +    NULL,                             /* event_to_wire */
 +    NULL,                             /* error */
 +    NULL,                             /* error_string */
 +};
 +
 +static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info, 
 +                                 xf86dri_extension_name, 
 +                                 &xf86dri_extension_hooks, 
 +                                 0, NULL)
 +
 +static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
 +
 +
 +/*****************************************************************************
 + *                                                                           *
 + *                public XFree86-DRI Extension routines                    *
 + *                                                                           *
 + *****************************************************************************/
 +
 +#if 0
 +#include <stdio.h>
 +#define TRACE(msg)  fprintf(stderr,"XF86DRI%s\n", msg);
 +#else
 +#define TRACE(msg)
 +#endif
 +
 +#define PUBLIC
 +
 +PUBLIC Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
 +    Display *dpy;
 +    int *event_basep, *error_basep;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +
 +    TRACE("QueryExtension...");
 +    if (XextHasExtension(info)) {
 +      *event_basep = info->codes->first_event;
 +      *error_basep = info->codes->first_error;
 +        TRACE("QueryExtension... return True");
 +      return True;
 +    } else {
 +        TRACE("QueryExtension... return False");
 +      return False;
 +    }
 +}
 +
 +PUBLIC Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
 +    Display* dpy;
 +    int* majorVersion; 
 +    int* minorVersion;
 +    int* patchVersion;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIQueryVersionReply rep;
 +    xXF86DRIQueryVersionReq *req;
 +
 +    TRACE("QueryVersion...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIQueryVersion, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIQueryVersion;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("QueryVersion... return False");
 +      return False;
 +    }
 +    *majorVersion = rep.majorVersion;
 +    *minorVersion = rep.minorVersion;
 +    *patchVersion = rep.patchVersion;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("QueryVersion... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
 +    Display* dpy;
 +    int screen;
 +    Bool* isCapable;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIQueryDirectRenderingCapableReply rep;
 +    xXF86DRIQueryDirectRenderingCapableReq *req;
 +
 +    TRACE("QueryDirectRenderingCapable...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIQueryDirectRenderingCapable, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
 +    req->screen = screen;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("QueryDirectRenderingCapable... return False");
 +      return False;
 +    }
 +    *isCapable = rep.isCapable;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("QueryDirectRenderingCapable... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
 +    Display* dpy;
 +    int screen;
 +    drm_handle_t * hSAREA;
 +    char **busIdString;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIOpenConnectionReply rep;
 +    xXF86DRIOpenConnectionReq *req;
 +
 +    TRACE("OpenConnection...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIOpenConnection, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIOpenConnection;
 +    req->screen = screen;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("OpenConnection... return False");
 +      return False;
 +    }
 +
 +    *hSAREA = rep.hSAREALow;
 +    if (sizeof(drm_handle_t) == 8) {
 +       int shift = 32; /* var to prevent warning on next line */
 +       *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
 +    }
 +
 +    if (rep.length) {
 +        if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
 +            _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
 +            UnlockDisplay(dpy);
 +            SyncHandle();
 +            TRACE("OpenConnection... return False");
 +            return False;
 +        }
 +      _XReadPad(dpy, *busIdString, rep.busIdStringLength);
 +    } else {
 +        *busIdString = NULL;
 +    }
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("OpenConnection... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIAuthConnection(dpy, screen, magic)
 +    Display* dpy;
 +    int screen;
 +    drm_magic_t magic;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIAuthConnectionReq *req;
 +    xXF86DRIAuthConnectionReply rep;
 +
 +    TRACE("AuthConnection...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIAuthConnection, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIAuthConnection;
 +    req->screen = screen;
 +    req->magic = magic;
 +    rep.authenticated = 0;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("AuthConnection... return False");
 +      return False;
 +    }
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("AuthConnection... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRICloseConnection(dpy, screen)
 +    Display* dpy;
 +    int screen;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRICloseConnectionReq *req;
 +
 +    TRACE("CloseConnection...");
 +
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRICloseConnection, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRICloseConnection;
 +    req->screen = screen;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("CloseConnection... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, 
 +      ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
 +    Display* dpy;
 +    int screen;
 +    int* ddxDriverMajorVersion;
 +    int* ddxDriverMinorVersion;
 +    int* ddxDriverPatchVersion;
 +    char** clientDriverName;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIGetClientDriverNameReply rep;
 +    xXF86DRIGetClientDriverNameReq *req;
 +
 +    TRACE("GetClientDriverName...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIGetClientDriverName, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIGetClientDriverName;
 +    req->screen = screen;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("GetClientDriverName... return False");
 +      return False;
 +    }
 +
 +    *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
 +    *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
 +    *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
 +
 +    if (rep.length) {
 +        if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
 +            _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
 +            UnlockDisplay(dpy);
 +            SyncHandle();
 +            TRACE("GetClientDriverName... return False");
 +            return False;
 +        }
 +      _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
 +    } else {
 +        *clientDriverName = NULL;
 +    }
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("GetClientDriverName... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
 +      hHWContext)
 +    Display* dpy;
 +    int screen;
 +    int configID;
 +    XID* context;
 +    drm_context_t * hHWContext;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRICreateContextReply rep;
 +    xXF86DRICreateContextReq *req;
 +
 +    TRACE("CreateContext...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRICreateContext, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRICreateContext;
 +    req->visual = configID;
 +    req->screen = screen;
 +    *context = XAllocID(dpy);
 +    req->context = *context;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("CreateContext... return False");
 +      return False;
 +    }
 +    *hHWContext = rep.hHWContext;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("CreateContext... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
 +    Display* dpy;
 +    int screen;
 +    Visual* visual;
 +    XID* context;
 +    drm_context_t * hHWContext;
 +{
 +    return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
 +                                         context, hHWContext );
 +}
 +
 +PUBLIC Bool XF86DRIDestroyContext( Display * ndpy, int screen, 
 +    XID context )
 +{
 +    Display * const dpy = (Display *) ndpy;
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIDestroyContextReq *req;
 +
 +    TRACE("DestroyContext...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIDestroyContext, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIDestroyContext;
 +    req->screen = screen;
 +    req->context = context;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("DestroyContext... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRICreateDrawable( Display * ndpy, int screen, 
 +    Drawable drawable, drm_drawable_t * hHWDrawable )
 +{
 +    Display * const dpy = (Display *) ndpy;
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRICreateDrawableReply rep;
 +    xXF86DRICreateDrawableReq *req;
 +
 +    TRACE("CreateDrawable...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRICreateDrawable, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRICreateDrawable;
 +    req->screen = screen;
 +    req->drawable = drawable;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("CreateDrawable... return False");
 +      return False;
 +    }
 +    *hHWDrawable = rep.hHWDrawable;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("CreateDrawable... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIDestroyDrawable( Display * ndpy, int screen,
 +    Drawable drawable )
 +{
 +    Display * const dpy = (Display *) ndpy;
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIDestroyDrawableReq *req;
 +
 +    TRACE("DestroyDrawable...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIDestroyDrawable, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIDestroyDrawable;
 +    req->screen = screen;
 +    req->drawable = drawable;
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("DestroyDrawable... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
 +    unsigned int* index, unsigned int* stamp,
 +    int* X, int* Y, int* W, int* H,
 +    int* numClipRects, drm_clip_rect_t ** pClipRects,
 +    int* backX, int* backY,
 +    int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIGetDrawableInfoReply rep;
 +    xXF86DRIGetDrawableInfoReq *req;
 +    int total_rects;
 +
 +    TRACE("GetDrawableInfo...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIGetDrawableInfo, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIGetDrawableInfo;
 +    req->screen = screen;
 +    req->drawable = drawable;
 +
 +    if (!_XReply(dpy, (xReply *)&rep, 1, xFalse)) 
 +    {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("GetDrawableInfo... return False");
 +      return False;
 +    }
 +    *index = rep.drawableTableIndex;
 +    *stamp = rep.drawableTableStamp;
 +    *X = (int)rep.drawableX;
 +    *Y = (int)rep.drawableY;
 +    *W = (int)rep.drawableWidth;
 +    *H = (int)rep.drawableHeight;
 +    *numClipRects = rep.numClipRects;
 +    total_rects = *numClipRects;
 +
 +    *backX = rep.backX;
 +    *backY = rep.backY;
 +    *numBackClipRects = rep.numBackClipRects;
 +    total_rects += *numBackClipRects;
 +
 +#if 0
 +    /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
 +     * backwards compatibility (Because of the >> 2 shift) but the fix
 +     * enables multi-threaded apps to work.
 +     */
 +    if (rep.length !=  ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - 
 +                     SIZEOF(xGenericReply) + 
 +                     total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
 +        _XEatData(dpy, rep.length);
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("GetDrawableInfo... return False");
 +        return False;
 +    }
 +#endif
 +
 +    if (*numClipRects) {
 +       int len = sizeof(drm_clip_rect_t) * (*numClipRects);
 +
 +       *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
 +       if (*pClipRects) 
 +        _XRead(dpy, (char*)*pClipRects, len);
 +    } else {
 +        *pClipRects = NULL;
 +    }
 +
 +    if (*numBackClipRects) {
 +       int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
 +
 +       *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
 +       if (*pBackClipRects) 
 +        _XRead(dpy, (char*)*pBackClipRects, len);
 +    } else {
 +        *pBackClipRects = NULL;
 +    }
 +
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("GetDrawableInfo... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, 
 +      fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
 +    Display* dpy;
 +    int screen;
 +    drm_handle_t * hFrameBuffer;
 +    int* fbOrigin;
 +    int* fbSize;
 +    int* fbStride;
 +    int* devPrivateSize;
 +    void** pDevPrivate;
 +{
 +    XExtDisplayInfo *info = find_display (dpy);
 +    xXF86DRIGetDeviceInfoReply rep;
 +    xXF86DRIGetDeviceInfoReq *req;
 +
 +    TRACE("GetDeviceInfo...");
 +    XF86DRICheckExtension (dpy, info, False);
 +
 +    LockDisplay(dpy);
 +    GetReq(XF86DRIGetDeviceInfo, req);
 +    req->reqType = info->codes->major_opcode;
 +    req->driReqType = X_XF86DRIGetDeviceInfo;
 +    req->screen = screen;
 +    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 +      UnlockDisplay(dpy);
 +      SyncHandle();
 +        TRACE("GetDeviceInfo... return False");
 +      return False;
 +    }
 +
 +    *hFrameBuffer = rep.hFrameBufferLow;
 +    if (sizeof(drm_handle_t) == 8) {
 +       int shift = 32; /* var to prevent warning on next line */
 +       *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
 +    }
 +
 +    *fbOrigin = rep.framebufferOrigin;
 +    *fbSize = rep.framebufferSize;
 +    *fbStride = rep.framebufferStride;
 +    *devPrivateSize = rep.devPrivateSize;
 +
 +    if (rep.length) {
 +        if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
 +            _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
 +            UnlockDisplay(dpy);
 +            SyncHandle();
 +            TRACE("GetDeviceInfo... return False");
 +            return False;
 +        }
 +      _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
 +    } else {
 +        *pDevPrivate = NULL;
 +    }
 +
 +    UnlockDisplay(dpy);
 +    SyncHandle();
 +    TRACE("GetDeviceInfo... return True");
 +    return True;
 +}
 +
 +PUBLIC Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
 +    Display* dpy;
 +    int screen;
 +    Drawable drawable;
 +{
 +    /* This function and the underlying X protocol are deprecated.
 +     */
 +    (void) dpy;
 +    (void) screen;
 +    (void) drawable;
 +    return False;
 +}
 +
 +PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
 +    Display* dpy;
 +    int screen;
 +    Drawable drawable;
 +{
 +    /* This function and the underlying X protocol are deprecated.
 +     */
 +    (void) dpy;
 +    (void) screen;
 +    (void) drawable;
 +    return True;
 +}
 +