[X2Go-Commits] [vcxsrv] 08/13: fontconfig libX11 libxcb libxcb/xcb-proto mesa xserver xkbcomp xkeyboard-config git update 29 Nov 2014

git-admin at x2go.org git-admin at x2go.org
Mon Mar 9 05:11:42 CET 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to annotated tag 1.16.2.0
in repository vcxsrv.

commit a1011d63ffb5cc4f41bf0f4622ee3f1493d419d9
Author: marha <marha at users.sourceforge.net>
Date:   Sat Nov 29 12:40:08 2014 +0100

    fontconfig libX11 libxcb libxcb/xcb-proto mesa xserver xkbcomp xkeyboard-config git update 29 Nov 2014
    
    xserver          commit c52a2b1ebad56820af932dfbc871701a8b04fd9c
    libxcb           commit bbca7b82f803fa13fd30a2891ec06f2a213a28c2
    libxcb/xcb-proto commit 691d2b97e5989d6d7006304d81bd8fa128477ca1
    xkeyboard-config commit b664d7fb8aab9b0f834dd9c81d273c7809561b34
    libX11           commit f3831dde6972e4da9e018c6a5f4013d8756a5e78
    xkbcomp          commit 1e8ee9d0aad072f04186df84752f5636340574e0
    fontconfig       commit b732bf057f4b3ec3bac539803005e9c42d056b2a
    mesa             commit 67c498086d0858a94d53ebb6921cfda847250368
---
 fontconfig/conf.d/30-metric-aliases.conf           |   94 +-
 fontconfig/conf.d/45-latin.conf                    |   12 +
 fontconfig/conf.d/60-latin.conf                    |    3 +
 libX11/nls/compose.dir.pre                         |   21 +-
 libX11/nls/en_US.UTF-8/Compose.pre                 |   41 +-
 libxcb/src/c_client.py                             |   52 +-
 libxcb/xcb-proto/src/xinput.xml                    |   37 +-
 mesalib/VERSION                                    |    2 +-
 mesalib/configure.ac                               |  166 +-
 mesalib/docs/GL3.txt                               |   18 +-
 mesalib/docs/egl.html                              |    7 -
 mesalib/docs/index.html                            |   12 +
 mesalib/docs/llvmpipe.html                         |    2 +-
 mesalib/docs/relnotes.html                         |    2 +
 mesalib/docs/relnotes/10.3.3.html                  |  209 +++
 mesalib/docs/relnotes/10.3.4.html                  |  106 ++
 mesalib/docs/relnotes/10.4.html                    |    4 +-
 mesalib/docs/relnotes/{10.4.html => 10.5.0.html}   |   11 +-
 mesalib/include/D3D9/d3d9.h                        | 1858 ++++++++++++++++++++
 mesalib/include/D3D9/d3d9caps.h                    |  387 ++++
 mesalib/include/D3D9/d3d9types.h                   | 1797 +++++++++++++++++++
 mesalib/include/GLES2/gl2ext.h                     |  313 +++-
 mesalib/include/d3dadapter/d3dadapter9.h           |  101 ++
 mesalib/include/d3dadapter/drm.h                   |   44 +
 mesalib/include/d3dadapter/present.h               |  136 ++
 mesalib/scons/gallium.py                           |   15 +-
 mesalib/src/gallium/Automake.inc                   |    3 +-
 mesalib/src/gallium/Makefile.am                    |   13 +-
 mesalib/src/gallium/auxiliary/Android.mk           |    4 +-
 mesalib/src/gallium/auxiliary/Makefile.am          |   42 +-
 mesalib/src/gallium/auxiliary/Makefile.sources     |  336 +++-
 mesalib/src/gallium/auxiliary/SConscript           |    2 +-
 mesalib/src/gallium/auxiliary/hud/hud_context.c    |    2 -
 mesalib/src/gallium/auxiliary/util/u_atomic.h      |   56 +-
 mesalib/src/gallium/auxiliary/util/u_blit.c        |    4 +-
 mesalib/src/gallium/auxiliary/util/u_blitter.c     |    7 +-
 mesalib/src/gallium/auxiliary/util/u_box.h         |  118 ++
 .../src/gallium/auxiliary/util/u_format_pack.py    |   35 +-
 mesalib/src/gallium/auxiliary/util/u_pstipple.c    |  228 +--
 mesalib/src/gallium/auxiliary/util/u_pstipple.h    |    5 +-
 mesalib/src/gallium/auxiliary/util/u_rect.h        |   18 +
 .../src/gallium/auxiliary/util/u_simple_shaders.c  |   80 +-
 .../src/gallium/auxiliary/util/u_simple_shaders.h  |   10 +-
 mesalib/src/gallium/auxiliary/util/u_snprintf.c    |    2 +-
 mesalib/src/gallium/auxiliary/util/u_tests.c       |  268 +++
 .../strtod.h => gallium/auxiliary/util/u_tests.h}  |   31 +-
 mesalib/src/glsl/Makefile.sources                  |    4 +-
 mesalib/src/glsl/ast.h                             |   29 -
 mesalib/src/glsl/glsl_lexer.ll                     |   23 +-
 mesalib/src/glsl/glsl_parser_extras.cpp            |   10 +-
 mesalib/src/glsl/glsl_types.cpp                    |   59 +-
 mesalib/src/glsl/glsl_types.h                      |   33 +-
 mesalib/src/glsl/ir.cpp                            |   48 -
 mesalib/src/glsl/ir.h                              |   30 +-
 mesalib/src/glsl/ir_optimization.h                 |    1 +
 mesalib/src/glsl/ir_reader.cpp                     |    2 +-
 mesalib/src/glsl/ir_uniform.h                      |    6 +
 mesalib/src/glsl/link_uniforms.cpp                 |   50 +
 mesalib/src/glsl/linker.cpp                        |   44 +-
 mesalib/src/glsl/list.h                            |   21 +
 mesalib/src/glsl/loop_unroll.cpp                   |   13 +-
 .../src/glsl/lower_const_arrays_to_uniforms.cpp    |  111 ++
 mesalib/src/glsl/main.cpp                          |   10 +
 mesalib/src/glsl/opt_algebraic.cpp                 |   49 +-
 mesalib/src/glsl/opt_cse.cpp                       |    9 +-
 mesalib/src/glsl/s_expression.cpp                  |    2 +-
 mesalib/src/glsl/s_expression.h                    |    2 +-
 mesalib/src/mapi/glapi/SConscript                  |    1 +
 .../mapi/glapi/gen/KHR_context_flush_control.xml   |   11 +
 mesalib/src/mapi/glapi/gen/Makefile.am             |    3 -
 mesalib/src/mapi/glapi/gen/extension_helper.py     |  324 ----
 mesalib/src/mapi/glapi/gen/gl_API.xml              |    2 +
 mesalib/src/mapi/glapi/gen/gl_offsets.py           |  120 --
 mesalib/src/mapi/glapi/gen/mesadef.py              |  215 ---
 mesalib/src/mesa/Android.libmesa_dricore.mk        |    8 +-
 mesalib/src/mesa/Android.libmesa_st_mesa.mk        |    5 +
 mesalib/src/mesa/Makefile.am                       |    3 +-
 mesalib/src/mesa/drivers/dri/common/dri_util.c     |   22 +-
 .../mesa/drivers/dri/common/xmlpool/t_options.h    |   18 +
 mesalib/src/mesa/drivers/windows/gdi/mesa.def      |  839 ++-------
 mesalib/src/mesa/main/api_validate.c               |   56 +-
 mesalib/src/mesa/main/api_validate.h               |    6 -
 mesalib/src/mesa/main/attrib.c                     |    3 +-
 mesalib/src/mesa/main/context.c                    |   11 +-
 mesalib/src/mesa/main/errors.c                     |  172 +-
 mesalib/src/mesa/main/extensions.c                 |    1 +
 mesalib/src/mesa/main/get_hash_params.py           |    5 +-
 mesalib/src/mesa/main/imports.c                    |   19 -
 mesalib/src/mesa/main/imports.h                    |    3 -
 mesalib/src/mesa/main/mtypes.h                     |    5 +
 mesalib/src/mesa/main/shaderapi.c                  |    6 +-
 mesalib/src/mesa/main/sse_minmax.c                 |   97 +
 .../src/mesa/main/sse_minmax.h                     |   44 +-
 mesalib/src/mesa/main/streaming-load-memcpy.c      |    3 -
 mesalib/src/mesa/main/texformat.c                  |    3 +
 mesalib/src/mesa/main/texstore.c                   |    4 +-
 mesalib/src/mesa/main/uniform_query.cpp            |  260 +--
 mesalib/src/mesa/main/uniforms.c                   |   98 +-
 mesalib/src/mesa/main/uniforms.h                   |    4 +-
 mesalib/src/mesa/main/viewport.c                   |    8 +-
 mesalib/src/mesa/program/prog_execute.c            |  156 --
 mesalib/src/mesa/program/prog_instruction.c        |   12 -
 mesalib/src/mesa/program/prog_instruction.h        |   12 -
 mesalib/src/mesa/program/program_lexer.l           |   14 +-
 .../src/mesa/state_tracker/st_atom_rasterizer.c    |   11 +-
 mesalib/src/mesa/state_tracker/st_atom_viewport.c  |    2 -
 mesalib/src/mesa/state_tracker/st_cb_bitmap.c      |    5 +-
 mesalib/src/mesa/state_tracker/st_cb_clear.c       |   30 +-
 mesalib/src/mesa/state_tracker/st_cb_drawpixels.c  |    2 -
 mesalib/src/mesa/state_tracker/st_cb_drawtex.c     |    4 +-
 mesalib/src/mesa/state_tracker/st_context.h        |    1 +
 mesalib/src/mesa/state_tracker/st_extensions.c     |    3 +-
 mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   19 +-
 mesalib/src/mesa/state_tracker/st_manager.c        |    3 +-
 mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c   |   12 +-
 mesalib/src/mesa/state_tracker/st_program.c        |   23 +-
 mesalib/src/mesa/vbo/vbo_exec_array.c              |   14 +-
 mesalib/src/mesa/x86/common_x86_features.h         |   26 +
 mesalib/src/util/Makefile.sources                  |    3 +-
 mesalib/src/util/hash_table.c                      |   10 +-
 mesalib/src/util/macros.h                          |   18 +-
 mesalib/src/{glsl/strtod.c => util/strtod.cpp}     |   32 +-
 mesalib/src/{glsl => util}/strtod.h                |    4 +-
 xkbcomp/configure.ac                               |    2 +-
 xkbcomp/xkbcomp.c                                  |   32 +-
 xorg-server/Xext/dpms.c                            |   10 +-
 xorg-server/Xext/dpmsstubs.c                       |   10 +-
 xorg-server/Xext/panoramiX.c                       |    2 +-
 xorg-server/Xext/panoramiX.h                       |    2 +-
 xorg-server/Xext/panoramiXprocs.c                  |    4 +-
 xorg-server/Xext/security.c                        |    4 +-
 xorg-server/Xext/shm.c                             |   21 +-
 xorg-server/Xext/sync.c                            |    2 +-
 xorg-server/Xext/syncsrv.h                         |    8 +-
 xorg-server/Xext/xres.c                            |   12 +-
 xorg-server/Xext/xvdisp.c                          |    8 +-
 xorg-server/Xext/xvdix.h                           |   14 +-
 xorg-server/Xext/xvmain.c                          |   20 +-
 xorg-server/composite/compalloc.c                  |    8 +-
 xorg-server/composite/compext.c                    |    4 +-
 xorg-server/composite/compinit.c                   |   21 +-
 xorg-server/composite/compint.h                    |    3 +-
 xorg-server/composite/compoverlay.c                |    4 +-
 xorg-server/composite/compwindow.c                 |    7 +-
 xorg-server/configure.ac                           |   14 +-
 xorg-server/dbe/dbe.c                              |   16 +-
 xorg-server/dbe/dbestruct.h                        |   12 +-
 xorg-server/dbe/midbe.c                            |   14 +-
 xorg-server/dbe/midbe.h                            |    8 +-
 xorg-server/dix/atom.c                             |    8 +-
 xorg-server/dix/colormap.c                         |   34 +-
 xorg-server/dix/cursor.c                           |    8 +-
 xorg-server/dix/devices.c                          |    2 +-
 xorg-server/dix/dispatch.c                         |   16 +-
 xorg-server/dix/dispatch.h                         |    2 +-
 xorg-server/dix/dixfonts.c                         |    6 +-
 xorg-server/dix/dixutils.c                         |   12 +-
 xorg-server/dix/extension.c                        |    8 +-
 xorg-server/dix/gc.c                               |   25 +-
 xorg-server/dix/getevents.c                        |   22 +-
 xorg-server/dix/globals.c                          |    8 +-
 xorg-server/dix/glyphcurs.c                        |    8 +-
 xorg-server/dix/grabs.c                            |   16 +-
 xorg-server/dix/inpututils.c                       |    2 +
 xorg-server/dix/main.c                             |    8 +-
 xorg-server/dix/property.c                         |    8 +-
 xorg-server/dix/region.c                           |   22 +-
 xorg-server/dix/resource.c                         |   16 +-
 xorg-server/dix/selection.c                        |   10 +-
 xorg-server/dix/swaprep.c                          |    8 +-
 xorg-server/dix/swapreq.c                          |    8 +-
 xorg-server/dix/tables.c                           |    8 +-
 xorg-server/dix/window.c                           |   38 +-
 xorg-server/exa/exa.c                              |    2 +-
 xorg-server/exa/exa.h                              |    8 +-
 xorg-server/exa/exa_accel.c                        |   20 +-
 xorg-server/exa/exa_glyphs.c                       |    8 +-
 xorg-server/exa/exa_priv.h                         |    7 +-
 xorg-server/exa/exa_render.c                       |    4 +-
 xorg-server/exa/exa_unaccel.c                      |   11 +-
 xorg-server/fb/Makefile.am                         |    2 -
 xorg-server/fb/fb.h                                |  338 +---
 xorg-server/fb/fb24_32.c                           |    2 +-
 xorg-server/fb/fb24_32.h                           |    2 +-
 xorg-server/fb/fbbits.c                            |   12 -
 xorg-server/fb/fbblt.c                             |  271 +--
 xorg-server/fb/fbbltone.c                          |  320 ++--
 xorg-server/fb/fbfill.c                            |   84 +-
 xorg-server/fb/fbfillrect.c                        |    2 +-
 xorg-server/fb/fbgc.c                              |   85 +-
 xorg-server/fb/fbglyph.c                           |   10 +-
 xorg-server/fb/fbline.c                            |    4 +-
 xorg-server/fb/fboverlay.c                         |    2 +-
 xorg-server/fb/fboverlay.h                         |    2 +-
 xorg-server/fb/fbpict.c                            |   16 +-
 xorg-server/fb/fbpict.h                            |    4 -
 xorg-server/fb/fbpixmap.c                          |    6 +-
 xorg-server/fb/fbpoint.c                           |    2 +-
 xorg-server/fb/fbpush.c                            |    4 +-
 xorg-server/fb/fbrop.h                             |   12 +-
 xorg-server/fb/fbseg.c                             |   42 +-
 xorg-server/fb/fbstipple.c                         |  264 ---
 xorg-server/fb/fbtile.c                            |  163 --
 xorg-server/fb/fbutil.c                            |  308 ----
 xorg-server/fb/wfbrename.h                         |   23 -
 xorg-server/glamor/glamor.c                        |    1 +
 xorg-server/glamor/glamor_fbo.c                    |    3 +-
 xorg-server/glamor/glamor_picture.c                |    2 +-
 xorg-server/glamor/glamor_pixmap.c                 |   75 +-
 xorg-server/glamor/glamor_priv.h                   |    2 +
 xorg-server/glx/glxbyteorder.h                     |    8 +-
 xorg-server/glx/glxcmds.c                          |   22 +-
 xorg-server/glx/glxdri2.c                          |    2 +-
 xorg-server/glx/glxscreens.c                       |    2 +-
 xorg-server/glx/glxscreens.h                       |    2 +-
 xorg-server/glx/indirect_dispatch.c                |    6 +-
 xorg-server/glx/indirect_dispatch.h                |    6 +-
 xorg-server/glx/indirect_dispatch_swap.c           |    6 +-
 xorg-server/glx/indirect_program.c                 |    6 +-
 xorg-server/glx/indirect_reqsize.c                 |    6 +-
 xorg-server/glx/indirect_reqsize.h                 |    6 +-
 xorg-server/glx/indirect_size.h                    |    6 +-
 xorg-server/glx/indirect_size_get.c                |    6 +-
 xorg-server/glx/indirect_size_get.h                |    6 +-
 xorg-server/glx/indirect_table.c                   |    6 +-
 xorg-server/glx/indirect_table.h                   |    6 +-
 xorg-server/glx/indirect_texture_compression.c     |    6 +-
 xorg-server/glx/indirect_util.c                    |    8 +-
 xorg-server/glx/indirect_util.h                    |    6 +-
 xorg-server/glx/rensize.c                          |    4 +-
 xorg-server/hw/dmx/config/Canvas.c                 |    2 +-
 xorg-server/hw/dmx/config/dmxprint.c               |    2 +-
 xorg-server/hw/dmx/dmxgc.c                         |   12 +-
 xorg-server/hw/dmx/dmxpict.h                       |    2 +-
 xorg-server/hw/dmx/glxProxy/glxcmds.c              |   16 +-
 xorg-server/hw/dmx/glxProxy/glxsingle.c            |    4 +-
 xorg-server/hw/dmx/glxProxy/glxvendor.c            |    4 +-
 xorg-server/hw/dmx/input/ChkNotMaskEv.c            |    2 +-
 xorg-server/hw/dmx/input/lnx-keyboard.c            |   20 +-
 xorg-server/hw/dmx/input/lnx-ms.c                  |    2 +-
 xorg-server/hw/kdrive/ephyr/ephyr.c                |   14 +-
 xorg-server/hw/kdrive/ephyr/ephyr.h                |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrdri.c             |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrdri.h             |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrdriext.c          |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrdriext.h          |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrglxext.c          |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrglxext.h          |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrhostglx.c         |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrhostglx.h         |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrinit.c            |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrlog.h             |    4 +-
 xorg-server/hw/kdrive/ephyr/ephyrvideo.c           |    4 +-
 xorg-server/hw/kdrive/ephyr/hostx.c                |   12 +-
 xorg-server/hw/kdrive/ephyr/hostx.h                |    4 +-
 xorg-server/hw/kdrive/ephyr/os.c                   |    4 +-
 xorg-server/hw/kdrive/src/kxv.c                    |    2 +-
 xorg-server/hw/xfree86/Makefile.am                 |    2 +-
 xorg-server/hw/xfree86/common/Makefile.am          |    4 +
 xorg-server/hw/xfree86/common/compiler.h           |    4 +-
 xorg-server/hw/xfree86/common/xf86AutoConfig.c     |    8 +-
 xorg-server/hw/xfree86/common/xf86Bus.c            |    2 +-
 xorg-server/hw/xfree86/common/xf86Config.c         |    4 +-
 xorg-server/hw/xfree86/common/xf86Configure.c      |    4 +-
 xorg-server/hw/xfree86/common/xf86Mode.c           |    8 +-
 xorg-server/hw/xfree86/common/xf86Module.h         |    4 +-
 xorg-server/hw/xfree86/common/xf86PciInfo.h        |    2 +-
 xorg-server/hw/xfree86/common/xf86Xinput.c         |   16 +-
 xorg-server/hw/xfree86/common/xf86Xinput.h         |    6 +-
 xorg-server/hw/xfree86/common/xf86cmap.c           |    4 +-
 xorg-server/hw/xfree86/common/xf86fbman.c          |    6 +-
 xorg-server/hw/xfree86/common/xf86platformBus.c    |    2 +-
 xorg-server/hw/xfree86/common/xf86str.h            |    2 +-
 xorg-server/hw/xfree86/common/xf86vmode.c          |    8 +-
 xorg-server/hw/xfree86/common/xf86xv.c             |    2 +-
 xorg-server/hw/xfree86/common/xf86xvmc.h           |   10 +-
 xorg-server/hw/xfree86/ddc/ddc.c                   |   10 +-
 xorg-server/hw/xfree86/ddc/edid.h                  |    8 +-
 xorg-server/hw/xfree86/ddc/print_edid.c            |    2 +-
 xorg-server/hw/xfree86/ddc/xf86DDC.h               |    6 +-
 xorg-server/hw/xfree86/dixmods/xkbKillSrv.c        |   16 +-
 xorg-server/hw/xfree86/dixmods/xkbVT.c             |   16 +-
 xorg-server/hw/xfree86/dri/dri.c                   |    4 +-
 xorg-server/hw/xfree86/dri/sarea.h                 |   10 +-
 xorg-server/hw/xfree86/dri2/Makefile.am            |    2 +
 xorg-server/hw/xfree86/dri2/dri2.c                 |   62 +-
 xorg-server/hw/xfree86/dri2/pci_ids/Makefile.am    |   11 +
 xorg-server/hw/xfree86/dri2/pci_ids/i810_pci_ids.h |    4 +
 xorg-server/hw/xfree86/dri2/pci_ids/i915_pci_ids.h |   15 +
 xorg-server/hw/xfree86/dri2/pci_ids/i965_pci_ids.h |  115 ++
 .../hw/xfree86/dri2/pci_ids/pci_id_driver_map.h    |   80 +
 xorg-server/hw/xfree86/dri2/pci_ids/r200_pci_ids.h |   24 +
 xorg-server/hw/xfree86/dri2/pci_ids/r300_pci_ids.h |  227 +++
 xorg-server/hw/xfree86/dri2/pci_ids/r600_pci_ids.h |  327 ++++
 .../hw/xfree86/dri2/pci_ids/radeon_pci_ids.h       |   23 +
 .../hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h     |  157 ++
 .../hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h       |    1 +
 .../hw/xfree86/drivers/modesetting/Makefile.am     |    6 +-
 xorg-server/hw/xfree86/drivers/modesetting/dri2.c  |  863 +++++++++
 .../hw/xfree86/drivers/modesetting/driver.c        |   29 +-
 .../hw/xfree86/drivers/modesetting/driver.h        |   44 +
 .../xfree86/drivers/modesetting/drmmode_display.c  |   25 +-
 .../xfree86/drivers/modesetting/drmmode_display.h  |   31 +-
 .../hw/xfree86/drivers/modesetting/vblank.c        |  383 ++++
 xorg-server/hw/xfree86/fbdevhw/fbdevhw.c           |    2 +-
 xorg-server/hw/xfree86/i2c/xf86i2c.c               |   40 +-
 xorg-server/hw/xfree86/i2c/xf86i2c.h               |    2 +-
 xorg-server/hw/xfree86/loader/loadmod.c            |    4 +-
 xorg-server/hw/xfree86/modes/xf86Crtc.c            |    4 +-
 xorg-server/hw/xfree86/modes/xf86Crtc.h            |   10 +-
 xorg-server/hw/xfree86/modes/xf86RandR12.c         |    4 +-
 xorg-server/hw/xfree86/modes/xf86cvt.c             |    4 +-
 xorg-server/hw/xfree86/modes/xf86gtf.c             |   10 +-
 .../hw/xfree86/os-support/bsd/alpha_video.c        |   20 +-
 xorg-server/hw/xfree86/os-support/bsd/arm_video.c  |   28 +-
 xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c    |    2 +-
 xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c   |   20 +-
 xorg-server/hw/xfree86/os-support/bsd/bsd_init.c   |   24 +-
 .../hw/xfree86/os-support/bsd/bsd_kqueue_apm.c     |   16 +-
 xorg-server/hw/xfree86/os-support/bsd/i386_video.c |   22 +-
 xorg-server/hw/xfree86/os-support/bsd/ppc_video.c  |   20 +-
 .../hw/xfree86/os-support/bsd/sparc64_video.c      |   20 +-
 .../hw/xfree86/os-support/hurd/hurd_video.c        |    4 +-
 xorg-server/hw/xfree86/os-support/linux/lnx_agp.c  |    4 +-
 xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c |    2 +-
 .../hw/xfree86/os-support/linux/systemd-logind.c   |    2 +-
 xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c |    8 +-
 .../hw/xfree86/os-support/shared/ioperm_noop.c     |    2 +-
 xorg-server/hw/xfree86/os-support/shared/sigio.c   |    6 +-
 .../hw/xfree86/os-support/solaris/sun_apm.c        |    2 +-
 xorg-server/hw/xfree86/os-support/xf86_OSlib.h     |   30 +-
 xorg-server/hw/xfree86/os-support/xf86_OSproc.h    |   28 +-
 xorg-server/hw/xfree86/parser/Configint.h          |   18 +-
 xorg-server/hw/xfree86/parser/DRI.c                |    8 +-
 xorg-server/hw/xfree86/parser/Device.c             |   16 +-
 xorg-server/hw/xfree86/parser/Files.c              |   14 +-
 xorg-server/hw/xfree86/parser/Flags.c              |   16 +-
 xorg-server/hw/xfree86/parser/Input.c              |   16 +-
 xorg-server/hw/xfree86/parser/Layout.c             |   16 +-
 xorg-server/hw/xfree86/parser/Module.c             |   16 +-
 xorg-server/hw/xfree86/parser/Monitor.c            |   18 +-
 xorg-server/hw/xfree86/parser/Pointer.c            |   16 +-
 xorg-server/hw/xfree86/parser/Screen.c             |   16 +-
 xorg-server/hw/xfree86/parser/Vendor.c             |   16 +-
 xorg-server/hw/xfree86/parser/Video.c              |   16 +-
 xorg-server/hw/xfree86/parser/read.c               |   22 +-
 xorg-server/hw/xfree86/parser/scan.c               |   36 +-
 xorg-server/hw/xfree86/parser/write.c              |   14 +-
 xorg-server/hw/xfree86/parser/xf86Optrec.h         |   18 +-
 xorg-server/hw/xfree86/parser/xf86Parser.h         |   18 +-
 xorg-server/hw/xfree86/parser/xf86tokens.h         |   18 +-
 xorg-server/hw/xfree86/ramdac/IBM.c                |    4 +-
 xorg-server/hw/xfree86/ramdac/TI.c                 |    2 +-
 xorg-server/hw/xfree86/ramdac/xf86Cursor.c         |    6 +-
 xorg-server/hw/xfree86/ramdac/xf86HWCurs.c         |    2 +-
 xorg-server/hw/xfree86/ramdac/xf86RamDac.h         |    4 +-
 xorg-server/hw/xfree86/sdksyms.sh                  |    3 -
 xorg-server/hw/xfree86/shadowfb/shadowfb.h         |    2 +-
 xorg-server/hw/xfree86/utils/gtf/gtf.c             |   26 +-
 xorg-server/hw/xfree86/vbe/vbe.c                   |    4 +-
 xorg-server/hw/xfree86/vbe/vbe.h                   |    4 +-
 xorg-server/hw/xfree86/vgahw/vgaHW.c               |    8 +-
 xorg-server/hw/xfree86/vgahw/vgaHW.h               |    2 +-
 xorg-server/hw/xfree86/x86emu/debug.c              |    4 +-
 xorg-server/hw/xfree86/x86emu/ops.c                |   22 +-
 xorg-server/hw/xfree86/x86emu/prim_ops.c           |   70 +-
 xorg-server/hw/xfree86/x86emu/sys.c                |    6 +-
 xorg-server/hw/xfree86/x86emu/x86emu/regs.h        |   10 +-
 xorg-server/hw/xnest/Color.c                       |    2 +-
 xorg-server/hw/xnest/GC.c                          |   56 +-
 xorg-server/hw/xnest/XNGC.h                        |    1 -
 xorg-server/hw/xnest/Xnest.h                       |    2 +-
 xorg-server/hw/xquartz/darwin.c                    |    8 +-
 xorg-server/hw/xquartz/darwinEvents.c              |    4 +-
 xorg-server/hw/xwayland/xwayland.c                 |    1 +
 xorg-server/hw/xwin/InitInput.c                    |    2 +-
 xorg-server/hw/xwin/InitOutput.c                   |   10 +-
 xorg-server/hw/xwin/ddraw.h                        |    6 +-
 xorg-server/hw/xwin/glx/glshim.c                   |    3 +
 xorg-server/hw/xwin/win.h                          |    2 +-
 xorg-server/hw/xwin/winSetAppUserModelID.c         |    2 +-
 xorg-server/hw/xwin/winclipboard/xevents.c         |    3 +-
 xorg-server/hw/xwin/wincmap.c                      |    2 +-
 xorg-server/hw/xwin/winconfig.c                    |   10 +-
 xorg-server/hw/xwin/wincreatewnd.c                 |    4 +-
 xorg-server/hw/xwin/wincursor.c                    |   10 +-
 xorg-server/hw/xwin/windialogs.c                   |   12 +-
 xorg-server/hw/xwin/winlayouts.h                   |    2 +-
 xorg-server/hw/xwin/winmsgwindow.c                 |    5 +-
 xorg-server/hw/xwin/winmultiwindowicons.c          |    4 +-
 xorg-server/hw/xwin/winmultiwindowshape.c          |    2 +-
 xorg-server/hw/xwin/winmultiwindowwindow.c         |   20 +-
 xorg-server/hw/xwin/winmultiwindowwm.c             |    2 +-
 xorg-server/hw/xwin/winmultiwindowwndproc.c        |    4 +-
 xorg-server/hw/xwin/winprefs.c                     |    2 +-
 xorg-server/hw/xwin/winprefslex.l                  |    2 -
 xorg-server/hw/xwin/winprefsyacc.y                 |   11 +-
 xorg-server/hw/xwin/winscrinit.c                   |    4 +-
 xorg-server/hw/xwin/winshaddd.c                    |    8 +-
 xorg-server/hw/xwin/winshadddnl.c                  |    8 +-
 xorg-server/hw/xwin/winshadgdi.c                   |   10 +-
 xorg-server/hw/xwin/winwin32rootlesswndproc.c      |    2 +-
 xorg-server/hw/xwin/winwindowswm.c                 |    2 +-
 xorg-server/hw/xwin/winwndproc.c                   |    8 +-
 xorg-server/include/closure.h                      |    8 +-
 xorg-server/include/colormap.h                     |    8 +-
 xorg-server/include/colormapst.h                   |    8 +-
 xorg-server/include/cursor.h                       |    8 +-
 xorg-server/include/cursorstr.h                    |   10 +-
 xorg-server/include/dbus-core.h                    |    2 +-
 xorg-server/include/dix.h                          |    8 +-
 xorg-server/include/extension.h                    |    8 +-
 xorg-server/include/extnsionst.h                   |   10 +-
 xorg-server/include/gc.h                           |    8 +-
 xorg-server/include/gcstruct.h                     |   25 +-
 xorg-server/include/input.h                        |    8 +-
 xorg-server/include/inputstr.h                     |   14 +-
 xorg-server/include/list.h                         |    2 +-
 xorg-server/include/misc.h                         |   18 +-
 xorg-server/include/miscstruct.h                   |    8 +-
 xorg-server/include/os.h                           |    8 +-
 xorg-server/include/pixmap.h                       |    8 +-
 xorg-server/include/pixmapstr.h                    |   10 +-
 xorg-server/include/property.h                     |    8 +-
 xorg-server/include/propertyst.h                   |   10 +-
 xorg-server/include/region.h                       |    8 +-
 xorg-server/include/regionstr.h                    |    2 +-
 xorg-server/include/resource.h                     |   10 +-
 xorg-server/include/rgb.h                          |    8 +-
 xorg-server/include/screenint.h                    |    8 +-
 xorg-server/include/scrnintstr.h                   |    8 +-
 xorg-server/include/selection.h                    |   10 +-
 xorg-server/include/servermd.h                     |   10 +-
 xorg-server/include/site.h                         |   14 +-
 xorg-server/include/window.h                       |    8 +-
 xorg-server/include/windowstr.h                    |    8 +-
 xorg-server/include/xkbfile.h                      |   18 +-
 xorg-server/include/xkbsrv.h                       |   16 +-
 xorg-server/include/xkbstr.h                       |   24 +-
 xorg-server/include/xsha1.h                        |    2 +-
 xorg-server/mi/Makefile.am                         |   11 +-
 xorg-server/mi/mi.h                                |   24 +-
 xorg-server/mi/miarc.c                             |  244 ++-
 xorg-server/mi/mibitblt.c                          |   30 +-
 xorg-server/mi/micopy.c                            |    5 +-
 xorg-server/mi/micursor.c                          |   68 -
 xorg-server/mi/midash.c                            |    9 +-
 xorg-server/mi/midispcur.c                         |    4 +-
 xorg-server/mi/miexpose.c                          |   18 +-
 xorg-server/mi/mifillarc.c                         |    5 +-
 xorg-server/mi/mifillarc.h                         |    9 -
 xorg-server/mi/mifillrct.c                         |    8 +-
 xorg-server/mi/mifpoly.h                           |   50 +-
 xorg-server/mi/mifpolycon.c                        |  249 ---
 xorg-server/mi/migc.c                              |   45 +-
 xorg-server/mi/miglblt.c                           |    8 +-
 xorg-server/mi/miinitext.c                         |    8 +-
 xorg-server/mi/mioverlay.c                         |    2 +-
 xorg-server/mi/mipointer.c                         |   19 +
 xorg-server/mi/mipoly.c                            |  627 ++++++-
 xorg-server/mi/mipoly.h                            |   22 +-
 xorg-server/mi/mipolycon.c                         |  235 ---
 xorg-server/mi/mipolygen.c                         |  213 ---
 xorg-server/mi/mipolypnt.c                         |    8 +-
 xorg-server/mi/mipolyrect.c                        |    8 +-
 xorg-server/mi/mipolyseg.c                         |   10 +-
 xorg-server/mi/mipolytext.c                        |    8 +-
 xorg-server/mi/mipolyutil.c                        |  369 ----
 xorg-server/mi/mipushpxl.c                         |    8 +-
 xorg-server/mi/miscrinit.c                         |    2 +-
 xorg-server/mi/mispans.c                           |  526 ------
 xorg-server/mi/mispans.h                           |   87 -
 xorg-server/mi/mistruct.h                          |    8 +-
 xorg-server/mi/mivaltree.c                         |   20 +-
 xorg-server/mi/miwideline.c                        |  526 +++++-
 xorg-server/mi/miwideline.h                        |   26 -
 xorg-server/mi/miwindow.c                          |    8 +-
 xorg-server/mi/mizerclip.c                         |    8 +-
 xorg-server/mi/mizerline.c                         |   12 +-
 xorg-server/miext/damage/damage.c                  |    2 +-
 xorg-server/miext/rootless/rootless.h              |    2 +-
 xorg-server/miext/rootless/rootlessGC.c            |    2 +-
 xorg-server/miext/rootless/rootlessValTree.c       |   32 +-
 xorg-server/miext/rootless/rootlessWindow.c        |    6 +-
 xorg-server/miext/shadow/shrotate.c                |    2 +-
 xorg-server/miext/sync/misyncfd.c                  |    4 +-
 xorg-server/os/WaitFor.c                           |   18 +-
 xorg-server/os/access.c                            |   58 +-
 xorg-server/os/busfault.c                          |    2 +-
 xorg-server/os/connection.c                        |   18 +-
 xorg-server/os/io.c                                |   10 +-
 xorg-server/os/log.c                               |    2 +-
 xorg-server/os/oscolor.c                           |    8 +-
 xorg-server/os/osdep.h                             |    8 +-
 xorg-server/os/osinit.c                            |   14 +-
 xorg-server/os/xdmcp.c                             |    2 +-
 xorg-server/present/present.c                      |    8 +-
 xorg-server/randr/randrstr.h                       |   20 +-
 xorg-server/randr/rrprovider.c                     |    2 +-
 xorg-server/randr/rrtransform.c                    |    2 +-
 xorg-server/randr/rrtransform.h                    |    2 +-
 xorg-server/randr/rrxinerama.c                     |    2 +-
 xorg-server/record/record.c                        |   20 +-
 xorg-server/render/animcur.c                       |    2 +-
 xorg-server/render/glyph.c                         |    2 +-
 xorg-server/render/glyphstr.h                      |    2 +-
 xorg-server/render/mipict.h                        |    2 +-
 xorg-server/render/picture.c                       |    2 +-
 xorg-server/render/picture.h                       |    8 +-
 xorg-server/render/render.c                        |    4 +-
 xorg-server/xfixes/cursor.c                        |   22 +-
 xorg-server/xfixes/region.c                        |   13 +-
 xorg-server/xkb/XKBAlloc.c                         |   16 +-
 xorg-server/xkb/XKBGAlloc.c                        |   16 +-
 xorg-server/xkb/XKBMAlloc.c                        |   18 +-
 xorg-server/xkb/XKBMisc.c                          |   16 +-
 xorg-server/xkb/ddxBeep.c                          |   16 +-
 xorg-server/xkb/ddxCtrls.c                         |   16 +-
 xorg-server/xkb/ddxKillSrv.c                       |   16 +-
 xorg-server/xkb/ddxLEDs.c                          |   16 +-
 xorg-server/xkb/ddxLoad.c                          |   16 +-
 xorg-server/xkb/ddxVT.c                            |   16 +-
 xorg-server/xkb/maprules.c                         |   18 +-
 xorg-server/xkb/xkb.c                              |   18 +-
 xorg-server/xkb/xkbAccessX.c                       |   18 +-
 xorg-server/xkb/xkbActions.c                       |   16 +-
 xorg-server/xkb/xkbEvents.c                        |   16 +-
 xorg-server/xkb/xkbInit.c                          |   22 +-
 xorg-server/xkb/xkbLEDs.c                          |   44 +-
 xorg-server/xkb/xkbPrKeyEv.c                       |   16 +-
 xorg-server/xkb/xkbSwap.c                          |   16 +-
 xorg-server/xkb/xkbUtils.c                         |   16 +-
 xorg-server/xkb/xkbfmisc.c                         |   18 +-
 xorg-server/xkb/xkbgeom.h                          |   16 +-
 xorg-server/xkb/xkbout.c                           |   18 +-
 xorg-server/xkb/xkbtext.c                          |   18 +-
 xorg-server/xkb/xkmread.c                          |   18 +-
 xorg-server/xkeyboard-config/README                |   54 +-
 538 files changed, 13331 insertions(+), 8085 deletions(-)

diff --git a/fontconfig/conf.d/30-metric-aliases.conf b/fontconfig/conf.d/30-metric-aliases.conf
index 49a9602..cd1e924 100644
--- a/fontconfig/conf.d/30-metric-aliases.conf
+++ b/fontconfig/conf.d/30-metric-aliases.conf
@@ -6,17 +6,17 @@
 
 Alias similar/metric-compatible families from various sources:
 
-PostScript fonts:       URW fonts:            GUST fonts:        Windows fonts:
-======================  ====================  =================  ==================
-Helvetica               Nimbus Sans L         TeX Gyre Heros
-Helvetica Condensed                           TeX Gyre Heros Cn
-Times                   Nimbus Roman No9 L    TeX Gyre Termes
-Courier                 Nimbus Mono L         TeX Gyre Cursor
-ITC Avant Garde Gothic  URW Gothic L          TeX Gyre Adventor
-ITC Bookman             URW Bookman L         TeX Gyre Bonum     Bookman Old Style
-ITC Zapf Chancery       URW Chancery L        TeX Gyre Chorus
-Palatino                URW Palladio L        TeX Gyre Pagella   Palatino Linotype
-New Century Schoolbook  Century Schoolbook L  TeX Gyre Schola    Century Schoolbook
+PostScript fonts:       URW fonts:              GUST fonts:        Windows fonts:
+======================  ======================  =================  ==================
+Helvetica               Nimbus Sans             TeX Gyre Heros
+Helvetica Condensed     Nimbus Sans Narrow      TeX Gyre Heros Cn
+Times                   Nimbus Roman            TeX Gyre Termes
+Courier                 Nimbus Mono             TeX Gyre Cursor
+ITC Avant Garde Gothic  URW Gothic              TeX Gyre Adventor
+ITC Bookman             Bookman URW             TeX Gyre Bonum     Bookman Old Style
+ITC Zapf Chancery       Chancery URW            TeX Gyre Chorus
+Palatino                Palladio URW            TeX Gyre Pagella   Palatino Linotype
+New Century Schoolbook  Century SchoolBook URW  TeX Gyre Schola    Century Schoolbook
 
 Microsoft fonts:  Liberation fonts:       Google CrOS core fonts:  StarOffice fonts:  AMT fonts:
 ================  ======================  =======================  =================  ==============
@@ -57,6 +57,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Nimbus Sans</family>
+	  <default>
+	  <family>Helvetica</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Heros</family>
 	  <default>
 	  <family>Helvetica</family>
@@ -64,6 +71,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Nimbus Sans Narrow</family>
+	  <default>
+	  <family>Helvetica Condensed</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Heros Cn</family>
 	  <default>
 	  <family>Helvetica Condensed</family>
@@ -78,6 +92,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Nimbus Roman</family>
+	  <default>
+	  <family>Times</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Termes</family>
 	  <default>
 	  <family>Times</family>
@@ -92,6 +113,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Nimbus Mono</family>
+	  <default>
+	  <family>Courier</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Cursor</family>
 	  <default>
 	  <family>Courier</family>
@@ -113,6 +141,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>URW Gothic</family>
+	  <default>
+	  <family>ITC Avant Garde Gothic</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Adventor</family>
 	  <default>
 	  <family>ITC Avant Garde Gothic</family>
@@ -134,6 +169,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Bookman URW</family>
+	  <default>
+	  <family>ITC Bookman</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Bonum</family>
 	  <default>
 	  <family>ITC Bookman</family>
@@ -162,6 +204,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Chancery URW</family>
+	  <default>
+	  <family>ITC Zapf Chancery</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Chorus</family>
 	  <default>
 	  <family>ITC Zapf Chancery</family>
@@ -176,6 +225,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Palladio URW</family>
+	  <default>
+	  <family>Palatino</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Pagella</family>
 	  <default>
 	  <family>Palatino</family>
@@ -197,6 +253,13 @@ but in an order preferring similar designs first.  We do this in three steps:
 	</alias>
 
 	<alias binding="same">
+	  <family>Century SchoolBook URW</family>
+	  <default>
+	  <family>New Century Schoolbook</family>
+	  </default>
+	</alias>
+
+	<alias binding="same">
 	  <family>TeX Gyre Schola</family>
 	  <default>
 	  <family>New Century Schoolbook</family>
@@ -401,6 +464,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>Helvetica</family>
 	  <accept>
 	  <family>TeX Gyre Heros</family>
+	  <family>Nimbus Sans</family>
 	  <family>Nimbus Sans L</family>
 	  </accept>
 	</alias>
@@ -409,6 +473,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>Helvetica Condensed</family>
 	  <accept>
 	  <family>TeX Gyre Heros Cn</family>
+	  <family>Nimbus Sans Narrow</family>
 	  </accept>
 	</alias>
 
@@ -416,6 +481,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>Times</family>
 	  <accept>
 	  <family>TeX Gyre Termes</family>
+	  <family>Nimbus Roman</family>
 	  <family>Nimbus Roman No9 L</family>
 	  </accept>
 	</alias>
@@ -424,6 +490,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>Courier</family>
 	  <accept>
 	  <family>TeX Gyre Cursor</family>
+	  <family>Nimbus Mono</family>
 	  <family>Nimbus Mono L</family>
 	  </accept>
 	</alias>
@@ -432,6 +499,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>ITC Avant Garde Gothic</family>
 	  <accept>
 	  <family>TeX Gyre Adventor</family>
+	  <family>URW Gothic</family>
 	  <family>URW Gothic L</family>
 	  </accept>
 	</alias>
@@ -441,6 +509,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <accept>
 	  <family>Bookman Old Style</family>
 	  <family>TeX Gyre Bonum</family>
+	  <family>Bookman URW</family>
 	  <family>URW Bookman L</family>
 	  </accept>
 	</alias>
@@ -449,6 +518,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <family>ITC Zapf Chancery</family>
 	  <accept>
 	  <family>TeX Gyre Chorus</family>
+	  <family>Chancery URW</family>
 	  <family>URW Chancery L</family>
 	  </accept>
 	</alias>
@@ -458,6 +528,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <accept>
 	  <family>Palatino Linotype</family>
 	  <family>TeX Gyre Pagella</family>
+	  <family>Palladio URW</family>
 	  <family>URW Palladio L</family>
 	  </accept>
 	</alias>
@@ -467,6 +538,7 @@ but in an order preferring similar designs first.  We do this in three steps:
 	  <accept>
 	  <family>Century Schoolbook</family>
 	  <family>TeX Gyre Schola</family>
+	  <family>Century SchoolBook URW</family>
 	  <family>Century Schoolbook L</family>
 	  </accept>
 	</alias>
diff --git a/fontconfig/conf.d/45-latin.conf b/fontconfig/conf.d/45-latin.conf
index 996fb81..72490f3 100644
--- a/fontconfig/conf.d/45-latin.conf
+++ b/fontconfig/conf.d/45-latin.conf
@@ -34,6 +34,10 @@
 		<default><family>serif</family></default>
 	</alias>
 	<alias>
+		<family>Nimbus Roman</family>
+		<default><family>serif</family></default>
+	</alias>
+	<alias>
 		<family>Luxi Serif</family>
 		<default><family>serif</family></default>
 	</alias>
@@ -97,6 +101,10 @@
 		<default><family>sans-serif</family></default>
 	</alias>
 	<alias>
+		<family>Nimbus Sans</family>
+		<default><family>sans-serif</family></default>
+	</alias>
+	<alias>
 		<family>Luxi Sans</family>
 		<default><family>sans-serif</family></default>
 	</alias>
@@ -151,6 +159,10 @@
 		<family>Nimbus Mono L</family>
 		<default><family>monospace</family></default>
 	</alias>
+	<alias>
+		<family>Nimbus Mono</family>
+		<default><family>monospace</family></default>
+	</alias>
 <!--
   Fantasy faces
  -->
diff --git a/fontconfig/conf.d/60-latin.conf b/fontconfig/conf.d/60-latin.conf
index 2107e31..35600ea 100644
--- a/fontconfig/conf.d/60-latin.conf
+++ b/fontconfig/conf.d/60-latin.conf
@@ -10,6 +10,7 @@
 			<family>Thorndale AMT</family>
 			<family>Luxi Serif</family>
 			<family>Nimbus Roman No9 L</family>
+			<family>Nimbus Roman</family>
 			<family>Times</family>
 		</prefer>
 	</alias>
@@ -23,6 +24,7 @@
 			<family>Albany AMT</family>
 			<family>Luxi Sans</family>
 			<family>Nimbus Sans L</family>
+			<family>Nimbus Sans</family>
 			<family>Helvetica</family>
 			<family>Lucida Sans Unicode</family>
 			<family>BPG Glaho International</family> <!-- lat,cyr,arab,geor -->
@@ -40,6 +42,7 @@
 			<family>Cumberland AMT</family>
 			<family>Luxi Mono</family>
 			<family>Nimbus Mono L</family>
+			<family>Nimbus Mono</family>
 			<family>Courier</family>
 		</prefer>
 	</alias>
diff --git a/libX11/nls/compose.dir.pre b/libX11/nls/compose.dir.pre
index 455070f..e52a5c5 100644
--- a/libX11/nls/compose.dir.pre
+++ b/libX11/nls/compose.dir.pre
@@ -1,7 +1,7 @@
 XCOMM
-XCOMM	This file contains compose table file name.
-XCOMM	The first word is the compose table file name and
-XCOMM	the second word is full locale name.
+XCOMM	This file contains compose table file names.
+XCOMM	The first word is the compose table file name
+XCOMM	and the second word is the full locale name.
 XCOMM
 XCOMM
 iso8859-1/Compose:		C
@@ -289,13 +289,12 @@ en_US.UTF-8/Compose:		ar_SY.UTF-8
 en_US.UTF-8/Compose:		ar_TN.UTF-8
 en_US.UTF-8/Compose:		ar_YE.UTF-8
 en_US.UTF-8/Compose:		as_IN.UTF-8
-en_US.UTF-8/Compose:		bo_IN.UTF-8
-en_US.UTF-8/Compose:		bs_BA.UTF-8
 en_US.UTF-8/Compose:		az_AZ.UTF-8
 en_US.UTF-8/Compose:		be_BY.UTF-8
 en_US.UTF-8/Compose:		bg_BG.UTF-8
-en_US.UTF-8/Compose:		bn_IN.UTF-8
 en_US.UTF-8/Compose:		bn_BD.UTF-8
+en_US.UTF-8/Compose:		bn_IN.UTF-8
+en_US.UTF-8/Compose:		bo_IN.UTF-8
 en_US.UTF-8/Compose:		br_FR.UTF-8
 en_US.UTF-8/Compose:		bs_BA.UTF-8
 en_US.UTF-8/Compose:		ca_AD.UTF-8
@@ -317,10 +316,10 @@ en_US.UTF-8/Compose:		en_AU.UTF-8
 en_US.UTF-8/Compose:		en_BE.UTF-8
 en_US.UTF-8/Compose:		en_BW.UTF-8
 en_US.UTF-8/Compose:		en_BZ.UTF-8
-en_US.UTF-8/Compose:		en_DK.UTF-8
 en_US.UTF-8/Compose:		en_CA.UTF-8
-en_US.UTF-8/Compose:		en_GB.UTF-8
+en_US.UTF-8/Compose:		en_DK.UTF-8
 en_US.UTF-8/Compose:		en_EN.UTF-8
+en_US.UTF-8/Compose:		en_GB.UTF-8
 en_US.UTF-8/Compose:		en_HK.UTF-8
 en_US.UTF-8/Compose:		en_IE.UTF-8
 en_US.UTF-8/Compose:		en_IN.UTF-8
@@ -458,16 +457,16 @@ en_US.UTF-8/Compose:		tr_TR.UTF-8
 en_US.UTF-8/Compose:		ts_ZA.UTF-8
 en_US.UTF-8/Compose:		tt_RU.UTF-8
 en_US.UTF-8/Compose:		uk_UA.UTF-8
-en_US.UTF-8/Compose:		ur_PK.UTF-8
 en_US.UTF-8/Compose:		ur_IN.UTF-8
+en_US.UTF-8/Compose:		ur_PK.UTF-8
 en_US.UTF-8/Compose:		uz_UZ.UTF-8
 en_US.UTF-8/Compose:		ve_ZA.UTF-8
 en_US.UTF-8/Compose:		vi_VN.UTF-8
 en_US.UTF-8/Compose:		wa_BE.UTF-8
-en_US.UTF-8/Compose:		yi_US.UTF-8
 en_US.UTF-8/Compose:		xh_ZA.UTF-8
+en_US.UTF-8/Compose:		yi_US.UTF-8
 zh_CN.UTF-8/Compose:		zh_CN.UTF-8
 zh_HK.UTF-8/Compose:		zh_HK.UTF-8
+en_US.UTF-8/Compose:		zh_SG.UTF-8
 zh_TW.UTF-8/Compose:		zh_TW.UTF-8
 en_US.UTF-8/Compose:		zu_ZA.UTF-8
-en_US.UTF-8/Compose:		zh_SG.UTF-8
diff --git a/libX11/nls/en_US.UTF-8/Compose.pre b/libX11/nls/en_US.UTF-8/Compose.pre
index 4a96570..972e111 100644
--- a/libX11/nls/en_US.UTF-8/Compose.pre
+++ b/libX11/nls/en_US.UTF-8/Compose.pre
@@ -103,6 +103,7 @@ XCOMM Spaces
 <Multi_key> <o> <R>              	: "®"   registered # REGISTERED SIGN
 <Multi_key> <O> <r>              	: "®"   registered # REGISTERED SIGN
 <Multi_key> <O> <R>              	: "®"   registered # REGISTERED SIGN
+<Multi_key> <R> <o> 			: "®"   registered # REGISTERED SIGN
 <Multi_key> <R> <O> 			: "®"   registered # REGISTERED SIGN
 
 <Multi_key> <period> <greater>   	: "›"   U203a # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
@@ -119,8 +120,6 @@ XCOMM Spaces
 <Multi_key> <plus> <minus>       	: "±"   plusminus # PLUS-MINUS SIGN
 <Multi_key> <minus> <plus> 		: "±"   plusminus # PLUS-MINUS SIGN
 <Multi_key> <question> <question> 	: "¿"   questiondown # INVERTED QUESTION MARK
-<Multi_key> <minus> <d>          	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
-<Multi_key> <minus> <D>          	: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
 <Multi_key> <s> <s>              	: "ß"   ssharp # LATIN SMALL LETTER SHARP S
 <Multi_key> <S> <S>              	: "ẞ"   U1e9e # LATIN CAPITAL LETTER SHARP S
 
@@ -200,21 +199,24 @@ XCOMM "₲" U20b2 GUARANI SIGN
 XCOMM "₳" U20b3 AUSTRAL SIGN
 XCOMM "₴" U20b4 HRYVNIA SIGN
 XCOMM "₵" U20b5 CEDI SIGN
+<Multi_key> <R> <equal>          	: "₹" U20b9 # INDIAN RUPEE SIGN
+<Multi_key> <equal> <R>          	: "₹" U20b9 # INDIAN RUPEE SIGN
+<Multi_key> <r> <equal>          	: "₹" U20b9 # INDIAN RUPEE SIGN
+<Multi_key> <equal> <r>          	: "₹" U20b9 # INDIAN RUPEE SIGN
 
-
-<Multi_key> <bar> <C>            	: "¢"   cent # CENT SIGN
-<Multi_key> <bar> <c>            	: "¢"   cent # CENT SIGN
 <Multi_key> <C> <bar>            	: "¢"   cent # CENT SIGN
+<Multi_key> <bar> <C>			: "¢"   cent # CENT SIGN
 <Multi_key> <c> <bar>            	: "¢"   cent # CENT SIGN
+<Multi_key> <bar> <c>			: "¢"   cent # CENT SIGN
 <Multi_key> <c> <slash>          	: "¢"   cent # CENT SIGN
 <Multi_key> <slash> <c>          	: "¢"   cent # CENT SIGN
 <Multi_key> <L> <minus>          	: "£"   sterling # POUND SIGN
-<Multi_key> <l> <minus>          	: "£"   sterling # POUND SIGN
 <Multi_key> <minus> <L>          	: "£"   sterling # POUND SIGN
+<Multi_key> <l> <minus> 		: "£"   sterling # POUND SIGN
 <Multi_key> <minus> <l>          	: "£"   sterling # POUND SIGN
 <Multi_key> <Y> <equal>          	: "¥"   yen # YEN SIGN
-<Multi_key> <y> <equal>          	: "¥"   yen # YEN SIGN
 <Multi_key> <equal> <Y>          	: "¥"   yen # YEN SIGN
+<Multi_key> <y> <equal> 		: "¥"   yen # YEN SIGN
 <Multi_key> <equal> <y>          	: "¥"   yen # YEN SIGN
 <Multi_key> <Y> <minus> 		: "¥"   yen # YEN SIGN
 <Multi_key> <minus> <Y> 		: "¥"   yen # YEN SIGN
@@ -878,12 +880,14 @@ XCOMM Part 3
 <Multi_key> <less> <d> 			: "ď"   U010F # LATIN SMALL LETTER D WITH CARON
 <Multi_key> <d> <less> 			: "ď"   U010F # LATIN SMALL LETTER D WITH CARON
 <dead_stroke> <D>               	: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
+<Multi_key> <minus> <D>          	: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
+<Multi_key> <D> <minus> 		: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
 <Multi_key> <slash> <D>          	: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
 <Multi_key> <KP_Divide> <D>      	: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
-<Multi_key> <D> <minus> 		: "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
 <dead_stroke> <d>               	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
-<Multi_key> <slash> <d>          	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
+<Multi_key> <minus> <d>          	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
 <Multi_key> <d> <minus> 		: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
+<Multi_key> <slash> <d>          	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
 <Multi_key> <KP_Divide> <d>      	: "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
 <dead_macron> <E>                	: "Ē"   U0112 # LATIN CAPITAL LETTER E WITH MACRON
 <Multi_key> <macron> <E>         	: "Ē"   U0112 # LATIN CAPITAL LETTER E WITH MACRON
@@ -4425,7 +4429,8 @@ XCOMM Part 3
 <Multi_key> <asciicircum> <plus> 	: "⁺"   U207A # SUPERSCRIPT PLUS SIGN
 <dead_circumflex> <KP_Add>       	: "⁺"   U207A # SUPERSCRIPT PLUS SIGN
 <Multi_key> <asciicircum> <KP_Add> 	: "⁺"   U207A # SUPERSCRIPT PLUS SIGN
-<dead_circumflex> <U2212>    	: "⁻"   U207B # SUPERSCRIPT MINUS
+<dead_circumflex> <minus> 		: "⁻"   U207B # SUPERSCRIPT MINUS
+<dead_circumflex> <U2212> 		: "⁻"   U207B # SUPERSCRIPT MINUS
 <Multi_key> <asciicircum> <U2212> 	: "⁻"   U207B # SUPERSCRIPT MINUS
 <dead_circumflex> <equal>        	: "⁼"   U207C # SUPERSCRIPT EQUALS SIGN
 <Multi_key> <asciicircum> <equal> 	: "⁼"   U207C # SUPERSCRIPT EQUALS SIGN
@@ -5069,13 +5074,18 @@ XCOMM Part 3
 <Multi_key> <parenleft> <U30F0> <parenright> 	: "㋼"   U32FC # CIRCLED KATAKANA WI
 <Multi_key> <parenleft> <U30F1> <parenright> 	: "㋽"   U32FD # CIRCLED KATAKANA WE
 <Multi_key> <parenleft> <kana_WO> <parenright> 	: "㋾"   U32FE # CIRCLED KATAKANA WO
+
+XCOMM
+XCOMM Hebrew letters with accents
+XCOMM
+
 <Multi_key> <U05B4> <hebrew_yod> 	: "יִ"   UFB1D # HEBREW LETTER YOD WITH HIRIQ
-<Multi_key> <U05B7> <U05F2> 	: "ײַ"   UFB1F # HEBREW LIGATURE YIDDISH YOD YOD PATAH
+<Multi_key> <U05B7> <U05F2> 		: "ײַ"   UFB1F # HEBREW LIGATURE YIDDISH YOD YOD PATAH
 <Multi_key> <U05C1> <hebrew_shin> 	: "שׁ"   UFB2A # HEBREW LETTER SHIN WITH SHIN DOT
 <Multi_key> <U05C2> <hebrew_shin> 	: "שׂ"   UFB2B # HEBREW LETTER SHIN WITH SIN DOT
-<Multi_key> <U05C1> <UFB49> 	: "שּׁ"   UFB2C # HEBREW LETTER SHIN WITH DAGESH AND SHIN DOT
+<Multi_key> <U05C1> <UFB49> 			: "שּׁ"   UFB2C # HEBREW LETTER SHIN WITH DAGESH AND SHIN DOT
 <Multi_key> <U05C1> <U05BC> <hebrew_shin> 	: "שּׁ"   UFB2C # HEBREW LETTER SHIN WITH DAGESH AND SHIN DOT
-<Multi_key> <U05C2> <UFB49> 	: "שּׂ"   UFB2D # HEBREW LETTER SHIN WITH DAGESH AND SIN DOT
+<Multi_key> <U05C2> <UFB49> 			: "שּׂ"   UFB2D # HEBREW LETTER SHIN WITH DAGESH AND SIN DOT
 <Multi_key> <U05C2> <U05BC> <hebrew_shin> 	: "שּׂ"   UFB2D # HEBREW LETTER SHIN WITH DAGESH AND SIN DOT
 <Multi_key> <U05B7> <hebrew_aleph> 	: "אַ"   UFB2E # HEBREW LETTER ALEF WITH PATAH
 <Multi_key> <U05B8> <hebrew_aleph> 	: "אָ"   UFB2F # HEBREW LETTER ALEF WITH QAMATS
@@ -5216,7 +5226,6 @@ XCOMM
 <dead_cedilla> <U0114> 		      : "Ḝ"   U1E1C               # LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE
 <dead_cedilla> <U0115> 		      : "ḝ"   U1E1D               # LATIN SMALL LETTER E WITH CEDILLA AND BREVE
 <dead_cedilla> <nobreakspace> 	      : "̧"   U0327               # COMBINING CEDILLA
-<dead_circumflex> <minus> 	      : "⁻"   U207B               # SUPERSCRIPT MINUS
 <dead_circumflex> <Aacute> 	      : "Ấ"   Acircumflexacute    # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE
 <dead_circumflex> <Agrave> 	      : "Ầ"   Acircumflexgrave    # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE
 <dead_circumflex> <Ahook> 	      : "Ẩ"   Acircumflexhook     # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE
@@ -5867,8 +5876,8 @@ XCOMM Characters from "Mathematical Operators"
 <Multi_key> <greater> <less>                    : "⋄"   U22c4   # > < DIAMOND OPERATOR
 <Multi_key> <U2227> <U2228>                     : "⋄"   U22c4   # ∧ ∨ DIAMOND OPERATOR
 <Multi_key> <U2228> <U2227>                     : "⋄"   U22c4   # ∨ ∧ DIAMOND OPERATOR
-<Multi_key> <colon> <period>                    : "∴"   therefore # THEREFORE
-<Multi_key> <period> <colon>                    : "∵"   because # BECAUSE
+<Multi_key> <colon> <period>                    : "∴"   therefore   # : . THEREFORE
+<Multi_key> <period> <colon>                    : "∵"   because     # . : BECAUSE
 
 XCOMM Characters from "Miscellaneous Technical"
 
diff --git a/libxcb/src/c_client.py b/libxcb/src/c_client.py
index 87f268b..56a1766 100644
--- a/libxcb/src/c_client.py
+++ b/libxcb/src/c_client.py
@@ -358,7 +358,8 @@ def _c_type_setup(self, name, postfix):
                 field.c_pointer = '*'
                 field.c_field_const_type = 'const ' + field.c_field_type
                 self.c_need_aux = True
-            elif not field.type.fixed_size() and not field.type.is_case_or_bitcase:
+
+            if not field.type.fixed_size() and not field.type.is_case_or_bitcase:
                 self.c_need_sizeof = True
 
             field.c_iterator_type = _t(field.field_type + ('iterator',))      # xcb_fieldtype_iterator_t
@@ -656,9 +657,15 @@ def get_serialize_params(context, self, buffer_var='_buffer', aux_var='_aux'):
     return (param_fields, wire_fields, params)
 # get_serialize_params()
 
-def _c_serialize_helper_insert_padding(context, code_lines, space, postpone):
+def _c_serialize_helper_insert_padding(context, code_lines, space, postpone, is_case_or_bitcase):
     code_lines.append('%s    /* insert padding */' % space)
-    code_lines.append('%s    xcb_pad = -xcb_block_len & (xcb_align_to - 1);' % space)
+    if is_case_or_bitcase:
+        code_lines.append(
+            '%s    xcb_pad = -(xcb_block_len + xcb_padding_offset) & (xcb_align_to - 1);'
+            % space)
+    else:
+        code_lines.append(
+            '%s    xcb_pad = -xcb_block_len & (xcb_align_to - 1);' % space)
 #    code_lines.append('%s    printf("automatically inserting padding: %%%%d\\n", xcb_pad);' % space)
     code_lines.append('%s    xcb_buffer_len += xcb_block_len + xcb_pad;' % space)
 
@@ -676,6 +683,8 @@ def _c_serialize_helper_insert_padding(context, code_lines, space, postpone):
         code_lines.append('%s    }' % space)
 
     code_lines.append('%s    xcb_block_len = 0;' % space)
+    if is_case_or_bitcase:
+        code_lines.append('%s    xcb_padding_offset = 0;' % space)
 
     # keep tracking of xcb_parts entries for serialize
     return 1
@@ -770,6 +779,10 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr
     elif context in ('unserialize', 'unpack'):
         length = "%s(xcb_tmp, %s&%s%s)" % (field.type.c_unpack_name,
                                            c_field_names, prefix_str, field.c_field_name)
+    elif 'sizeof' == context:
+        # remove trailing ", " from c_field_names because it will be used at end of arglist
+        my_c_field_names = c_field_names[:-2]
+        length = "%s(xcb_tmp, %s)" % (field.type.c_sizeof_name, my_c_field_names)
 
     return length
 # _c_serialize_helper_switch_field()
@@ -869,9 +882,13 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
             # total padding = sizeof(pad0) * nmemb
             length += " * %d" % field.type.nmemb
 
-        if field.type.is_list:
-            # no such case in the protocol, cannot be tested and therefore ignored for now
-            raise Exception('list with fixed number of elemens unhandled in _unserialize()')
+        elif field.type.is_list:
+            # list with fixed number of elements
+            # length of array = sizeof(arrayElementType) * nmemb
+            length += " * %d" % field.type.nmemb
+            # use memcpy because C cannot assign whole arrays with operator=
+            value = '    memcpy(%s, xcb_tmp, %s);' % (abs_field_name, length)
+
 
     elif 'serialize' == context:
         value = '    xcb_parts[xcb_parts_idx].iov_base = (char *) '
@@ -996,13 +1013,15 @@ def _c_serialize_helper_fields(context, self,
                 # Variable length pad is <pad align= />
                 code_lines.append('%s    xcb_align_to = %d;' % (space, field.type.align))
                 count += _c_serialize_helper_insert_padding(context, code_lines, space,
-                                                        self.c_var_followed_by_fixed_fields)
+                                                            self.c_var_followed_by_fixed_fields,
+                                                            is_case_or_bitcase)
                 continue
             else:
                 # switch/bitcase: always calculate padding before and after variable sized fields
                 if need_padding or is_case_or_bitcase:
                     count += _c_serialize_helper_insert_padding(context, code_lines, space,
-                                                            self.c_var_followed_by_fixed_fields)
+                                                                self.c_var_followed_by_fixed_fields,
+                                                                is_case_or_bitcase)
 
                 value, length = _c_serialize_helper_fields_variable_size(context, self, field,
                                                                          code_lines, temp_vars,
@@ -1042,7 +1061,12 @@ def _c_serialize_helper_fields(context, self,
             code_lines.append('%s    xcb_parts_idx++;' % space)
             count += 1
 
-        code_lines.append('%s    xcb_align_to = ALIGNOF(%s);' % (space, 'char' if field.c_field_type == 'void' else field.c_field_type))
+        code_lines.append(
+            '%s    xcb_align_to = ALIGNOF(%s);'
+             % (space,
+                 'char'
+                  if field.c_field_type == 'void' or field.type.is_switch
+                  else field.c_field_type))
 
         need_padding = True
         if self.c_var_followed_by_fixed_fields:
@@ -1086,7 +1110,7 @@ def _c_serialize_helper(context, complex_type,
                                             code_lines, temp_vars,
                                             space, prefix, False)
     # "final padding"
-    count += _c_serialize_helper_insert_padding(context, code_lines, space, False)
+    count += _c_serialize_helper_insert_padding(context, code_lines, space, False, self.is_switch)
 
     return count
 # _c_serialize_helper()
@@ -1156,6 +1180,8 @@ def _c_serialize(context, self):
             _c('    char *xcb_out = *_buffer;')
             _c('    unsigned int xcb_buffer_len = 0;')
             _c('    unsigned int xcb_align_to = 0;')
+        if self.is_switch:
+            _c('    unsigned int xcb_padding_offset = ((size_t)xcb_out) & 7;')
         prefix = [('_aux', '->', self)]
         aux_ptr = 'xcb_out'
 
@@ -1179,6 +1205,8 @@ def _c_serialize(context, self):
         _c('    unsigned int xcb_block_len = 0;')
         _c('    unsigned int xcb_pad = 0;')
         _c('    unsigned int xcb_align_to = 0;')
+        if self.is_switch:
+            _c('    unsigned int xcb_padding_offset = ((size_t)_buffer) & 7;')
 
     elif 'sizeof' == context:
         param_names = [p[2] for p in params]
@@ -1196,6 +1224,8 @@ def _c_serialize(context, self):
         else:
             _c('    char *xcb_tmp = (char *)_buffer;')
             prefix = [('_aux', '->', self)]
+            if self.is_switch:
+                _c('    unsigned int xcb_padding_offset = 0;')
 
     count = _c_serialize_helper(context, self, code_lines, temp_vars, prefix=prefix)
     # update variable size fields (only important for context=='serialize'
@@ -1774,7 +1804,7 @@ def _c_complex(self, force_packed = False):
         for b in self.bitcases:
             space = ''
             if b.type.has_name:
-                _h('    struct _%s {', b.c_field_name)
+                _h('    struct {')
                 space = '    '
             for field in b.type.fields:
                 _c_complex_field(self, field, space)
diff --git a/libxcb/xcb-proto/src/xinput.xml b/libxcb/xcb-proto/src/xinput.xml
index dc87e78..7f7b0a6 100644
--- a/libxcb/xcb-proto/src/xinput.xml
+++ b/libxcb/xcb-proto/src/xinput.xml
@@ -862,7 +862,7 @@ in struct DeviceTimeCoord.
         <field type="CARD8" name="len" />
         <field type="CARD8" name="num_valuators" />
         <field type="CARD8" name="mode" mask="ValuatorStateModeMask" />
-        <list type="CARD32" name="valuators">
+        <list type="INT32" name="valuators">
             <fieldref>num_valuators</fieldref>
         </list>
     </struct>
@@ -870,14 +870,33 @@ in struct DeviceTimeCoord.
     <struct name="InputState">
         <field type="CARD8" name="class_id" enum="InputClass" />
         <field type="CARD8" name="len" />
-        <field type="CARD8" name="num_items" />
-        <pad bytes="1" />
-        <list type="CARD8" name="uninterpreted_data">
-            <op op="-">
-                <fieldref>len</fieldref>
-                <value>4</value>
-            </op>
-        </list>
+        <switch name="data">
+            <fieldref>class_id</fieldref>
+            <case name="key">
+                <enumref ref="InputClass">Key</enumref>
+                <field type="CARD8" name="num_keys" />
+                <pad bytes="1" />
+                <list type="CARD8" name="keys">
+                    <value>32</value>
+                </list>
+            </case>
+            <case name="button">
+                <enumref ref="InputClass">Button</enumref>
+                <field type="CARD8" name="num_buttons" />
+                <pad bytes="1" />
+                <list type="CARD8" name="buttons">
+                    <value>32</value>
+                </list>
+            </case>
+            <case name="valuator">
+                <enumref ref="InputClass">Valuator</enumref>
+                <field type="CARD8" name="num_valuators" />
+                <field type="CARD8" name="mode" mask="ValuatorStateModeMask" />
+                <list type="INT32" name="valuators">
+                    <fieldref>num_valuators</fieldref>
+                </list>
+            </case>
+        </switch>
     </struct>
 
     <request name="QueryDeviceState" opcode="30">
diff --git a/mesalib/VERSION b/mesalib/VERSION
index d43f97a..093d8ba 100644
--- a/mesalib/VERSION
+++ b/mesalib/VERSION
@@ -1 +1 @@
-10.4.0-devel
+10.5.0-devel
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 03f1bca..1d9d015 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -39,6 +39,7 @@ PRESENTPROTO_REQUIRED=1.0
 LIBUDEV_REQUIRED=151
 GLPROTO_REQUIRED=1.4.14
 LIBOMXIL_BELLAGIO_REQUIRED=0.0
+LIBVA_REQUIRED=0.35.0
 VDPAU_REQUIRED=0.4.1
 WAYLAND_REQUIRED=1.2.0
 XCB_REQUIRED=1.9.3
@@ -252,7 +253,16 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
 dnl
 dnl Optional flags, check for compiler support
 dnl
-AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
+save_CFLAGS="$CFLAGS"
+CFLAGS="-msse4.1 $CFLAGS"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include <smmintrin.h>
+int main () {
+    __m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+    c = _mm_max_epu32(a, b);
+    return 0;
+}]])], SSE41_SUPPORTED=1)
+CFLAGS="$save_CFLAGS"
 if test "x$SSE41_SUPPORTED" = x1; then
     DEFINES="$DEFINES -DUSE_SSE41"
 fi
@@ -527,6 +537,9 @@ if test "x$enable_asm" = xyes; then
     esac
 fi
 
+AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
+AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
+
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
 AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
@@ -657,6 +670,11 @@ AC_ARG_ENABLE([gbm],
          [enable gbm library @<:@default=auto@:>@])],
    [enable_gbm="$enableval"],
    [enable_gbm=auto])
+AC_ARG_ENABLE([nine],
+    [AS_HELP_STRING([--enable-nine],
+        [enable build of the nine Direct3D9 API @<:@default=no@:>@])],
+    [enable_nine="$enableval"],
+    [enable_nine=no])
 
 AC_ARG_ENABLE([xvmc],
    [AS_HELP_STRING([--enable-xvmc],
@@ -694,20 +712,6 @@ AC_ARG_ENABLE([xlib-glx],
         [make GLX library Xlib-based instead of DRI-based @<:@default=disabled@:>@])],
     [enable_xlib_glx="$enableval"],
     [enable_xlib_glx=no])
-AC_ARG_ENABLE([gallium-egl],
-    [AS_HELP_STRING([--enable-gallium-egl],
-        [enable optional EGL state tracker (not required
-         for EGL support in Gallium with OpenGL and OpenGL ES)
-         @<:@default=disabled@:>@])],
-    [enable_gallium_egl="$enableval"],
-    [enable_gallium_egl=no])
-AC_ARG_ENABLE([gallium-gbm],
-    [AS_HELP_STRING([--enable-gallium-gbm],
-        [enable optional gbm state tracker (not required for
-         gbm support in Gallium)
-         @<:@default=auto@:>@])],
-    [enable_gallium_gbm="$enableval"],
-    [enable_gallium_gbm=auto])
 
 AC_ARG_ENABLE([r600-llvm-compiler],
     [AS_HELP_STRING([--enable-r600-llvm-compiler],
@@ -744,6 +748,7 @@ esac
 if test "x$enable_opengl" = xno -a \
         "x$enable_gles1" = xno -a \
         "x$enable_gles2" = xno -a \
+        "x$enable_nine" = xno -a \
         "x$enable_openvg" = xno -a \
         "x$enable_xa" = xno -a \
         "x$enable_xvmc" = xno -a \
@@ -1311,51 +1316,6 @@ AM_CONDITIONAL(HAVE_EGL, test "x$enable_egl" = xyes)
 AC_SUBST([EGL_LIB_DEPS])
 
 dnl
-dnl EGL Gallium configuration
-dnl
-if test "x$enable_gallium_egl" = xyes; then
-    if test -z "$with_gallium_drivers"; then
-        AC_MSG_ERROR([cannot enable egl_gallium without Gallium])
-    fi
-    if test "x$enable_egl" = xno; then
-        AC_MSG_ERROR([cannot enable egl_gallium without EGL])
-    fi
-    if test "x$have_libdrm" != xyes; then
-        AC_MSG_ERROR([egl_gallium requires libdrm >= $LIBDRM_REQUIRED])
-    fi
-# XXX: Uncomment once converted to use static/shared pipe-drivers
-#    enable_gallium_loader=$enable_shared_pipe_drivers
-fi
-AM_CONDITIONAL(HAVE_GALLIUM_EGL, test "x$enable_gallium_egl" = xyes)
-
-dnl
-dnl gbm Gallium configuration
-dnl
-if test "x$enable_gallium_gbm" = xauto; then
-    case "$enable_gbm$enable_gallium_egl$enable_dri$with_egl_platforms" in
-        yesyesyes*drm*)
-            enable_gallium_gbm=yes ;;
-         *)
-            enable_gallium_gbm=no ;;
-    esac
-fi
-if test "x$enable_gallium_gbm" = xyes; then
-    if test -z "$with_gallium_drivers"; then
-        AC_MSG_ERROR([cannot enable gbm_gallium without Gallium])
-    fi
-    if test "x$enable_gbm" = xno; then
-        AC_MSG_ERROR([cannot enable gbm_gallium without gbm])
-    fi
-
-    if test "x$enable_gallium_egl" != xyes; then
-        AC_MSG_ERROR([gbm_gallium is only used by egl_gallium])
-    fi
-
-    enable_gallium_loader=$enable_shared_pipe_drivers
-fi
-AM_CONDITIONAL(HAVE_GALLIUM_GBM, test "x$enable_gallium_gbm" = xyes)
-
-dnl
 dnl XA configuration
 dnl
 if test "x$enable_xa" = xyes; then
@@ -1383,9 +1343,9 @@ if test "x$enable_openvg" = xyes; then
     if test -z "$with_gallium_drivers"; then
         AC_MSG_ERROR([cannot enable OpenVG without Gallium])
     fi
-    if test "x$enable_gallium_egl" = xno; then
-        AC_MSG_ERROR([cannot enable OpenVG without egl_gallium])
-    fi
+
+    AC_MSG_ERROR([Cannot enable OpenVG, because egl_gallium has been removed and
+                  OpenVG hasn't been integrated into standard libEGL yet])
 
     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
     VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS $PTHREAD_LIBS"
@@ -1399,49 +1359,74 @@ dnl Gallium G3DVL configuration
 dnl
 if test -n "$with_gallium_drivers" -a "x$with_gallium_drivers" != xswrast; then
     if test "x$enable_xvmc" = xauto; then
-	PKG_CHECK_EXISTS([xvmc], [enable_xvmc=yes], [enable_xvmc=no])
+	PKG_CHECK_EXISTS([xvmc >= $XVMC_REQUIRED], [enable_xvmc=yes], [enable_xvmc=no])
     fi
 
     if test "x$enable_vdpau" = xauto; then
-	PKG_CHECK_EXISTS([vdpau], [enable_vdpau=yes], [enable_vdpau=no])
+	PKG_CHECK_EXISTS([vdpau >= $VDPAU_REQUIRED], [enable_vdpau=yes], [enable_vdpau=no])
     fi
 
     if test "x$enable_omx" = xauto; then
-	PKG_CHECK_EXISTS([libomxil-bellagio], [enable_omx=yes], [enable_omx=no])
+	PKG_CHECK_EXISTS([libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED], [enable_omx=yes], [enable_omx=no])
     fi
 
     if test "x$enable_va" = xauto; then
-        PKG_CHECK_EXISTS([libva], [enable_va=yes], [enable_va=no])
+        PKG_CHECK_EXISTS([libva >= $LIBVA_REQUIRED], [enable_va=yes], [enable_va=no])
     fi
 fi
 
+if test "x$enable_xvmc" = xyes -o \
+        "x$enable_vdpau" = xyes -o \
+        "x$enable_omx" = xyes -o \
+        "x$enable_va" = xyes; then
+    PKG_CHECK_MODULES([VL], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
+    need_gallium_vl=yes
+fi
+AM_CONDITIONAL(NEED_GALLIUM_VL, test "x$need_gallium_vl" = xyes)
+
 if test "x$enable_xvmc" = xyes; then
-    PKG_CHECK_MODULES([XVMC], [xvmc >= $XVMC_REQUIRED x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
+    PKG_CHECK_MODULES([XVMC], [xvmc >= $XVMC_REQUIRED])
     enable_gallium_loader=$enable_shared_pipe_drivers
 fi
 AM_CONDITIONAL(HAVE_ST_XVMC, test "x$enable_xvmc" = xyes)
 
 if test "x$enable_vdpau" = xyes; then
-    PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED],
-                      [VDPAU_LIBS="`$PKG_CONFIG --libs x11-xcb xcb xcb-dri2`"])
+    PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED])
     enable_gallium_loader=$enable_shared_pipe_drivers
 fi
 AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
 
 if test "x$enable_omx" = xyes; then
-    PKG_CHECK_MODULES([OMX], [libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED])
+    PKG_CHECK_MODULES([OMX], [libomxil-bellagio >= $LIBOMXIL_BELLAGIO_REQUIRED])
     enable_gallium_loader=$enable_shared_pipe_drivers
 fi
 AM_CONDITIONAL(HAVE_ST_OMX, test "x$enable_omx" = xyes)
 
 if test "x$enable_va" = xyes; then
-    PKG_CHECK_MODULES([VA], [libva >= 0.35.0 x11-xcb xcb-dri2 >= $XCBDRI2_REQUIRED],
-                      [VA_LIBS="`$PKG_CONFIG --libs x11-xcb xcb-dri2`"])
+    PKG_CHECK_MODULES([VA], [libva >= $LIBVA_REQUIRED])
     enable_gallium_loader=$enable_shared_pipe_drivers
 fi
 AM_CONDITIONAL(HAVE_ST_VA, test "x$enable_va" = xyes)
 
 dnl
+dnl Nine Direct3D9 configuration
+dnl
+if test "x$enable_nine" = xyes; then
+    if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
+        AC_MSG_ERROR([nine requires the gallium swrast driver])
+    fi
+    if test "x$with_gallium_drivers" == xswrast; then
+        AC_MSG_ERROR([nine requires at least one non-swrast gallium driver])
+    fi
+    if test "x$enable_dri3" = xno; then
+        AC_MSG_WARN([using nine together with wine requires DRI3 enabled system])
+    fi
+
+    enable_gallium_loader=$enable_shared_pipe_drivers
+fi
+AM_CONDITIONAL(HAVE_ST_NINE, test "x$enable_nine" = xyes)
+
+dnl
 dnl OpenCL configuration
 dnl
 
@@ -1815,6 +1800,13 @@ AC_ARG_WITH([va-libdir],
     [VA_LIB_INSTALL_DIR="${libdir}/dri"])
 AC_SUBST([VA_LIB_INSTALL_DIR])
 
+AC_ARG_WITH([d3d-libdir],
+    [AS_HELP_STRING([--with-d3d-libdir=DIR],
+        [directory for the D3D modules @<:@${libdir}/d3d@:>@])],
+    [D3D_DRIVER_INSTALL_DIR="$withval"],
+    [D3D_DRIVER_INSTALL_DIR="${libdir}/d3d"])
+AC_SUBST([D3D_DRIVER_INSTALL_DIR])
+
 dnl
 dnl Gallium helper functions
 dnl
@@ -1970,7 +1962,7 @@ if test -n "$with_gallium_drivers"; then
 fi
 
 dnl Set LLVM_LIBS - This is done after the driver configuration so
-dnl that drivers can add additonal components to LLVM_COMPONENTS.
+dnl that drivers can add additional components to LLVM_COMPONENTS.
 dnl Previously, gallium drivers were updating LLVM_LIBS directly
 dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
 dnl this was causing the same libraries to be appear multiple times
@@ -2003,11 +1995,16 @@ if test "x$MESA_LLVM" != x0; then
 	invocation and rebuild.])])
 
            dnl We don't need to update LLVM_LIBS in this case because the LLVM
-           dnl install uses a shared object for each compoenent and we have
+           dnl install uses a shared object for each component and we have
            dnl already added all of these objects to LLVM_LIBS.
         fi
     else
-        AC_MSG_WARN([Building mesa with staticly linked LLVM may cause compilation issues])
+        AC_MSG_WARN([Building mesa with statically linked LLVM may cause compilation issues])
+        dnl We need to link to llvm system libs when using static libs
+        dnl However, only llvm 3.5+ provides --system-libs
+        if test $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then
+            LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`"
+        fi
     fi
 fi
 
@@ -2094,6 +2091,11 @@ AM_CONDITIONAL(HAVE_X86_ASM, test "x$asm_arch" = xx86 -o "x$asm_arch" = xx86_64)
 AM_CONDITIONAL(HAVE_X86_64_ASM, test "x$asm_arch" = xx86_64)
 AM_CONDITIONAL(HAVE_SPARC_ASM, test "x$asm_arch" = xsparc)
 
+AC_SUBST([NINE_MAJOR], 1)
+AC_SUBST([NINE_MINOR], 0)
+AC_SUBST([NINE_TINY], 0)
+AC_SUBST([NINE_VERSION], "$NINE_MAJOR.$NINE_MINOR.$NINE_TINY")
+
 AC_SUBST([VDPAU_MAJOR], 1)
 AC_SUBST([VDPAU_MINOR], 0)
 
@@ -2162,9 +2164,8 @@ AC_CONFIG_FILES([Makefile
 		src/gallium/drivers/vc4/kernel/Makefile
 		src/gallium/state_trackers/clover/Makefile
 		src/gallium/state_trackers/dri/Makefile
-		src/gallium/state_trackers/egl/Makefile
-		src/gallium/state_trackers/gbm/Makefile
 		src/gallium/state_trackers/glx/xlib/Makefile
+		src/gallium/state_trackers/nine/Makefile
 		src/gallium/state_trackers/omx/Makefile
 		src/gallium/state_trackers/osmesa/Makefile
 		src/gallium/state_trackers/va/Makefile
@@ -2172,6 +2173,8 @@ AC_CONFIG_FILES([Makefile
 		src/gallium/state_trackers/vega/Makefile
 		src/gallium/state_trackers/xa/Makefile
 		src/gallium/state_trackers/xvmc/Makefile
+		src/gallium/targets/d3dadapter9/Makefile
+		src/gallium/targets/d3dadapter9/d3d.pc
 		src/gallium/targets/dri/Makefile
 		src/gallium/targets/egl-static/Makefile
 		src/gallium/targets/gbm/Makefile
@@ -2299,12 +2302,7 @@ if test "$enable_egl" = yes; then
         egl_drivers="$egl_drivers builtin:egl_dri2"
     fi
 
-    if test "x$enable_gallium_egl" = xyes; then
-        echo "        EGL drivers:    ${egl_drivers} egl_gallium"
-        echo "        EGL Gallium STs:$EGL_CLIENT_APIS"
-    else
-        echo "        EGL drivers:    $egl_drivers"
-    fi
+    echo "        EGL drivers:    $egl_drivers"
 fi
 
 echo ""
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt
index 6a988d5..648f5ac 100644
--- a/mesalib/docs/GL3.txt
+++ b/mesalib/docs/GL3.txt
@@ -18,7 +18,7 @@ are exposed in the 3.0 context as extensions.
 Feature                                               Status
 ----------------------------------------------------- ------------------------
 
-GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe (*), softpipe (*)
+GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe
 
   glBindFragDataLocation, glGetFragDataLocation         DONE
   Conditional rendering (GL_NV_conditional_render)      DONE (r300, swrast)
@@ -45,7 +45,7 @@ GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe (*),
   glVertexAttribI commands                              DONE
   Depth format cube textures                            DONE ()
   GLX_ARB_create_context (GLX 1.4 is required)          DONE
-  Multisample anti-aliasing                             DONE (r300)
+  Multisample anti-aliasing                             DONE (llvmpipe (*), softpipe (*), r300)
 
 (*) llvmpipe and softpipe have fake Multisample anti-aliasing support
 
@@ -98,8 +98,8 @@ GL 4.0, GLSL 4.00:
   GL_ARB_draw_indirect                                 DONE (i965, nvc0, radeonsi, llvmpipe, softpipe)
   GL_ARB_gpu_shader5                                   DONE (i965, nvc0)
   - 'precise' qualifier                                DONE
-  - Dynamically uniform sampler array indices          DONE ()
-  - Dynamically uniform UBO array indices              DONE ()
+  - Dynamically uniform sampler array indices          DONE (r600)
+  - Dynamically uniform UBO array indices              DONE (r600)
   - Implicit signed -> unsigned conversions            DONE
   - Fused multiply-add                                 DONE ()
   - Packing/bitfield/conversion functions              DONE (r600)
@@ -107,7 +107,7 @@ GL 4.0, GLSL 4.00:
   - Geometry shader instancing                         DONE (r600)
   - Geometry shader multiple streams                   DONE ()
   - Enhanced per-sample shading                        DONE (r600)
-  - Interpolation functions                            DONE ()
+  - Interpolation functions                            DONE (r600)
   - New overload resolution rules                      DONE
   GL_ARB_gpu_shader_fp64                               started (Dave)
   GL_ARB_sample_shading                                DONE (i965, nv50, nvc0, r600, radeonsi)
@@ -187,15 +187,15 @@ GL 4.4, GLSL 4.40:
 GL 4.5, GLSL 4.50:
 
   GL_ARB_ES3_1_compatibility                           not started
-  GL_ARB_clip_control                                  DONE (llvmpipe, softpipe, r300, r600, radeonsi)
-  GL_ARB_conditional_render_inverted                   DONE (i965, nvc0, llvmpipe, softpipe)
+  GL_ARB_clip_control                                  DONE (nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe)
+  GL_ARB_conditional_render_inverted                   DONE (i965, nv50, nvc0, llvmpipe, softpipe)
   GL_ARB_cull_distance                                 not started
   GL_ARB_derivative_control                            DONE (i965, nv50, nvc0, r600)
-  GL_ARB_direct_state_access                           not started
+  GL_ARB_direct_state_access                           started (Laura Ekstrand)
   GL_ARB_get_texture_sub_image                         started (Brian Paul)
   GL_ARB_shader_texture_image_samples                  not started
   GL_ARB_texture_barrier                               DONE (nv50, nvc0, r300, r600, radeonsi)
-  GL_KHR_context_flush_control                         not started
+  GL_KHR_context_flush_control                         DONE (all - but needs GLX/EXT extension to be useful)
   GL_KHR_robust_buffer_access_behavior                 not started
   GL_KHR_robustness                                    90% done (the ARB variant)
 
diff --git a/mesalib/docs/egl.html b/mesalib/docs/egl.html
index eebb8c7..e77c235 100644
--- a/mesalib/docs/egl.html
+++ b/mesalib/docs/egl.html
@@ -77,13 +77,6 @@ drivers will be installed to <code>${libdir}/egl</code>.</p>
 
 </dd>
 
-<dt><code>--enable-gallium-egl</code></dt>
-<dd>
-
-<p>Enable the optional <code>egl_gallium</code> driver.</p>
-
-</dd>
-
 <dt><code>--with-egl-platforms</code></dt>
 <dd>
 
diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html
index 0a491a2..024bb5f 100644
--- a/mesalib/docs/index.html
+++ b/mesalib/docs/index.html
@@ -16,6 +16,18 @@
 
 <h1>News</h1>
 
+<h2>November 21, 2014</h2>
+<p>
+<a href="relnotes/10.3.4.html">Mesa 10.3.4</a> is released.
+This is a bug-fix release.
+</p>
+
+<h2>November 8, 2014</h2>
+<p>
+<a href="relnotes/10.3.3.html">Mesa 10.3.3</a> is released.
+This is a bug-fix release.
+</p>
+
 <h2>October 24, 2014</h2>
 <p>
 <a href="relnotes/10.3.2.html">Mesa 10.3.2</a> is released.
diff --git a/mesalib/docs/llvmpipe.html b/mesalib/docs/llvmpipe.html
index 291527b..72db93a 100644
--- a/mesalib/docs/llvmpipe.html
+++ b/mesalib/docs/llvmpipe.html
@@ -43,7 +43,7 @@ It's the fastest software rasterizer for Mesa.
    </p>
 </li>
 <li>
-   <p>LLVM: version 3.4 recommended; 3.1 or later required.</p>
+   <p>LLVM: version 3.4 recommended; 3.3 or later required.</p>
    <p>
    For Linux, on a recent Debian based distribution do:
    </p>
diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html
index 1c97edd..8dd7326 100644
--- a/mesalib/docs/relnotes.html
+++ b/mesalib/docs/relnotes.html
@@ -21,6 +21,8 @@ The release notes summarize what's new or changed in each Mesa release.
 </p>
 
 <ul>
+<li><a href="relnotes/10.3.4.html">10.3.4 release notes</a>
+<li><a href="relnotes/10.3.3.html">10.3.3 release notes</a>
 <li><a href="relnotes/10.3.2.html">10.3.2 release notes</a>
 <li><a href="relnotes/10.3.1.html">10.3.1 release notes</a>
 <li><a href="relnotes/10.2.9.html">10.2.9 release notes</a>
diff --git a/mesalib/docs/relnotes/10.3.3.html b/mesalib/docs/relnotes/10.3.3.html
new file mode 100644
index 0000000..3ca6496
--- /dev/null
+++ b/mesalib/docs/relnotes/10.3.3.html
@@ -0,0 +1,209 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8">
+  <title>Mesa Release Notes</title>
+  <link rel="stylesheet" type="text/css" href="../mesa.css">
+</head>
+<body>
+
+<div class="header">
+  <h1>The Mesa 3D Graphics Library</h1>
+</div>
+
+<iframe src="../contents.html"></iframe>
+<div class="content">
+
+<h1>Mesa 10.3.3 Release Notes / November 8, 2014</h1>
+
+<p>
+Mesa 10.3.3 is a bug fix release which fixes bugs found since the 10.3.2 release.
+</p>
+<p>
+Mesa 10.3.3 implements the OpenGL 3.3 API, but the version reported by
+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.3.  OpenGL
+3.3 is <strong>only</strong> available if requested at context creation
+because compatibility contexts are not supported.
+</p>
+
+<h2>SHA256 checksums</h2>
+<pre>
+23a0c36d88cd5d8968ae6454160de2878192fd1d37b5d606adca1f1b7e788b79  MesaLib-10.3.3.tar.gz
+0e4eee4a2ddf86456eed2fc44da367f95471f74249636710491e85cc256c4753  MesaLib-10.3.3.tar.bz2
+a83648f17d776b7cf6c813fbb15782d2644b937dc6a7c53d8c0d1b35411f4840  MesaLib-10.3.3.zip
+</pre>
+
+<h2>New features</h2>
+<p>None</p>
+
+<h2>Bug fixes</h2>
+
+<p>This list is likely incomplete.</p>
+
+<ul>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=70410">Bug 70410</a> - egl-static/Makefile: linking fails with llvm >= 3.4</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=82921">Bug 82921</a> - layout(location=0) emits error >= MAX_UNIFORM_LOCATIONS due to integer underflow</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=83574">Bug 83574</a> - [llvmpipe] [softpipe] piglit arb_explicit_uniform_location-use-of-unused-loc regression</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=85454">Bug 85454</a> - Unigine Sanctuary with Wine crashes on Mesa Git</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=85918">Bug 85918</a> - Mesa: MSVC 2010/2012 Compile error</li>
+
+</ul>
+
+
+<h2>Changes</h2>
+
+<p>Anuj Phogat (2):</p>
+<ul>
+  <li>glsl: Fix crash due to negative array index</li>
+  <li>glsl: Use signed array index in update_max_array_access()</li>
+</ul>
+
+<p>Brian Paul (1):</p>
+<ul>
+  <li>mesa: fix UNCLAMPED_FLOAT_TO_UBYTE() macro for MSVC</li>
+</ul>
+
+<p>Emil Velikov (2):</p>
+<ul>
+  <li>docs: Add sha256 sums for the 10.3.2 release</li>
+  <li>Update version to 10.3.3</li>
+</ul>
+
+<p>Ilia Mirkin (27):</p>
+<ul>
+  <li>freedreno/ir3: fix FSLT/etc handling to return 0/-1 instead of 0/1.0</li>
+  <li>freedreno/ir3: INEG operates on src0, not src1</li>
+  <li>freedreno/ir3: add UARL support</li>
+  <li>freedreno/ir3: negate result of USLT/etc</li>
+  <li>freedreno/ir3: use unsigned comparison for UIF</li>
+  <li>freedreno/ir3: add TXL support</li>
+  <li>freedreno/ir3: fix UCMP handling</li>
+  <li>freedreno/ir3: implement UMUL correctly</li>
+  <li>freedreno: add default .dir-locals.el for emacs settings</li>
+  <li>freedreno/ir3: make texture instruction construction more dynamic</li>
+  <li>freedreno/ir3: fix TXB/TXL to actually pull the bias/lod argument</li>
+  <li>freedreno/ir3: add TXQ support</li>
+  <li>freedreno/ir3: add TXB2 support</li>
+  <li>freedreno: dual-source render targets are not supported</li>
+  <li>freedreno: instanced drawing/compute not yet supported</li>
+  <li>freedreno/ir3: avoid fan-in sources referring to same instruction</li>
+  <li>freedreno/ir3: add IDIV/UDIV support</li>
+  <li>freedreno/ir3: add UMOD support, based on UDIV</li>
+  <li>freedreno/ir3: add MOD support</li>
+  <li>freedreno/ir3: add ISSG support</li>
+  <li>freedreno/ir3: add UMAD support</li>
+  <li>freedreno/ir3: make TXQ return integers, not floats</li>
+  <li>freedreno/ir3: shadow comes before array</li>
+  <li>freedreno/ir3: add texture offset support</li>
+  <li>freedreno/ir3: add TXD support and expose ARB_shader_texture_lod</li>
+  <li>freedreno/ir3: add TXF support</li>
+  <li>freedreno: positions come out as integers, not half-integers</li>
+</ul>
+
+<p>Jan Vesely (1):</p>
+<ul>
+  <li>configure: include llvm systemlibs when using static llvm</li>
+</ul>
+
+<p>Marek Olšák (5):</p>
+<ul>
+  <li>r600g: fix polygon mode for points and lines and point/line fill modes</li>
+  <li>radeonsi: fix polygon mode for points and lines and point/line fill modes</li>
+  <li>radeonsi: fix incorrect index buffer max size for lowered 8-bit indices</li>
+  <li>Revert "st/mesa: set MaxUnrollIterations = 255"</li>
+  <li>r300g: remove enabled/disabled hyperz and AA compression messages</li>
+</ul>
+
+<p>Mauro Rossi (1):</p>
+<ul>
+  <li>gallium/nouveau: fully build the driver under android</li>
+</ul>
+
+<p>Michel Dänzer (1):</p>
+<ul>
+  <li>radeon/llvm: Dynamically allocate branch/loop stack arrays</li>
+</ul>
+
+<p>Rob Clark (62):</p>
+<ul>
+  <li>freedreno/ir3: detect scheduler fail</li>
+  <li>freedreno/ir3: add TXB</li>
+  <li>freedreno/ir3: add DDX/DDY</li>
+  <li>freedreno/ir3: bit of debug</li>
+  <li>freedreno/ir3: fix error in bail logic</li>
+  <li>freedreno/ir3: fix constlen with relative addressing</li>
+  <li>freedreno/ir3: add no-copy-propagate fallback step</li>
+  <li>freedreno: don't overflow cmdstream buffer so much</li>
+  <li>freedreno/ir3: fix potential segfault in RA</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno/a3xx: enable hw primitive-restart</li>
+  <li>freedreno/a3xx: handle rendering to layer != 0</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno/a3xx: format fixes</li>
+  <li>util/u_format: add _is_alpha()</li>
+  <li>freedreno/a3xx: alpha render-target shenanigans</li>
+  <li>freedreno/ir3: catch incorrect usage of tmp-dst</li>
+  <li>freedreno/ir3: add missing put_dst</li>
+  <li>freedreno: "fix" problems with excessive flushes</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno/a3xx: 3d/array textures</li>
+  <li>freedreno: add DRM_CONF_SHARE_FD</li>
+  <li>freedreno/a3xx: more texture array fixes</li>
+  <li>freedreno/a3xx: initial texture border-color</li>
+  <li>freedreno: fix compiler warning</li>
+  <li>freedreno: don't advertise mirror-clamp support</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno: we have more than 0 viewports!</li>
+  <li>freedreno: turn missing caps into compile warnings</li>
+  <li>freedreno/a3xx: add LOD_BIAS</li>
+  <li>freedreno/a3xx: add flat interpolation mode</li>
+  <li>freedreno/a3xx: add 32bit integer vtx formats</li>
+  <li>freedreno/a3xx: fix border color order</li>
+  <li>freedreno: move bind_sampler_states to per-generation</li>
+  <li>freedreno: add texcoord clamp support to lowering</li>
+  <li>freedreno/a3xx: add support to emulate GL_CLAMP</li>
+  <li>freedreno/a3xx: re-emit shaders on variant change</li>
+  <li>freedreno/lowering: fix token calculation for lowering</li>
+  <li>freedreno: destroy transfer pool after blitter</li>
+  <li>freedreno: max-texture-lod-bias should be 15.0f</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno/a3xx: handle large shader program sizes</li>
+  <li>freedreno/a3xx: emit all immediates in one shot</li>
+  <li>freedreno/ir3: fix lockups with lame FRAG shaders</li>
+  <li>freedreno/a3xx: handle VS only outputting BCOLOR</li>
+  <li>freedreno: query fixes</li>
+  <li>freedreno/a3xx: refactor vertex state emit</li>
+  <li>freedreno/a3xx: refactor/optimize emit</li>
+  <li>freedreno/ir3: optimize shader key comparision</li>
+  <li>freedreno: inline fd_draw_emit()</li>
+  <li>freedreno: fix layer_stride</li>
+  <li>freedreno: update generated headers</li>
+  <li>freedreno/ir3: large const support</li>
+  <li>freedreno/a3xx: more layer/level fixes</li>
+  <li>freedreno/ir3: comment + better fxn name</li>
+  <li>freedreno/ir3: fix potential gpu lockup with kill</li>
+  <li>freedreno/a3xx: disable early-z when we have kill's</li>
+  <li>freedreno/ir3: add debug flag to disable cp</li>
+  <li>freedreno: clear vs scissor</li>
+  <li>freedreno: mark scissor state dirty when enable bit changes</li>
+  <li>freedreno/a3xx: fix viewport state during clear</li>
+  <li>freedreno/a3xx: fix depth/stencil restore format</li>
+</ul>
+
+<p>Tapani Pälli (2):</p>
+<ul>
+  <li>glsl: fix uniform location count used for glsl types</li>
+  <li>mesa: check that uniform exists in glUniform* functions</li>
+</ul>
+
+
+</div>
+</body>
+</html>
diff --git a/mesalib/docs/relnotes/10.3.4.html b/mesalib/docs/relnotes/10.3.4.html
new file mode 100644
index 0000000..bc29462
--- /dev/null
+++ b/mesalib/docs/relnotes/10.3.4.html
@@ -0,0 +1,106 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8">
+  <title>Mesa Release Notes</title>
+  <link rel="stylesheet" type="text/css" href="../mesa.css">
+</head>
+<body>
+
+<div class="header">
+  <h1>The Mesa 3D Graphics Library</h1>
+</div>
+
+<iframe src="../contents.html"></iframe>
+<div class="content">
+
+<h1>Mesa 10.3.4 Release Notes / November 21, 2014</h1>
+
+<p>
+Mesa 10.3.4 is a bug fix release which fixes bugs found since the 10.3.3 release.
+</p>
+<p>
+Mesa 10.3.4 implements the OpenGL 3.3 API, but the version reported by
+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.3.  OpenGL
+3.3 is <strong>only</strong> available if requested at context creation
+because compatibility contexts are not supported.
+</p>
+
+<h2>SHA256 checksums</h2>
+<pre>
+26482495ef6177f889dbd87c7edcccfedd995598785bbbd7e3e066352574c8e0  MesaLib-10.3.4.tar.gz
+e6373913142338d10515daf619d659433bfd2989988198930c13b0945a15e98a  MesaLib-10.3.4.tar.bz2
+8c3ebbb6535daf3414305860ebca6ac67dbb6e3d35058c7a6ce18b84b5945b7f  MesaLib-10.3.4.zip
+</pre>
+
+<h2>New features</h2>
+<p>None</p>
+
+<h2>Bug fixes</h2>
+
+<p>This list is likely incomplete.</p>
+
+<ul>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=76252">Bug 76252</a> - Dynamic loading/unloading of opengl32.dll results in a deadlock</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=78770">Bug 78770</a> - [SNB bisected]Webglc conformance/textures/texture-size-limit.html fails</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=83500">Bug 83500</a> - si_dma_copy_tile causes GPU hangs</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=85647">Bug 85647</a> - Random radeonsi crashes with mesa 10.3.x</li>
+
+</ul>
+
+<h2>Changes</h2>
+<p>Brian Paul (1):</p>
+<ul>
+  <li>st/mesa: copy sampler_array_size field when copying instructions</li>
+</ul>
+
+<p>Chad Versace (1):</p>
+<ul>
+  <li>i965: Fix segfault in WebGL Conformance on Ivybridge</li>
+</ul>
+
+<p>Dave Airlie (5):</p>
+<ul>
+  <li>r600g/cayman: fix integer multiplication output overwrite (v2)</li>
+  <li>r600g/cayman: fix texture gather tests</li>
+  <li>r600g/cayman: handle empty vertex shaders</li>
+  <li>r600g: geom shaders: always load texture src regs from inputs</li>
+  <li>r600g: limit texture offset application to specific types (v2)</li>
+</ul>
+
+<p>Emil Velikov (3):</p>
+<ul>
+  <li>docs: Add sha256 sums for the 10.3.3 release</li>
+  <li>configure.ac: roll up a program for the sse4.1 check</li>
+  <li>get-pick-list.sh: Require explicit "10.3" for nominating stable patches</li>
+</ul>
+
+<p>Ilia Mirkin (1):</p>
+<ul>
+  <li>st/mesa: add a fallback for clear_with_quad when no vs_layer</li>
+</ul>
+
+<p>José Fonseca (1):</p>
+<ul>
+  <li>llvmpipe: Avoid deadlock when unloading opengl32.dll</li>
+</ul>
+
+<p>Kenneth Graunke (1):</p>
+<ul>
+  <li>i915g: we also have more than 0 viewports!</li>
+</ul>
+
+<p>Michel Dänzer (1):</p>
+<ul>
+  <li>radeonsi: Disable asynchronous DMA except for PIPE_BUFFER</li>
+</ul>
+
+</div>
+</body>
+</html>
diff --git a/mesalib/docs/relnotes/10.4.html b/mesalib/docs/relnotes/10.4.html
index 67c3087..8682d71 100644
--- a/mesalib/docs/relnotes/10.4.html
+++ b/mesalib/docs/relnotes/10.4.html
@@ -44,9 +44,11 @@ Note: some of the new features are only available with certain drivers.
 </p>
 
 <ul>
+<li>GL_ARB_conditional_render_inverted on nv50</li>
 <li>GL_ARB_sample_shading on r600</li>
 <li>GL_ARB_texture_view on nv50, nvc0</li>
-<li>GL_ARB_clip_control on llvmpipe, softpipe, r300, r600, radeonsi</li>
+<li>GL_ARB_clip_control on nv50, nvc0, r300, r600, radeonsi, llvmpipe, softpipe</li>
+<li>GL_KHR_context_flush_control on all drivers</li>
 </ul>
 
 
diff --git a/mesalib/docs/relnotes/10.4.html b/mesalib/docs/relnotes/10.5.0.html
similarity index 75%
copy from mesalib/docs/relnotes/10.4.html
copy to mesalib/docs/relnotes/10.5.0.html
index 67c3087..84bfcdb 100644
--- a/mesalib/docs/relnotes/10.4.html
+++ b/mesalib/docs/relnotes/10.5.0.html
@@ -14,15 +14,15 @@
 <iframe src="../contents.html"></iframe>
 <div class="content">
 
-<h1>Mesa 10.4 Release Notes / TBD</h1>
+<h1>Mesa 10.5.0 Release Notes / TBD</h1>
 
 <p>
-Mesa 10.4 is a new development release.
+Mesa 10.5.0 is a new development release.
 People who are concerned with stability and reliability should stick
-with a previous release or wait for Mesa 10.4.1.
+with a previous release or wait for Mesa 10.5.1.
 </p>
 <p>
-Mesa 10.4 implements the OpenGL 3.3 API, but the version reported by
+Mesa 10.5.0 implements the OpenGL 3.3 API, but the version reported by
 glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
 glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
 Some drivers don't support all the features required in OpenGL 3.3.  OpenGL
@@ -44,9 +44,6 @@ Note: some of the new features are only available with certain drivers.
 </p>
 
 <ul>
-<li>GL_ARB_sample_shading on r600</li>
-<li>GL_ARB_texture_view on nv50, nvc0</li>
-<li>GL_ARB_clip_control on llvmpipe, softpipe, r300, r600, radeonsi</li>
 </ul>
 
 
diff --git a/mesalib/include/D3D9/d3d9.h b/mesalib/include/D3D9/d3d9.h
new file mode 100644
index 0000000..f872be7
--- /dev/null
+++ b/mesalib/include/D3D9/d3d9.h
@@ -0,0 +1,1858 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+/*** THIS FILE IS AUTOGENERATED. DO NOT MODIFY MANUALLY. ***/
+
+#ifndef _D3D9_H_
+#define _D3D9_H_
+
+#include "d3d9types.h"
+#include "d3d9caps.h"
+
+typedef struct IDirect3D9 IDirect3D9, *PDIRECT3D9, *LPDIRECT3D9;
+typedef struct IDirect3D9Ex IDirect3D9Ex, *PDIRECT3D9EX, *LPDIRECT3D9EX;
+typedef struct IDirect3D9ExOverlayExtension IDirect3D9ExOverlayExtension, *PDIRECT3D9EXOVERLAYEXTENSION, *LPDIRECT3D9EXOVERLAYEXTENSION;
+typedef struct IDirect3DAuthenticatedChannel9 IDirect3DAuthenticatedChannel9, *PDIRECT3DAUTHENTICATEDCHANNEL9, *LPDIRECT3DAUTHENTICATEDCHANNEL9;
+typedef struct IDirect3DBaseTexture9 IDirect3DBaseTexture9, *PDIRECT3DBASETEXTURE9, *LPDIRECT3DBASETEXTURE9;
+typedef struct IDirect3DCryptoSession9 IDirect3DCryptoSession9, *PDIRECT3DCRYPTOSESSION9, *LPDIRECT3DCRYPTOSESSION9;
+typedef struct IDirect3DCubeTexture9 IDirect3DCubeTexture9, *PDIRECT3DCUBETEXTURE9, *LPDIRECT3DCUBETEXTURE9;
+typedef struct IDirect3DDevice9 IDirect3DDevice9, *PDIRECT3DDEVICE9, *LPDIRECT3DDEVICE9;
+typedef struct IDirect3DDevice9Ex IDirect3DDevice9Ex, *PDIRECT3DDEVICE9EX, *LPDIRECT3DDEVICE9EX;
+typedef struct IDirect3DDevice9Video IDirect3DDevice9Video, *PDIRECT3DDEVICE9VIDEO, *LPDIRECT3DDEVICE9VIDEO;
+typedef struct IDirect3DIndexBuffer9 IDirect3DIndexBuffer9, *PDIRECT3DINDEXBUFFER9, *LPDIRECT3DINDEXBUFFER9;
+typedef struct IDirect3DPixelShader9 IDirect3DPixelShader9, *PDIRECT3DPIXELSHADER9, *LPDIRECT3DPIXELSHADER9;
+typedef struct IDirect3DQuery9 IDirect3DQuery9, *PDIRECT3DQUERY9, *LPDIRECT3DQUERY9;
+typedef struct IDirect3DResource9 IDirect3DResource9, *PDIRECT3DRESOURCE9, *LPDIRECT3DRESOURCE9;
+typedef struct IDirect3DStateBlock9 IDirect3DStateBlock9, *PDIRECT3DSTATEBLOCK9, *LPDIRECT3DSTATEBLOCK9;
+typedef struct IDirect3DSurface9 IDirect3DSurface9, *PDIRECT3DSURFACE9, *LPDIRECT3DSURFACE9;
+typedef struct IDirect3DSwapChain9 IDirect3DSwapChain9, *PDIRECT3DSWAPCHAIN9, *LPDIRECT3DSWAPCHAIN9;
+typedef struct IDirect3DSwapChain9Ex IDirect3DSwapChain9Ex, *PDIRECT3DSWAPCHAIN9EX, *LPDIRECT3DSWAPCHAIN9EX;
+typedef struct IDirect3DTexture9 IDirect3DTexture9, *PDIRECT3DTEXTURE9, *LPDIRECT3DTEXTURE9;
+typedef struct IDirect3DVertexBuffer9 IDirect3DVertexBuffer9, *PDIRECT3DVERTEXBUFFER9, *LPDIRECT3DVERTEXBUFFER9;
+typedef struct IDirect3DVertexDeclaration9 IDirect3DVertexDeclaration9, *PDIRECT3DVERTEXDECLARATION9, *LPDIRECT3DVERTEXDECLARATION9;
+typedef struct IDirect3DVertexShader9 IDirect3DVertexShader9, *PDIRECT3DVERTEXSHADER9, *LPDIRECT3DVERTEXSHADER9;
+typedef struct IDirect3DVolume9 IDirect3DVolume9, *PDIRECT3DVOLUME9, *LPDIRECT3DVOLUME9;
+typedef struct IDirect3DVolumeTexture9 IDirect3DVolumeTexture9, *PDIRECT3DVOLUMETEXTURE9, *LPDIRECT3DVOLUMETEXTURE9;
+
+#ifdef __cplusplus
+
+extern "C" const GUID IID_IDirect3D9;
+extern "C" const GUID IID_IDirect3D9Ex;
+extern "C" const GUID IID_IDirect3D9ExOverlayExtension;
+extern "C" const GUID IID_IDirect3DAuthenticatedChannel9;
+extern "C" const GUID IID_IDirect3DBaseTexture9;
+extern "C" const GUID IID_IDirect3DCryptoSession9;
+extern "C" const GUID IID_IDirect3DCubeTexture9;
+extern "C" const GUID IID_IDirect3DDevice9;
+extern "C" const GUID IID_IDirect3DDevice9Ex;
+extern "C" const GUID IID_IDirect3DDevice9Video;
+extern "C" const GUID IID_IDirect3DIndexBuffer9;
+extern "C" const GUID IID_IDirect3DPixelShader9;
+extern "C" const GUID IID_IDirect3DQuery9;
+extern "C" const GUID IID_IDirect3DResource9;
+extern "C" const GUID IID_IDirect3DStateBlock9;
+extern "C" const GUID IID_IDirect3DSurface9;
+extern "C" const GUID IID_IDirect3DSwapChain9;
+extern "C" const GUID IID_IDirect3DSwapChain9Ex;
+extern "C" const GUID IID_IDirect3DTexture9;
+extern "C" const GUID IID_IDirect3DVertexBuffer9;
+extern "C" const GUID IID_IDirect3DVertexDeclaration9;
+extern "C" const GUID IID_IDirect3DVertexShader9;
+extern "C" const GUID IID_IDirect3DVolume9;
+extern "C" const GUID IID_IDirect3DVolumeTexture9;
+
+struct IDirect3D9 : public IUnknown
+{
+	virtual HRESULT WINAPI RegisterSoftwareDevice(void *pInitializeFunction) = 0;
+	virtual UINT WINAPI GetAdapterCount() = 0;
+	virtual HRESULT WINAPI GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier) = 0;
+	virtual UINT WINAPI GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) = 0;
+	virtual HRESULT WINAPI EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode) = 0;
+	virtual HRESULT WINAPI GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE *pMode) = 0;
+	virtual HRESULT WINAPI CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) = 0;
+	virtual HRESULT WINAPI CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) = 0;
+	virtual HRESULT WINAPI CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels) = 0;
+	virtual HRESULT WINAPI CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) = 0;
+	virtual HRESULT WINAPI CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) = 0;
+	virtual HRESULT WINAPI GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps) = 0;
+	virtual HMONITOR WINAPI GetAdapterMonitor(UINT Adapter) = 0;
+	virtual HRESULT WINAPI CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface) = 0;
+};
+
+struct IDirect3D9Ex : public IDirect3D9
+{
+	virtual UINT WINAPI GetAdapterModeCountEx(UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter) = 0;
+	virtual HRESULT WINAPI EnumAdapterModesEx(UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode) = 0;
+	virtual HRESULT WINAPI GetAdapterDisplayModeEx(UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) = 0;
+	virtual HRESULT WINAPI CreateDeviceEx(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface) = 0;
+	virtual HRESULT WINAPI GetAdapterLUID(UINT Adapter, LUID *pLUID) = 0;
+};
+
+struct IDirect3D9ExOverlayExtension : public IUnknown
+{
+	virtual HRESULT WINAPI CheckDeviceOverlayType(UINT Adapter, D3DDEVTYPE DevType, UINT OverlayWidth, UINT OverlayHeight, D3DFORMAT OverlayFormat, D3DDISPLAYMODEEX *pDisplayMode, D3DDISPLAYROTATION DisplayRotation, D3DOVERLAYCAPS *pOverlayCaps) = 0;
+};
+
+struct IDirect3DResource9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI SetPrivateData(REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) = 0;
+	virtual HRESULT WINAPI GetPrivateData(REFGUID refguid, void *pData, DWORD *pSizeOfData) = 0;
+	virtual HRESULT WINAPI FreePrivateData(REFGUID refguid) = 0;
+	virtual DWORD WINAPI SetPriority(DWORD PriorityNew) = 0;
+	virtual DWORD WINAPI GetPriority() = 0;
+	virtual void WINAPI PreLoad() = 0;
+	virtual D3DRESOURCETYPE WINAPI GetType() = 0;
+};
+
+struct IDirect3DBaseTexture9 : public IDirect3DResource9
+{
+	virtual DWORD WINAPI SetLOD(DWORD LODNew) = 0;
+	virtual DWORD WINAPI GetLOD() = 0;
+	virtual DWORD WINAPI GetLevelCount() = 0;
+	virtual HRESULT WINAPI SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType) = 0;
+	virtual D3DTEXTUREFILTERTYPE WINAPI GetAutoGenFilterType() = 0;
+	virtual void WINAPI GenerateMipSubLevels() = 0;
+};
+
+struct IDirect3DCryptoSession9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetCertificateSize(UINT *pCertificateSize) = 0;
+	virtual HRESULT WINAPI GetCertificate(UINT CertifacteSize, BYTE *ppCertificate) = 0;
+	virtual HRESULT WINAPI NegotiateKeyExchange(UINT DataSize, void *pData) = 0;
+	virtual HRESULT WINAPI EncryptionBlt(IDirect3DSurface9 *pSrcSurface, IDirect3DSurface9 *pDstSurface, UINT DstSurfaceSize, void *pIV) = 0;
+	virtual HRESULT WINAPI DecryptionBlt(IDirect3DSurface9 *pSrcSurface, IDirect3DSurface9 *pDstSurface, UINT SrcSurfaceSize, D3DENCRYPTED_BLOCK_INFO *pEncryptedBlockInfo, void *pContentKey, void *pIV) = 0;
+	virtual HRESULT WINAPI GetSurfacePitch(IDirect3DSurface9 *pSrcSurface, UINT *pSurfacePitch) = 0;
+	virtual HRESULT WINAPI StartSessionKeyRefresh(void *pRandomNumber, UINT RandomNumberSize) = 0;
+	virtual HRESULT WINAPI FinishSessionKeyRefresh() = 0;
+	virtual HRESULT WINAPI GetEncryptionBltKey(void *pReadbackKey, UINT KeySize) = 0;
+};
+
+struct IDirect3DCubeTexture9 : public IDirect3DBaseTexture9
+{
+	virtual HRESULT WINAPI GetLevelDesc(UINT Level, D3DSURFACE_DESC *pDesc) = 0;
+	virtual HRESULT WINAPI GetCubeMapSurface(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface) = 0;
+	virtual HRESULT WINAPI LockRect(D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags) = 0;
+	virtual HRESULT WINAPI UnlockRect(D3DCUBEMAP_FACES FaceType, UINT Level) = 0;
+	virtual HRESULT WINAPI AddDirtyRect(D3DCUBEMAP_FACES FaceType, const RECT *pDirtyRect) = 0;
+};
+
+struct IDirect3DDevice9 : public IUnknown
+{
+	virtual HRESULT WINAPI TestCooperativeLevel() = 0;
+	virtual UINT WINAPI GetAvailableTextureMem() = 0;
+	virtual HRESULT WINAPI EvictManagedResources() = 0;
+	virtual HRESULT WINAPI GetDirect3D(IDirect3D9 **ppD3D9) = 0;
+	virtual HRESULT WINAPI GetDeviceCaps(D3DCAPS9 *pCaps) = 0;
+	virtual HRESULT WINAPI GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE *pMode) = 0;
+	virtual HRESULT WINAPI GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) = 0;
+	virtual HRESULT WINAPI SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap) = 0;
+	virtual void WINAPI SetCursorPosition(int X, int Y, DWORD Flags) = 0;
+	virtual BOOL WINAPI ShowCursor(BOOL bShow) = 0;
+	virtual HRESULT WINAPI CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain9 **pSwapChain) = 0;
+	virtual HRESULT WINAPI GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) = 0;
+	virtual UINT WINAPI GetNumberOfSwapChains() = 0;
+	virtual HRESULT WINAPI Reset(D3DPRESENT_PARAMETERS *pPresentationParameters) = 0;
+	virtual HRESULT WINAPI Present(const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion) = 0;
+	virtual HRESULT WINAPI GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer) = 0;
+	virtual HRESULT WINAPI GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS *pRasterStatus) = 0;
+	virtual HRESULT WINAPI SetDialogBoxMode(BOOL bEnableDialogs) = 0;
+	virtual void WINAPI SetGammaRamp(UINT iSwapChain, DWORD Flags, const D3DGAMMARAMP *pRamp) = 0;
+	virtual void WINAPI GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP *pRamp) = 0;
+	virtual HRESULT WINAPI CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9 **ppIndexBuffer, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI UpdateSurface(IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestinationSurface, const POINT *pDestPoint) = 0;
+	virtual HRESULT WINAPI UpdateTexture(IDirect3DBaseTexture9 *pSourceTexture, IDirect3DBaseTexture9 *pDestinationTexture) = 0;
+	virtual HRESULT WINAPI GetRenderTargetData(IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface) = 0;
+	virtual HRESULT WINAPI GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9 *pDestSurface) = 0;
+	virtual HRESULT WINAPI StretchRect(IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, const RECT *pDestRect, D3DTEXTUREFILTERTYPE Filter) = 0;
+	virtual HRESULT WINAPI ColorFill(IDirect3DSurface9 *pSurface, const RECT *pRect, D3DCOLOR color) = 0;
+	virtual HRESULT WINAPI CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle) = 0;
+	virtual HRESULT WINAPI SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget) = 0;
+	virtual HRESULT WINAPI GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) = 0;
+	virtual HRESULT WINAPI SetDepthStencilSurface(IDirect3DSurface9 *pNewZStencil) = 0;
+	virtual HRESULT WINAPI GetDepthStencilSurface(IDirect3DSurface9 **ppZStencilSurface) = 0;
+	virtual HRESULT WINAPI BeginScene() = 0;
+	virtual HRESULT WINAPI EndScene() = 0;
+	virtual HRESULT WINAPI Clear(DWORD Count, const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) = 0;
+	virtual HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix) = 0;
+	virtual HRESULT WINAPI GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix) = 0;
+	virtual HRESULT WINAPI MultiplyTransform(D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix) = 0;
+	virtual HRESULT WINAPI SetViewport(const D3DVIEWPORT9 *pViewport) = 0;
+	virtual HRESULT WINAPI GetViewport(D3DVIEWPORT9 *pViewport) = 0;
+	virtual HRESULT WINAPI SetMaterial(const D3DMATERIAL9 *pMaterial) = 0;
+	virtual HRESULT WINAPI GetMaterial(D3DMATERIAL9 *pMaterial) = 0;
+	virtual HRESULT WINAPI SetLight(DWORD Index, const D3DLIGHT9 *pLight) = 0;
+	virtual HRESULT WINAPI GetLight(DWORD Index, D3DLIGHT9 *pLight) = 0;
+	virtual HRESULT WINAPI LightEnable(DWORD Index, BOOL Enable) = 0;
+	virtual HRESULT WINAPI GetLightEnable(DWORD Index, BOOL *pEnable) = 0;
+	virtual HRESULT WINAPI SetClipPlane(DWORD Index, const float *pPlane) = 0;
+	virtual HRESULT WINAPI GetClipPlane(DWORD Index, float *pPlane) = 0;
+	virtual HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) = 0;
+	virtual HRESULT WINAPI GetRenderState(D3DRENDERSTATETYPE State, DWORD *pValue) = 0;
+	virtual HRESULT WINAPI CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB) = 0;
+	virtual HRESULT WINAPI BeginStateBlock() = 0;
+	virtual HRESULT WINAPI EndStateBlock(IDirect3DStateBlock9 **ppSB) = 0;
+	virtual HRESULT WINAPI SetClipStatus(const D3DCLIPSTATUS9 *pClipStatus) = 0;
+	virtual HRESULT WINAPI GetClipStatus(D3DCLIPSTATUS9 *pClipStatus) = 0;
+	virtual HRESULT WINAPI GetTexture(DWORD Stage, IDirect3DBaseTexture9 **ppTexture) = 0;
+	virtual HRESULT WINAPI SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture) = 0;
+	virtual HRESULT WINAPI GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue) = 0;
+	virtual HRESULT WINAPI SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) = 0;
+	virtual HRESULT WINAPI GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD *pValue) = 0;
+	virtual HRESULT WINAPI SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) = 0;
+	virtual HRESULT WINAPI ValidateDevice(DWORD *pNumPasses) = 0;
+	virtual HRESULT WINAPI SetPaletteEntries(UINT PaletteNumber, const PALETTEENTRY *pEntries) = 0;
+	virtual HRESULT WINAPI GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY *pEntries) = 0;
+	virtual HRESULT WINAPI SetCurrentTexturePalette(UINT PaletteNumber) = 0;
+	virtual HRESULT WINAPI GetCurrentTexturePalette(UINT *PaletteNumber) = 0;
+	virtual HRESULT WINAPI SetScissorRect(const RECT *pRect) = 0;
+	virtual HRESULT WINAPI GetScissorRect(RECT *pRect) = 0;
+	virtual HRESULT WINAPI SetSoftwareVertexProcessing(BOOL bSoftware) = 0;
+	virtual BOOL WINAPI GetSoftwareVertexProcessing() = 0;
+	virtual HRESULT WINAPI SetNPatchMode(float nSegments) = 0;
+	virtual float WINAPI GetNPatchMode() = 0;
+	virtual HRESULT WINAPI DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) = 0;
+	virtual HRESULT WINAPI DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) = 0;
+	virtual HRESULT WINAPI DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride) = 0;
+	virtual HRESULT WINAPI DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride) = 0;
+	virtual HRESULT WINAPI ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9 *pDestBuffer, IDirect3DVertexDeclaration9 *pVertexDecl, DWORD Flags) = 0;
+	virtual HRESULT WINAPI CreateVertexDeclaration(const D3DVERTEXELEMENT9 *pVertexElements, IDirect3DVertexDeclaration9 **ppDecl) = 0;
+	virtual HRESULT WINAPI SetVertexDeclaration(IDirect3DVertexDeclaration9 *pDecl) = 0;
+	virtual HRESULT WINAPI GetVertexDeclaration(IDirect3DVertexDeclaration9 **ppDecl) = 0;
+	virtual HRESULT WINAPI SetFVF(DWORD FVF) = 0;
+	virtual HRESULT WINAPI GetFVF(DWORD *pFVF) = 0;
+	virtual HRESULT WINAPI CreateVertexShader(const DWORD *pFunction, IDirect3DVertexShader9 **ppShader) = 0;
+	virtual HRESULT WINAPI SetVertexShader(IDirect3DVertexShader9 *pShader) = 0;
+	virtual HRESULT WINAPI GetVertexShader(IDirect3DVertexShader9 **ppShader) = 0;
+	virtual HRESULT WINAPI SetVertexShaderConstantF(UINT StartRegister, const float *pConstantData, UINT Vector4fCount) = 0;
+	virtual HRESULT WINAPI GetVertexShaderConstantF(UINT StartRegister, float *pConstantData, UINT Vector4fCount) = 0;
+	virtual HRESULT WINAPI SetVertexShaderConstantI(UINT StartRegister, const int *pConstantData, UINT Vector4iCount) = 0;
+	virtual HRESULT WINAPI GetVertexShaderConstantI(UINT StartRegister, int *pConstantData, UINT Vector4iCount) = 0;
+	virtual HRESULT WINAPI SetVertexShaderConstantB(UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) = 0;
+	virtual HRESULT WINAPI GetVertexShaderConstantB(UINT StartRegister, BOOL *pConstantData, UINT BoolCount) = 0;
+	virtual HRESULT WINAPI SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData, UINT OffsetInBytes, UINT Stride) = 0;
+	virtual HRESULT WINAPI GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9 **ppStreamData, UINT *pOffsetInBytes, UINT *pStride) = 0;
+	virtual HRESULT WINAPI SetStreamSourceFreq(UINT StreamNumber, UINT Setting) = 0;
+	virtual HRESULT WINAPI GetStreamSourceFreq(UINT StreamNumber, UINT *pSetting) = 0;
+	virtual HRESULT WINAPI SetIndices(IDirect3DIndexBuffer9 *pIndexData) = 0;
+	virtual HRESULT WINAPI GetIndices(IDirect3DIndexBuffer9 **ppIndexData, UINT *pBaseVertexIndex) = 0;
+	virtual HRESULT WINAPI CreatePixelShader(const DWORD *pFunction, IDirect3DPixelShader9 **ppShader) = 0;
+	virtual HRESULT WINAPI SetPixelShader(IDirect3DPixelShader9 *pShader) = 0;
+	virtual HRESULT WINAPI GetPixelShader(IDirect3DPixelShader9 **ppShader) = 0;
+	virtual HRESULT WINAPI SetPixelShaderConstantF(UINT StartRegister, const float *pConstantData, UINT Vector4fCount) = 0;
+	virtual HRESULT WINAPI GetPixelShaderConstantF(UINT StartRegister, float *pConstantData, UINT Vector4fCount) = 0;
+	virtual HRESULT WINAPI SetPixelShaderConstantI(UINT StartRegister, const int *pConstantData, UINT Vector4iCount) = 0;
+	virtual HRESULT WINAPI GetPixelShaderConstantI(UINT StartRegister, int *pConstantData, UINT Vector4iCount) = 0;
+	virtual HRESULT WINAPI SetPixelShaderConstantB(UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) = 0;
+	virtual HRESULT WINAPI GetPixelShaderConstantB(UINT StartRegister, BOOL *pConstantData, UINT BoolCount) = 0;
+	virtual HRESULT WINAPI DrawRectPatch(UINT Handle, const float *pNumSegs, const D3DRECTPATCH_INFO *pRectPatchInfo) = 0;
+	virtual HRESULT WINAPI DrawTriPatch(UINT Handle, const float *pNumSegs, const D3DTRIPATCH_INFO *pTriPatchInfo) = 0;
+	virtual HRESULT WINAPI DeletePatch(UINT Handle) = 0;
+	virtual HRESULT WINAPI CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery) = 0;
+};
+
+struct IDirect3DDevice9Ex : public IDirect3DDevice9
+{
+	virtual HRESULT WINAPI SetConvolutionMonoKernel(UINT width, UINT height, float *rows, float *columns) = 0;
+	virtual HRESULT WINAPI ComposeRects(IDirect3DSurface9 *pSrc, IDirect3DSurface9 *pDst, IDirect3DVertexBuffer9 *pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset) = 0;
+	virtual HRESULT WINAPI PresentEx(const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags) = 0;
+	virtual HRESULT WINAPI GetGPUThreadPriority(INT *pPriority) = 0;
+	virtual HRESULT WINAPI SetGPUThreadPriority(INT Priority) = 0;
+	virtual HRESULT WINAPI WaitForVBlank(UINT iSwapChain) = 0;
+	virtual HRESULT WINAPI CheckResourceResidency(IDirect3DResource9 **pResourceArray, UINT32 NumResources) = 0;
+	virtual HRESULT WINAPI SetMaximumFrameLatency(UINT MaxLatency) = 0;
+	virtual HRESULT WINAPI GetMaximumFrameLatency(UINT *pMaxLatency) = 0;
+	virtual HRESULT WINAPI CheckDeviceState(HWND hDestinationWindow) = 0;
+	virtual HRESULT WINAPI CreateRenderTargetEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) = 0;
+	virtual HRESULT WINAPI CreateOffscreenPlainSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) = 0;
+	virtual HRESULT WINAPI CreateDepthStencilSurfaceEx(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage) = 0;
+	virtual HRESULT WINAPI ResetEx(D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode) = 0;
+	virtual HRESULT WINAPI GetDisplayModeEx(UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) = 0;
+};
+
+struct IDirect3DDevice9Video : public IUnknown
+{
+	virtual HRESULT WINAPI GetContentProtectionCaps(const GUID *pCryptoType, const GUID *pDecodeProfile, D3DCONTENTPROTECTIONCAPS *pCaps) = 0;
+	virtual HRESULT WINAPI CreateAuthenticatedChannel(D3DAUTHENTICATEDCHANNELTYPE ChannelType, IDirect3DAuthenticatedChannel9 **ppAuthenticatedChannel, HANDLE *pChannelHandle) = 0;
+	virtual HRESULT WINAPI CreateCryptoSession(const GUID *pCryptoType, const GUID *pDecodeProfile, IDirect3DCryptoSession9 **ppCryptoSession, HANDLE *pCryptoHandle) = 0;
+};
+
+struct IDirect3DIndexBuffer9 : public IDirect3DResource9
+{
+	virtual HRESULT WINAPI Lock(UINT OffsetToLock, UINT SizeToLock, void **ppbData, DWORD Flags) = 0;
+	virtual HRESULT WINAPI Unlock() = 0;
+	virtual HRESULT WINAPI GetDesc(D3DINDEXBUFFER_DESC *pDesc) = 0;
+};
+
+struct IDirect3DPixelShader9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI GetFunction(void *pData, UINT *pSizeOfData) = 0;
+};
+
+struct IDirect3DQuery9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual D3DQUERYTYPE WINAPI GetType() = 0;
+	virtual DWORD WINAPI GetDataSize() = 0;
+	virtual HRESULT WINAPI Issue(DWORD dwIssueFlags) = 0;
+	virtual HRESULT WINAPI GetData(void *pData, DWORD dwSize, DWORD dwGetDataFlags) = 0;
+};
+
+struct IDirect3DStateBlock9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI Capture() = 0;
+	virtual HRESULT WINAPI Apply() = 0;
+};
+
+struct IDirect3DSurface9 : public IDirect3DResource9
+{
+	virtual HRESULT WINAPI GetContainer(REFIID riid, void **ppContainer) = 0;
+	virtual HRESULT WINAPI GetDesc(D3DSURFACE_DESC *pDesc) = 0;
+	virtual HRESULT WINAPI LockRect(D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags) = 0;
+	virtual HRESULT WINAPI UnlockRect() = 0;
+	virtual HRESULT WINAPI GetDC(HDC *phdc) = 0;
+	virtual HRESULT WINAPI ReleaseDC(HDC hdc) = 0;
+};
+
+struct IDirect3DSwapChain9 : public IUnknown
+{
+	virtual HRESULT WINAPI Present(const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags) = 0;
+	virtual HRESULT WINAPI GetFrontBufferData(IDirect3DSurface9 *pDestSurface) = 0;
+	virtual HRESULT WINAPI GetBackBuffer(UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer) = 0;
+	virtual HRESULT WINAPI GetRasterStatus(D3DRASTER_STATUS *pRasterStatus) = 0;
+	virtual HRESULT WINAPI GetDisplayMode(D3DDISPLAYMODE *pMode) = 0;
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI GetPresentParameters(D3DPRESENT_PARAMETERS *pPresentationParameters) = 0;
+};
+
+struct IDirect3DSwapChain9Ex : public IDirect3DSwapChain9
+{
+	virtual HRESULT WINAPI GetLastPresentCount(UINT *pLastPresentCount) = 0;
+	virtual HRESULT WINAPI GetPresentStats(D3DPRESENTSTATS *pPresentationStatistics) = 0;
+	virtual HRESULT WINAPI GetDisplayModeEx(D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) = 0;
+};
+
+struct IDirect3DTexture9 : public IDirect3DBaseTexture9
+{
+	virtual HRESULT WINAPI GetLevelDesc(UINT Level, D3DSURFACE_DESC *pDesc) = 0;
+	virtual HRESULT WINAPI GetSurfaceLevel(UINT Level, IDirect3DSurface9 **ppSurfaceLevel) = 0;
+	virtual HRESULT WINAPI LockRect(UINT Level, D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags) = 0;
+	virtual HRESULT WINAPI UnlockRect(UINT Level) = 0;
+	virtual HRESULT WINAPI AddDirtyRect(const RECT *pDirtyRect) = 0;
+};
+
+struct IDirect3DVertexBuffer9 : public IDirect3DResource9
+{
+	virtual HRESULT WINAPI Lock(UINT OffsetToLock, UINT SizeToLock, void **ppbData, DWORD Flags) = 0;
+	virtual HRESULT WINAPI Unlock() = 0;
+	virtual HRESULT WINAPI GetDesc(D3DVERTEXBUFFER_DESC *pDesc) = 0;
+};
+
+struct IDirect3DVertexDeclaration9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI GetDeclaration(D3DVERTEXELEMENT9 *pElement, UINT *pNumElements) = 0;
+};
+
+struct IDirect3DVertexShader9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI GetFunction(void *pData, UINT *pSizeOfData) = 0;
+};
+
+struct IDirect3DVolume9 : public IUnknown
+{
+	virtual HRESULT WINAPI GetDevice(IDirect3DDevice9 **ppDevice) = 0;
+	virtual HRESULT WINAPI SetPrivateData(REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) = 0;
+	virtual HRESULT WINAPI GetPrivateData(REFGUID refguid, void *pData, DWORD *pSizeOfData) = 0;
+	virtual HRESULT WINAPI FreePrivateData(REFGUID refguid) = 0;
+	virtual HRESULT WINAPI GetContainer(REFIID riid, void **ppContainer) = 0;
+	virtual HRESULT WINAPI GetDesc(D3DVOLUME_DESC *pDesc) = 0;
+	virtual HRESULT WINAPI LockBox(D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) = 0;
+	virtual HRESULT WINAPI UnlockBox() = 0;
+};
+
+#else /* __cplusplus */
+
+extern const GUID IID_IDirect3D9;
+extern const GUID IID_IDirect3D9Ex;
+extern const GUID IID_IDirect3D9ExOverlayExtension;
+extern const GUID IID_IDirect3DAuthenticatedChannel9;
+extern const GUID IID_IDirect3DBaseTexture9;
+extern const GUID IID_IDirect3DCryptoSession9;
+extern const GUID IID_IDirect3DCubeTexture9;
+extern const GUID IID_IDirect3DDevice9;
+extern const GUID IID_IDirect3DDevice9Ex;
+extern const GUID IID_IDirect3DDevice9Video;
+extern const GUID IID_IDirect3DIndexBuffer9;
+extern const GUID IID_IDirect3DPixelShader9;
+extern const GUID IID_IDirect3DQuery9;
+extern const GUID IID_IDirect3DResource9;
+extern const GUID IID_IDirect3DStateBlock9;
+extern const GUID IID_IDirect3DSurface9;
+extern const GUID IID_IDirect3DSwapChain9;
+extern const GUID IID_IDirect3DSwapChain9Ex;
+extern const GUID IID_IDirect3DTexture9;
+extern const GUID IID_IDirect3DVertexBuffer9;
+extern const GUID IID_IDirect3DVertexDeclaration9;
+extern const GUID IID_IDirect3DVertexShader9;
+extern const GUID IID_IDirect3DVolume9;
+extern const GUID IID_IDirect3DVolumeTexture9;
+
+typedef struct IDirect3D9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3D9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3D9 *This);
+	ULONG (WINAPI *Release)(IDirect3D9 *This);
+	/* IDirect3D9 */
+	HRESULT (WINAPI *RegisterSoftwareDevice)(IDirect3D9 *This, void *pInitializeFunction);
+	UINT (WINAPI *GetAdapterCount)(IDirect3D9 *This);
+	HRESULT (WINAPI *GetAdapterIdentifier)(IDirect3D9 *This, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier);
+	UINT (WINAPI *GetAdapterModeCount)(IDirect3D9 *This, UINT Adapter, D3DFORMAT Format);
+	HRESULT (WINAPI *EnumAdapterModes)(IDirect3D9 *This, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetAdapterDisplayMode)(IDirect3D9 *This, UINT Adapter, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *CheckDeviceType)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed);
+	HRESULT (WINAPI *CheckDeviceFormat)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
+	HRESULT (WINAPI *CheckDeviceMultiSampleType)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels);
+	HRESULT (WINAPI *CheckDepthStencilMatch)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
+	HRESULT (WINAPI *CheckDeviceFormatConversion)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
+	HRESULT (WINAPI *GetDeviceCaps)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps);
+	HMONITOR (WINAPI *GetAdapterMonitor)(IDirect3D9 *This, UINT Adapter);
+	HRESULT (WINAPI *CreateDevice)(IDirect3D9 *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface);
+} IDirect3D9Vtbl;
+struct IDirect3D9
+{
+	IDirect3D9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3D9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3D9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3D9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3D9 macros */
+#define IDirect3D9_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a)
+#define IDirect3D9_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p)
+#define IDirect3D9_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c)
+#define IDirect3D9_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b)
+#define IDirect3D9_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d)
+#define IDirect3D9_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b)
+#define IDirect3D9_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e)
+#define IDirect3D9_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
+#define IDirect3D9_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f)
+#define IDirect3D9_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e)
+#define IDirect3D9_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
+#define IDirect3D9_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
+#define IDirect3D9_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a)
+#define IDirect3D9_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f)
+
+typedef struct IDirect3D9ExVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3D9Ex *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3D9Ex *This);
+	ULONG (WINAPI *Release)(IDirect3D9Ex *This);
+	/* IDirect3D9 */
+	HRESULT (WINAPI *RegisterSoftwareDevice)(IDirect3D9Ex *This, void *pInitializeFunction);
+	UINT (WINAPI *GetAdapterCount)(IDirect3D9Ex *This);
+	HRESULT (WINAPI *GetAdapterIdentifier)(IDirect3D9Ex *This, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier);
+	UINT (WINAPI *GetAdapterModeCount)(IDirect3D9Ex *This, UINT Adapter, D3DFORMAT Format);
+	HRESULT (WINAPI *EnumAdapterModes)(IDirect3D9Ex *This, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetAdapterDisplayMode)(IDirect3D9Ex *This, UINT Adapter, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *CheckDeviceType)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed);
+	HRESULT (WINAPI *CheckDeviceFormat)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
+	HRESULT (WINAPI *CheckDeviceMultiSampleType)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels);
+	HRESULT (WINAPI *CheckDepthStencilMatch)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
+	HRESULT (WINAPI *CheckDeviceFormatConversion)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
+	HRESULT (WINAPI *GetDeviceCaps)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps);
+	HMONITOR (WINAPI *GetAdapterMonitor)(IDirect3D9Ex *This, UINT Adapter);
+	HRESULT (WINAPI *CreateDevice)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface);
+	/* IDirect3D9Ex */
+	UINT (WINAPI *GetAdapterModeCountEx)(IDirect3D9Ex *This, UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter);
+	HRESULT (WINAPI *EnumAdapterModesEx)(IDirect3D9Ex *This, UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode);
+	HRESULT (WINAPI *GetAdapterDisplayModeEx)(IDirect3D9Ex *This, UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
+	HRESULT (WINAPI *CreateDeviceEx)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface);
+	HRESULT (WINAPI *GetAdapterLUID)(IDirect3D9Ex *This, UINT Adapter, LUID *pLUID);
+} IDirect3D9ExVtbl;
+struct IDirect3D9Ex
+{
+	IDirect3D9ExVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3D9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3D9Ex_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3D9Ex_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3D9 macros */
+#define IDirect3D9Ex_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a)
+#define IDirect3D9Ex_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p)
+#define IDirect3D9Ex_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c)
+#define IDirect3D9Ex_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b)
+#define IDirect3D9Ex_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d)
+#define IDirect3D9Ex_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b)
+#define IDirect3D9Ex_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e)
+#define IDirect3D9Ex_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
+#define IDirect3D9Ex_CheckDeviceMultiSampleType(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e,f)
+#define IDirect3D9Ex_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e)
+#define IDirect3D9Ex_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
+#define IDirect3D9Ex_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
+#define IDirect3D9Ex_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a)
+#define IDirect3D9Ex_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f)
+/* IDirect3D9Ex macros */
+#define IDirect3D9Ex_GetAdapterModeCountEx(p,a,b) (p)->lpVtbl->GetAdapterModeCountEx(p,a,b)
+#define IDirect3D9Ex_EnumAdapterModesEx(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModesEx(p,a,b,c,d)
+#define IDirect3D9Ex_GetAdapterDisplayModeEx(p,a,b,c) (p)->lpVtbl->GetAdapterDisplayModeEx(p,a,b,c)
+#define IDirect3D9Ex_CreateDeviceEx(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d,e,f,g)
+#define IDirect3D9Ex_GetAdapterLUID(p,a,b) (p)->lpVtbl->GetAdapterLUID(p,a,b)
+
+typedef struct IDirect3D9ExOverlayExtensionVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3D9ExOverlayExtension *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3D9ExOverlayExtension *This);
+	ULONG (WINAPI *Release)(IDirect3D9ExOverlayExtension *This);
+	/* IDirect3D9ExOverlayExtension */
+	HRESULT (WINAPI *CheckDeviceOverlayType)(IDirect3D9ExOverlayExtension *This, UINT Adapter, D3DDEVTYPE DevType, UINT OverlayWidth, UINT OverlayHeight, D3DFORMAT OverlayFormat, D3DDISPLAYMODEEX *pDisplayMode, D3DDISPLAYROTATION DisplayRotation, D3DOVERLAYCAPS *pOverlayCaps);
+} IDirect3D9ExOverlayExtensionVtbl;
+struct IDirect3D9ExOverlayExtension
+{
+	IDirect3D9ExOverlayExtensionVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3D9ExOverlayExtension_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3D9ExOverlayExtension_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3D9ExOverlayExtension_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3D9ExOverlayExtension macros */
+#define IDirect3D9ExOverlayExtension_CheckDeviceOverlayType(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CheckDeviceOverlayType(p,a,b,c,d,e,f,g,h)
+
+typedef struct IDirect3DAuthenticatedChannel9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DAuthenticatedChannel9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DAuthenticatedChannel9 *This);
+	ULONG (WINAPI *Release)(IDirect3DAuthenticatedChannel9 *This);
+	/* IDirect3DAuthenticatedChannel9 */
+	HRESULT (WINAPI *GetCertificateSize)(IDirect3DAuthenticatedChannel9 *This, UINT *pCertificateSize);
+	HRESULT (WINAPI *GetCertificate)(IDirect3DAuthenticatedChannel9 *This, UINT CertifacteSize, BYTE *ppCertificate);
+	HRESULT (WINAPI *NegotiateKeyExchange)(IDirect3DAuthenticatedChannel9 *This, UINT DataSize, void *pData);
+	HRESULT (WINAPI *Query)(IDirect3DAuthenticatedChannel9 *This, UINT InputSize, const void *pInput, UINT OutputSize, void *pOutput);
+	HRESULT (WINAPI *Configure)(IDirect3DAuthenticatedChannel9 *This, UINT InputSize, const void *pInput, D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT *pOutput);
+} IDirect3DAuthenticatedChannel9Vtbl;
+struct IDirect3DAuthenticatedChannel9
+{
+	IDirect3DAuthenticatedChannel9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DAuthenticatedChannel9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DAuthenticatedChannel9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DAuthenticatedChannel9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DAuthenticatedChannel9 macros */
+#define IDirect3DAuthenticatedChannel9_GetCertificateSize(p,a) (p)->lpVtbl->GetCertificateSize(p,a)
+#define IDirect3DAuthenticatedChannel9_GetCertificate(p,a,b) (p)->lpVtbl->GetCertificate(p,a,b)
+#define IDirect3DAuthenticatedChannel9_NegotiateKeyExchange(p,a,b) (p)->lpVtbl->NegotiateKeyExchange(p,a,b)
+#define IDirect3DAuthenticatedChannel9_Query(p,a,b,c,d) (p)->lpVtbl->Query(p,a,b,c,d)
+#define IDirect3DAuthenticatedChannel9_Configure(p,a,b,c) (p)->lpVtbl->Configure(p,a,b,c)
+
+typedef struct IDirect3DBaseTexture9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DBaseTexture9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DBaseTexture9 *This);
+	ULONG (WINAPI *Release)(IDirect3DBaseTexture9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DBaseTexture9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DBaseTexture9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DBaseTexture9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DBaseTexture9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DBaseTexture9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DBaseTexture9 *This);
+	void (WINAPI *PreLoad)(IDirect3DBaseTexture9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DBaseTexture9 *This);
+	/* IDirect3DBaseTexture9 */
+	DWORD (WINAPI *SetLOD)(IDirect3DBaseTexture9 *This, DWORD LODNew);
+	DWORD (WINAPI *GetLOD)(IDirect3DBaseTexture9 *This);
+	DWORD (WINAPI *GetLevelCount)(IDirect3DBaseTexture9 *This);
+	HRESULT (WINAPI *SetAutoGenFilterType)(IDirect3DBaseTexture9 *This, D3DTEXTUREFILTERTYPE FilterType);
+	D3DTEXTUREFILTERTYPE (WINAPI *GetAutoGenFilterType)(IDirect3DBaseTexture9 *This);
+	void (WINAPI *GenerateMipSubLevels)(IDirect3DBaseTexture9 *This);
+} IDirect3DBaseTexture9Vtbl;
+struct IDirect3DBaseTexture9
+{
+	IDirect3DBaseTexture9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DBaseTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DBaseTexture9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DBaseTexture9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DBaseTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DBaseTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DBaseTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DBaseTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DBaseTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DBaseTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DBaseTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DBaseTexture9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DBaseTexture9 macros */
+#define IDirect3DBaseTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
+#define IDirect3DBaseTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p)
+#define IDirect3DBaseTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
+#define IDirect3DBaseTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a)
+#define IDirect3DBaseTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p)
+#define IDirect3DBaseTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p)
+
+typedef struct IDirect3DCryptoSession9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DCryptoSession9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DCryptoSession9 *This);
+	ULONG (WINAPI *Release)(IDirect3DCryptoSession9 *This);
+	/* IDirect3DCryptoSession9 */
+	HRESULT (WINAPI *GetCertificateSize)(IDirect3DCryptoSession9 *This, UINT *pCertificateSize);
+	HRESULT (WINAPI *GetCertificate)(IDirect3DCryptoSession9 *This, UINT CertifacteSize, BYTE *ppCertificate);
+	HRESULT (WINAPI *NegotiateKeyExchange)(IDirect3DCryptoSession9 *This, UINT DataSize, void *pData);
+	HRESULT (WINAPI *EncryptionBlt)(IDirect3DCryptoSession9 *This, IDirect3DSurface9 *pSrcSurface, IDirect3DSurface9 *pDstSurface, UINT DstSurfaceSize, void *pIV);
+	HRESULT (WINAPI *DecryptionBlt)(IDirect3DCryptoSession9 *This, IDirect3DSurface9 *pSrcSurface, IDirect3DSurface9 *pDstSurface, UINT SrcSurfaceSize, D3DENCRYPTED_BLOCK_INFO *pEncryptedBlockInfo, void *pContentKey, void *pIV);
+	HRESULT (WINAPI *GetSurfacePitch)(IDirect3DCryptoSession9 *This, IDirect3DSurface9 *pSrcSurface, UINT *pSurfacePitch);
+	HRESULT (WINAPI *StartSessionKeyRefresh)(IDirect3DCryptoSession9 *This, void *pRandomNumber, UINT RandomNumberSize);
+	HRESULT (WINAPI *FinishSessionKeyRefresh)(IDirect3DCryptoSession9 *This);
+	HRESULT (WINAPI *GetEncryptionBltKey)(IDirect3DCryptoSession9 *This, void *pReadbackKey, UINT KeySize);
+} IDirect3DCryptoSession9Vtbl;
+struct IDirect3DCryptoSession9
+{
+	IDirect3DCryptoSession9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DCryptoSession9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DCryptoSession9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DCryptoSession9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DCryptoSession9 macros */
+#define IDirect3DCryptoSession9_GetCertificateSize(p,a) (p)->lpVtbl->GetCertificateSize(p,a)
+#define IDirect3DCryptoSession9_GetCertificate(p,a,b) (p)->lpVtbl->GetCertificate(p,a,b)
+#define IDirect3DCryptoSession9_NegotiateKeyExchange(p,a,b) (p)->lpVtbl->NegotiateKeyExchange(p,a,b)
+#define IDirect3DCryptoSession9_EncryptionBlt(p,a,b,c,d) (p)->lpVtbl->EncryptionBlt(p,a,b,c,d)
+#define IDirect3DCryptoSession9_DecryptionBlt(p,a,b,c,d,e,f) (p)->lpVtbl->DecryptionBlt(p,a,b,c,d,e,f)
+#define IDirect3DCryptoSession9_GetSurfacePitch(p,a,b) (p)->lpVtbl->GetSurfacePitch(p,a,b)
+#define IDirect3DCryptoSession9_StartSessionKeyRefresh(p,a,b) (p)->lpVtbl->StartSessionKeyRefresh(p,a,b)
+#define IDirect3DCryptoSession9_FinishSessionKeyRefresh(p) (p)->lpVtbl->FinishSessionKeyRefresh(p)
+#define IDirect3DCryptoSession9_GetEncryptionBltKey(p,a,b) (p)->lpVtbl->GetEncryptionBltKey(p,a,b)
+
+typedef struct IDirect3DCubeTexture9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DCubeTexture9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DCubeTexture9 *This);
+	ULONG (WINAPI *Release)(IDirect3DCubeTexture9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DCubeTexture9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DCubeTexture9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DCubeTexture9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DCubeTexture9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DCubeTexture9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DCubeTexture9 *This);
+	void (WINAPI *PreLoad)(IDirect3DCubeTexture9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DCubeTexture9 *This);
+	/* IDirect3DBaseTexture9 */
+	DWORD (WINAPI *SetLOD)(IDirect3DCubeTexture9 *This, DWORD LODNew);
+	DWORD (WINAPI *GetLOD)(IDirect3DCubeTexture9 *This);
+	DWORD (WINAPI *GetLevelCount)(IDirect3DCubeTexture9 *This);
+	HRESULT (WINAPI *SetAutoGenFilterType)(IDirect3DCubeTexture9 *This, D3DTEXTUREFILTERTYPE FilterType);
+	D3DTEXTUREFILTERTYPE (WINAPI *GetAutoGenFilterType)(IDirect3DCubeTexture9 *This);
+	void (WINAPI *GenerateMipSubLevels)(IDirect3DCubeTexture9 *This);
+	/* IDirect3DCubeTexture9 */
+	HRESULT (WINAPI *GetLevelDesc)(IDirect3DCubeTexture9 *This, UINT Level, D3DSURFACE_DESC *pDesc);
+	HRESULT (WINAPI *GetCubeMapSurface)(IDirect3DCubeTexture9 *This, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface);
+	HRESULT (WINAPI *LockRect)(IDirect3DCubeTexture9 *This, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags);
+	HRESULT (WINAPI *UnlockRect)(IDirect3DCubeTexture9 *This, D3DCUBEMAP_FACES FaceType, UINT Level);
+	HRESULT (WINAPI *AddDirtyRect)(IDirect3DCubeTexture9 *This, D3DCUBEMAP_FACES FaceType, const RECT *pDirtyRect);
+} IDirect3DCubeTexture9Vtbl;
+struct IDirect3DCubeTexture9
+{
+	IDirect3DCubeTexture9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DCubeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DCubeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DCubeTexture9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DCubeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DCubeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DCubeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DCubeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DCubeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DCubeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DCubeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DCubeTexture9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DBaseTexture9 macros */
+#define IDirect3DCubeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
+#define IDirect3DCubeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p)
+#define IDirect3DCubeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
+#define IDirect3DCubeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a)
+#define IDirect3DCubeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p)
+#define IDirect3DCubeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p)
+/* IDirect3DCubeTexture9 macros */
+#define IDirect3DCubeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b)
+#define IDirect3DCubeTexture9_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c)
+#define IDirect3DCubeTexture9_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e)
+#define IDirect3DCubeTexture9_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b)
+#define IDirect3DCubeTexture9_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b)
+
+typedef struct IDirect3DDevice9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DDevice9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DDevice9 *This);
+	ULONG (WINAPI *Release)(IDirect3DDevice9 *This);
+	/* IDirect3DDevice9 */
+	HRESULT (WINAPI *TestCooperativeLevel)(IDirect3DDevice9 *This);
+	UINT (WINAPI *GetAvailableTextureMem)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *EvictManagedResources)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *GetDirect3D)(IDirect3DDevice9 *This, IDirect3D9 **ppD3D9);
+	HRESULT (WINAPI *GetDeviceCaps)(IDirect3DDevice9 *This, D3DCAPS9 *pCaps);
+	HRESULT (WINAPI *GetDisplayMode)(IDirect3DDevice9 *This, UINT iSwapChain, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetCreationParameters)(IDirect3DDevice9 *This, D3DDEVICE_CREATION_PARAMETERS *pParameters);
+	HRESULT (WINAPI *SetCursorProperties)(IDirect3DDevice9 *This, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap);
+	void (WINAPI *SetCursorPosition)(IDirect3DDevice9 *This, int X, int Y, DWORD Flags);
+	BOOL (WINAPI *ShowCursor)(IDirect3DDevice9 *This, BOOL bShow);
+	HRESULT (WINAPI *CreateAdditionalSwapChain)(IDirect3DDevice9 *This, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain9 **pSwapChain);
+	HRESULT (WINAPI *GetSwapChain)(IDirect3DDevice9 *This, UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain);
+	UINT (WINAPI *GetNumberOfSwapChains)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *Reset)(IDirect3DDevice9 *This, D3DPRESENT_PARAMETERS *pPresentationParameters);
+	HRESULT (WINAPI *Present)(IDirect3DDevice9 *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion);
+	HRESULT (WINAPI *GetBackBuffer)(IDirect3DDevice9 *This, UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer);
+	HRESULT (WINAPI *GetRasterStatus)(IDirect3DDevice9 *This, UINT iSwapChain, D3DRASTER_STATUS *pRasterStatus);
+	HRESULT (WINAPI *SetDialogBoxMode)(IDirect3DDevice9 *This, BOOL bEnableDialogs);
+	void (WINAPI *SetGammaRamp)(IDirect3DDevice9 *This, UINT iSwapChain, DWORD Flags, const D3DGAMMARAMP *pRamp);
+	void (WINAPI *GetGammaRamp)(IDirect3DDevice9 *This, UINT iSwapChain, D3DGAMMARAMP *pRamp);
+	HRESULT (WINAPI *CreateTexture)(IDirect3DDevice9 *This, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateVolumeTexture)(IDirect3DDevice9 *This, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateCubeTexture)(IDirect3DDevice9 *This, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateVertexBuffer)(IDirect3DDevice9 *This, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateIndexBuffer)(IDirect3DDevice9 *This, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9 **ppIndexBuffer, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateRenderTarget)(IDirect3DDevice9 *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateDepthStencilSurface)(IDirect3DDevice9 *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *UpdateSurface)(IDirect3DDevice9 *This, IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestinationSurface, const POINT *pDestPoint);
+	HRESULT (WINAPI *UpdateTexture)(IDirect3DDevice9 *This, IDirect3DBaseTexture9 *pSourceTexture, IDirect3DBaseTexture9 *pDestinationTexture);
+	HRESULT (WINAPI *GetRenderTargetData)(IDirect3DDevice9 *This, IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *GetFrontBufferData)(IDirect3DDevice9 *This, UINT iSwapChain, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *StretchRect)(IDirect3DDevice9 *This, IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, const RECT *pDestRect, D3DTEXTUREFILTERTYPE Filter);
+	HRESULT (WINAPI *ColorFill)(IDirect3DDevice9 *This, IDirect3DSurface9 *pSurface, const RECT *pRect, D3DCOLOR color);
+	HRESULT (WINAPI *CreateOffscreenPlainSurface)(IDirect3DDevice9 *This, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *SetRenderTarget)(IDirect3DDevice9 *This, DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget);
+	HRESULT (WINAPI *GetRenderTarget)(IDirect3DDevice9 *This, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget);
+	HRESULT (WINAPI *SetDepthStencilSurface)(IDirect3DDevice9 *This, IDirect3DSurface9 *pNewZStencil);
+	HRESULT (WINAPI *GetDepthStencilSurface)(IDirect3DDevice9 *This, IDirect3DSurface9 **ppZStencilSurface);
+	HRESULT (WINAPI *BeginScene)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *EndScene)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *Clear)(IDirect3DDevice9 *This, DWORD Count, const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
+	HRESULT (WINAPI *SetTransform)(IDirect3DDevice9 *This, D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *GetTransform)(IDirect3DDevice9 *This, D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *MultiplyTransform)(IDirect3DDevice9 *This, D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *SetViewport)(IDirect3DDevice9 *This, const D3DVIEWPORT9 *pViewport);
+	HRESULT (WINAPI *GetViewport)(IDirect3DDevice9 *This, D3DVIEWPORT9 *pViewport);
+	HRESULT (WINAPI *SetMaterial)(IDirect3DDevice9 *This, const D3DMATERIAL9 *pMaterial);
+	HRESULT (WINAPI *GetMaterial)(IDirect3DDevice9 *This, D3DMATERIAL9 *pMaterial);
+	HRESULT (WINAPI *SetLight)(IDirect3DDevice9 *This, DWORD Index, const D3DLIGHT9 *pLight);
+	HRESULT (WINAPI *GetLight)(IDirect3DDevice9 *This, DWORD Index, D3DLIGHT9 *pLight);
+	HRESULT (WINAPI *LightEnable)(IDirect3DDevice9 *This, DWORD Index, BOOL Enable);
+	HRESULT (WINAPI *GetLightEnable)(IDirect3DDevice9 *This, DWORD Index, BOOL *pEnable);
+	HRESULT (WINAPI *SetClipPlane)(IDirect3DDevice9 *This, DWORD Index, const float *pPlane);
+	HRESULT (WINAPI *GetClipPlane)(IDirect3DDevice9 *This, DWORD Index, float *pPlane);
+	HRESULT (WINAPI *SetRenderState)(IDirect3DDevice9 *This, D3DRENDERSTATETYPE State, DWORD Value);
+	HRESULT (WINAPI *GetRenderState)(IDirect3DDevice9 *This, D3DRENDERSTATETYPE State, DWORD *pValue);
+	HRESULT (WINAPI *CreateStateBlock)(IDirect3DDevice9 *This, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB);
+	HRESULT (WINAPI *BeginStateBlock)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *EndStateBlock)(IDirect3DDevice9 *This, IDirect3DStateBlock9 **ppSB);
+	HRESULT (WINAPI *SetClipStatus)(IDirect3DDevice9 *This, const D3DCLIPSTATUS9 *pClipStatus);
+	HRESULT (WINAPI *GetClipStatus)(IDirect3DDevice9 *This, D3DCLIPSTATUS9 *pClipStatus);
+	HRESULT (WINAPI *GetTexture)(IDirect3DDevice9 *This, DWORD Stage, IDirect3DBaseTexture9 **ppTexture);
+	HRESULT (WINAPI *SetTexture)(IDirect3DDevice9 *This, DWORD Stage, IDirect3DBaseTexture9 *pTexture);
+	HRESULT (WINAPI *GetTextureStageState)(IDirect3DDevice9 *This, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue);
+	HRESULT (WINAPI *SetTextureStageState)(IDirect3DDevice9 *This, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
+	HRESULT (WINAPI *GetSamplerState)(IDirect3DDevice9 *This, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD *pValue);
+	HRESULT (WINAPI *SetSamplerState)(IDirect3DDevice9 *This, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
+	HRESULT (WINAPI *ValidateDevice)(IDirect3DDevice9 *This, DWORD *pNumPasses);
+	HRESULT (WINAPI *SetPaletteEntries)(IDirect3DDevice9 *This, UINT PaletteNumber, const PALETTEENTRY *pEntries);
+	HRESULT (WINAPI *GetPaletteEntries)(IDirect3DDevice9 *This, UINT PaletteNumber, PALETTEENTRY *pEntries);
+	HRESULT (WINAPI *SetCurrentTexturePalette)(IDirect3DDevice9 *This, UINT PaletteNumber);
+	HRESULT (WINAPI *GetCurrentTexturePalette)(IDirect3DDevice9 *This, UINT *PaletteNumber);
+	HRESULT (WINAPI *SetScissorRect)(IDirect3DDevice9 *This, const RECT *pRect);
+	HRESULT (WINAPI *GetScissorRect)(IDirect3DDevice9 *This, RECT *pRect);
+	HRESULT (WINAPI *SetSoftwareVertexProcessing)(IDirect3DDevice9 *This, BOOL bSoftware);
+	BOOL (WINAPI *GetSoftwareVertexProcessing)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *SetNPatchMode)(IDirect3DDevice9 *This, float nSegments);
+	float (WINAPI *GetNPatchMode)(IDirect3DDevice9 *This);
+	HRESULT (WINAPI *DrawPrimitive)(IDirect3DDevice9 *This, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
+	HRESULT (WINAPI *DrawIndexedPrimitive)(IDirect3DDevice9 *This, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
+	HRESULT (WINAPI *DrawPrimitiveUP)(IDirect3DDevice9 *This, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride);
+	HRESULT (WINAPI *DrawIndexedPrimitiveUP)(IDirect3DDevice9 *This, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride);
+	HRESULT (WINAPI *ProcessVertices)(IDirect3DDevice9 *This, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9 *pDestBuffer, IDirect3DVertexDeclaration9 *pVertexDecl, DWORD Flags);
+	HRESULT (WINAPI *CreateVertexDeclaration)(IDirect3DDevice9 *This, const D3DVERTEXELEMENT9 *pVertexElements, IDirect3DVertexDeclaration9 **ppDecl);
+	HRESULT (WINAPI *SetVertexDeclaration)(IDirect3DDevice9 *This, IDirect3DVertexDeclaration9 *pDecl);
+	HRESULT (WINAPI *GetVertexDeclaration)(IDirect3DDevice9 *This, IDirect3DVertexDeclaration9 **ppDecl);
+	HRESULT (WINAPI *SetFVF)(IDirect3DDevice9 *This, DWORD FVF);
+	HRESULT (WINAPI *GetFVF)(IDirect3DDevice9 *This, DWORD *pFVF);
+	HRESULT (WINAPI *CreateVertexShader)(IDirect3DDevice9 *This, const DWORD *pFunction, IDirect3DVertexShader9 **ppShader);
+	HRESULT (WINAPI *SetVertexShader)(IDirect3DDevice9 *This, IDirect3DVertexShader9 *pShader);
+	HRESULT (WINAPI *GetVertexShader)(IDirect3DDevice9 *This, IDirect3DVertexShader9 **ppShader);
+	HRESULT (WINAPI *SetVertexShaderConstantF)(IDirect3DDevice9 *This, UINT StartRegister, const float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *GetVertexShaderConstantF)(IDirect3DDevice9 *This, UINT StartRegister, float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *SetVertexShaderConstantI)(IDirect3DDevice9 *This, UINT StartRegister, const int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *GetVertexShaderConstantI)(IDirect3DDevice9 *This, UINT StartRegister, int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *SetVertexShaderConstantB)(IDirect3DDevice9 *This, UINT StartRegister, const BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *GetVertexShaderConstantB)(IDirect3DDevice9 *This, UINT StartRegister, BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *SetStreamSource)(IDirect3DDevice9 *This, UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData, UINT OffsetInBytes, UINT Stride);
+	HRESULT (WINAPI *GetStreamSource)(IDirect3DDevice9 *This, UINT StreamNumber, IDirect3DVertexBuffer9 **ppStreamData, UINT *pOffsetInBytes, UINT *pStride);
+	HRESULT (WINAPI *SetStreamSourceFreq)(IDirect3DDevice9 *This, UINT StreamNumber, UINT Setting);
+	HRESULT (WINAPI *GetStreamSourceFreq)(IDirect3DDevice9 *This, UINT StreamNumber, UINT *pSetting);
+	HRESULT (WINAPI *SetIndices)(IDirect3DDevice9 *This, IDirect3DIndexBuffer9 *pIndexData);
+	HRESULT (WINAPI *GetIndices)(IDirect3DDevice9 *This, IDirect3DIndexBuffer9 **ppIndexData, UINT *pBaseVertexIndex);
+	HRESULT (WINAPI *CreatePixelShader)(IDirect3DDevice9 *This, const DWORD *pFunction, IDirect3DPixelShader9 **ppShader);
+	HRESULT (WINAPI *SetPixelShader)(IDirect3DDevice9 *This, IDirect3DPixelShader9 *pShader);
+	HRESULT (WINAPI *GetPixelShader)(IDirect3DDevice9 *This, IDirect3DPixelShader9 **ppShader);
+	HRESULT (WINAPI *SetPixelShaderConstantF)(IDirect3DDevice9 *This, UINT StartRegister, const float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *GetPixelShaderConstantF)(IDirect3DDevice9 *This, UINT StartRegister, float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *SetPixelShaderConstantI)(IDirect3DDevice9 *This, UINT StartRegister, const int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *GetPixelShaderConstantI)(IDirect3DDevice9 *This, UINT StartRegister, int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *SetPixelShaderConstantB)(IDirect3DDevice9 *This, UINT StartRegister, const BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *GetPixelShaderConstantB)(IDirect3DDevice9 *This, UINT StartRegister, BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *DrawRectPatch)(IDirect3DDevice9 *This, UINT Handle, const float *pNumSegs, const D3DRECTPATCH_INFO *pRectPatchInfo);
+	HRESULT (WINAPI *DrawTriPatch)(IDirect3DDevice9 *This, UINT Handle, const float *pNumSegs, const D3DTRIPATCH_INFO *pTriPatchInfo);
+	HRESULT (WINAPI *DeletePatch)(IDirect3DDevice9 *This, UINT Handle);
+	HRESULT (WINAPI *CreateQuery)(IDirect3DDevice9 *This, D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery);
+} IDirect3DDevice9Vtbl;
+struct IDirect3DDevice9
+{
+	IDirect3DDevice9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DDevice9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DDevice9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DDevice9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DDevice9 macros */
+#define IDirect3DDevice9_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p)
+#define IDirect3DDevice9_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p)
+#define IDirect3DDevice9_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p)
+#define IDirect3DDevice9_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a)
+#define IDirect3DDevice9_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a)
+#define IDirect3DDevice9_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
+#define IDirect3DDevice9_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a)
+#define IDirect3DDevice9_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c)
+#define IDirect3DDevice9_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c)
+#define IDirect3DDevice9_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a)
+#define IDirect3DDevice9_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b)
+#define IDirect3DDevice9_GetSwapChain(p,a,b) (p)->lpVtbl->GetSwapChain(p,a,b)
+#define IDirect3DDevice9_GetNumberOfSwapChains(p) (p)->lpVtbl->GetNumberOfSwapChains(p)
+#define IDirect3DDevice9_Reset(p,a) (p)->lpVtbl->Reset(p,a)
+#define IDirect3DDevice9_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d)
+#define IDirect3DDevice9_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d)
+#define IDirect3DDevice9_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b)
+#define IDirect3DDevice9_SetDialogBoxMode(p,a) (p)->lpVtbl->SetDialogBoxMode(p,a)
+#define IDirect3DDevice9_SetGammaRamp(p,a,b,c) (p)->lpVtbl->SetGammaRamp(p,a,b,c)
+#define IDirect3DDevice9_GetGammaRamp(p,a,b) (p)->lpVtbl->GetGammaRamp(p,a,b)
+#define IDirect3DDevice9_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DDevice9_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f,g)
+#define IDirect3DDevice9_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d)
+#define IDirect3DDevice9_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b)
+#define IDirect3DDevice9_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b)
+#define IDirect3DDevice9_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b)
+#define IDirect3DDevice9_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e)
+#define IDirect3DDevice9_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c)
+#define IDirect3DDevice9_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->lpVtbl->CreateOffscreenPlainSurface(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b)
+#define IDirect3DDevice9_GetRenderTarget(p,a,b) (p)->lpVtbl->GetRenderTarget(p,a,b)
+#define IDirect3DDevice9_SetDepthStencilSurface(p,a) (p)->lpVtbl->SetDepthStencilSurface(p,a)
+#define IDirect3DDevice9_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a)
+#define IDirect3DDevice9_BeginScene(p) (p)->lpVtbl->BeginScene(p)
+#define IDirect3DDevice9_EndScene(p) (p)->lpVtbl->EndScene(p)
+#define IDirect3DDevice9_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b)
+#define IDirect3DDevice9_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b)
+#define IDirect3DDevice9_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b)
+#define IDirect3DDevice9_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a)
+#define IDirect3DDevice9_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a)
+#define IDirect3DDevice9_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DDevice9_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a)
+#define IDirect3DDevice9_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b)
+#define IDirect3DDevice9_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b)
+#define IDirect3DDevice9_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b)
+#define IDirect3DDevice9_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b)
+#define IDirect3DDevice9_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b)
+#define IDirect3DDevice9_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b)
+#define IDirect3DDevice9_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b)
+#define IDirect3DDevice9_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b)
+#define IDirect3DDevice9_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b)
+#define IDirect3DDevice9_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p)
+#define IDirect3DDevice9_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a)
+#define IDirect3DDevice9_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a)
+#define IDirect3DDevice9_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a)
+#define IDirect3DDevice9_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b)
+#define IDirect3DDevice9_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b)
+#define IDirect3DDevice9_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c)
+#define IDirect3DDevice9_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c)
+#define IDirect3DDevice9_GetSamplerState(p,a,b,c) (p)->lpVtbl->GetSamplerState(p,a,b,c)
+#define IDirect3DDevice9_SetSamplerState(p,a,b,c) (p)->lpVtbl->SetSamplerState(p,a,b,c)
+#define IDirect3DDevice9_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a)
+#define IDirect3DDevice9_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b)
+#define IDirect3DDevice9_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b)
+#define IDirect3DDevice9_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a)
+#define IDirect3DDevice9_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a)
+#define IDirect3DDevice9_SetScissorRect(p,a) (p)->lpVtbl->SetScissorRect(p,a)
+#define IDirect3DDevice9_GetScissorRect(p,a) (p)->lpVtbl->GetScissorRect(p,a)
+#define IDirect3DDevice9_SetSoftwareVertexProcessing(p,a) (p)->lpVtbl->SetSoftwareVertexProcessing(p,a)
+#define IDirect3DDevice9_GetSoftwareVertexProcessing(p) (p)->lpVtbl->GetSoftwareVertexProcessing(p)
+#define IDirect3DDevice9_SetNPatchMode(p,a) (p)->lpVtbl->SetNPatchMode(p,a)
+#define IDirect3DDevice9_GetNPatchMode(p) (p)->lpVtbl->GetNPatchMode(p)
+#define IDirect3DDevice9_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c)
+#define IDirect3DDevice9_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d)
+#define IDirect3DDevice9_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9_ProcessVertices(p,a,b,c,d,e,f) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f)
+#define IDirect3DDevice9_CreateVertexDeclaration(p,a,b) (p)->lpVtbl->CreateVertexDeclaration(p,a,b)
+#define IDirect3DDevice9_SetVertexDeclaration(p,a) (p)->lpVtbl->SetVertexDeclaration(p,a)
+#define IDirect3DDevice9_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a)
+#define IDirect3DDevice9_SetFVF(p,a) (p)->lpVtbl->SetFVF(p,a)
+#define IDirect3DDevice9_GetFVF(p,a) (p)->lpVtbl->GetFVF(p,a)
+#define IDirect3DDevice9_CreateVertexShader(p,a,b) (p)->lpVtbl->CreateVertexShader(p,a,b)
+#define IDirect3DDevice9_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a)
+#define IDirect3DDevice9_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a)
+#define IDirect3DDevice9_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9_SetStreamSource(p,a,b,c,d) (p)->lpVtbl->SetStreamSource(p,a,b,c,d)
+#define IDirect3DDevice9_GetStreamSource(p,a,b,c,d) (p)->lpVtbl->GetStreamSource(p,a,b,c,d)
+#define IDirect3DDevice9_SetStreamSourceFreq(p,a,b) (p)->lpVtbl->SetStreamSourceFreq(p,a,b)
+#define IDirect3DDevice9_GetStreamSourceFreq(p,a,b) (p)->lpVtbl->GetStreamSourceFreq(p,a,b)
+#define IDirect3DDevice9_SetIndices(p,a) (p)->lpVtbl->SetIndices(p,a)
+#define IDirect3DDevice9_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b)
+#define IDirect3DDevice9_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b)
+#define IDirect3DDevice9_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a)
+#define IDirect3DDevice9_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a)
+#define IDirect3DDevice9_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c)
+#define IDirect3DDevice9_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c)
+#define IDirect3DDevice9_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a)
+#define IDirect3DDevice9_CreateQuery(p,a,b) (p)->lpVtbl->CreateQuery(p,a,b)
+
+typedef struct IDirect3DDevice9ExVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DDevice9Ex *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DDevice9Ex *This);
+	ULONG (WINAPI *Release)(IDirect3DDevice9Ex *This);
+	/* IDirect3DDevice9 */
+	HRESULT (WINAPI *TestCooperativeLevel)(IDirect3DDevice9Ex *This);
+	UINT (WINAPI *GetAvailableTextureMem)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *EvictManagedResources)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *GetDirect3D)(IDirect3DDevice9Ex *This, IDirect3D9 **ppD3D9);
+	HRESULT (WINAPI *GetDeviceCaps)(IDirect3DDevice9Ex *This, D3DCAPS9 *pCaps);
+	HRESULT (WINAPI *GetDisplayMode)(IDirect3DDevice9Ex *This, UINT iSwapChain, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetCreationParameters)(IDirect3DDevice9Ex *This, D3DDEVICE_CREATION_PARAMETERS *pParameters);
+	HRESULT (WINAPI *SetCursorProperties)(IDirect3DDevice9Ex *This, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap);
+	void (WINAPI *SetCursorPosition)(IDirect3DDevice9Ex *This, int X, int Y, DWORD Flags);
+	BOOL (WINAPI *ShowCursor)(IDirect3DDevice9Ex *This, BOOL bShow);
+	HRESULT (WINAPI *CreateAdditionalSwapChain)(IDirect3DDevice9Ex *This, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain9 **pSwapChain);
+	HRESULT (WINAPI *GetSwapChain)(IDirect3DDevice9Ex *This, UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain);
+	UINT (WINAPI *GetNumberOfSwapChains)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *Reset)(IDirect3DDevice9Ex *This, D3DPRESENT_PARAMETERS *pPresentationParameters);
+	HRESULT (WINAPI *Present)(IDirect3DDevice9Ex *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion);
+	HRESULT (WINAPI *GetBackBuffer)(IDirect3DDevice9Ex *This, UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer);
+	HRESULT (WINAPI *GetRasterStatus)(IDirect3DDevice9Ex *This, UINT iSwapChain, D3DRASTER_STATUS *pRasterStatus);
+	HRESULT (WINAPI *SetDialogBoxMode)(IDirect3DDevice9Ex *This, BOOL bEnableDialogs);
+	void (WINAPI *SetGammaRamp)(IDirect3DDevice9Ex *This, UINT iSwapChain, DWORD Flags, const D3DGAMMARAMP *pRamp);
+	void (WINAPI *GetGammaRamp)(IDirect3DDevice9Ex *This, UINT iSwapChain, D3DGAMMARAMP *pRamp);
+	HRESULT (WINAPI *CreateTexture)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateVolumeTexture)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateCubeTexture)(IDirect3DDevice9Ex *This, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateVertexBuffer)(IDirect3DDevice9Ex *This, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateIndexBuffer)(IDirect3DDevice9Ex *This, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9 **ppIndexBuffer, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateRenderTarget)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *CreateDepthStencilSurface)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *UpdateSurface)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestinationSurface, const POINT *pDestPoint);
+	HRESULT (WINAPI *UpdateTexture)(IDirect3DDevice9Ex *This, IDirect3DBaseTexture9 *pSourceTexture, IDirect3DBaseTexture9 *pDestinationTexture);
+	HRESULT (WINAPI *GetRenderTargetData)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *GetFrontBufferData)(IDirect3DDevice9Ex *This, UINT iSwapChain, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *StretchRect)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, const RECT *pDestRect, D3DTEXTUREFILTERTYPE Filter);
+	HRESULT (WINAPI *ColorFill)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pSurface, const RECT *pRect, D3DCOLOR color);
+	HRESULT (WINAPI *CreateOffscreenPlainSurface)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
+	HRESULT (WINAPI *SetRenderTarget)(IDirect3DDevice9Ex *This, DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget);
+	HRESULT (WINAPI *GetRenderTarget)(IDirect3DDevice9Ex *This, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget);
+	HRESULT (WINAPI *SetDepthStencilSurface)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pNewZStencil);
+	HRESULT (WINAPI *GetDepthStencilSurface)(IDirect3DDevice9Ex *This, IDirect3DSurface9 **ppZStencilSurface);
+	HRESULT (WINAPI *BeginScene)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *EndScene)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *Clear)(IDirect3DDevice9Ex *This, DWORD Count, const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
+	HRESULT (WINAPI *SetTransform)(IDirect3DDevice9Ex *This, D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *GetTransform)(IDirect3DDevice9Ex *This, D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *MultiplyTransform)(IDirect3DDevice9Ex *This, D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix);
+	HRESULT (WINAPI *SetViewport)(IDirect3DDevice9Ex *This, const D3DVIEWPORT9 *pViewport);
+	HRESULT (WINAPI *GetViewport)(IDirect3DDevice9Ex *This, D3DVIEWPORT9 *pViewport);
+	HRESULT (WINAPI *SetMaterial)(IDirect3DDevice9Ex *This, const D3DMATERIAL9 *pMaterial);
+	HRESULT (WINAPI *GetMaterial)(IDirect3DDevice9Ex *This, D3DMATERIAL9 *pMaterial);
+	HRESULT (WINAPI *SetLight)(IDirect3DDevice9Ex *This, DWORD Index, const D3DLIGHT9 *pLight);
+	HRESULT (WINAPI *GetLight)(IDirect3DDevice9Ex *This, DWORD Index, D3DLIGHT9 *pLight);
+	HRESULT (WINAPI *LightEnable)(IDirect3DDevice9Ex *This, DWORD Index, BOOL Enable);
+	HRESULT (WINAPI *GetLightEnable)(IDirect3DDevice9Ex *This, DWORD Index, BOOL *pEnable);
+	HRESULT (WINAPI *SetClipPlane)(IDirect3DDevice9Ex *This, DWORD Index, const float *pPlane);
+	HRESULT (WINAPI *GetClipPlane)(IDirect3DDevice9Ex *This, DWORD Index, float *pPlane);
+	HRESULT (WINAPI *SetRenderState)(IDirect3DDevice9Ex *This, D3DRENDERSTATETYPE State, DWORD Value);
+	HRESULT (WINAPI *GetRenderState)(IDirect3DDevice9Ex *This, D3DRENDERSTATETYPE State, DWORD *pValue);
+	HRESULT (WINAPI *CreateStateBlock)(IDirect3DDevice9Ex *This, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB);
+	HRESULT (WINAPI *BeginStateBlock)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *EndStateBlock)(IDirect3DDevice9Ex *This, IDirect3DStateBlock9 **ppSB);
+	HRESULT (WINAPI *SetClipStatus)(IDirect3DDevice9Ex *This, const D3DCLIPSTATUS9 *pClipStatus);
+	HRESULT (WINAPI *GetClipStatus)(IDirect3DDevice9Ex *This, D3DCLIPSTATUS9 *pClipStatus);
+	HRESULT (WINAPI *GetTexture)(IDirect3DDevice9Ex *This, DWORD Stage, IDirect3DBaseTexture9 **ppTexture);
+	HRESULT (WINAPI *SetTexture)(IDirect3DDevice9Ex *This, DWORD Stage, IDirect3DBaseTexture9 *pTexture);
+	HRESULT (WINAPI *GetTextureStageState)(IDirect3DDevice9Ex *This, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue);
+	HRESULT (WINAPI *SetTextureStageState)(IDirect3DDevice9Ex *This, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
+	HRESULT (WINAPI *GetSamplerState)(IDirect3DDevice9Ex *This, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD *pValue);
+	HRESULT (WINAPI *SetSamplerState)(IDirect3DDevice9Ex *This, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
+	HRESULT (WINAPI *ValidateDevice)(IDirect3DDevice9Ex *This, DWORD *pNumPasses);
+	HRESULT (WINAPI *SetPaletteEntries)(IDirect3DDevice9Ex *This, UINT PaletteNumber, const PALETTEENTRY *pEntries);
+	HRESULT (WINAPI *GetPaletteEntries)(IDirect3DDevice9Ex *This, UINT PaletteNumber, PALETTEENTRY *pEntries);
+	HRESULT (WINAPI *SetCurrentTexturePalette)(IDirect3DDevice9Ex *This, UINT PaletteNumber);
+	HRESULT (WINAPI *GetCurrentTexturePalette)(IDirect3DDevice9Ex *This, UINT *PaletteNumber);
+	HRESULT (WINAPI *SetScissorRect)(IDirect3DDevice9Ex *This, const RECT *pRect);
+	HRESULT (WINAPI *GetScissorRect)(IDirect3DDevice9Ex *This, RECT *pRect);
+	HRESULT (WINAPI *SetSoftwareVertexProcessing)(IDirect3DDevice9Ex *This, BOOL bSoftware);
+	BOOL (WINAPI *GetSoftwareVertexProcessing)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *SetNPatchMode)(IDirect3DDevice9Ex *This, float nSegments);
+	float (WINAPI *GetNPatchMode)(IDirect3DDevice9Ex *This);
+	HRESULT (WINAPI *DrawPrimitive)(IDirect3DDevice9Ex *This, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
+	HRESULT (WINAPI *DrawIndexedPrimitive)(IDirect3DDevice9Ex *This, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
+	HRESULT (WINAPI *DrawPrimitiveUP)(IDirect3DDevice9Ex *This, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride);
+	HRESULT (WINAPI *DrawIndexedPrimitiveUP)(IDirect3DDevice9Ex *This, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride);
+	HRESULT (WINAPI *ProcessVertices)(IDirect3DDevice9Ex *This, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9 *pDestBuffer, IDirect3DVertexDeclaration9 *pVertexDecl, DWORD Flags);
+	HRESULT (WINAPI *CreateVertexDeclaration)(IDirect3DDevice9Ex *This, const D3DVERTEXELEMENT9 *pVertexElements, IDirect3DVertexDeclaration9 **ppDecl);
+	HRESULT (WINAPI *SetVertexDeclaration)(IDirect3DDevice9Ex *This, IDirect3DVertexDeclaration9 *pDecl);
+	HRESULT (WINAPI *GetVertexDeclaration)(IDirect3DDevice9Ex *This, IDirect3DVertexDeclaration9 **ppDecl);
+	HRESULT (WINAPI *SetFVF)(IDirect3DDevice9Ex *This, DWORD FVF);
+	HRESULT (WINAPI *GetFVF)(IDirect3DDevice9Ex *This, DWORD *pFVF);
+	HRESULT (WINAPI *CreateVertexShader)(IDirect3DDevice9Ex *This, const DWORD *pFunction, IDirect3DVertexShader9 **ppShader);
+	HRESULT (WINAPI *SetVertexShader)(IDirect3DDevice9Ex *This, IDirect3DVertexShader9 *pShader);
+	HRESULT (WINAPI *GetVertexShader)(IDirect3DDevice9Ex *This, IDirect3DVertexShader9 **ppShader);
+	HRESULT (WINAPI *SetVertexShaderConstantF)(IDirect3DDevice9Ex *This, UINT StartRegister, const float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *GetVertexShaderConstantF)(IDirect3DDevice9Ex *This, UINT StartRegister, float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *SetVertexShaderConstantI)(IDirect3DDevice9Ex *This, UINT StartRegister, const int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *GetVertexShaderConstantI)(IDirect3DDevice9Ex *This, UINT StartRegister, int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *SetVertexShaderConstantB)(IDirect3DDevice9Ex *This, UINT StartRegister, const BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *GetVertexShaderConstantB)(IDirect3DDevice9Ex *This, UINT StartRegister, BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *SetStreamSource)(IDirect3DDevice9Ex *This, UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData, UINT OffsetInBytes, UINT Stride);
+	HRESULT (WINAPI *GetStreamSource)(IDirect3DDevice9Ex *This, UINT StreamNumber, IDirect3DVertexBuffer9 **ppStreamData, UINT *pOffsetInBytes, UINT *pStride);
+	HRESULT (WINAPI *SetStreamSourceFreq)(IDirect3DDevice9Ex *This, UINT StreamNumber, UINT Setting);
+	HRESULT (WINAPI *GetStreamSourceFreq)(IDirect3DDevice9Ex *This, UINT StreamNumber, UINT *pSetting);
+	HRESULT (WINAPI *SetIndices)(IDirect3DDevice9Ex *This, IDirect3DIndexBuffer9 *pIndexData);
+	HRESULT (WINAPI *GetIndices)(IDirect3DDevice9Ex *This, IDirect3DIndexBuffer9 **ppIndexData, UINT *pBaseVertexIndex);
+	HRESULT (WINAPI *CreatePixelShader)(IDirect3DDevice9Ex *This, const DWORD *pFunction, IDirect3DPixelShader9 **ppShader);
+	HRESULT (WINAPI *SetPixelShader)(IDirect3DDevice9Ex *This, IDirect3DPixelShader9 *pShader);
+	HRESULT (WINAPI *GetPixelShader)(IDirect3DDevice9Ex *This, IDirect3DPixelShader9 **ppShader);
+	HRESULT (WINAPI *SetPixelShaderConstantF)(IDirect3DDevice9Ex *This, UINT StartRegister, const float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *GetPixelShaderConstantF)(IDirect3DDevice9Ex *This, UINT StartRegister, float *pConstantData, UINT Vector4fCount);
+	HRESULT (WINAPI *SetPixelShaderConstantI)(IDirect3DDevice9Ex *This, UINT StartRegister, const int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *GetPixelShaderConstantI)(IDirect3DDevice9Ex *This, UINT StartRegister, int *pConstantData, UINT Vector4iCount);
+	HRESULT (WINAPI *SetPixelShaderConstantB)(IDirect3DDevice9Ex *This, UINT StartRegister, const BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *GetPixelShaderConstantB)(IDirect3DDevice9Ex *This, UINT StartRegister, BOOL *pConstantData, UINT BoolCount);
+	HRESULT (WINAPI *DrawRectPatch)(IDirect3DDevice9Ex *This, UINT Handle, const float *pNumSegs, const D3DRECTPATCH_INFO *pRectPatchInfo);
+	HRESULT (WINAPI *DrawTriPatch)(IDirect3DDevice9Ex *This, UINT Handle, const float *pNumSegs, const D3DTRIPATCH_INFO *pTriPatchInfo);
+	HRESULT (WINAPI *DeletePatch)(IDirect3DDevice9Ex *This, UINT Handle);
+	HRESULT (WINAPI *CreateQuery)(IDirect3DDevice9Ex *This, D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery);
+	/* IDirect3DDevice9Ex */
+	HRESULT (WINAPI *SetConvolutionMonoKernel)(IDirect3DDevice9Ex *This, UINT width, UINT height, float *rows, float *columns);
+	HRESULT (WINAPI *ComposeRects)(IDirect3DDevice9Ex *This, IDirect3DSurface9 *pSrc, IDirect3DSurface9 *pDst, IDirect3DVertexBuffer9 *pSrcRectDescs, UINT NumRects, IDirect3DVertexBuffer9 *pDstRectDescs, D3DCOMPOSERECTSOP Operation, int Xoffset, int Yoffset);
+	HRESULT (WINAPI *PresentEx)(IDirect3DDevice9Ex *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags);
+	HRESULT (WINAPI *GetGPUThreadPriority)(IDirect3DDevice9Ex *This, INT *pPriority);
+	HRESULT (WINAPI *SetGPUThreadPriority)(IDirect3DDevice9Ex *This, INT Priority);
+	HRESULT (WINAPI *WaitForVBlank)(IDirect3DDevice9Ex *This, UINT iSwapChain);
+	HRESULT (WINAPI *CheckResourceResidency)(IDirect3DDevice9Ex *This, IDirect3DResource9 **pResourceArray, UINT32 NumResources);
+	HRESULT (WINAPI *SetMaximumFrameLatency)(IDirect3DDevice9Ex *This, UINT MaxLatency);
+	HRESULT (WINAPI *GetMaximumFrameLatency)(IDirect3DDevice9Ex *This, UINT *pMaxLatency);
+	HRESULT (WINAPI *CheckDeviceState)(IDirect3DDevice9Ex *This, HWND hDestinationWindow);
+	HRESULT (WINAPI *CreateRenderTargetEx)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
+	HRESULT (WINAPI *CreateOffscreenPlainSurfaceEx)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
+	HRESULT (WINAPI *CreateDepthStencilSurfaceEx)(IDirect3DDevice9Ex *This, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle, DWORD Usage);
+	HRESULT (WINAPI *ResetEx)(IDirect3DDevice9Ex *This, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode);
+	HRESULT (WINAPI *GetDisplayModeEx)(IDirect3DDevice9Ex *This, UINT iSwapChain, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
+} IDirect3DDevice9ExVtbl;
+struct IDirect3DDevice9Ex
+{
+	IDirect3DDevice9ExVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DDevice9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DDevice9Ex_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DDevice9Ex_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DDevice9 macros */
+#define IDirect3DDevice9Ex_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p)
+#define IDirect3DDevice9Ex_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p)
+#define IDirect3DDevice9Ex_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p)
+#define IDirect3DDevice9Ex_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a)
+#define IDirect3DDevice9Ex_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a)
+#define IDirect3DDevice9Ex_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
+#define IDirect3DDevice9Ex_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a)
+#define IDirect3DDevice9Ex_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c)
+#define IDirect3DDevice9Ex_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c)
+#define IDirect3DDevice9Ex_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a)
+#define IDirect3DDevice9Ex_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b)
+#define IDirect3DDevice9Ex_GetSwapChain(p,a,b) (p)->lpVtbl->GetSwapChain(p,a,b)
+#define IDirect3DDevice9Ex_GetNumberOfSwapChains(p) (p)->lpVtbl->GetNumberOfSwapChains(p)
+#define IDirect3DDevice9Ex_Reset(p,a) (p)->lpVtbl->Reset(p,a)
+#define IDirect3DDevice9Ex_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d)
+#define IDirect3DDevice9Ex_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d)
+#define IDirect3DDevice9Ex_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b)
+#define IDirect3DDevice9Ex_SetDialogBoxMode(p,a) (p)->lpVtbl->SetDialogBoxMode(p,a)
+#define IDirect3DDevice9Ex_SetGammaRamp(p,a,b,c) (p)->lpVtbl->SetGammaRamp(p,a,b,c)
+#define IDirect3DDevice9Ex_GetGammaRamp(p,a,b) (p)->lpVtbl->GetGammaRamp(p,a,b)
+#define IDirect3DDevice9Ex_CreateTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9Ex_CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DDevice9Ex_CreateCubeTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f,g)
+#define IDirect3DDevice9Ex_CreateVertexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_CreateIndexBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_CreateRenderTarget(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9Ex_CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9Ex_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d)
+#define IDirect3DDevice9Ex_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b)
+#define IDirect3DDevice9Ex_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b)
+#define IDirect3DDevice9Ex_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b)
+#define IDirect3DDevice9Ex_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e)
+#define IDirect3DDevice9Ex_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c)
+#define IDirect3DDevice9Ex_CreateOffscreenPlainSurface(p,a,b,c,d,e,f) (p)->lpVtbl->CreateOffscreenPlainSurface(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b)
+#define IDirect3DDevice9Ex_GetRenderTarget(p,a,b) (p)->lpVtbl->GetRenderTarget(p,a,b)
+#define IDirect3DDevice9Ex_SetDepthStencilSurface(p,a) (p)->lpVtbl->SetDepthStencilSurface(p,a)
+#define IDirect3DDevice9Ex_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a)
+#define IDirect3DDevice9Ex_BeginScene(p) (p)->lpVtbl->BeginScene(p)
+#define IDirect3DDevice9Ex_EndScene(p) (p)->lpVtbl->EndScene(p)
+#define IDirect3DDevice9Ex_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b)
+#define IDirect3DDevice9Ex_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b)
+#define IDirect3DDevice9Ex_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b)
+#define IDirect3DDevice9Ex_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a)
+#define IDirect3DDevice9Ex_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a)
+#define IDirect3DDevice9Ex_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DDevice9Ex_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a)
+#define IDirect3DDevice9Ex_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b)
+#define IDirect3DDevice9Ex_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b)
+#define IDirect3DDevice9Ex_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b)
+#define IDirect3DDevice9Ex_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b)
+#define IDirect3DDevice9Ex_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b)
+#define IDirect3DDevice9Ex_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b)
+#define IDirect3DDevice9Ex_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b)
+#define IDirect3DDevice9Ex_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b)
+#define IDirect3DDevice9Ex_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b)
+#define IDirect3DDevice9Ex_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p)
+#define IDirect3DDevice9Ex_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a)
+#define IDirect3DDevice9Ex_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a)
+#define IDirect3DDevice9Ex_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a)
+#define IDirect3DDevice9Ex_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b)
+#define IDirect3DDevice9Ex_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b)
+#define IDirect3DDevice9Ex_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c)
+#define IDirect3DDevice9Ex_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c)
+#define IDirect3DDevice9Ex_GetSamplerState(p,a,b,c) (p)->lpVtbl->GetSamplerState(p,a,b,c)
+#define IDirect3DDevice9Ex_SetSamplerState(p,a,b,c) (p)->lpVtbl->SetSamplerState(p,a,b,c)
+#define IDirect3DDevice9Ex_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a)
+#define IDirect3DDevice9Ex_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b)
+#define IDirect3DDevice9Ex_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b)
+#define IDirect3DDevice9Ex_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a)
+#define IDirect3DDevice9Ex_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a)
+#define IDirect3DDevice9Ex_SetScissorRect(p,a) (p)->lpVtbl->SetScissorRect(p,a)
+#define IDirect3DDevice9Ex_GetScissorRect(p,a) (p)->lpVtbl->GetScissorRect(p,a)
+#define IDirect3DDevice9Ex_SetSoftwareVertexProcessing(p,a) (p)->lpVtbl->SetSoftwareVertexProcessing(p,a)
+#define IDirect3DDevice9Ex_GetSoftwareVertexProcessing(p) (p)->lpVtbl->GetSoftwareVertexProcessing(p)
+#define IDirect3DDevice9Ex_SetNPatchMode(p,a) (p)->lpVtbl->SetNPatchMode(p,a)
+#define IDirect3DDevice9Ex_GetNPatchMode(p) (p)->lpVtbl->GetNPatchMode(p)
+#define IDirect3DDevice9Ex_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c)
+#define IDirect3DDevice9Ex_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d)
+#define IDirect3DDevice9Ex_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9Ex_ProcessVertices(p,a,b,c,d,e,f) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e,f)
+#define IDirect3DDevice9Ex_CreateVertexDeclaration(p,a,b) (p)->lpVtbl->CreateVertexDeclaration(p,a,b)
+#define IDirect3DDevice9Ex_SetVertexDeclaration(p,a) (p)->lpVtbl->SetVertexDeclaration(p,a)
+#define IDirect3DDevice9Ex_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a)
+#define IDirect3DDevice9Ex_SetFVF(p,a) (p)->lpVtbl->SetFVF(p,a)
+#define IDirect3DDevice9Ex_GetFVF(p,a) (p)->lpVtbl->GetFVF(p,a)
+#define IDirect3DDevice9Ex_CreateVertexShader(p,a,b) (p)->lpVtbl->CreateVertexShader(p,a,b)
+#define IDirect3DDevice9Ex_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a)
+#define IDirect3DDevice9Ex_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a)
+#define IDirect3DDevice9Ex_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9Ex_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9Ex_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9Ex_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9Ex_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9Ex_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9Ex_SetStreamSource(p,a,b,c,d) (p)->lpVtbl->SetStreamSource(p,a,b,c,d)
+#define IDirect3DDevice9Ex_GetStreamSource(p,a,b,c,d) (p)->lpVtbl->GetStreamSource(p,a,b,c,d)
+#define IDirect3DDevice9Ex_SetStreamSourceFreq(p,a,b) (p)->lpVtbl->SetStreamSourceFreq(p,a,b)
+#define IDirect3DDevice9Ex_GetStreamSourceFreq(p,a,b) (p)->lpVtbl->GetStreamSourceFreq(p,a,b)
+#define IDirect3DDevice9Ex_SetIndices(p,a) (p)->lpVtbl->SetIndices(p,a)
+#define IDirect3DDevice9Ex_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b)
+#define IDirect3DDevice9Ex_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b)
+#define IDirect3DDevice9Ex_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a)
+#define IDirect3DDevice9Ex_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a)
+#define IDirect3DDevice9Ex_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9Ex_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c)
+#define IDirect3DDevice9Ex_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9Ex_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c)
+#define IDirect3DDevice9Ex_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9Ex_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c)
+#define IDirect3DDevice9Ex_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c)
+#define IDirect3DDevice9Ex_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c)
+#define IDirect3DDevice9Ex_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a)
+#define IDirect3DDevice9Ex_CreateQuery(p,a,b) (p)->lpVtbl->CreateQuery(p,a,b)
+/* IDirect3DDevice9Ex macros */
+#define IDirect3DDevice9Ex_SetConvolutionMonoKernel(p,a,b,c,d) (p)->lpVtbl->SetConvolutionMonoKernel(p,a,b,c,d)
+#define IDirect3DDevice9Ex_ComposeRects(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->ComposeRects(p,a,b,c,d,e,f,g,h)
+#define IDirect3DDevice9Ex_PresentEx(p,a,b,c,d,e) (p)->lpVtbl->PresentEx(p,a,b,c,d,e)
+#define IDirect3DDevice9Ex_GetGPUThreadPriority(p,a) (p)->lpVtbl->GetGPUThreadPriority(p,a)
+#define IDirect3DDevice9Ex_SetGPUThreadPriority(p,a) (p)->lpVtbl->SetGPUThreadPriority(p,a)
+#define IDirect3DDevice9Ex_WaitForVBlank(p,a) (p)->lpVtbl->WaitForVBlank(p,a)
+#define IDirect3DDevice9Ex_CheckResourceResidency(p,a,b) (p)->lpVtbl->CheckResourceResidency(p,a,b)
+#define IDirect3DDevice9Ex_SetMaximumFrameLatency(p,a) (p)->lpVtbl->SetMaximumFrameLatency(p,a)
+#define IDirect3DDevice9Ex_GetMaximumFrameLatency(p,a) (p)->lpVtbl->GetMaximumFrameLatency(p,a)
+#define IDirect3DDevice9Ex_CheckDeviceState(p,a) (p)->lpVtbl->CheckDeviceState(p,a)
+#define IDirect3DDevice9Ex_CreateRenderTargetEx(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateRenderTargetEx(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DDevice9Ex_CreateOffscreenPlainSurfaceEx(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateOffscreenPlainSurfaceEx(p,a,b,c,d,e,f,g)
+#define IDirect3DDevice9Ex_CreateDepthStencilSurfaceEx(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateDepthStencilSurfaceEx(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DDevice9Ex_ResetEx(p,a,b) (p)->lpVtbl->ResetEx(p,a,b)
+#define IDirect3DDevice9Ex_GetDisplayModeEx(p,a,b,c) (p)->lpVtbl->GetDisplayModeEx(p,a,b,c)
+
+typedef struct IDirect3DDevice9VideoVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DDevice9Video *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DDevice9Video *This);
+	ULONG (WINAPI *Release)(IDirect3DDevice9Video *This);
+	/* IDirect3DDevice9Video */
+	HRESULT (WINAPI *GetContentProtectionCaps)(IDirect3DDevice9Video *This, const GUID *pCryptoType, const GUID *pDecodeProfile, D3DCONTENTPROTECTIONCAPS *pCaps);
+	HRESULT (WINAPI *CreateAuthenticatedChannel)(IDirect3DDevice9Video *This, D3DAUTHENTICATEDCHANNELTYPE ChannelType, IDirect3DAuthenticatedChannel9 **ppAuthenticatedChannel, HANDLE *pChannelHandle);
+	HRESULT (WINAPI *CreateCryptoSession)(IDirect3DDevice9Video *This, const GUID *pCryptoType, const GUID *pDecodeProfile, IDirect3DCryptoSession9 **ppCryptoSession, HANDLE *pCryptoHandle);
+} IDirect3DDevice9VideoVtbl;
+struct IDirect3DDevice9Video
+{
+	IDirect3DDevice9VideoVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DDevice9Video_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DDevice9Video_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DDevice9Video_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DDevice9Video macros */
+#define IDirect3DDevice9Video_GetContentProtectionCaps(p,a,b,c) (p)->lpVtbl->GetContentProtectionCaps(p,a,b,c)
+#define IDirect3DDevice9Video_CreateAuthenticatedChannel(p,a,b,c) (p)->lpVtbl->CreateAuthenticatedChannel(p,a,b,c)
+#define IDirect3DDevice9Video_CreateCryptoSession(p,a,b,c,d) (p)->lpVtbl->CreateCryptoSession(p,a,b,c,d)
+
+typedef struct IDirect3DIndexBuffer9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DIndexBuffer9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DIndexBuffer9 *This);
+	ULONG (WINAPI *Release)(IDirect3DIndexBuffer9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DIndexBuffer9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DIndexBuffer9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DIndexBuffer9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DIndexBuffer9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DIndexBuffer9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DIndexBuffer9 *This);
+	void (WINAPI *PreLoad)(IDirect3DIndexBuffer9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DIndexBuffer9 *This);
+	/* IDirect3DIndexBuffer9 */
+	HRESULT (WINAPI *Lock)(IDirect3DIndexBuffer9 *This, UINT OffsetToLock, UINT SizeToLock, void **ppbData, DWORD Flags);
+	HRESULT (WINAPI *Unlock)(IDirect3DIndexBuffer9 *This);
+	HRESULT (WINAPI *GetDesc)(IDirect3DIndexBuffer9 *This, D3DINDEXBUFFER_DESC *pDesc);
+} IDirect3DIndexBuffer9Vtbl;
+struct IDirect3DIndexBuffer9
+{
+	IDirect3DIndexBuffer9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DIndexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DIndexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DIndexBuffer9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DIndexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DIndexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DIndexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DIndexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DIndexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DIndexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DIndexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DIndexBuffer9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DIndexBuffer9 macros */
+#define IDirect3DIndexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d)
+#define IDirect3DIndexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p)
+#define IDirect3DIndexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
+
+typedef struct IDirect3DPixelShader9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DPixelShader9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DPixelShader9 *This);
+	ULONG (WINAPI *Release)(IDirect3DPixelShader9 *This);
+	/* IDirect3DPixelShader9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DPixelShader9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *GetFunction)(IDirect3DPixelShader9 *This, void *pData, UINT *pSizeOfData);
+} IDirect3DPixelShader9Vtbl;
+struct IDirect3DPixelShader9
+{
+	IDirect3DPixelShader9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DPixelShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DPixelShader9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DPixelShader9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DPixelShader9 macros */
+#define IDirect3DPixelShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DPixelShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
+
+typedef struct IDirect3DQuery9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DQuery9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DQuery9 *This);
+	ULONG (WINAPI *Release)(IDirect3DQuery9 *This);
+	/* IDirect3DQuery9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DQuery9 *This, IDirect3DDevice9 **ppDevice);
+	D3DQUERYTYPE (WINAPI *GetType)(IDirect3DQuery9 *This);
+	DWORD (WINAPI *GetDataSize)(IDirect3DQuery9 *This);
+	HRESULT (WINAPI *Issue)(IDirect3DQuery9 *This, DWORD dwIssueFlags);
+	HRESULT (WINAPI *GetData)(IDirect3DQuery9 *This, void *pData, DWORD dwSize, DWORD dwGetDataFlags);
+} IDirect3DQuery9Vtbl;
+struct IDirect3DQuery9
+{
+	IDirect3DQuery9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DQuery9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DQuery9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DQuery9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DQuery9 macros */
+#define IDirect3DQuery9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DQuery9_GetType(p) (p)->lpVtbl->GetType(p)
+#define IDirect3DQuery9_GetDataSize(p) (p)->lpVtbl->GetDataSize(p)
+#define IDirect3DQuery9_Issue(p,a) (p)->lpVtbl->Issue(p,a)
+#define IDirect3DQuery9_GetData(p,a,b,c) (p)->lpVtbl->GetData(p,a,b,c)
+
+typedef struct IDirect3DResource9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DResource9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DResource9 *This);
+	ULONG (WINAPI *Release)(IDirect3DResource9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DResource9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DResource9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DResource9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DResource9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DResource9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DResource9 *This);
+	void (WINAPI *PreLoad)(IDirect3DResource9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DResource9 *This);
+} IDirect3DResource9Vtbl;
+struct IDirect3DResource9
+{
+	IDirect3DResource9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DResource9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DResource9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DResource9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DResource9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DResource9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DResource9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DResource9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DResource9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DResource9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DResource9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DResource9_GetType(p) (p)->lpVtbl->GetType(p)
+
+typedef struct IDirect3DStateBlock9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DStateBlock9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DStateBlock9 *This);
+	ULONG (WINAPI *Release)(IDirect3DStateBlock9 *This);
+	/* IDirect3DStateBlock9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DStateBlock9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *Capture)(IDirect3DStateBlock9 *This);
+	HRESULT (WINAPI *Apply)(IDirect3DStateBlock9 *This);
+} IDirect3DStateBlock9Vtbl;
+struct IDirect3DStateBlock9
+{
+	IDirect3DStateBlock9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DStateBlock9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DStateBlock9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DStateBlock9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DStateBlock9 macros */
+#define IDirect3DStateBlock9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DStateBlock9_Capture(p) (p)->lpVtbl->Capture(p)
+#define IDirect3DStateBlock9_Apply(p) (p)->lpVtbl->Apply(p)
+
+typedef struct IDirect3DSurface9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DSurface9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DSurface9 *This);
+	ULONG (WINAPI *Release)(IDirect3DSurface9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DSurface9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DSurface9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DSurface9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DSurface9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DSurface9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DSurface9 *This);
+	void (WINAPI *PreLoad)(IDirect3DSurface9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DSurface9 *This);
+	/* IDirect3DSurface9 */
+	HRESULT (WINAPI *GetContainer)(IDirect3DSurface9 *This, REFIID riid, void **ppContainer);
+	HRESULT (WINAPI *GetDesc)(IDirect3DSurface9 *This, D3DSURFACE_DESC *pDesc);
+	HRESULT (WINAPI *LockRect)(IDirect3DSurface9 *This, D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags);
+	HRESULT (WINAPI *UnlockRect)(IDirect3DSurface9 *This);
+	HRESULT (WINAPI *GetDC)(IDirect3DSurface9 *This, HDC *phdc);
+	HRESULT (WINAPI *ReleaseDC)(IDirect3DSurface9 *This, HDC hdc);
+} IDirect3DSurface9Vtbl;
+struct IDirect3DSurface9
+{
+	IDirect3DSurface9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DSurface9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DSurface9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DSurface9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DSurface9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DSurface9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DSurface9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DSurface9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DSurface9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DSurface9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DSurface9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DSurface9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DSurface9 macros */
+#define IDirect3DSurface9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b)
+#define IDirect3DSurface9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
+#define IDirect3DSurface9_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c)
+#define IDirect3DSurface9_UnlockRect(p) (p)->lpVtbl->UnlockRect(p)
+#define IDirect3DSurface9_GetDC(p,a) (p)->lpVtbl->GetDC(p,a)
+#define IDirect3DSurface9_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a)
+
+typedef struct IDirect3DSwapChain9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DSwapChain9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DSwapChain9 *This);
+	ULONG (WINAPI *Release)(IDirect3DSwapChain9 *This);
+	/* IDirect3DSwapChain9 */
+	HRESULT (WINAPI *Present)(IDirect3DSwapChain9 *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags);
+	HRESULT (WINAPI *GetFrontBufferData)(IDirect3DSwapChain9 *This, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *GetBackBuffer)(IDirect3DSwapChain9 *This, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer);
+	HRESULT (WINAPI *GetRasterStatus)(IDirect3DSwapChain9 *This, D3DRASTER_STATUS *pRasterStatus);
+	HRESULT (WINAPI *GetDisplayMode)(IDirect3DSwapChain9 *This, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetDevice)(IDirect3DSwapChain9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *GetPresentParameters)(IDirect3DSwapChain9 *This, D3DPRESENT_PARAMETERS *pPresentationParameters);
+} IDirect3DSwapChain9Vtbl;
+struct IDirect3DSwapChain9
+{
+	IDirect3DSwapChain9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DSwapChain9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DSwapChain9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DSwapChain9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DSwapChain9 macros */
+#define IDirect3DSwapChain9_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e)
+#define IDirect3DSwapChain9_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a)
+#define IDirect3DSwapChain9_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c)
+#define IDirect3DSwapChain9_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
+#define IDirect3DSwapChain9_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a)
+#define IDirect3DSwapChain9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DSwapChain9_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
+
+typedef struct IDirect3DSwapChain9ExVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DSwapChain9Ex *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DSwapChain9Ex *This);
+	ULONG (WINAPI *Release)(IDirect3DSwapChain9Ex *This);
+	/* IDirect3DSwapChain9 */
+	HRESULT (WINAPI *Present)(IDirect3DSwapChain9Ex *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags);
+	HRESULT (WINAPI *GetFrontBufferData)(IDirect3DSwapChain9Ex *This, IDirect3DSurface9 *pDestSurface);
+	HRESULT (WINAPI *GetBackBuffer)(IDirect3DSwapChain9Ex *This, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer);
+	HRESULT (WINAPI *GetRasterStatus)(IDirect3DSwapChain9Ex *This, D3DRASTER_STATUS *pRasterStatus);
+	HRESULT (WINAPI *GetDisplayMode)(IDirect3DSwapChain9Ex *This, D3DDISPLAYMODE *pMode);
+	HRESULT (WINAPI *GetDevice)(IDirect3DSwapChain9Ex *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *GetPresentParameters)(IDirect3DSwapChain9Ex *This, D3DPRESENT_PARAMETERS *pPresentationParameters);
+	/* IDirect3DSwapChain9Ex */
+	HRESULT (WINAPI *GetLastPresentCount)(IDirect3DSwapChain9Ex *This, UINT *pLastPresentCount);
+	HRESULT (WINAPI *GetPresentStats)(IDirect3DSwapChain9Ex *This, D3DPRESENTSTATS *pPresentationStatistics);
+	HRESULT (WINAPI *GetDisplayModeEx)(IDirect3DSwapChain9Ex *This, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
+} IDirect3DSwapChain9ExVtbl;
+struct IDirect3DSwapChain9Ex
+{
+	IDirect3DSwapChain9ExVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DSwapChain9Ex_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DSwapChain9Ex_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DSwapChain9Ex_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DSwapChain9 macros */
+#define IDirect3DSwapChain9Ex_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e)
+#define IDirect3DSwapChain9Ex_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a)
+#define IDirect3DSwapChain9Ex_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c)
+#define IDirect3DSwapChain9Ex_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
+#define IDirect3DSwapChain9Ex_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a)
+#define IDirect3DSwapChain9Ex_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DSwapChain9Ex_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
+/* IDirect3DSwapChain9Ex macros */
+#define IDirect3DSwapChain9Ex_GetLastPresentCount(p,a) (p)->lpVtbl->GetLastPresentCount(p,a)
+#define IDirect3DSwapChain9Ex_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a)
+#define IDirect3DSwapChain9Ex_GetDisplayModeEx(p,a,b) (p)->lpVtbl->GetDisplayModeEx(p,a,b)
+
+typedef struct IDirect3DTexture9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DTexture9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DTexture9 *This);
+	ULONG (WINAPI *Release)(IDirect3DTexture9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DTexture9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DTexture9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DTexture9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DTexture9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DTexture9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DTexture9 *This);
+	void (WINAPI *PreLoad)(IDirect3DTexture9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DTexture9 *This);
+	/* IDirect3DBaseTexture9 */
+	DWORD (WINAPI *SetLOD)(IDirect3DTexture9 *This, DWORD LODNew);
+	DWORD (WINAPI *GetLOD)(IDirect3DTexture9 *This);
+	DWORD (WINAPI *GetLevelCount)(IDirect3DTexture9 *This);
+	HRESULT (WINAPI *SetAutoGenFilterType)(IDirect3DTexture9 *This, D3DTEXTUREFILTERTYPE FilterType);
+	D3DTEXTUREFILTERTYPE (WINAPI *GetAutoGenFilterType)(IDirect3DTexture9 *This);
+	void (WINAPI *GenerateMipSubLevels)(IDirect3DTexture9 *This);
+	/* IDirect3DTexture9 */
+	HRESULT (WINAPI *GetLevelDesc)(IDirect3DTexture9 *This, UINT Level, D3DSURFACE_DESC *pDesc);
+	HRESULT (WINAPI *GetSurfaceLevel)(IDirect3DTexture9 *This, UINT Level, IDirect3DSurface9 **ppSurfaceLevel);
+	HRESULT (WINAPI *LockRect)(IDirect3DTexture9 *This, UINT Level, D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags);
+	HRESULT (WINAPI *UnlockRect)(IDirect3DTexture9 *This, UINT Level);
+	HRESULT (WINAPI *AddDirtyRect)(IDirect3DTexture9 *This, const RECT *pDirtyRect);
+} IDirect3DTexture9Vtbl;
+struct IDirect3DTexture9
+{
+	IDirect3DTexture9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DTexture9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DTexture9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DTexture9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DBaseTexture9 macros */
+#define IDirect3DTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
+#define IDirect3DTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p)
+#define IDirect3DTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
+#define IDirect3DTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a)
+#define IDirect3DTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p)
+#define IDirect3DTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p)
+/* IDirect3DTexture9 macros */
+#define IDirect3DTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b)
+#define IDirect3DTexture9_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b)
+#define IDirect3DTexture9_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d)
+#define IDirect3DTexture9_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a)
+#define IDirect3DTexture9_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a)
+
+typedef struct IDirect3DVertexBuffer9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DVertexBuffer9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DVertexBuffer9 *This);
+	ULONG (WINAPI *Release)(IDirect3DVertexBuffer9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DVertexBuffer9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DVertexBuffer9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DVertexBuffer9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DVertexBuffer9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DVertexBuffer9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DVertexBuffer9 *This);
+	void (WINAPI *PreLoad)(IDirect3DVertexBuffer9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DVertexBuffer9 *This);
+	/* IDirect3DVertexBuffer9 */
+	HRESULT (WINAPI *Lock)(IDirect3DVertexBuffer9 *This, UINT OffsetToLock, UINT SizeToLock, void **ppbData, DWORD Flags);
+	HRESULT (WINAPI *Unlock)(IDirect3DVertexBuffer9 *This);
+	HRESULT (WINAPI *GetDesc)(IDirect3DVertexBuffer9 *This, D3DVERTEXBUFFER_DESC *pDesc);
+} IDirect3DVertexBuffer9Vtbl;
+struct IDirect3DVertexBuffer9
+{
+	IDirect3DVertexBuffer9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DVertexBuffer9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVertexBuffer9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DVertexBuffer9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DVertexBuffer9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DVertexBuffer9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DVertexBuffer9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DVertexBuffer9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DVertexBuffer9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DVertexBuffer9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DVertexBuffer9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DVertexBuffer9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DVertexBuffer9 macros */
+#define IDirect3DVertexBuffer9_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d)
+#define IDirect3DVertexBuffer9_Unlock(p) (p)->lpVtbl->Unlock(p)
+#define IDirect3DVertexBuffer9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
+
+typedef struct IDirect3DVertexDeclaration9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DVertexDeclaration9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DVertexDeclaration9 *This);
+	ULONG (WINAPI *Release)(IDirect3DVertexDeclaration9 *This);
+	/* IDirect3DVertexDeclaration9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DVertexDeclaration9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *GetDeclaration)(IDirect3DVertexDeclaration9 *This, D3DVERTEXELEMENT9 *pElement, UINT *pNumElements);
+} IDirect3DVertexDeclaration9Vtbl;
+struct IDirect3DVertexDeclaration9
+{
+	IDirect3DVertexDeclaration9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DVertexDeclaration9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVertexDeclaration9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DVertexDeclaration9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DVertexDeclaration9 macros */
+#define IDirect3DVertexDeclaration9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DVertexDeclaration9_GetDeclaration(p,a,b) (p)->lpVtbl->GetDeclaration(p,a,b)
+
+typedef struct IDirect3DVertexShader9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DVertexShader9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DVertexShader9 *This);
+	ULONG (WINAPI *Release)(IDirect3DVertexShader9 *This);
+	/* IDirect3DVertexShader9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DVertexShader9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *GetFunction)(IDirect3DVertexShader9 *This, void *pData, UINT *pSizeOfData);
+} IDirect3DVertexShader9Vtbl;
+struct IDirect3DVertexShader9
+{
+	IDirect3DVertexShader9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DVertexShader9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVertexShader9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DVertexShader9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DVertexShader9 macros */
+#define IDirect3DVertexShader9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DVertexShader9_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
+
+typedef struct IDirect3DVolume9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DVolume9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DVolume9 *This);
+	ULONG (WINAPI *Release)(IDirect3DVolume9 *This);
+	/* IDirect3DVolume9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DVolume9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DVolume9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DVolume9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DVolume9 *This, REFGUID refguid);
+	HRESULT (WINAPI *GetContainer)(IDirect3DVolume9 *This, REFIID riid, void **ppContainer);
+	HRESULT (WINAPI *GetDesc)(IDirect3DVolume9 *This, D3DVOLUME_DESC *pDesc);
+	HRESULT (WINAPI *LockBox)(IDirect3DVolume9 *This, D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags);
+	HRESULT (WINAPI *UnlockBox)(IDirect3DVolume9 *This);
+} IDirect3DVolume9Vtbl;
+struct IDirect3DVolume9
+{
+	IDirect3DVolume9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DVolume9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVolume9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DVolume9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DVolume9 macros */
+#define IDirect3DVolume9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DVolume9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DVolume9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DVolume9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DVolume9_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b)
+#define IDirect3DVolume9_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
+#define IDirect3DVolume9_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c)
+#define IDirect3DVolume9_UnlockBox(p) (p)->lpVtbl->UnlockBox(p)
+
+typedef struct IDirect3DVolumeTexture9Vtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IDirect3DVolumeTexture9 *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IDirect3DVolumeTexture9 *This);
+	ULONG (WINAPI *Release)(IDirect3DVolumeTexture9 *This);
+	/* IDirect3DResource9 */
+	HRESULT (WINAPI *GetDevice)(IDirect3DVolumeTexture9 *This, IDirect3DDevice9 **ppDevice);
+	HRESULT (WINAPI *SetPrivateData)(IDirect3DVolumeTexture9 *This, REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags);
+	HRESULT (WINAPI *GetPrivateData)(IDirect3DVolumeTexture9 *This, REFGUID refguid, void *pData, DWORD *pSizeOfData);
+	HRESULT (WINAPI *FreePrivateData)(IDirect3DVolumeTexture9 *This, REFGUID refguid);
+	DWORD (WINAPI *SetPriority)(IDirect3DVolumeTexture9 *This, DWORD PriorityNew);
+	DWORD (WINAPI *GetPriority)(IDirect3DVolumeTexture9 *This);
+	void (WINAPI *PreLoad)(IDirect3DVolumeTexture9 *This);
+	D3DRESOURCETYPE (WINAPI *GetType)(IDirect3DVolumeTexture9 *This);
+	/* IDirect3DBaseTexture9 */
+	DWORD (WINAPI *SetLOD)(IDirect3DVolumeTexture9 *This, DWORD LODNew);
+	DWORD (WINAPI *GetLOD)(IDirect3DVolumeTexture9 *This);
+	DWORD (WINAPI *GetLevelCount)(IDirect3DVolumeTexture9 *This);
+	HRESULT (WINAPI *SetAutoGenFilterType)(IDirect3DVolumeTexture9 *This, D3DTEXTUREFILTERTYPE FilterType);
+	D3DTEXTUREFILTERTYPE (WINAPI *GetAutoGenFilterType)(IDirect3DVolumeTexture9 *This);
+	void (WINAPI *GenerateMipSubLevels)(IDirect3DVolumeTexture9 *This);
+	/* IDirect3DVolumeTexture9 */
+	HRESULT (WINAPI *GetLevelDesc)(IDirect3DVolumeTexture9 *This, UINT Level, D3DVOLUME_DESC *pDesc);
+	HRESULT (WINAPI *GetVolumeLevel)(IDirect3DVolumeTexture9 *This, UINT Level, IDirect3DVolume9 **ppVolumeLevel);
+	HRESULT (WINAPI *LockBox)(IDirect3DVolumeTexture9 *This, UINT Level, D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags);
+	HRESULT (WINAPI *UnlockBox)(IDirect3DVolumeTexture9 *This, UINT Level);
+	HRESULT (WINAPI *AddDirtyBox)(IDirect3DVolumeTexture9 *This, const D3DBOX *pDirtyBox);
+} IDirect3DVolumeTexture9Vtbl;
+struct IDirect3DVolumeTexture9
+{
+	IDirect3DVolumeTexture9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IDirect3DVolumeTexture9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVolumeTexture9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirect3DVolumeTexture9_Release(p) (p)->lpVtbl->Release(p)
+/* IDirect3DResource9 macros */
+#define IDirect3DVolumeTexture9_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DVolumeTexture9_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
+#define IDirect3DVolumeTexture9_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
+#define IDirect3DVolumeTexture9_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
+#define IDirect3DVolumeTexture9_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
+#define IDirect3DVolumeTexture9_GetPriority(p) (p)->lpVtbl->GetPriority(p)
+#define IDirect3DVolumeTexture9_PreLoad(p) (p)->lpVtbl->PreLoad(p)
+#define IDirect3DVolumeTexture9_GetType(p) (p)->lpVtbl->GetType(p)
+/* IDirect3DBaseTexture9 macros */
+#define IDirect3DVolumeTexture9_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
+#define IDirect3DVolumeTexture9_GetLOD(p) (p)->lpVtbl->GetLOD(p)
+#define IDirect3DVolumeTexture9_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
+#define IDirect3DVolumeTexture9_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a)
+#define IDirect3DVolumeTexture9_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p)
+#define IDirect3DVolumeTexture9_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p)
+/* IDirect3DVolumeTexture9 macros */
+#define IDirect3DVolumeTexture9_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b)
+#define IDirect3DVolumeTexture9_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b)
+#define IDirect3DVolumeTexture9_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d)
+#define IDirect3DVolumeTexture9_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a)
+#define IDirect3DVolumeTexture9_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a)
+
+#endif /* __cplusplus */
+
+#ifdef _WIN32
+
+IDirect3D9 *WINAPI
+Direct3DCreate9( UINT SDKVersion );
+
+HRESULT WINAPI
+Direct3DCreate9Ex( UINT SDKVersion,
+                   IDirect3D9Ex **ppD3D9 );
+
+void *WINAPI
+Direct3DShaderValidatorCreate9( void );
+
+int WINAPI
+D3DPERF_BeginEvent( D3DCOLOR color,
+                    LPCWSTR name );
+
+int WINAPI
+D3DPERF_EndEvent( void );
+
+DWORD WINAPI
+D3DPERF_GetStatus( void );
+
+void WINAPI
+D3DPERF_SetOptions( DWORD options );
+
+BOOL WINAPI
+D3DPERF_QueryRepeatFrame( void );
+
+void WINAPI
+D3DPERF_SetMarker( D3DCOLOR color,
+                   LPCWSTR name );
+
+void WINAPI
+D3DPERF_SetRegion( D3DCOLOR color,
+                   LPCWSTR name );
+
+void WINAPI
+DebugSetMute( void );
+
+#endif
+
+#endif /* _D3D9_H_ */
diff --git a/mesalib/include/D3D9/d3d9caps.h b/mesalib/include/D3D9/d3d9caps.h
new file mode 100644
index 0000000..0cce5d3
--- /dev/null
+++ b/mesalib/include/D3D9/d3d9caps.h
@@ -0,0 +1,387 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+#ifndef _D3D9CAPS_H_
+#define _D3D9CAPS_H_
+
+#include "d3d9types.h"
+
+/* Caps flags */
+#define D3DCAPS2_FULLSCREENGAMMA   0x00020000
+#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000
+#define D3DCAPS2_RESERVED          0x02000000
+#define D3DCAPS2_CANMANAGERESOURCE 0x10000000
+#define D3DCAPS2_DYNAMICTEXTURES   0x20000000
+#define D3DCAPS2_CANAUTOGENMIPMAP  0x40000000
+#define D3DCAPS2_CANSHARERESOURCE  0x80000000
+
+#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020
+#define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION      0x00000080
+#define D3DCAPS3_COPY_TO_VIDMEM                   0x00000100
+#define D3DCAPS3_COPY_TO_SYSTEMMEM                0x00000200
+#define D3DCAPS3_DXVAHD                           0x00000400
+#define D3DCAPS3_RESERVED                         0x8000001F
+
+#define D3DPRESENT_INTERVAL_DEFAULT   0x00000000
+#define D3DPRESENT_INTERVAL_ONE       0x00000001
+#define D3DPRESENT_INTERVAL_TWO       0x00000002
+#define D3DPRESENT_INTERVAL_THREE     0x00000004
+#define D3DPRESENT_INTERVAL_FOUR      0x00000008
+#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000
+
+#define D3DCURSORCAPS_COLOR  0x00000001
+#define D3DCURSORCAPS_LOWRES 0x00000002
+
+#define D3DDEVCAPS_EXECUTESYSTEMMEMORY     0x00000010
+#define D3DDEVCAPS_EXECUTEVIDEOMEMORY      0x00000020
+#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY    0x00000040
+#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY     0x00000080
+#define D3DDEVCAPS_TEXTURESYSTEMMEMORY     0x00000100
+#define D3DDEVCAPS_TEXTUREVIDEOMEMORY      0x00000200
+#define D3DDEVCAPS_DRAWPRIMTLVERTEX        0x00000400
+#define D3DDEVCAPS_CANRENDERAFTERFLIP      0x00000800
+#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM   0x00001000
+#define D3DDEVCAPS_DRAWPRIMITIVES2         0x00002000
+#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000
+#define D3DDEVCAPS_DRAWPRIMITIVES2EX       0x00008000
+#define D3DDEVCAPS_HWTRANSFORMANDLIGHT     0x00010000
+#define D3DDEVCAPS_CANBLTSYSTONONLOCAL     0x00020000
+#define D3DDEVCAPS_HWRASTERIZATION         0x00080000
+#define D3DDEVCAPS_PUREDEVICE              0x00100000
+#define D3DDEVCAPS_QUINTICRTPATCHES        0x00200000
+#define D3DDEVCAPS_RTPATCHES               0x00400000
+#define D3DDEVCAPS_RTPATCHHANDLEZERO       0x00800000
+#define D3DDEVCAPS_NPATCHES                0x01000000
+
+#define D3DPMISCCAPS_MASKZ                      0x00000002
+#define D3DPMISCCAPS_CULLNONE                   0x00000010
+#define D3DPMISCCAPS_CULLCW                     0x00000020
+#define D3DPMISCCAPS_CULLCCW                    0x00000040
+#define D3DPMISCCAPS_COLORWRITEENABLE           0x00000080
+#define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS      0x00000100
+#define D3DPMISCCAPS_CLIPTLVERTS                0x00000200
+#define D3DPMISCCAPS_TSSARGTEMP                 0x00000400
+#define D3DPMISCCAPS_BLENDOP                    0x00000800
+#define D3DPMISCCAPS_NULLREFERENCE              0x00001000
+#define D3DPMISCCAPS_INDEPENDENTWRITEMASKS      0x00004000
+#define D3DPMISCCAPS_PERSTAGECONSTANT           0x00008000
+#define D3DPMISCCAPS_FOGANDSPECULARALPHA        0x00010000
+#define D3DPMISCCAPS_SEPARATEALPHABLEND         0x00020000
+#define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS    0x00040000
+#define D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING 0x00080000
+#define D3DPMISCCAPS_FOGVERTEXCLAMPED           0x00100000
+#define D3DPMISCCAPS_POSTBLENDSRGBCONVERT       0x00200000
+
+#define D3DPRASTERCAPS_DITHER              0x00000001
+#define D3DPRASTERCAPS_ZTEST               0x00000010
+#define D3DPRASTERCAPS_FOGVERTEX           0x00000080
+#define D3DPRASTERCAPS_FOGTABLE            0x00000100
+#define D3DPRASTERCAPS_MIPMAPLODBIAS       0x00002000
+#define D3DPRASTERCAPS_ZBUFFERLESSHSR      0x00008000
+#define D3DPRASTERCAPS_FOGRANGE            0x00010000
+#define D3DPRASTERCAPS_ANISOTROPY          0x00020000
+#define D3DPRASTERCAPS_WBUFFER             0x00040000
+#define D3DPRASTERCAPS_WFOG                0x00100000
+#define D3DPRASTERCAPS_ZFOG                0x00200000
+#define D3DPRASTERCAPS_COLORPERSPECTIVE    0x00400000
+#define D3DPRASTERCAPS_SCISSORTEST         0x01000000
+#define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000
+#define D3DPRASTERCAPS_DEPTHBIAS           0x04000000
+#define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE  0x08000000
+
+#define D3DPCMPCAPS_NEVER        0x00000001
+#define D3DPCMPCAPS_LESS         0x00000002
+#define D3DPCMPCAPS_EQUAL        0x00000004
+#define D3DPCMPCAPS_LESSEQUAL    0x00000008
+#define D3DPCMPCAPS_GREATER      0x00000010
+#define D3DPCMPCAPS_NOTEQUAL     0x00000020
+#define D3DPCMPCAPS_GREATEREQUAL 0x00000040
+#define D3DPCMPCAPS_ALWAYS       0x00000080
+
+#define D3DPBLENDCAPS_ZERO            0x00000001
+#define D3DPBLENDCAPS_ONE             0x00000002
+#define D3DPBLENDCAPS_SRCCOLOR        0x00000004
+#define D3DPBLENDCAPS_INVSRCCOLOR     0x00000008
+#define D3DPBLENDCAPS_SRCALPHA        0x00000010
+#define D3DPBLENDCAPS_INVSRCALPHA     0x00000020
+#define D3DPBLENDCAPS_DESTALPHA       0x00000040
+#define D3DPBLENDCAPS_INVDESTALPHA    0x00000080
+#define D3DPBLENDCAPS_DESTCOLOR       0x00000100
+#define D3DPBLENDCAPS_INVDESTCOLOR    0x00000200
+#define D3DPBLENDCAPS_SRCALPHASAT     0x00000400
+#define D3DPBLENDCAPS_BOTHSRCALPHA    0x00000800
+#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000
+#define D3DPBLENDCAPS_BLENDFACTOR     0x00002000
+#ifndef D3D_DISABLE_9EX
+# define D3DPBLENDCAPS_SRCCOLOR2      0x00004000
+# define D3DPBLENDCAPS_INVSRCCOLOR2   0x00008000
+#endif
+
+#define D3DPSHADECAPS_COLORGOURAUDRGB    0x00000008
+#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200
+#define D3DPSHADECAPS_ALPHAGOURAUDBLEND  0x00004000
+#define D3DPSHADECAPS_FOGGOURAUD         0x00080000
+
+#define D3DPTEXTURECAPS_PERSPECTIVE              0x00000001
+#define D3DPTEXTURECAPS_POW2                     0x00000002
+#define D3DPTEXTURECAPS_ALPHA                    0x00000004
+#define D3DPTEXTURECAPS_SQUAREONLY               0x00000020
+#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040
+#define D3DPTEXTURECAPS_ALPHAPALETTE             0x00000080
+#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL       0x00000100
+#define D3DPTEXTURECAPS_PROJECTED                0x00000400
+#define D3DPTEXTURECAPS_CUBEMAP                  0x00000800
+#define D3DPTEXTURECAPS_VOLUMEMAP                0x00002000
+#define D3DPTEXTURECAPS_MIPMAP                   0x00004000
+#define D3DPTEXTURECAPS_MIPVOLUMEMAP             0x00008000
+#define D3DPTEXTURECAPS_MIPCUBEMAP               0x00010000
+#define D3DPTEXTURECAPS_CUBEMAP_POW2             0x00020000
+#define D3DPTEXTURECAPS_VOLUMEMAP_POW2           0x00040000
+#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV       0x00200000
+
+#define D3DPTFILTERCAPS_MINFPOINT         0x00000100
+#define D3DPTFILTERCAPS_MINFLINEAR        0x00000200
+#define D3DPTFILTERCAPS_MINFANISOTROPIC   0x00000400
+#define D3DPTFILTERCAPS_MINFPYRAMIDALQUAD 0x00000800
+#define D3DPTFILTERCAPS_MINFGAUSSIANQUAD  0x00001000
+#define D3DPTFILTERCAPS_MIPFPOINT         0x00010000
+#define D3DPTFILTERCAPS_MIPFLINEAR        0x00020000
+#define D3DPTFILTERCAPS_MAGFPOINT         0x01000000
+#define D3DPTFILTERCAPS_MAGFLINEAR        0x02000000
+#define D3DPTFILTERCAPS_MAGFANISOTROPIC   0x04000000
+#define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000
+#define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD  0x10000000
+
+#define D3DPTADDRESSCAPS_WRAP          0x00000001
+#define D3DPTADDRESSCAPS_MIRROR        0x00000002
+#define D3DPTADDRESSCAPS_CLAMP         0x00000004
+#define D3DPTADDRESSCAPS_BORDER        0x00000008
+#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010
+#define D3DPTADDRESSCAPS_MIRRORONCE    0x00000020
+
+#define D3DLINECAPS_TEXTURE   0x00000001
+#define D3DLINECAPS_ZTEST     0x00000002
+#define D3DLINECAPS_BLEND     0x00000004
+#define D3DLINECAPS_ALPHACMP  0x00000008
+#define D3DLINECAPS_FOG       0x00000010
+#define D3DLINECAPS_ANTIALIAS 0x00000020
+
+#define D3DSTENCILCAPS_KEEP     0x00000001
+#define D3DSTENCILCAPS_ZERO     0x00000002
+#define D3DSTENCILCAPS_REPLACE  0x00000004
+#define D3DSTENCILCAPS_INCRSAT  0x00000008
+#define D3DSTENCILCAPS_DECRSAT  0x00000010
+#define D3DSTENCILCAPS_INVERT   0x00000020
+#define D3DSTENCILCAPS_INCR     0x00000040
+#define D3DSTENCILCAPS_DECR     0x00000080
+#define D3DSTENCILCAPS_TWOSIDED 0x00000100
+
+#define D3DFVFCAPS_TEXCOORDCOUNTMASK  0x0000FFFF
+#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000
+#define D3DFVFCAPS_PSIZE              0x00100000
+
+#define D3DTEXOPCAPS_DISABLE                   0x00000001
+#define D3DTEXOPCAPS_SELECTARG1                0x00000002
+#define D3DTEXOPCAPS_SELECTARG2                0x00000004
+#define D3DTEXOPCAPS_MODULATE                  0x00000008
+#define D3DTEXOPCAPS_MODULATE2X                0x00000010
+#define D3DTEXOPCAPS_MODULATE4X                0x00000020
+#define D3DTEXOPCAPS_ADD                       0x00000040
+#define D3DTEXOPCAPS_ADDSIGNED                 0x00000080
+#define D3DTEXOPCAPS_ADDSIGNED2X               0x00000100
+#define D3DTEXOPCAPS_SUBTRACT                  0x00000200
+#define D3DTEXOPCAPS_ADDSMOOTH                 0x00000400
+#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA         0x00000800
+#define D3DTEXOPCAPS_BLENDTEXTUREALPHA         0x00001000
+#define D3DTEXOPCAPS_BLENDFACTORALPHA          0x00002000
+#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM       0x00004000
+#define D3DTEXOPCAPS_BLENDCURRENTALPHA         0x00008000
+#define D3DTEXOPCAPS_PREMODULATE               0x00010000
+#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR    0x00020000
+#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA    0x00040000
+#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000
+#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000
+#define D3DTEXOPCAPS_BUMPENVMAP                0x00200000
+#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE       0x00400000
+#define D3DTEXOPCAPS_DOTPRODUCT3               0x00800000
+#define D3DTEXOPCAPS_MULTIPLYADD               0x01000000
+#define D3DTEXOPCAPS_LERP                      0x02000000
+
+#define D3DVTXPCAPS_TEXGEN                   0x00000001
+#define D3DVTXPCAPS_MATERIALSOURCE7          0x00000002
+#define D3DVTXPCAPS_DIRECTIONALLIGHTS        0x00000008
+#define D3DVTXPCAPS_POSITIONALLIGHTS         0x00000010
+#define D3DVTXPCAPS_LOCALVIEWER              0x00000020
+#define D3DVTXPCAPS_TWEENING                 0x00000040
+#define D3DVTXPCAPS_TEXGEN_SPHEREMAP         0x00000100
+#define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200
+
+#define D3DDEVCAPS2_STREAMOFFSET                       0x00000001
+#define D3DDEVCAPS2_DMAPNPATCH                         0x00000002
+#define D3DDEVCAPS2_ADAPTIVETESSRTPATCH                0x00000004
+#define D3DDEVCAPS2_ADAPTIVETESSNPATCH                 0x00000008
+#define D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES      0x00000010
+#define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH               0x00000020
+#define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040
+
+#define D3DDTCAPS_UBYTE4    0x00000001
+#define D3DDTCAPS_UBYTE4N   0x00000002
+#define D3DDTCAPS_SHORT2N   0x00000004
+#define D3DDTCAPS_SHORT4N   0x00000008
+#define D3DDTCAPS_USHORT2N  0x00000010
+#define D3DDTCAPS_USHORT4N  0x00000020
+#define D3DDTCAPS_UDEC3     0x00000040
+#define D3DDTCAPS_DEC3N     0x00000080
+#define D3DDTCAPS_FLOAT16_2 0x00000100
+#define D3DDTCAPS_FLOAT16_4 0x00000200
+
+
+#define D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH  24
+#define D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH  0
+#define D3DVS20_MAX_NUMTEMPS                 32
+#define D3DVS20_MIN_NUMTEMPS                 12
+#define D3DVS20_MAX_STATICFLOWCONTROLDEPTH   4
+#define D3DVS20_MIN_STATICFLOWCONTROLDEPTH   1
+
+#define D3DVS20CAPS_PREDICATION              (1 << 0)
+
+#define D3DPS20CAPS_ARBITRARYSWIZZLE         (1 << 0)
+#define D3DPS20CAPS_GRADIENTINSTRUCTIONS     (1 << 1)
+#define D3DPS20CAPS_PREDICATION              (1 << 2)
+#define D3DPS20CAPS_NODEPENDENTREADLIMIT     (1 << 3)
+#define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT    (1 << 4)
+
+#define D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH  24
+#define D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH  0
+#define D3DPS20_MAX_NUMTEMPS                 32
+#define D3DPS20_MIN_NUMTEMPS                 12
+#define D3DPS20_MAX_STATICFLOWCONTROLDEPTH   4
+#define D3DPS20_MIN_STATICFLOWCONTROLDEPTH   0
+#define D3DPS20_MAX_NUMINSTRUCTIONSLOTS      512
+#define D3DPS20_MIN_NUMINSTRUCTIONSLOTS      96
+
+#define D3DMIN30SHADERINSTRUCTIONS          512
+#define D3DMAX30SHADERINSTRUCTIONS          32768
+
+/* Structs */
+typedef struct _D3DVSHADERCAPS2_0 {
+	DWORD Caps;
+	INT DynamicFlowControlDepth;
+	INT NumTemps;
+	INT StaticFlowControlDepth;
+} D3DVSHADERCAPS2_0, *PD3DVSHADERCAPS2_0, *LPD3DVSHADERCAPS2_0;
+
+typedef struct _D3DPSHADERCAPS2_0 {
+	DWORD Caps;
+	INT DynamicFlowControlDepth;
+	INT NumTemps;
+	INT StaticFlowControlDepth;
+	INT NumInstructionSlots;
+} D3DPSHADERCAPS2_0, *PD3DPSHADERCAPS2_0, *LPD3DPSHADERCAPS2_0;
+
+typedef struct _D3DCAPS9 {
+	D3DDEVTYPE DeviceType;
+	UINT AdapterOrdinal;
+	DWORD Caps;
+	DWORD Caps2;
+	DWORD Caps3;
+	DWORD PresentationIntervals;
+	DWORD CursorCaps;
+	DWORD DevCaps;
+	DWORD PrimitiveMiscCaps;
+	DWORD RasterCaps;
+	DWORD ZCmpCaps;
+	DWORD SrcBlendCaps;
+	DWORD DestBlendCaps;
+	DWORD AlphaCmpCaps;
+	DWORD ShadeCaps;
+	DWORD TextureCaps;
+	DWORD TextureFilterCaps;
+	DWORD CubeTextureFilterCaps;
+	DWORD VolumeTextureFilterCaps;
+	DWORD TextureAddressCaps;
+	DWORD VolumeTextureAddressCaps;
+	DWORD LineCaps;
+	DWORD MaxTextureWidth;
+	DWORD MaxTextureHeight;
+	DWORD MaxVolumeExtent;
+	DWORD MaxTextureRepeat;
+	DWORD MaxTextureAspectRatio;
+	DWORD MaxAnisotropy;
+	float MaxVertexW;
+	float GuardBandLeft;
+	float GuardBandTop;
+	float GuardBandRight;
+	float GuardBandBottom;
+	float ExtentsAdjust;
+	DWORD StencilCaps;
+	DWORD FVFCaps;
+	DWORD TextureOpCaps;
+	DWORD MaxTextureBlendStages;
+	DWORD MaxSimultaneousTextures;
+	DWORD VertexProcessingCaps;
+	DWORD MaxActiveLights;
+	DWORD MaxUserClipPlanes;
+	DWORD MaxVertexBlendMatrices;
+	DWORD MaxVertexBlendMatrixIndex;
+	float MaxPointSize;
+	DWORD MaxPrimitiveCount;
+	DWORD MaxVertexIndex;
+	DWORD MaxStreams;
+	DWORD MaxStreamStride;
+	DWORD VertexShaderVersion;
+	DWORD MaxVertexShaderConst;
+	DWORD PixelShaderVersion;
+	float PixelShader1xMaxValue;
+	DWORD DevCaps2;
+	float MaxNpatchTessellationLevel;
+	DWORD Reserved5;
+	UINT MasterAdapterOrdinal;
+	UINT AdapterOrdinalInGroup;
+	UINT NumberOfAdaptersInGroup;
+	DWORD DeclTypes;
+	DWORD NumSimultaneousRTs;
+	DWORD StretchRectFilterCaps;
+	D3DVSHADERCAPS2_0 VS20Caps;
+	D3DPSHADERCAPS2_0 PS20Caps;
+	DWORD VertexTextureFilterCaps;
+	DWORD MaxVShaderInstructionsExecuted;
+	DWORD MaxPShaderInstructionsExecuted;
+	DWORD MaxVertexShader30InstructionSlots;
+	DWORD MaxPixelShader30InstructionSlots;
+} D3DCAPS9, *PD3DCAPS9, *LPD3DCAPS9;
+
+typedef struct _D3DCONTENTPROTECTIONCAPS {
+    DWORD Caps;
+    GUID KeyExchangeType;
+    UINT BufferAlignmentStart;
+    UINT BlockAlignmentSize;
+    ULONGLONG ProtectedMemorySize;
+} D3DCONTENTPROTECTIONCAPS, *PD3DCONTENTPROTECTIONCAPS, *LPD3DCONTENTPROTECTIONCAPS;
+
+typedef struct _D3DOVERLAYCAPS {
+    UINT Caps;
+    UINT MaxOverlayDisplayWidth;
+    UINT MaxOverlayDisplayHeight;
+} D3DOVERLAYCAPS, *PD3DOVERLAYCAPS, *LPD3DOVERLAYCAPS;
+
+#endif /* _D3D9CAPS_H_ */
diff --git a/mesalib/include/D3D9/d3d9types.h b/mesalib/include/D3D9/d3d9types.h
new file mode 100644
index 0000000..0a8f9e5
--- /dev/null
+++ b/mesalib/include/D3D9/d3d9types.h
@@ -0,0 +1,1797 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+#ifndef _D3D9TYPES_H_
+#define _D3D9TYPES_H_
+
+#ifdef _WIN32
+#include <windows.h>
+#else /* _WIN32 */
+#include <stdint.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/********************************************************
+ * Windows types                                        *
+ ********************************************************/
+/* Function macros */
+#define FAILED(x)    ((HRESULT)(x) < 0)
+#define SUCCEEDED(x) ((HRESULT)(x) >= 0)
+
+#define MAKE_HRESULT(sev,fac,code) \
+    ( \
+        ((HRESULT)(sev) << 31) | \
+        ((HRESULT)(fac) << 16) | \
+         (HRESULT)(code) \
+    )
+
+/* Windows errors */
+#define E_OUTOFMEMORY MAKE_HRESULT(1, 0x007, 14)
+#define E_NOINTERFACE MAKE_HRESULT(1, 0x000, 0x4002)
+#define E_POINTER     MAKE_HRESULT(1, 0x000, 0x4003)
+
+#define S_OK          ((HRESULT)0)
+#define S_FALSE       ((HRESULT)1)
+
+/* WORD types */
+typedef uint8_t BYTE;
+typedef uint16_t WORD;
+typedef uint32_t DWORD;
+
+/* Renamed types */
+typedef int BOOL;
+#ifndef FALSE
+#define FALSE 0
+#define TRUE (!FALSE)
+#endif
+
+typedef uint32_t UINT32;
+typedef uint64_t UINT64;
+
+typedef unsigned short USHORT;
+typedef unsigned int UINT;
+typedef unsigned int ULONG;
+typedef unsigned long long ULONGLONG;
+
+typedef short SHORT;
+typedef int INT;
+typedef int LONG;
+typedef long long LONGLONG;
+typedef float FLOAT;
+
+/* Windows types */
+typedef void *HANDLE;
+typedef int32_t HRESULT;
+typedef HANDLE HWND;
+typedef HANDLE HMONITOR;
+typedef HANDLE HDC;
+
+/* Unions */
+typedef union {
+    struct {
+        DWORD LowPart;
+        LONG HighPart;
+    };
+
+    struct {
+        DWORD LowPart;
+        LONG HighPart;
+    } u;
+
+    LONGLONG QuadPart;
+} LARGE_INTEGER, *LPLARGE_INTEGER;
+
+/* Structs */
+
+typedef struct _GUID {
+    DWORD Data1;
+    WORD Data2;
+    WORD Data3;
+    BYTE Data4[8];
+} GUID, IID, *LPGUID, *REFGUID, *REFIID;
+
+typedef struct _LUID {
+    DWORD LowPart;
+    LONG HighPart;
+} LUID, *LPLUID, *PLUID;
+
+typedef struct _PALETTEENTRY {
+    BYTE peRed;
+    BYTE peGreen;
+    BYTE peBlue;
+    BYTE peFlags;
+} PALETTEENTRY, *LPPALETTEENTRY;
+
+typedef struct _POINT {
+    LONG x;
+    LONG y;
+} POINT, *LPPOINT;
+
+typedef struct _RECT {
+    LONG left;
+    LONG top;
+    LONG right;
+    LONG bottom;
+} RECT, *LPRECT;
+
+typedef struct _RGNDATAHEADER {
+    DWORD dwSize;
+    DWORD iType;
+    DWORD nCount;
+    DWORD nRgnSize;
+    RECT rcBound;
+} RGNDATAHEADER, *LPRGNDATAHEADER;
+
+typedef struct _RGNDATA {
+    RGNDATAHEADER rdh;
+    char Buffer[1];
+} RGNDATA, *LPRGNDATA;
+#endif /* _WIN32 */
+
+#ifndef MAKEFOURCC
+#define MAKEFOURCC(a, b, c, d) \
+    ( \
+         (DWORD)(BYTE)(a) | \
+        ((DWORD)(BYTE)(b) << 8) | \
+        ((DWORD)(BYTE)(c) << 16) | \
+        ((DWORD)(BYTE)(d) << 24) \
+    )
+#endif /* MAKEFOURCC */
+
+
+#define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER             0x00000001
+#define D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL            0x00000002
+#define D3DPRESENTFLAG_DEVICECLIP                      0x00000004
+#define D3DPRESENTFLAG_VIDEO                           0x00000010
+#define D3DPRESENTFLAG_NOAUTOROTATE                    0x00000020
+#define D3DPRESENTFLAG_UNPRUNEDMODE                    0x00000040
+#define D3DPRESENTFLAG_OVERLAY_LIMITEDRGB              0x00000080
+#define D3DPRESENTFLAG_OVERLAY_YCbCr_BT709             0x00000100
+#define D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC             0x00000200
+#define D3DPRESENTFLAG_RESTRICTED_CONTENT              0x00000400
+#define D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER 0x00000800
+
+
+#ifdef WINAPI
+#undef WINAPI
+#endif /* WINAPI*/
+
+#if defined(__x86_64__) || defined(_M_X64)
+#define WINAPI __attribute__((ms_abi))
+#else /* x86_64 */
+#define WINAPI __attribute__((__stdcall__))
+#endif /* x86_64 */
+
+/* Implementation caps */
+#define D3DPRESENT_BACK_BUFFERS_MAX    3
+#define D3DPRESENT_BACK_BUFFERS_MAX_EX 30
+
+/* Functions */
+#define MAKE_D3DHRESULT(code) MAKE_HRESULT(1, 0x876, code)
+#define MAKE_D3DSTATUS(code)  MAKE_HRESULT(0, 0x876, code)
+
+/* SDK version */
+#define D3D_SDK_VERSION 32
+
+/* Adapter */
+#define D3DADAPTER_DEFAULT 0
+
+/********************************************************
+ * Return codes                                         *
+ ********************************************************/
+#define D3D_OK                           S_OK
+#define D3DOK_NOAUTOGEN                  MAKE_D3DSTATUS(2159)
+#define D3DERR_OUTOFVIDEOMEMORY          MAKE_D3DHRESULT(380)
+#define D3DERR_WASSTILLDRAWING           MAKE_D3DHRESULT(540)
+#define D3DERR_WRONGTEXTUREFORMAT        MAKE_D3DHRESULT(2072)
+#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073)
+#define D3DERR_UNSUPPORTEDCOLORARG       MAKE_D3DHRESULT(2074)
+#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075)
+#define D3DERR_UNSUPPORTEDALPHAARG       MAKE_D3DHRESULT(2076)
+#define D3DERR_TOOMANYOPERATIONS         MAKE_D3DHRESULT(2077)
+#define D3DERR_CONFLICTINGTEXTUREFILTER  MAKE_D3DHRESULT(2078)
+#define D3DERR_UNSUPPORTEDFACTORVALUE    MAKE_D3DHRESULT(2079)
+#define D3DERR_CONFLICTINGRENDERSTATE    MAKE_D3DHRESULT(2081)
+#define D3DERR_UNSUPPORTEDTEXTUREFILTER  MAKE_D3DHRESULT(2082)
+#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086)
+#define D3DERR_DRIVERINTERNALERROR       MAKE_D3DHRESULT(2087)
+#define D3DERR_NOTFOUND                  MAKE_D3DHRESULT(2150)
+#define D3DERR_MOREDATA                  MAKE_D3DHRESULT(2151)
+#define D3DERR_DEVICELOST                MAKE_D3DHRESULT(2152)
+#define D3DERR_DEVICENOTRESET            MAKE_D3DHRESULT(2153)
+#define D3DERR_NOTAVAILABLE              MAKE_D3DHRESULT(2154)
+#define D3DERR_INVALIDDEVICE             MAKE_D3DHRESULT(2155)
+#define D3DERR_INVALIDCALL               MAKE_D3DHRESULT(2156)
+#define D3DERR_DRIVERINVALIDCALL         MAKE_D3DHRESULT(2157)
+
+/********************************************************
+ * Bitmasks                                             *
+ *******************************************************/
+/* IDirect3DDevice9::Clear */
+#define D3DCLEAR_TARGET  0x00000001
+#define D3DCLEAR_ZBUFFER 0x00000002
+#define D3DCLEAR_STENCIL 0x00000004
+
+/* Usage */
+/* http://msdn.microsoft.com/en-us/library/ee416659(VS.85).aspx */
+#define D3DUSAGE_RENDERTARGET                    0x00000001
+#define D3DUSAGE_DEPTHSTENCIL                    0x00000002
+#define D3DUSAGE_WRITEONLY                       0x00000008
+#define D3DUSAGE_SOFTWAREPROCESSING              0x00000010
+#define D3DUSAGE_DONOTCLIP                       0x00000020
+#define D3DUSAGE_POINTS                          0x00000040
+#define D3DUSAGE_RTPATCHES                       0x00000080
+#define D3DUSAGE_NPATCHES                        0x00000100
+#define D3DUSAGE_DYNAMIC                         0x00000200
+#define D3DUSAGE_AUTOGENMIPMAP                   0x00000400
+#ifndef D3D_DISABLE_9EX
+#define D3DUSAGE_RESTRICTED_CONTENT              0x00000800
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER 0x00001000
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE        0x00002000
+#endif
+#define D3DUSAGE_DMAP                            0x00004000
+#define D3DUSAGE_QUERY_LEGACYBUMPMAP             0x00008000
+#define D3DUSAGE_QUERY_SRGBREAD                  0x00010000
+#define D3DUSAGE_QUERY_FILTER                    0x00020000
+#define D3DUSAGE_QUERY_SRGBWRITE                 0x00040000
+#define D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING  0x00080000
+#define D3DUSAGE_QUERY_VERTEXTEXTURE             0x00100000
+#define D3DUSAGE_QUERY_WRAPANDMIP	             0x00200000
+#ifndef D3D_DISABLE_9EX
+#define D3DUSAGE_NONSECURE                       0x00800000
+#define D3DUSAGE_TEXTAPI                         0x10000000
+#endif
+
+/* Buffer locking */
+/* http://msdn.microsoft.com/en-us/library/ee416503(VS.85).aspx */
+#define D3DLOCK_READONLY        0x00000010
+#define D3DLOCK_NOSYSLOCK       0x00000800
+#define D3DLOCK_NOOVERWRITE     0x00001000
+#define D3DLOCK_DISCARD         0x00002000
+#define D3DLOCK_DONOTWAIT       0x00004000
+#define D3DLOCK_NO_DIRTY_UPDATE 0x00008000
+
+/* FVF */
+/* http://msdn.microsoft.com/en-us/library/ee416490(VS.85).aspx */
+/* http://msdn.microsoft.com/en-us/library/ms791638.aspx */
+#define D3DFVF_XYZ              0x00000002
+#define D3DFVF_XYZRHW           0x00000004
+#define D3DFVF_XYZB1            0x00000006
+#define D3DFVF_XYZB2            0x00000008
+#define D3DFVF_XYZB3            0x0000000A
+#define D3DFVF_XYZB4            0x0000000C
+#define D3DFVF_XYZB5            0x0000000E
+#define D3DFVF_XYZW             0x00004002
+#define D3DFVF_POSITION_MASK    0x0000400E
+
+#define D3DFVF_NORMAL           0x00000010
+#define D3DFVF_PSIZE            0x00000020
+#define D3DFVF_DIFFUSE          0x00000040
+#define D3DFVF_SPECULAR         0x00000080
+
+#define D3DFVF_TEX0             0x00000000
+#define D3DFVF_TEX1             0x00000100
+#define D3DFVF_TEX2             0x00000200
+#define D3DFVF_TEX3             0x00000300
+#define D3DFVF_TEX4             0x00000400
+#define D3DFVF_TEX5             0x00000500
+#define D3DFVF_TEX6             0x00000600
+#define D3DFVF_TEX7             0x00000700
+#define D3DFVF_TEX8             0x00000800
+#define D3DFVF_TEXCOUNT_MASK    0x00000F00
+#define D3DFVF_TEXCOUNT_SHIFT            8
+#define D3DFVF_TEXTUREFORMAT1   0x00000003
+#define D3DFVF_TEXTUREFORMAT2   0x00000000
+#define D3DFVF_TEXTUREFORMAT3   0x00000001
+#define D3DFVF_TEXTUREFORMAT4   0x00000002
+
+#define D3DFVF_POSITION_MASK  0x0000400E
+#define D3DFVF_TEXCOUNT_MASK  0x00000F00
+#define D3DFVF_TEXCOUNT_SHIFT 8
+
+#define D3DFVF_LASTBETA_UBYTE4   0x00001000
+#define D3DFVF_LASTBETA_D3DCOLOR 0x00008000
+
+#define D3DFVF_RESERVED0 0x00000001
+#define D3DFVF_RESERVED2 0x00006000
+
+#define D3DTA_SELECTMASK        0x0000000f
+#define D3DTA_DIFFUSE           0x00000000
+#define D3DTA_CURRENT           0x00000001
+#define D3DTA_TEXTURE           0x00000002
+#define D3DTA_TFACTOR           0x00000003
+#define D3DTA_SPECULAR          0x00000004
+#define D3DTA_TEMP              0x00000005
+#define D3DTA_CONSTANT          0x00000006
+#define D3DTA_COMPLEMENT        0x00000010
+#define D3DTA_ALPHAREPLICATE    0x00000020
+
+#define D3DSPD_IUNKNOWN 0x00000001
+
+#define D3DPRESENT_DONOTWAIT      0x00000001
+#define D3DPRESENT_LINEAR_CONTENT 0x00000002
+
+#define D3DCREATE_FPU_PRESERVE              0x00000002
+#define D3DCREATE_MULTITHREADED             0x00000004
+#define D3DCREATE_PUREDEVICE                0x00000010
+#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020
+#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040
+#define D3DCREATE_MIXED_VERTEXPROCESSING    0x00000080
+#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100
+#define D3DCREATE_ADAPTERGROUP_DEVICE       0x00000200
+
+#define D3DSTREAMSOURCE_INDEXEDDATA  (1 << 30)
+#define D3DSTREAMSOURCE_INSTANCEDATA (2 << 30)
+
+/********************************************************
+ * Function macros                                      *
+ *******************************************************/
+
+/* Colors */
+#define D3DCOLOR_ARGB(a,r,g,b) \
+    ((D3DCOLOR)( \
+        (((a) & 0xFF) << 24) | \
+        (((r) & 0xFF) << 16) | \
+        (((g) & 0xFF) << 8) | \
+         ((b) & 0xFF) \
+    ))
+
+#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)
+#define D3DCOLOR_XRGB(r,g,b)   D3DCOLOR_ARGB(0xFF,r,g,b)
+#define D3DCOLOR_AYUV(a,y,u,v) D3DCOLOR_ARGB(a,y,u,v)
+#define D3DCOLOR_XYUV(y,u,v)   D3DCOLOR_ARGB(0xFF,y,u,v)
+
+#define D3DCOLOR_COLORVALUE(r,g,b,a) \
+    D3DCOLOR_RGBA( \
+        (DWORD)((r) * 255.0f), \
+        (DWORD)((g) * 255.0f), \
+        (DWORD)((b) * 255.0f), \
+        (DWORD)((a) * 255.0f) \
+    )
+
+/* Shaders */
+#define D3DDECL_END() { 0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0 }
+
+/*****************************************************************************
+ * Typedefs                                                                  *
+ *****************************************************************************/
+typedef DWORD D3DCOLOR;
+
+/*****************************************************************************
+ * Enums                                                                     *
+ *****************************************************************************/
+typedef enum D3DDISPLAYROTATION {
+    D3DDISPLAYROTATION_IDENTITY = 1,
+    D3DDISPLAYROTATION_90 = 2,
+    D3DDISPLAYROTATION_180 = 3,
+    D3DDISPLAYROTATION_270 = 4
+} D3DDISPLAYROTATION;
+
+typedef enum D3DSCANLINEORDERING {
+    D3DSCANLINEORDERING_UNKNOWN = 0,
+    D3DSCANLINEORDERING_PROGRESSIVE = 1,
+    D3DSCANLINEORDERING_INTERLACED = 2
+} D3DSCANLINEORDERING;
+
+typedef enum _D3DAUTHENTICATEDCHANNELTYPE {
+    D3DAUTHENTICATEDCHANNEL_D3D9 = 1,
+    D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE = 2,
+    D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE = 3
+} D3DAUTHENTICATEDCHANNELTYPE;
+
+typedef enum _D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE {
+    PROCESSIDTYPE_UNKNOWN = 0,
+    PROCESSIDTYPE_DWM = 1,
+    PROCESSIDTYPE_HANDLE = 2
+} D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE;
+
+typedef enum _D3DBACKBUFFER_TYPE {
+    D3DBACKBUFFER_TYPE_MONO = 0,
+    D3DBACKBUFFER_TYPE_LEFT = 1,
+    D3DBACKBUFFER_TYPE_RIGHT = 2
+} D3DBACKBUFFER_TYPE;
+
+typedef enum _D3DBASISTYPE {
+   D3DBASIS_BEZIER = 0,
+   D3DBASIS_BSPLINE = 1,
+   D3DBASIS_CATMULL_ROM = 2
+} D3DBASISTYPE;
+
+typedef enum _D3DBLEND {
+    D3DBLEND_ZERO = 1,
+    D3DBLEND_ONE = 2,
+    D3DBLEND_SRCCOLOR = 3,
+    D3DBLEND_INVSRCCOLOR = 4,
+    D3DBLEND_SRCALPHA = 5,
+    D3DBLEND_INVSRCALPHA = 6,
+    D3DBLEND_DESTALPHA = 7,
+    D3DBLEND_INVDESTALPHA = 8,
+    D3DBLEND_DESTCOLOR = 9,
+    D3DBLEND_INVDESTCOLOR = 10,
+    D3DBLEND_SRCALPHASAT = 11,
+    D3DBLEND_BOTHSRCALPHA = 12,
+    D3DBLEND_BOTHINVSRCALPHA = 13,
+    D3DBLEND_BLENDFACTOR = 14,
+    D3DBLEND_INVBLENDFACTOR = 15,
+    D3DBLEND_SRCCOLOR2 = 16,
+    D3DBLEND_INVSRCCOLOR2 = 17
+} D3DBLEND;
+
+typedef enum _D3DBLENDOP {
+    D3DBLENDOP_ADD = 1,
+    D3DBLENDOP_SUBTRACT = 2,
+    D3DBLENDOP_REVSUBTRACT = 3,
+    D3DBLENDOP_MIN = 4,
+    D3DBLENDOP_MAX = 5
+} D3DBLENDOP;
+
+typedef enum _D3DBUSTYPE {
+    D3DBUSTYPE_OTHER = 0x00000000,
+    D3DBUSTYPE_PCI = 0x00000001,
+    D3DBUSTYPE_PCIX = 0x00000002,
+    D3DBUSTYPE_PCIEXPRESS = 0x00000003,
+    D3DBUSTYPE_AGP = 0x00000004,
+    D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x00010000,
+    D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000,
+    D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000,
+    D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000,
+    D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000,
+    D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000
+} D3DBUSTYPE;
+
+typedef enum _D3DCMPFUNC {
+    D3DCMP_NEVER = 1,
+    D3DCMP_LESS = 2,
+    D3DCMP_EQUAL = 3,
+    D3DCMP_LESSEQUAL = 4,
+    D3DCMP_GREATER = 5,
+    D3DCMP_NOTEQUAL = 6,
+    D3DCMP_GREATEREQUAL = 7,
+    D3DCMP_ALWAYS = 8
+} D3DCMPFUNC;
+
+typedef enum _D3DCOMPOSERECTSOP{
+    D3DCOMPOSERECTS_COPY = 1,
+    D3DCOMPOSERECTS_OR = 2,
+    D3DCOMPOSERECTS_AND = 3,
+    D3DCOMPOSERECTS_NEG = 4
+} D3DCOMPOSERECTSOP;
+
+typedef enum _D3DCUBEMAP_FACES {
+    D3DCUBEMAP_FACE_POSITIVE_X = 0,
+    D3DCUBEMAP_FACE_NEGATIVE_X = 1,
+    D3DCUBEMAP_FACE_POSITIVE_Y = 2,
+    D3DCUBEMAP_FACE_NEGATIVE_Y = 3,
+    D3DCUBEMAP_FACE_POSITIVE_Z = 4,
+    D3DCUBEMAP_FACE_NEGATIVE_Z = 5
+} D3DCUBEMAP_FACES;
+
+typedef enum _D3DCULL {
+    D3DCULL_NONE = 1,
+    D3DCULL_CW = 2,
+    D3DCULL_CCW = 3
+} D3DCULL;
+
+typedef enum _D3DDEBUGMONITORTOKENS {
+    D3DDMT_ENABLE = 0,
+    D3DDMT_DISABLE = 1
+} D3DDEBUGMONITORTOKENS;
+
+typedef enum _D3DDECLMETHOD {
+    D3DDECLMETHOD_DEFAULT = 0,
+    D3DDECLMETHOD_PARTIALU = 1,
+    D3DDECLMETHOD_PARTIALV = 2,
+    D3DDECLMETHOD_CROSSUV = 3,
+    D3DDECLMETHOD_UV = 4,
+    D3DDECLMETHOD_LOOKUP = 5,
+    D3DDECLMETHOD_LOOKUPPRESAMPLED = 6
+} D3DDECLMETHOD;
+
+typedef enum _D3DDECLTYPE {
+    D3DDECLTYPE_FLOAT1 = 0,
+    D3DDECLTYPE_FLOAT2 = 1,
+    D3DDECLTYPE_FLOAT3 = 2,
+    D3DDECLTYPE_FLOAT4 = 3,
+    D3DDECLTYPE_D3DCOLOR = 4,
+    D3DDECLTYPE_UBYTE4 = 5,
+    D3DDECLTYPE_SHORT2 = 6,
+    D3DDECLTYPE_SHORT4 = 7,
+    D3DDECLTYPE_UBYTE4N = 8,
+    D3DDECLTYPE_SHORT2N = 9,
+    D3DDECLTYPE_SHORT4N = 10,
+    D3DDECLTYPE_USHORT2N = 11,
+    D3DDECLTYPE_USHORT4N = 12,
+    D3DDECLTYPE_UDEC3 = 13,
+    D3DDECLTYPE_DEC3N = 14,
+    D3DDECLTYPE_FLOAT16_2 = 15,
+    D3DDECLTYPE_FLOAT16_4 = 16,
+    D3DDECLTYPE_UNUSED = 17
+} D3DDECLTYPE;
+
+typedef enum _D3DDECLUSAGE {
+    D3DDECLUSAGE_POSITION = 0,
+    D3DDECLUSAGE_BLENDWEIGHT = 1,
+    D3DDECLUSAGE_BLENDINDICES = 2,
+    D3DDECLUSAGE_NORMAL = 3,
+    D3DDECLUSAGE_PSIZE = 4,
+    D3DDECLUSAGE_TEXCOORD = 5,
+    D3DDECLUSAGE_TANGENT = 6,
+    D3DDECLUSAGE_BINORMAL = 7,
+    D3DDECLUSAGE_TESSFACTOR = 8,
+    D3DDECLUSAGE_POSITIONT = 9,
+    D3DDECLUSAGE_COLOR = 10,
+    D3DDECLUSAGE_FOG = 11,
+    D3DDECLUSAGE_DEPTH = 12,
+    D3DDECLUSAGE_SAMPLE = 13
+} D3DDECLUSAGE;
+
+typedef enum _D3DDEGREETYPE {
+   D3DDEGREE_LINEAR = 1,
+   D3DDEGREE_QUADRATIC = 2,
+   D3DDEGREE_CUBIC = 3,
+   D3DDEGREE_QUINTIC = 5
+} D3DDEGREETYPE;
+
+typedef enum _D3DDEVTYPE {
+    D3DDEVTYPE_HAL = 1,
+    D3DDEVTYPE_REF = 2,
+    D3DDEVTYPE_SW = 3,
+    D3DDEVTYPE_NULLREF = 4
+} D3DDEVTYPE;
+
+typedef enum _D3DFILLMODE {
+    D3DFILL_POINT = 1,
+    D3DFILL_WIREFRAME = 2,
+    D3DFILL_SOLID = 3
+} D3DFILLMODE;
+
+typedef enum _D3DFOGMODE {
+    D3DFOG_NONE = 0,
+    D3DFOG_EXP = 1,
+    D3DFOG_EXP2 = 2,
+    D3DFOG_LINEAR = 3
+} D3DFOGMODE;
+
+typedef enum _D3DFORMAT {
+    D3DFMT_UNKNOWN = 0,
+    D3DFMT_R8G8B8 = 20,
+    D3DFMT_A8R8G8B8 = 21,
+    D3DFMT_X8R8G8B8 = 22,
+    D3DFMT_R5G6B5 = 23,
+    D3DFMT_X1R5G5B5 = 24,
+    D3DFMT_A1R5G5B5 = 25,
+    D3DFMT_A4R4G4B4 = 26,
+    D3DFMT_R3G3B2 = 27,
+    D3DFMT_A8 = 28,
+    D3DFMT_A8R3G3B2 = 29,
+    D3DFMT_X4R4G4B4 = 30,
+    D3DFMT_A2B10G10R10 = 31,
+    D3DFMT_A8B8G8R8 = 32,
+    D3DFMT_X8B8G8R8 = 33,
+    D3DFMT_G16R16 = 34,
+    D3DFMT_A2R10G10B10 = 35,
+    D3DFMT_A16B16G16R16 = 36,
+    D3DFMT_A8P8 = 40,
+    D3DFMT_P8 = 41,
+    D3DFMT_L8 = 50,
+    D3DFMT_A8L8 = 51,
+    D3DFMT_A4L4 = 52,
+    D3DFMT_V8U8 = 60,
+    D3DFMT_L6V5U5 = 61,
+    D3DFMT_X8L8V8U8 = 62,
+    D3DFMT_Q8W8V8U8 = 63,
+    D3DFMT_V16U16 = 64,
+    D3DFMT_A2W10V10U10 = 67,
+    D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
+    D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
+    D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
+    D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
+    D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
+    D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
+    D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
+    D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
+    D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
+    D3DFMT_D16_LOCKABLE = 70,
+    D3DFMT_D32 = 71,
+    D3DFMT_D15S1 = 73,
+    D3DFMT_D24S8 = 75,
+    D3DFMT_D24X8 = 77,
+    D3DFMT_D24X4S4 = 79,
+    D3DFMT_D16 = 80,
+    D3DFMT_D32F_LOCKABLE = 82,
+    D3DFMT_D24FS8 = 83,
+    D3DFMT_D32_LOCKABLE = 84,
+    D3DFMT_S8_LOCKABLE = 85,
+    D3DFMT_L16 = 81,
+    D3DFMT_VERTEXDATA = 100,
+    D3DFMT_INDEX16 = 101,
+    D3DFMT_INDEX32 = 102,
+    D3DFMT_Q16W16V16U16 = 110,
+    D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'),
+    D3DFMT_R16F = 111,
+    D3DFMT_G16R16F = 112,
+    D3DFMT_A16B16G16R16F = 113,
+    D3DFMT_R32F = 114,
+    D3DFMT_G32R32F = 115,
+    D3DFMT_A32B32G32R32F = 116,
+    D3DFMT_CxV8U8 = 117,
+    D3DFMT_A1 = 118,
+    D3DFMT_A2B10G10R10_XR_BIAS = 119,
+    D3DFMT_BINARYBUFFER = 199,
+    D3DFMT_DF16 = MAKEFOURCC('D', 'F', '1', '6'),
+    D3DFMT_DF24 = MAKEFOURCC('D', 'F', '2', '4'),
+    D3DFMT_INTZ = MAKEFOURCC('I', 'N', 'T', 'Z'),
+    D3DFMT_NULL = MAKEFOURCC('N', 'U', 'L', 'L'),
+    D3DFMT_NV11 = MAKEFOURCC('N', 'V', '1', '1'),
+    D3DFMT_NV12 = MAKEFOURCC('N', 'V', '1', '2'),
+    D3DFMT_Y210 = MAKEFOURCC('Y', '2', '1', '0'),
+    D3DFMT_Y216 = MAKEFOURCC('Y', '2', '1', '6'),
+    D3DFMT_Y410 = MAKEFOURCC('Y', '4', '1', '0')
+} D3DFORMAT;
+
+typedef enum _D3DLIGHTTYPE {
+    D3DLIGHT_POINT = 1,
+    D3DLIGHT_SPOT = 2,
+    D3DLIGHT_DIRECTIONAL = 3
+} D3DLIGHTTYPE;
+
+typedef enum _D3DMATERIALCOLORSOURCE {
+    D3DMCS_MATERIAL = 0,
+    D3DMCS_COLOR1 = 1,
+    D3DMCS_COLOR2 = 2
+} D3DMATERIALCOLORSOURCE;
+
+typedef enum _D3DMULTISAMPLE_TYPE {
+    D3DMULTISAMPLE_NONE = 0,
+    D3DMULTISAMPLE_NONMASKABLE = 1,
+    D3DMULTISAMPLE_2_SAMPLES = 2,
+    D3DMULTISAMPLE_3_SAMPLES = 3,
+    D3DMULTISAMPLE_4_SAMPLES = 4,
+    D3DMULTISAMPLE_5_SAMPLES = 5,
+    D3DMULTISAMPLE_6_SAMPLES = 6,
+    D3DMULTISAMPLE_7_SAMPLES = 7,
+    D3DMULTISAMPLE_8_SAMPLES = 8,
+    D3DMULTISAMPLE_9_SAMPLES = 9,
+    D3DMULTISAMPLE_10_SAMPLES = 10,
+    D3DMULTISAMPLE_11_SAMPLES = 11,
+    D3DMULTISAMPLE_12_SAMPLES = 12,
+    D3DMULTISAMPLE_13_SAMPLES = 13,
+    D3DMULTISAMPLE_14_SAMPLES = 14,
+    D3DMULTISAMPLE_15_SAMPLES = 15,
+    D3DMULTISAMPLE_16_SAMPLES = 16
+} D3DMULTISAMPLE_TYPE;
+
+typedef enum _D3DPATCHEDGESTYLE {
+   D3DPATCHEDGE_DISCRETE = 0,
+   D3DPATCHEDGE_CONTINUOUS = 1
+} D3DPATCHEDGESTYLE;
+
+typedef enum _D3DPOOL {
+    D3DPOOL_DEFAULT = 0,
+    D3DPOOL_MANAGED = 1,
+    D3DPOOL_SYSTEMMEM = 2,
+    D3DPOOL_SCRATCH = 3
+} D3DPOOL;
+
+typedef enum _D3DPRIMITIVETYPE {
+    D3DPT_POINTLIST = 1,
+    D3DPT_LINELIST = 2,
+    D3DPT_LINESTRIP = 3,
+    D3DPT_TRIANGLELIST = 4,
+    D3DPT_TRIANGLESTRIP = 5,
+    D3DPT_TRIANGLEFAN = 6
+} D3DPRIMITIVETYPE;
+
+typedef enum _D3DQUERYTYPE {
+    D3DQUERYTYPE_VCACHE = 4,
+    D3DQUERYTYPE_RESOURCEMANAGER = 5,
+    D3DQUERYTYPE_VERTEXSTATS = 6,
+    D3DQUERYTYPE_EVENT = 8,
+    D3DQUERYTYPE_OCCLUSION = 9,
+    D3DQUERYTYPE_TIMESTAMP = 10,
+    D3DQUERYTYPE_TIMESTAMPDISJOINT = 11,
+    D3DQUERYTYPE_TIMESTAMPFREQ = 12,
+    D3DQUERYTYPE_PIPELINETIMINGS = 13,
+    D3DQUERYTYPE_INTERFACETIMINGS = 14,
+    D3DQUERYTYPE_VERTEXTIMINGS = 15,
+    D3DQUERYTYPE_PIXELTIMINGS = 16,
+    D3DQUERYTYPE_BANDWIDTHTIMINGS = 17,
+    D3DQUERYTYPE_CACHEUTILIZATION = 18,
+    D3DQUERYTYPE_MEMORYPRESSURE = 19
+} D3DQUERYTYPE;
+
+#define D3DISSUE_BEGIN   (1 << 1)
+#define D3DISSUE_END     (1 << 0)
+#define D3DGETDATA_FLUSH (1 << 0)
+
+
+typedef enum _D3DRENDERSTATETYPE {
+    D3DRS_ZENABLE = 7,
+    D3DRS_FILLMODE = 8,
+    D3DRS_SHADEMODE = 9,
+    D3DRS_ZWRITEENABLE = 14,
+    D3DRS_ALPHATESTENABLE = 15,
+    D3DRS_LASTPIXEL = 16,
+    D3DRS_SRCBLEND = 19,
+    D3DRS_DESTBLEND = 20,
+    D3DRS_CULLMODE = 22,
+    D3DRS_ZFUNC = 23,
+    D3DRS_ALPHAREF = 24,
+    D3DRS_ALPHAFUNC = 25,
+    D3DRS_DITHERENABLE = 26,
+    D3DRS_ALPHABLENDENABLE = 27,
+    D3DRS_FOGENABLE = 28,
+    D3DRS_SPECULARENABLE = 29,
+    D3DRS_FOGCOLOR = 34,
+    D3DRS_FOGTABLEMODE = 35,
+    D3DRS_FOGSTART = 36,
+    D3DRS_FOGEND = 37,
+    D3DRS_FOGDENSITY = 38,
+    D3DRS_RANGEFOGENABLE = 48,
+    D3DRS_STENCILENABLE = 52,
+    D3DRS_STENCILFAIL = 53,
+    D3DRS_STENCILZFAIL = 54,
+    D3DRS_STENCILPASS = 55,
+    D3DRS_STENCILFUNC = 56,
+    D3DRS_STENCILREF = 57,
+    D3DRS_STENCILMASK = 58,
+    D3DRS_STENCILWRITEMASK = 59,
+    D3DRS_TEXTUREFACTOR = 60,
+    D3DRS_WRAP0 = 128,
+    D3DRS_WRAP1 = 129,
+    D3DRS_WRAP2 = 130,
+    D3DRS_WRAP3 = 131,
+    D3DRS_WRAP4 = 132,
+    D3DRS_WRAP5 = 133,
+    D3DRS_WRAP6 = 134,
+    D3DRS_WRAP7 = 135,
+    D3DRS_CLIPPING = 136,
+    D3DRS_LIGHTING = 137,
+    D3DRS_AMBIENT = 139,
+    D3DRS_FOGVERTEXMODE = 140,
+    D3DRS_COLORVERTEX = 141,
+    D3DRS_LOCALVIEWER = 142,
+    D3DRS_NORMALIZENORMALS = 143,
+    D3DRS_DIFFUSEMATERIALSOURCE = 145,
+    D3DRS_SPECULARMATERIALSOURCE = 146,
+    D3DRS_AMBIENTMATERIALSOURCE = 147,
+    D3DRS_EMISSIVEMATERIALSOURCE = 148,
+    D3DRS_VERTEXBLEND = 151,
+    D3DRS_CLIPPLANEENABLE = 152,
+    D3DRS_POINTSIZE = 154,
+    D3DRS_POINTSIZE_MIN = 155,
+    D3DRS_POINTSPRITEENABLE = 156,
+    D3DRS_POINTSCALEENABLE = 157,
+    D3DRS_POINTSCALE_A = 158,
+    D3DRS_POINTSCALE_B = 159,
+    D3DRS_POINTSCALE_C = 160,
+    D3DRS_MULTISAMPLEANTIALIAS = 161,
+    D3DRS_MULTISAMPLEMASK = 162,
+    D3DRS_PATCHEDGESTYLE = 163,
+    D3DRS_DEBUGMONITORTOKEN = 165,
+    D3DRS_POINTSIZE_MAX = 166,
+    D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
+    D3DRS_COLORWRITEENABLE = 168,
+    D3DRS_TWEENFACTOR = 170,
+    D3DRS_BLENDOP = 171,
+    D3DRS_POSITIONDEGREE = 172,
+    D3DRS_NORMALDEGREE = 173,
+    D3DRS_SCISSORTESTENABLE = 174,
+    D3DRS_SLOPESCALEDEPTHBIAS = 175,
+    D3DRS_ANTIALIASEDLINEENABLE = 176,
+    D3DRS_MINTESSELLATIONLEVEL = 178,
+    D3DRS_MAXTESSELLATIONLEVEL = 179,
+    D3DRS_ADAPTIVETESS_X = 180,
+    D3DRS_ADAPTIVETESS_Y = 181,
+    D3DRS_ADAPTIVETESS_Z = 182,
+    D3DRS_ADAPTIVETESS_W = 183,
+    D3DRS_ENABLEADAPTIVETESSELLATION = 184,
+    D3DRS_TWOSIDEDSTENCILMODE = 185,
+    D3DRS_CCW_STENCILFAIL = 186,
+    D3DRS_CCW_STENCILZFAIL = 187,
+    D3DRS_CCW_STENCILPASS = 188,
+    D3DRS_CCW_STENCILFUNC = 189,
+    D3DRS_COLORWRITEENABLE1 = 190,
+    D3DRS_COLORWRITEENABLE2 = 191,
+    D3DRS_COLORWRITEENABLE3 = 192,
+    D3DRS_BLENDFACTOR = 193,
+    D3DRS_SRGBWRITEENABLE = 194,
+    D3DRS_DEPTHBIAS = 195,
+    D3DRS_WRAP8 = 198,
+    D3DRS_WRAP9 = 199,
+    D3DRS_WRAP10 = 200,
+    D3DRS_WRAP11 = 201,
+    D3DRS_WRAP12 = 202,
+    D3DRS_WRAP13 = 203,
+    D3DRS_WRAP14 = 204,
+    D3DRS_WRAP15 = 205,
+    D3DRS_SEPARATEALPHABLENDENABLE = 206,
+    D3DRS_SRCBLENDALPHA = 207,
+    D3DRS_DESTBLENDALPHA = 208,
+    D3DRS_BLENDOPALPHA = 209
+} D3DRENDERSTATETYPE;
+
+typedef enum _D3DRESOURCETYPE {
+    D3DRTYPE_SURFACE = 1,
+    D3DRTYPE_VOLUME = 2,
+    D3DRTYPE_TEXTURE = 3,
+    D3DRTYPE_VOLUMETEXTURE = 4,
+    D3DRTYPE_CUBETEXTURE = 5,
+    D3DRTYPE_VERTEXBUFFER = 6,
+    D3DRTYPE_INDEXBUFFER = 7
+} D3DRESOURCETYPE;
+#define D3DRTYPECOUNT (D3DRTYPE_INDEXBUFFER+1)
+
+typedef enum _D3DSAMPLERSTATETYPE {
+    D3DSAMP_ADDRESSU = 1,
+    D3DSAMP_ADDRESSV = 2,
+    D3DSAMP_ADDRESSW = 3,
+    D3DSAMP_BORDERCOLOR = 4,
+    D3DSAMP_MAGFILTER = 5,
+    D3DSAMP_MINFILTER = 6,
+    D3DSAMP_MIPFILTER = 7,
+    D3DSAMP_MIPMAPLODBIAS = 8,
+    D3DSAMP_MAXMIPLEVEL = 9,
+    D3DSAMP_MAXANISOTROPY = 10,
+    D3DSAMP_SRGBTEXTURE = 11,
+    D3DSAMP_ELEMENTINDEX = 12,
+    D3DSAMP_DMAPOFFSET = 13
+} D3DSAMPLERSTATETYPE;
+
+typedef enum _D3DSAMPLER_TEXTURE_TYPE {
+    D3DSTT_UNKNOWN = 0<<27,
+    D3DSTT_1D = 1<<27,
+    D3DSTT_2D = 2<<27,
+    D3DSTT_CUBE = 3<<27,
+    D3DSTT_VOLUME = 4<<27
+} D3DSAMPLER_TEXTURE_TYPE;
+
+typedef enum _D3DSHADEMODE {
+    D3DSHADE_FLAT = 1,
+    D3DSHADE_GOURAUD = 2,
+    D3DSHADE_PHONG = 3
+} D3DSHADEMODE;
+
+typedef enum _D3DSHADER_ADDRESSMODE_TYPE {
+    D3DSHADER_ADDRMODE_ABSOLUTE = 0<<13,
+    D3DSHADER_ADDRMODE_RELATIVE = 1<<13
+} D3DSHADER_ADDRESSMODE_TYPE;
+
+typedef enum _D3DSHADER_COMPARISON {
+    D3DSPC_RESERVED0 = 0,
+    D3DSPC_GT = 1,
+    D3DSPC_EQ = 2,
+    D3DSPC_GE = 3,
+    D3DSPC_LT = 4,
+    D3DSPC_NE = 5,
+    D3DSPC_LE = 6,
+    D3DSPC_RESERVED1 = 7
+} D3DSHADER_COMPARISON;
+
+#define D3DDP_MAXTEXCOORD   8
+
+#define D3DSI_OPCODE_MASK       0x0000FFFF
+#define D3DSI_INSTLENGTH_MASK   0x0F000000
+#define D3DSI_INSTLENGTH_SHIFT  24
+
+typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE {
+    D3DSIO_NOP = 0,
+    D3DSIO_MOV = 1,
+    D3DSIO_ADD = 2,
+    D3DSIO_SUB = 3,
+    D3DSIO_MAD = 4,
+    D3DSIO_MUL = 5,
+    D3DSIO_RCP = 6,
+    D3DSIO_RSQ = 7,
+    D3DSIO_DP3 = 8,
+    D3DSIO_DP4 = 9,
+    D3DSIO_MIN = 10,
+    D3DSIO_MAX = 11,
+    D3DSIO_SLT = 12,
+    D3DSIO_SGE = 13,
+    D3DSIO_EXP = 14,
+    D3DSIO_LOG = 15,
+    D3DSIO_LIT = 16,
+    D3DSIO_DST = 17,
+    D3DSIO_LRP = 18,
+    D3DSIO_FRC = 19,
+    D3DSIO_M4x4 = 20,
+    D3DSIO_M4x3 = 21,
+    D3DSIO_M3x4 = 22,
+    D3DSIO_M3x3 = 23,
+    D3DSIO_M3x2 = 24,
+    D3DSIO_CALL = 25,
+    D3DSIO_CALLNZ = 26,
+    D3DSIO_LOOP = 27,
+    D3DSIO_RET = 28,
+    D3DSIO_ENDLOOP = 29,
+    D3DSIO_LABEL = 30,
+    D3DSIO_DCL = 31,
+    D3DSIO_POW = 32,
+    D3DSIO_CRS = 33,
+    D3DSIO_SGN = 34,
+    D3DSIO_ABS = 35,
+    D3DSIO_NRM = 36,
+    D3DSIO_SINCOS = 37,
+    D3DSIO_REP = 38,
+    D3DSIO_ENDREP = 39,
+    D3DSIO_IF = 40,
+    D3DSIO_IFC = 41,
+    D3DSIO_ELSE = 42,
+    D3DSIO_ENDIF = 43,
+    D3DSIO_BREAK = 44,
+    D3DSIO_BREAKC = 45,
+    D3DSIO_MOVA = 46,
+    D3DSIO_DEFB = 47,
+    D3DSIO_DEFI = 48,
+    D3DSIO_TEXCOORD = 64,
+    D3DSIO_TEXKILL = 65,
+    D3DSIO_TEX = 66,
+    D3DSIO_TEXBEM = 67,
+    D3DSIO_TEXBEML = 68,
+    D3DSIO_TEXREG2AR = 69,
+    D3DSIO_TEXREG2GB = 70,
+    D3DSIO_TEXM3x2PAD = 71,
+    D3DSIO_TEXM3x2TEX = 72,
+    D3DSIO_TEXM3x3PAD = 73,
+    D3DSIO_TEXM3x3TEX = 74,
+    D3DSIO_RESERVED0 = 75,
+    D3DSIO_TEXM3x3SPEC = 76,
+    D3DSIO_TEXM3x3VSPEC = 77,
+    D3DSIO_EXPP = 78,
+    D3DSIO_LOGP = 79,
+    D3DSIO_CND = 80,
+    D3DSIO_DEF = 81,
+    D3DSIO_TEXREG2RGB = 82,
+    D3DSIO_TEXDP3TEX = 83,
+    D3DSIO_TEXM3x2DEPTH = 84,
+    D3DSIO_TEXDP3 = 85,
+    D3DSIO_TEXM3x3 = 86,
+    D3DSIO_TEXDEPTH = 87,
+    D3DSIO_CMP = 88,
+    D3DSIO_BEM = 89,
+    D3DSIO_DP2ADD = 90,
+    D3DSIO_DSX = 91,
+    D3DSIO_DSY = 92,
+    D3DSIO_TEXLDD = 93,
+    D3DSIO_SETP = 94,
+    D3DSIO_TEXLDL = 95,
+    D3DSIO_BREAKP = 96,
+    D3DSIO_PHASE = 0xFFFD,
+    D3DSIO_COMMENT = 0xFFFE,
+    D3DSIO_END = 0xFFFF
+} D3DSHADER_INSTRUCTION_OPCODE_TYPE;
+
+#define D3DSI_COISSUE 0x40000000
+
+#define D3DSP_DCL_USAGE_SHIFT 0
+#define D3DSP_DCL_USAGE_MASK  0x0000000f
+
+#define D3DSP_DCL_USAGEINDEX_SHIFT 16
+#define D3DSP_DCL_USAGEINDEX_MASK  0x000f0000
+
+#define D3DSP_TEXTURETYPE_SHIFT 27
+#define D3DSP_TEXTURETYPE_MASK  0x78000000
+
+#define D3DSP_REGNUM_MASK       0x000007FF
+
+#define D3DSP_WRITEMASK_0       0x00010000
+#define D3DSP_WRITEMASK_1       0x00020000
+#define D3DSP_WRITEMASK_2       0x00040000
+#define D3DSP_WRITEMASK_3       0x00080000
+#define D3DSP_WRITEMASK_ALL     0x000F0000
+
+#define D3DSP_DSTMOD_SHIFT      20
+#define D3DSP_DSTMOD_MASK       (0xF << D3DSP_DSTMOD_SHIFT)
+
+typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE {
+    D3DSPDM_NONE             = 0 << D3DSP_DSTMOD_SHIFT,
+    D3DSPDM_SATURATE         = 1 << D3DSP_DSTMOD_SHIFT,
+    D3DSPDM_PARTIALPRECISION = 2 << D3DSP_DSTMOD_SHIFT,
+    D3DSPDM_MSAMPCENTROID    = 4 << D3DSP_DSTMOD_SHIFT,
+    D3DSPDM_FORCE_DWORD  = 0x7FFFFFFF
+} D3DSHADER_PARAM_DSTMOD_TYPE;
+
+#define D3DSP_DSTSHIFT_SHIFT     24
+#define D3DSP_DSTSHIFT_MASK      (0xF << D3DSP_DSTSHIFT_SHIFT)
+
+#define D3DSP_REGTYPE_SHIFT      28
+#define D3DSP_REGTYPE_SHIFT2     8
+#define D3DSP_REGTYPE_MASK       (0x7 << D3DSP_REGTYPE_SHIFT)
+#define D3DSP_REGTYPE_MASK2      0x00001800
+
+typedef enum _D3DSHADER_MISCTYPE_OFFSETS {
+    D3DSMO_POSITION = 0,
+    D3DSMO_FACE = 1
+} D3DSHADER_MISCTYPE_OFFSETS;
+
+typedef enum _D3DSHADER_PARAM_REGISTER_TYPE {
+    D3DSPR_TEMP = 0,
+    D3DSPR_INPUT = 1,
+    D3DSPR_CONST = 2,
+    D3DSPR_ADDR = 3,
+    D3DSPR_TEXTURE = 3,
+    D3DSPR_RASTOUT = 4,
+    D3DSPR_ATTROUT = 5,
+    D3DSPR_TEXCRDOUT = 6,
+    D3DSPR_OUTPUT = 6,
+    D3DSPR_CONSTINT = 7,
+    D3DSPR_COLOROUT = 8,
+    D3DSPR_DEPTHOUT = 9,
+    D3DSPR_SAMPLER = 10,
+    D3DSPR_CONST2 = 11,
+    D3DSPR_CONST3 = 12,
+    D3DSPR_CONST4 = 13,
+    D3DSPR_CONSTBOOL = 14,
+    D3DSPR_LOOP = 15,
+    D3DSPR_TEMPFLOAT16 = 16,
+    D3DSPR_MISCTYPE = 17,
+    D3DSPR_LABEL = 18,
+    D3DSPR_PREDICATE = 19
+} D3DSHADER_PARAM_REGISTER_TYPE;
+
+#define D3DSP_SWIZZLE_SHIFT      16
+#define D3DSP_SWIZZLE_MASK       (0xFF << D3DSP_SWIZZLE_SHIFT)
+
+#define D3DSP_NOSWIZZLE \
+    ((0 << (D3DSP_SWIZZLE_SHIFT + 0)) | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | (3 << (D3DSP_SWIZZLE_SHIFT + 6)))
+
+#define D3DSP_SRCMOD_SHIFT      24
+#define D3DSP_SRCMOD_MASK       (0xF << D3DSP_SRCMOD_SHIFT)
+
+typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE {
+    D3DSPSM_NONE = 0<<24,
+    D3DSPSM_NEG = 1<<24,
+    D3DSPSM_BIAS = 2<<24,
+    D3DSPSM_BIASNEG = 3<<24,
+    D3DSPSM_SIGN = 4<<24,
+    D3DSPSM_SIGNNEG = 5<<24,
+    D3DSPSM_COMP = 6<<24,
+    D3DSPSM_X2 = 7<<24,
+    D3DSPSM_X2NEG = 8<<24,
+    D3DSPSM_DZ = 9<<24,
+    D3DSPSM_DW = 10<<24,
+    D3DSPSM_ABS = 11<<24,
+    D3DSPSM_ABSNEG = 12<<24,
+    D3DSPSM_NOT = 13<<24
+} D3DSHADER_PARAM_SRCMOD_TYPE;
+
+#define D3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor))
+#define D3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor))
+#define D3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF)
+#define D3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF)
+
+#define D3DSI_COMMENTSIZE_SHIFT 16
+#define D3DSI_COMMENTSIZE_MASK (0x7FFF << D3DSI_COMMENTSIZE_SHIFT)
+
+typedef enum _D3DSTATEBLOCKTYPE {
+    D3DSBT_ALL = 1,
+    D3DSBT_PIXELSTATE = 2,
+    D3DSBT_VERTEXSTATE = 3
+} D3DSTATEBLOCKTYPE;
+
+typedef enum _D3DSTENCILOP {
+    D3DSTENCILOP_KEEP = 1,
+    D3DSTENCILOP_ZERO = 2,
+    D3DSTENCILOP_REPLACE = 3,
+    D3DSTENCILOP_INCRSAT = 4,
+    D3DSTENCILOP_DECRSAT = 5,
+    D3DSTENCILOP_INVERT = 6,
+    D3DSTENCILOP_INCR = 7,
+    D3DSTENCILOP_DECR = 8
+} D3DSTENCILOP;
+
+typedef enum _D3DSWAPEFFECT {
+    D3DSWAPEFFECT_DISCARD = 1,
+    D3DSWAPEFFECT_FLIP = 2,
+    D3DSWAPEFFECT_COPY = 3,
+    D3DSWAPEFFECT_OVERLAY = 4,
+    D3DSWAPEFFECT_FLIPEX = 5
+} D3DSWAPEFFECT;
+
+typedef enum _D3DTEXTUREADDRESS {
+    D3DTADDRESS_WRAP = 1,
+    D3DTADDRESS_MIRROR = 2,
+    D3DTADDRESS_CLAMP = 3,
+    D3DTADDRESS_BORDER = 4,
+    D3DTADDRESS_MIRRORONCE = 5
+} D3DTEXTUREADDRESS;
+
+typedef enum _D3DTEXTUREFILTERTYPE {
+    D3DTEXF_NONE = 0,
+    D3DTEXF_POINT = 1,
+    D3DTEXF_LINEAR = 2,
+    D3DTEXF_ANISOTROPIC = 3,
+    D3DTEXF_PYRAMIDALQUAD = 6,
+    D3DTEXF_GAUSSIANQUAD = 7,
+    D3DTEXF_CONVOLUTIONMONO = 8
+} D3DTEXTUREFILTERTYPE;
+
+typedef enum _D3DTEXTUREOP {
+    D3DTOP_DISABLE = 1,
+    D3DTOP_SELECTARG1 = 2,
+    D3DTOP_SELECTARG2 = 3,
+    D3DTOP_MODULATE = 4,
+    D3DTOP_MODULATE2X = 5,
+    D3DTOP_MODULATE4X = 6,
+    D3DTOP_ADD = 7,
+    D3DTOP_ADDSIGNED = 8,
+    D3DTOP_ADDSIGNED2X = 9,
+    D3DTOP_SUBTRACT = 10,
+    D3DTOP_ADDSMOOTH = 11,
+    D3DTOP_BLENDDIFFUSEALPHA = 12,
+    D3DTOP_BLENDTEXTUREALPHA = 13,
+    D3DTOP_BLENDFACTORALPHA = 14,
+    D3DTOP_BLENDTEXTUREALPHAPM = 15,
+    D3DTOP_BLENDCURRENTALPHA = 16,
+    D3DTOP_PREMODULATE = 17,
+    D3DTOP_MODULATEALPHA_ADDCOLOR = 18,
+    D3DTOP_MODULATECOLOR_ADDALPHA = 19,
+    D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
+    D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
+    D3DTOP_BUMPENVMAP = 22,
+    D3DTOP_BUMPENVMAPLUMINANCE = 23,
+    D3DTOP_DOTPRODUCT3 = 24,
+    D3DTOP_MULTIPLYADD = 25,
+    D3DTOP_LERP = 26
+} D3DTEXTUREOP;
+
+typedef enum _D3DTEXTURESTAGESTATETYPE {
+    D3DTSS_COLOROP = 1,
+    D3DTSS_COLORARG1 = 2,
+    D3DTSS_COLORARG2 = 3,
+    D3DTSS_ALPHAOP = 4,
+    D3DTSS_ALPHAARG1 = 5,
+    D3DTSS_ALPHAARG2 = 6,
+    D3DTSS_BUMPENVMAT00 = 7,
+    D3DTSS_BUMPENVMAT01 = 8,
+    D3DTSS_BUMPENVMAT10 = 9,
+    D3DTSS_BUMPENVMAT11 = 10,
+    D3DTSS_TEXCOORDINDEX = 11,
+    D3DTSS_BUMPENVLSCALE = 22,
+    D3DTSS_BUMPENVLOFFSET = 23,
+    D3DTSS_TEXTURETRANSFORMFLAGS = 24,
+    D3DTSS_COLORARG0 = 26,
+    D3DTSS_ALPHAARG0 = 27,
+    D3DTSS_RESULTARG = 28,
+    D3DTSS_CONSTANT = 32
+} D3DTEXTURESTAGESTATETYPE;
+
+/* MSDN has this in d3d9caps.h, but it should be here */
+#define D3DTSS_TCI_PASSTHRU                       0x00000
+#define D3DTSS_TCI_CAMERASPACENORMAL              0x10000
+#define D3DTSS_TCI_CAMERASPACEPOSITION            0x20000
+#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR    0x30000
+#define D3DTSS_TCI_SPHEREMAP                      0x40000
+
+typedef enum _D3DTEXTURETRANSFORMFLAGS {
+    D3DTTFF_DISABLE = 0,
+    D3DTTFF_COUNT1 = 1,
+    D3DTTFF_COUNT2 = 2,
+    D3DTTFF_COUNT3 = 3,
+    D3DTTFF_COUNT4 = 4,
+    D3DTTFF_PROJECTED = 256
+} D3DTEXTURETRANSFORMFLAGS;
+
+typedef enum _D3DTRANSFORMSTATETYPE {
+    D3DTS_VIEW = 2,
+    D3DTS_PROJECTION = 3,
+    D3DTS_TEXTURE0 = 16,
+    D3DTS_TEXTURE1 = 17,
+    D3DTS_TEXTURE2 = 18,
+    D3DTS_TEXTURE3 = 19,
+    D3DTS_TEXTURE4 = 20,
+    D3DTS_TEXTURE5 = 21,
+    D3DTS_TEXTURE6 = 22,
+    D3DTS_TEXTURE7 = 23
+} D3DTRANSFORMSTATETYPE;
+
+#define D3DDMAPSAMPLER 256
+#define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1)
+#define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2)
+#define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3)
+#define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4)
+
+#define D3DTS_WORLD  D3DTS_WORLDMATRIX(0)
+#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
+#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
+#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
+#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
+
+typedef enum _D3DVERTEXBLENDFLAGS {
+    D3DVBF_DISABLE = 0,
+    D3DVBF_1WEIGHTS = 1,
+    D3DVBF_2WEIGHTS = 2,
+    D3DVBF_3WEIGHTS = 3,
+    D3DVBF_TWEENING = 255,
+    D3DVBF_0WEIGHTS = 256
+} D3DVERTEXBLENDFLAGS;
+
+typedef enum _D3DVS_ADDRESSMODE_TYPE {
+    D3DVS_ADDRMODE_ABSOLUTE = 0<<13,
+    D3DVS_ADDRMODE_RELATIVE = 1<<13
+} D3DVS_ADDRESSMODE_TYPE;
+
+typedef enum _D3DVS_RASTOUT_OFFSETS {
+    D3DSRO_POSITION = 0,
+    D3DSRO_FOG = 1,
+    D3DSRO_POINT_SIZE = 2
+} D3DVS_RASTOUT_OFFSETS;
+
+typedef enum _D3DZBUFFERTYPE {
+    D3DZB_FALSE = 0,
+    D3DZB_TRUE = 1,
+    D3DZB_USEW = 2
+} D3DZBUFFERTYPE;
+
+/*****************************************************************************
+ * Structs                                                                   *
+ *****************************************************************************/
+typedef struct D3DDISPLAYMODEEX {
+    UINT Size;
+    UINT Width;
+    UINT Height;
+    UINT RefreshRate;
+    D3DFORMAT Format;
+    D3DSCANLINEORDERING ScanLineOrdering;
+} D3DDISPLAYMODEEX, *PD3DDISPLAYMODEEX, *LPD3DDISPLAYMODEEX;
+
+typedef struct D3DDISPLAYMODEFILTER {
+    UINT Size;
+    D3DFORMAT Format;
+    D3DSCANLINEORDERING ScanLineOrdering;
+} D3DDISPLAYMODEFILTER, *PD3DDISPLAYMODEFILTER, *LPD3DDISPLAYMODEFILTER;
+
+typedef struct _D3D_OMAC {
+    BYTE Omac[16];
+} D3D_OMAC, *PD3D_OMAC, *LPD3D_OMAC;
+
+typedef struct _D3DADAPTER_IDENTIFIER9 {
+    char Driver[512];
+    char Description[512];
+    char DeviceName[32];
+    DWORD DriverVersionLowPart;
+    DWORD DriverVersionHighPart;
+    DWORD VendorId;
+    DWORD DeviceId;
+    DWORD SubSysId;
+    DWORD Revision;
+    GUID DeviceIdentifier;
+    DWORD WHQLLevel;
+} D3DADAPTER_IDENTIFIER9, *PD3DADAPTER_IDENTIFIER9, *LPD3DADAPTER_IDENTIFIER9;
+
+typedef struct _D3DAES_CTR_IV {
+    UINT64 IV;
+    UINT64 Count;
+} D3DAES_CTR_IV, *PD3DAES_CTR_IV, *LPD3DAES_CTR_IV;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT {
+    D3D_OMAC omac;
+    GUID ConfigureType;
+    HANDLE hChannel;
+    UINT SequenceNumber;
+} D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, *PD3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION {
+    D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
+    HANDLE DXVA2DecodeHandle;
+    HANDLE CryptoSessionHandle;
+    HANDLE DeviceHandle;
+} D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION, *PD3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE {
+    D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
+    UINT StartSequenceQuery;
+    UINT StartSequenceConfigure;
+} D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS {
+    union {
+        struct {
+            UINT ProtectionEnabled : 1;
+            UINT OverlayOrFullscreenRequired : 1;
+            UINT Reserved : 30;
+        };
+        UINT Value;
+    };
+} D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, *PD3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, *LPD3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION {
+    D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
+    D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS Protections;
+} D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE {
+    D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
+    D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentiferType;
+    HANDLE ProcessHandle;
+    BOOL AllowAccess;
+} D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE, *PD3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION {
+    D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
+    GUID EncryptionGuid;
+} D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT {
+    D3D_OMAC omac;
+    GUID ConfigureType;
+    HANDLE hChannel;
+    UINT SequenceNumber;
+    HRESULT ReturnCode;
+} D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_INPUT {
+    GUID QueryType;
+    HANDLE hChannel;
+    UINT SequenceNumber;
+} D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERY_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERY_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT {
+    D3D_OMAC omac;
+    GUID QueryType;
+    HANDLE hChannel;
+    UINT SequenceNumber;
+    HRESULT ReturnCode;
+} D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    D3DAUTHENTICATEDCHANNELTYPE ChannelType;
+} D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
+    HANDLE DXVA2DecodeHandle;
+} D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    HANDLE DXVA2DecodeHandle;
+    HANDLE CryptoSessionHandle;
+    HANDLE DeviceHandle;
+} D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    HANDLE DeviceHandle;
+} D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    UINT NumEncryptionGuids;
+} D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
+    UINT EncryptionGuidIndex;
+} D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    UINT EncryptionGuidIndex;
+    GUID EncryptionGuid;
+} D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    D3DBUSTYPE BusType;
+    BOOL bAccessibleInContiguousBlocks;
+    BOOL bAccessibleInNonContiguousBlocks;
+} D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
+    HANDLE DeviceHandle;
+    HANDLE CryptoSessionHandle;
+} D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    HANDLE DeviceHandle;
+    HANDLE CryptoSessionHandle;
+    UINT NumOutputIDs;
+} D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
+    HANDLE DeviceHandle;
+    HANDLE CryptoSessionHandle;
+    UINT OutputIDIndex;
+} D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    HANDLE DeviceHandle;
+    HANDLE CryptoSessionHandle;
+    UINT OutputIDIndex;
+    UINT64 OutputID;
+} D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS ProtectionFlags;
+} D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    UINT NumRestrictedSharedResourceProcesses;
+} D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
+    UINT ProcessIndex;
+} D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    UINT ProcessIndex;
+    D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentifer;
+    HANDLE ProcessHandle;
+} D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    GUID EncryptionGuid;
+} D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT;
+
+typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT {
+    D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
+    UINT NumUnrestrictedProtectedSharedResources;
+} D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT;
+
+typedef struct _D3DBOX {
+    UINT Left;
+    UINT Top;
+    UINT Right;
+    UINT Bottom;
+    UINT Front;
+    UINT Back;
+} D3DBOX, *PD3DBOX, *LPD3DBOX;
+
+typedef struct _D3DCLIPSTATUS9 {
+    DWORD ClipUnion;
+    DWORD ClipIntersection;
+} D3DCLIPSTATUS9, *PD3DCLIPSTATUS9, *LPD3DCLIPSTATUS9;
+
+typedef struct _D3DCOLORVALUE {
+    float r;
+    float g;
+    float b;
+    float a;
+} D3DCOLORVALUE, *PD3DCOLORVALUE, *LPD3DCOLORVALUE;
+
+typedef struct _D3DCOMPOSERECTDESC {
+    USHORT X, Y;
+    USHORT Width, Height;
+} D3DCOMPOSERECTDESC, *PD3DCOMPOSERECTDESC, *LPD3DCOMPOSERECTDESC;
+
+typedef struct _D3DCOMPOSERECTDESTINATION {
+    USHORT SrcRectIndex;
+    USHORT Reserved;
+    SHORT X, Y;
+} D3DCOMPOSERECTDESTINATION, *PD3DCOMPOSERECTDESTINATION, *LPD3DCOMPOSERECTDESTINATION;
+
+typedef struct _D3DDEVICE_CREATION_PARAMETERS {
+    UINT AdapterOrdinal;
+    D3DDEVTYPE DeviceType;
+    HWND hFocusWindow;
+    DWORD BehaviorFlags;
+} D3DDEVICE_CREATION_PARAMETERS, *PD3DDEVICE_CREATION_PARAMETERS, *LPD3DDEVICE_CREATION_PARAMETERS;
+
+typedef struct _D3DDEVINFO_D3D9BANDWIDTHTIMINGS {
+    FLOAT MaxBandwidthUtilized;
+    FLOAT FrontEndUploadMemoryUtilizedPercent;
+    FLOAT VertexRateUtilizedPercent;
+    FLOAT TriangleSetupRateUtilizedPercent;
+    FLOAT FillRateUtilizedPercent;
+} D3DDEVINFO_D3D9BANDWIDTHTIMINGS, *PD3DDEVINFO_D3D9BANDWIDTHTIMINGS, *LPD3DDEVINFO_D3D9BANDWIDTHTIMINGS;
+
+typedef struct _D3DDEVINFO_D3D9CACHEUTILIZATION {
+    FLOAT TextureCacheHitRate;
+    FLOAT PostTransformVertexCacheHitRate;
+} D3DDEVINFO_D3D9CACHEUTILIZATION, *PD3DDEVINFO_D3D9CACHEUTILIZATION, *LPD3DDEVINFO_D3D9CACHEUTILIZATION;
+
+typedef struct _D3DDEVINFO_D3D9INTERFACETIMINGS {
+    FLOAT WaitingForGPUToUseApplicationResourceTimePercent;
+    FLOAT WaitingForGPUToAcceptMoreCommandsTimePercent;
+    FLOAT WaitingForGPUToStayWithinLatencyTimePercent;
+    FLOAT WaitingForGPUExclusiveResourceTimePercent;
+    FLOAT WaitingForGPUOtherTimePercent;
+} D3DDEVINFO_D3D9INTERFACETIMINGS, *PD3DDEVINFO_D3D9INTERFACETIMINGS, *LPD3DDEVINFO_D3D9INTERFACETIMINGS;
+
+typedef struct _D3DDEVINFO_D3D9PIPELINETIMINGS {
+    FLOAT VertexProcessingTimePercent;
+    FLOAT PixelProcessingTimePercent;
+    FLOAT OtherGPUProcessingTimePercent;
+    FLOAT GPUIdleTimePercent;
+} D3DDEVINFO_D3D9PIPELINETIMINGS, *PD3DDEVINFO_D3D9PIPELINETIMINGS, *LPD3DDEVINFO_D3D9PIPELINETIMINGS;
+
+typedef struct _D3DDEVINFO_D3D9STAGETIMINGS {
+    FLOAT MemoryProcessingPercent;
+    FLOAT ComputationProcessingPercent;
+} D3DDEVINFO_D3D9STAGETIMINGS, *PD3DDEVINFO_D3D9STAGETIMINGS, *LPD3DDEVINFO_D3D9STAGETIMINGS;
+
+typedef struct _D3DDEVINFO_D3DVERTEXSTATS {
+    DWORD NumRenderedTriangles;
+    DWORD NumExtraClippingTriangles;
+} D3DDEVINFO_D3DVERTEXSTATS, *LPD3DDEVINFO_D3DVERTEXSTATS;
+
+typedef struct _D3DRESOURCESTATS {
+    BOOL bThrashing;
+    DWORD ApproxBytesDownloaded;
+    DWORD NumEvicts;
+    DWORD NumVidCreates;
+    DWORD LastPri;
+    DWORD NumUsed;
+    DWORD NumUsedInVidMem;
+    DWORD WorkingSet;
+    DWORD WorkingSetBytes;
+    DWORD TotalManaged;
+    DWORD TotalBytes;
+} D3DRESOURCESTATS, *PD3DRESOURCESTATS, *LPD3DRESOURCESTATS;
+
+typedef struct _D3DDEVINFO_RESOURCEMANAGER {
+    D3DRESOURCESTATS stats[(D3DRTYPE_INDEXBUFFER+1)];
+} D3DDEVINFO_RESOURCEMANAGER, *LPD3DDEVINFO_RESOURCEMANAGER;
+
+typedef struct _D3DDEVINFO_VCACHE {
+    DWORD Pattern;
+    DWORD OptMethod;
+    DWORD CacheSize;
+    DWORD MagicNumber;
+} D3DDEVINFO_VCACHE, *LPD3DDEVINFO_VCACHE;
+
+typedef struct _D3DDISPLAYMODE {
+    UINT Width;
+    UINT Height;
+    UINT RefreshRate;
+    D3DFORMAT Format;
+} D3DDISPLAYMODE, *PD3DDISPLAYMODE, *LPD3DDISPLAYMODE;
+
+typedef struct _D3DENCRYPTED_BLOCK_INFO {
+    UINT NumEncryptedBytesAtBeginning;
+    UINT NumBytesInSkipPattern;
+    UINT NumBytesInEncryptPattern;
+} D3DENCRYPTED_BLOCK_INFO, *PD3DENCRYPTED_BLOCK_INFO, *LPD3DENCRYPTED_BLOCK_INFO;
+
+typedef struct _D3DGAMMARAMP {
+    WORD red [256];
+    WORD green[256];
+    WORD blue [256];
+} D3DGAMMARAMP, *PD3DGAMMARAMP, *LPD3DGAMMARAMP;
+
+typedef struct _D3DINDEXBUFFER_DESC {
+    D3DFORMAT Format;
+    D3DRESOURCETYPE Type;
+    DWORD Usage;
+    D3DPOOL Pool;
+    UINT Size;
+} D3DINDEXBUFFER_DESC, *PD3DINDEXBUFFER_DESC, *LPD3DINDEXBUFFER_DESC;
+
+typedef struct _D3DVECTOR {
+    float x;
+    float y;
+    float z;
+} D3DVECTOR, *PD3DVECTOR, *LPD3DVECTOR;
+
+typedef struct _D3DLIGHT9 {
+    D3DLIGHTTYPE Type;
+    D3DCOLORVALUE Diffuse;
+    D3DCOLORVALUE Specular;
+    D3DCOLORVALUE Ambient;
+    D3DVECTOR Position;
+    D3DVECTOR Direction;
+    float Range;
+    float Falloff;
+    float Attenuation0;
+    float Attenuation1;
+    float Attenuation2;
+    float Theta;
+    float Phi;
+} D3DLIGHT9, *PD3DLIGHT9, *LPD3DLIGHT9;
+
+typedef struct _D3DLOCKED_BOX {
+    INT RowPitch;
+    INT SlicePitch;
+    void* pBits;
+} D3DLOCKED_BOX, *PD3DLOCKED_BOX, *LPD3DLOCKED_BOX;
+
+typedef struct _D3DLOCKED_RECT {
+    INT Pitch;
+    void* pBits;
+} D3DLOCKED_RECT, *PD3DLOCKED_RECT, *LPD3DLOCKED_RECT;
+
+typedef struct _D3DMATERIAL9 {
+    D3DCOLORVALUE Diffuse;
+    D3DCOLORVALUE Ambient;
+    D3DCOLORVALUE Specular;
+    D3DCOLORVALUE Emissive;
+    float Power;
+} D3DMATERIAL9, *PD3DMATERIAL9, *LPD3DMATERIAL9;
+
+typedef struct _D3DMATRIX {
+    union {
+        struct {
+            float _11, _12, _13, _14;
+            float _21, _22, _23, _24;
+            float _31, _32, _33, _34;
+            float _41, _42, _43, _44;
+        };
+        float m[4][4];
+    };
+} D3DMATRIX, *PD3DMATRIX, *LPD3DMATRIX;
+
+typedef struct _D3DMEMORYPRESSURE {
+    UINT64 BytesEvictedFromProcess;
+    UINT64 SizeOfInefficientAllocation;
+    DWORD LevelOfEfficiency;
+} D3DMEMORYPRESSURE, *PD3DMEMORYPRESSURE, *LPD3DMEMORYPRESSURE;
+
+typedef struct _D3DPRESENTSTATS {
+    UINT PresentCount;
+    UINT PresentRefreshCount;
+    UINT SyncRefreshCount;
+    LARGE_INTEGER SyncQPCTime;
+    LARGE_INTEGER SyncGPUTime;
+} D3DPRESENTSTATS, *PD3DPRESENTSTATS, *LPD3DPRESENTSTATS;
+
+typedef struct _D3DPRESENT_PARAMETERS_ {
+    UINT BackBufferWidth;
+    UINT BackBufferHeight;
+    D3DFORMAT BackBufferFormat;
+    UINT BackBufferCount;
+    D3DMULTISAMPLE_TYPE MultiSampleType;
+    DWORD MultiSampleQuality;
+    D3DSWAPEFFECT SwapEffect;
+    HWND hDeviceWindow;
+    BOOL Windowed;
+    BOOL EnableAutoDepthStencil;
+    D3DFORMAT AutoDepthStencilFormat;
+    DWORD Flags;
+    UINT FullScreen_RefreshRateInHz;
+    UINT PresentationInterval;
+} D3DPRESENT_PARAMETERS, *PD3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS;
+
+typedef struct _D3DRANGE {
+    UINT Offset;
+    UINT Size;
+} D3DRANGE, *PD3DRANGE, *LPD3DRANGE;
+
+typedef struct _D3DRASTER_STATUS {
+    BOOL InVBlank;
+    UINT ScanLine;
+} D3DRASTER_STATUS, *PD3DRASTER_STATUS, *LPD3DRASTER_STATUS;
+
+typedef struct _D3DRECT {
+    LONG x1;
+    LONG y1;
+    LONG x2;
+    LONG y2;
+} D3DRECT, *PD3DRECT, *LPD3DRECT;
+
+typedef struct _D3DRECTPATCH_INFO {
+    UINT StartVertexOffsetWidth;
+    UINT StartVertexOffsetHeight;
+    UINT Width;
+    UINT Height;
+    UINT Stride;
+    D3DBASISTYPE Basis;
+    D3DDEGREETYPE Degree;
+} D3DRECTPATCH_INFO, *PD3DRECTPATCH_INFO, *LPD3DRECTPATCH_INFO;
+
+typedef struct _D3DSURFACE_DESC {
+    D3DFORMAT Format;
+    D3DRESOURCETYPE Type;
+    DWORD Usage;
+    D3DPOOL Pool;
+    D3DMULTISAMPLE_TYPE MultiSampleType;
+    DWORD MultiSampleQuality;
+    UINT Width;
+    UINT Height;
+} D3DSURFACE_DESC, *PD3DSURFACE_DESC, *LPD3DSURFACE_DESC;
+
+typedef struct _D3DTRIPATCH_INFO {
+    UINT StartVertexOffset;
+    UINT NumVertices;
+    D3DBASISTYPE Basis;
+    D3DDEGREETYPE Degree;
+} D3DTRIPATCH_INFO, *PD3DTRIPATCH_INFO, *LPD3DTRIPATCH_INFO;
+
+typedef struct _D3DVERTEXBUFFER_DESC {
+    D3DFORMAT Format;
+    D3DRESOURCETYPE Type;
+    DWORD Usage;
+    D3DPOOL Pool;
+    UINT Size;
+    DWORD FVF;
+} D3DVERTEXBUFFER_DESC, *PD3DVERTEXBUFFER_DESC, *LPD3DVERTEXBUFFER_DESC;
+
+typedef struct _D3DVERTEXELEMENT9 {
+    WORD Stream;
+    WORD Offset;
+    BYTE Type;
+    BYTE Method;
+    BYTE Usage;
+    BYTE UsageIndex;
+} D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
+
+typedef struct _D3DVIEWPORT9 {
+    DWORD X;
+    DWORD Y;
+    DWORD Width;
+    DWORD Height;
+    float MinZ;
+    float MaxZ;
+} D3DVIEWPORT9, *PD3DVIEWPORT9, *LPD3DVIEWPORT9;
+
+typedef struct _D3DVOLUME_DESC {
+    D3DFORMAT Format;
+    D3DRESOURCETYPE Type;
+    DWORD Usage;
+    D3DPOOL Pool;
+    UINT Width;
+    UINT Height;
+    UINT Depth;
+} D3DVOLUME_DESC, *PD3DVOLUME_DESC, *LPD3DVOLUME_DESC;
+
+#ifndef _WIN32
+/* If _WIN32 isn't declared it means only internal header files are used. To
+ * avoid a conflict, IUnknown is declared here rather than in d3d9.h */
+
+typedef struct IUnknown IUnknown, *PUNKNOWN, *LPUNKNOWN;
+
+#ifdef __cplusplus
+extern "C" const GUID IID_IUnknown;
+
+struct IUnknown
+{
+	virtual HRESULT WINAPI QueryInterface(REFIID riid, void **ppvObject) = 0;
+	virtual ULONG WINAPI AddRef() = 0;
+	virtual ULONG WINAPI Release() = 0;
+};
+#else /* __cplusplus */
+extern const GUID IID_IUnknown;
+
+typedef struct IUnknownVtbl
+{
+	/* IUnknown */
+	HRESULT (WINAPI *QueryInterface)(IUnknown *This, REFIID riid, void **ppvObject);
+	ULONG (WINAPI *AddRef)(IUnknown *This);
+	ULONG (WINAPI *Release)(IUnknown *This);
+} IUnknownVtbl;
+
+struct IUnknown
+{
+	IUnknownVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IUnknown_Release(p) (p)->lpVtbl->Release(p)
+#endif /* __cplusplus */
+#endif /* _WIN32 */
+
+#endif /* _D3D9TYPES_H_ */
diff --git a/mesalib/include/GLES2/gl2ext.h b/mesalib/include/GLES2/gl2ext.h
index a5e3f47..2b67c6e 100644
--- a/mesalib/include/GLES2/gl2ext.h
+++ b/mesalib/include/GLES2/gl2ext.h
@@ -33,14 +33,14 @@ extern "C" {
 ** used to make the header, and the header can be found at
 **   http://www.opengl.org/registry/
 **
-** Khronos $Revision: 25922 $ on $Date: 2014-03-17 03:54:32 -0700 (Mon, 17 Mar 2014) $
+** Khronos $Revision: 28335 $ on $Date: 2014-09-26 18:55:45 -0700 (Fri, 26 Sep 2014) $
 */
 
 #ifndef GL_APIENTRYP
 #define GL_APIENTRYP GL_APIENTRY*
 #endif
 
-/* Generated on date 20140317 */
+/* Generated on date 20140926 */
 
 /* Generated C header for:
  * API: gles2
@@ -54,7 +54,6 @@ extern "C" {
 
 #ifndef GL_KHR_blend_equation_advanced
 #define GL_KHR_blend_equation_advanced 1
-#define GL_BLEND_ADVANCED_COHERENT_KHR    0x9285
 #define GL_MULTIPLY_KHR                   0x9294
 #define GL_SCREEN_KHR                     0x9295
 #define GL_OVERLAY_KHR                    0x9296
@@ -76,6 +75,17 @@ GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void);
 #endif
 #endif /* GL_KHR_blend_equation_advanced */
 
+#ifndef GL_KHR_blend_equation_advanced_coherent
+#define GL_KHR_blend_equation_advanced_coherent 1
+#define GL_BLEND_ADVANCED_COHERENT_KHR    0x9285
+#endif /* GL_KHR_blend_equation_advanced_coherent */
+
+#ifndef GL_KHR_context_flush_control
+#define GL_KHR_context_flush_control 1
+#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR   0x82FB
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC
+#endif /* GL_KHR_context_flush_control */
+
 #ifndef GL_KHR_debug
 #define GL_KHR_debug 1
 typedef void (GL_APIENTRY  *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
@@ -145,6 +155,34 @@ GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
 #endif
 #endif /* GL_KHR_debug */
 
+#ifndef GL_KHR_robust_buffer_access_behavior
+#define GL_KHR_robust_buffer_access_behavior 1
+#endif /* GL_KHR_robust_buffer_access_behavior */
+
+#ifndef GL_KHR_robustness
+#define GL_KHR_robustness 1
+#define GL_CONTEXT_ROBUST_ACCESS_KHR      0x90F3
+#define GL_LOSE_CONTEXT_ON_RESET_KHR      0x8252
+#define GL_GUILTY_CONTEXT_RESET_KHR       0x8253
+#define GL_INNOCENT_CONTEXT_RESET_KHR     0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_KHR      0x8255
+#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
+#define GL_NO_RESET_NOTIFICATION_KHR      0x8261
+#define GL_CONTEXT_LOST_KHR               0x0507
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void);
+GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+#endif
+#endif /* GL_KHR_robustness */
+
 #ifndef GL_KHR_texture_compression_astc_hdr
 #define GL_KHR_texture_compression_astc_hdr 1
 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR   0x93B0
@@ -200,6 +238,10 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum targe
 #define GL_SAMPLER_EXTERNAL_OES           0x8D66
 #endif /* GL_OES_EGL_image_external */
 
+#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture
+#define GL_OES_compressed_ETC1_RGB8_sub_texture 1
+#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */
+
 #ifndef GL_OES_compressed_ETC1_RGB8_texture
 #define GL_OES_compressed_ETC1_RGB8_texture 1
 #define GL_ETC1_RGB8_OES                  0x8D64
@@ -512,6 +554,10 @@ GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLen
 #define GL_Z400_BINARY_AMD                0x8740
 #endif /* GL_AMD_program_binary_Z400 */
 
+#ifndef GL_ANDROID_extension_pack_es31a
+#define GL_ANDROID_extension_pack_es31a 1
+#endif /* GL_ANDROID_extension_pack_es31a */
+
 #ifndef GL_ANGLE_depth_texture
 #define GL_ANGLE_depth_texture 1
 #endif /* GL_ANGLE_depth_texture */
@@ -587,6 +633,23 @@ GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLs
 #endif
 #endif /* GL_ANGLE_translated_shader_source */
 
+#ifndef GL_APPLE_clip_distance
+#define GL_APPLE_clip_distance 1
+#define GL_MAX_CLIP_DISTANCES_APPLE       0x0D32
+#define GL_CLIP_DISTANCE0_APPLE           0x3000
+#define GL_CLIP_DISTANCE1_APPLE           0x3001
+#define GL_CLIP_DISTANCE2_APPLE           0x3002
+#define GL_CLIP_DISTANCE3_APPLE           0x3003
+#define GL_CLIP_DISTANCE4_APPLE           0x3004
+#define GL_CLIP_DISTANCE5_APPLE           0x3005
+#define GL_CLIP_DISTANCE6_APPLE           0x3006
+#define GL_CLIP_DISTANCE7_APPLE           0x3007
+#endif /* GL_APPLE_clip_distance */
+
+#ifndef GL_APPLE_color_buffer_packed_float
+#define GL_APPLE_color_buffer_packed_float 1
+#endif /* GL_APPLE_color_buffer_packed_float */
+
 #ifndef GL_APPLE_copy_texture_levels
 #define GL_APPLE_copy_texture_levels 1
 typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
@@ -667,6 +730,14 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei
 #define GL_TEXTURE_MAX_LEVEL_APPLE        0x813D
 #endif /* GL_APPLE_texture_max_level */
 
+#ifndef GL_APPLE_texture_packed_float
+#define GL_APPLE_texture_packed_float 1
+#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B
+#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E
+#define GL_R11F_G11F_B10F_APPLE           0x8C3A
+#define GL_RGB9_E5_APPLE                  0x8C3D
+#endif /* GL_APPLE_texture_packed_float */
+
 #ifndef GL_ARM_mali_program_binary
 #define GL_ARM_mali_program_binary 1
 #define GL_MALI_PROGRAM_BINARY_ARM        0x8F61
@@ -691,6 +762,13 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei
 #define GL_ARM_shader_framebuffer_fetch_depth_stencil 1
 #endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */
 
+#ifndef GL_DMP_program_binary
+#define GL_DMP_program_binary 1
+#define GL_SMAPHS30_PROGRAM_BINARY_DMP    0x9251
+#define GL_SMAPHS_PROGRAM_BINARY_DMP      0x9252
+#define GL_DMP_PROGRAM_BINARY_DMP         0x9253
+#endif /* GL_DMP_program_binary */
+
 #ifndef GL_DMP_shader_binary
 #define GL_DMP_shader_binary 1
 #define GL_SHADER_BINARY_DMP              0x9250
@@ -712,6 +790,14 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei
 #define GL_UNSIGNED_NORMALIZED_EXT        0x8C17
 #endif /* GL_EXT_color_buffer_half_float */
 
+#ifndef GL_EXT_copy_image
+#define GL_EXT_copy_image 1
+typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+#endif /* GL_EXT_copy_image */
+
 #ifndef GL_EXT_debug_label
 #define GL_EXT_debug_label 1
 #define GL_PROGRAM_PIPELINE_OBJECT_EXT    0x8A4F
@@ -829,6 +915,30 @@ GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
 #endif
 #endif /* GL_EXT_draw_buffers */
 
+#ifndef GL_EXT_draw_buffers_indexed
+#define GL_EXT_draw_buffers_indexed 1
+#define GL_MIN                            0x8007
+#define GL_MAX                            0x8008
+typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index);
+#endif
+#endif /* GL_EXT_draw_buffers_indexed */
+
 #ifndef GL_EXT_draw_instanced
 #define GL_EXT_draw_instanced 1
 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
@@ -839,6 +949,55 @@ GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei cou
 #endif
 #endif /* GL_EXT_draw_instanced */
 
+#ifndef GL_EXT_geometry_point_size
+#define GL_EXT_geometry_point_size 1
+#endif /* GL_EXT_geometry_point_size */
+
+#ifndef GL_EXT_geometry_shader
+#define GL_EXT_geometry_shader 1
+#define GL_GEOMETRY_SHADER_EXT            0x8DD9
+#define GL_GEOMETRY_SHADER_BIT_EXT        0x00000004
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
+#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
+#define GL_LAYER_PROVOKING_VERTEX_EXT     0x825E
+#define GL_LINES_ADJACENCY_EXT            0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT       0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT        0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
+#define GL_FIRST_VERTEX_CONVENTION_EXT    0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT     0x8E4E
+#define GL_UNDEFINED_VERTEX_EXT           0x8260
+#define GL_PRIMITIVES_GENERATED_EXT       0x8C87
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
+#define GL_MAX_FRAMEBUFFER_LAYERS_EXT     0x9317
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+#endif /* GL_EXT_geometry_shader */
+
+#ifndef GL_EXT_gpu_shader5
+#define GL_EXT_gpu_shader5 1
+#endif /* GL_EXT_gpu_shader5 */
+
 #ifndef GL_EXT_instanced_arrays
 #define GL_EXT_instanced_arrays 1
 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
@@ -911,12 +1070,23 @@ GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLi
 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
 #endif /* GL_EXT_occlusion_query_boolean */
 
+#ifndef GL_EXT_primitive_bounding_box
+#define GL_EXT_primitive_bounding_box 1
+#define GL_PRIMITIVE_BOUNDING_BOX_EXT     0x92BE
+typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#endif
+#endif /* GL_EXT_primitive_bounding_box */
+
 #ifndef GL_EXT_pvrtc_sRGB
 #define GL_EXT_pvrtc_sRGB 1
 #define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
 #define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
 #endif /* GL_EXT_pvrtc_sRGB */
 
 #ifndef GL_EXT_read_format_bgra
@@ -1064,10 +1234,18 @@ GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLin
 #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
 #endif /* GL_EXT_shader_framebuffer_fetch */
 
+#ifndef GL_EXT_shader_implicit_conversions
+#define GL_EXT_shader_implicit_conversions 1
+#endif /* GL_EXT_shader_implicit_conversions */
+
 #ifndef GL_EXT_shader_integer_mix
 #define GL_EXT_shader_integer_mix 1
 #endif /* GL_EXT_shader_integer_mix */
 
+#ifndef GL_EXT_shader_io_blocks
+#define GL_EXT_shader_io_blocks 1
+#endif /* GL_EXT_shader_io_blocks */
+
 #ifndef GL_EXT_shader_pixel_local_storage
 #define GL_EXT_shader_pixel_local_storage 1
 #define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
@@ -1087,6 +1265,109 @@ GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLin
 #define GL_SAMPLER_2D_SHADOW_EXT          0x8B62
 #endif /* GL_EXT_shadow_samplers */
 
+#ifndef GL_EXT_tessellation_point_size
+#define GL_EXT_tessellation_point_size 1
+#endif /* GL_EXT_tessellation_point_size */
+
+#ifndef GL_EXT_tessellation_shader
+#define GL_EXT_tessellation_shader 1
+#define GL_PATCHES_EXT                    0x000E
+#define GL_PATCH_VERTICES_EXT             0x8E72
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
+#define GL_TESS_GEN_MODE_EXT              0x8E76
+#define GL_TESS_GEN_SPACING_EXT           0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_EXT      0x8E78
+#define GL_TESS_GEN_POINT_MODE_EXT        0x8E79
+#define GL_ISOLINES_EXT                   0x8E7A
+#define GL_QUADS_EXT                      0x0007
+#define GL_FRACTIONAL_ODD_EXT             0x8E7B
+#define GL_FRACTIONAL_EVEN_EXT            0x8E7C
+#define GL_MAX_PATCH_VERTICES_EXT         0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL_EXT         0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS_EXT  0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_IS_PER_PATCH_EXT               0x92E7
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
+#define GL_TESS_CONTROL_SHADER_EXT        0x8E88
+#define GL_TESS_EVALUATION_SHADER_EXT     0x8E87
+#define GL_TESS_CONTROL_SHADER_BIT_EXT    0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
+typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value);
+#endif
+#endif /* GL_EXT_tessellation_shader */
+
+#ifndef GL_EXT_texture_border_clamp
+#define GL_EXT_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_EXT       0x1004
+#define GL_CLAMP_TO_BORDER_EXT            0x812D
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param);
+GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+#endif /* GL_EXT_texture_border_clamp */
+
+#ifndef GL_EXT_texture_buffer
+#define GL_EXT_texture_buffer 1
+#define GL_TEXTURE_BUFFER_EXT             0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_EXT     0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT    0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT     0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
+#define GL_SAMPLER_BUFFER_EXT             0x8DC2
+#define GL_INT_SAMPLER_BUFFER_EXT         0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#define GL_IMAGE_BUFFER_EXT               0x9051
+#define GL_INT_IMAGE_BUFFER_EXT           0x905C
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT  0x9067
+#define GL_TEXTURE_BUFFER_OFFSET_EXT      0x919D
+#define GL_TEXTURE_BUFFER_SIZE_EXT        0x919E
+typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+#endif /* GL_EXT_texture_buffer */
+
 #ifndef GL_EXT_texture_compression_dxt1
 #define GL_EXT_texture_compression_dxt1 1
 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
@@ -1099,6 +1380,19 @@ GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLin
 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3
 #endif /* GL_EXT_texture_compression_s3tc */
 
+#ifndef GL_EXT_texture_cube_map_array
+#define GL_EXT_texture_cube_map_array 1
+#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT     0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
+#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT     0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT       0x9054
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT   0x905F
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#endif /* GL_EXT_texture_cube_map_array */
+
 #ifndef GL_EXT_texture_filter_anisotropic
 #define GL_EXT_texture_filter_anisotropic 1
 #define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
@@ -1161,6 +1455,19 @@ GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target
 #define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
 #endif /* GL_EXT_texture_type_2_10_10_10_REV */
 
+#ifndef GL_EXT_texture_view
+#define GL_EXT_texture_view 1
+#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT     0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT    0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER_EXT     0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT    0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS       0x82DF
+typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+#endif /* GL_EXT_texture_view */
+
 #ifndef GL_EXT_unpack_subimage
 #define GL_EXT_unpack_subimage 1
 #define GL_UNPACK_ROW_LENGTH_EXT          0x0CF2
diff --git a/mesalib/include/d3dadapter/d3dadapter9.h b/mesalib/include/d3dadapter/d3dadapter9.h
new file mode 100644
index 0000000..76ad3d4
--- /dev/null
+++ b/mesalib/include/d3dadapter/d3dadapter9.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+#ifndef _D3DADAPTER9_H_
+#define _D3DADAPTER9_H_
+
+#include "present.h"
+
+#ifndef __cplusplus
+
+/* Representation of an adapter group, although since this is implemented by
+ * the driver, it knows nothing about the windowing system it's on */
+typedef struct ID3DAdapter9Vtbl
+{
+    /* IUnknown */
+    HRESULT (WINAPI *QueryInterface)(ID3DAdapter9 *This, REFIID riid, void **ppvObject);
+    ULONG (WINAPI *AddRef)(ID3DAdapter9 *This);
+    ULONG (WINAPI *Release)(ID3DAdapter9 *This);
+
+    /* ID3DAdapter9 */
+    HRESULT (WINAPI *GetAdapterIdentifier)(ID3DAdapter9 *This, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier);
+    HRESULT (WINAPI *CheckDeviceType)(ID3DAdapter9 *This, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed);
+    HRESULT (WINAPI *CheckDeviceFormat)(ID3DAdapter9 *This, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
+    HRESULT (WINAPI *CheckDeviceMultiSampleType)(ID3DAdapter9 *This, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels);
+    HRESULT (WINAPI *CheckDepthStencilMatch)(ID3DAdapter9 *This, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
+    HRESULT (WINAPI *CheckDeviceFormatConversion)(ID3DAdapter9 *This, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
+    HRESULT (WINAPI *GetDeviceCaps)(ID3DAdapter9 *This, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps);
+    HRESULT (WINAPI *CreateDevice)(ID3DAdapter9 *This, UINT RealAdapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3D9 *pD3D9, ID3DPresentGroup *pPresentationFactory, IDirect3DDevice9 **ppReturnedDeviceInterface);
+    HRESULT (WINAPI *CreateDeviceEx)(ID3DAdapter9 *This, UINT RealAdapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3D9Ex *pD3D9Ex, ID3DPresentGroup *pPresentationFactory, IDirect3DDevice9Ex **ppReturnedDeviceInterface);
+} ID3DAdapter9Vtbl;
+
+struct ID3DAdapter9
+{
+    ID3DAdapter9Vtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define ID3DAdapter9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ID3DAdapter9_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ID3DAdapter9_Release(p) (p)->lpVtbl->Release(p)
+/* ID3DAdapter9 macros */
+#define ID3DAdapter9_GetAdapterIdentifier(p,a,b) (p)->lpVtbl->GetAdapterIdentifier(p,a,b)
+#define ID3DAdapter9_CheckDeviceType(p,a,b,c,d) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d)
+#define ID3DAdapter9_CheckDeviceFormat(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e)
+#define ID3DAdapter9_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e)
+#define ID3DAdapter9_CheckDepthStencilMatch(p,a,b,c,d) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d)
+#define ID3DAdapter9_CheckDeviceFormatConversion(p,a,b,c) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c)
+#define ID3DAdapter9_GetDeviceCaps(p,a,b) (p)->lpVtbl->GetDeviceCaps(p,a,b)
+#define ID3DAdapter9_CreateDevice(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f,g,h)
+#define ID3DAdapter9_CreateDeviceEx(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d,e,f,g,h,i)
+
+#else /* __cplusplus */
+
+struct ID3DAdapter9 : public IUnknown
+{
+    HRESULT WINAPI GetAdapterIdentifier(DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier);
+    HRESULT WINAPI CheckDeviceType(D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed);
+    HRESULT WINAPI CheckDeviceFormat(D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
+    HRESULT WINAPI CheckDeviceMultiSampleType(D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels);
+    HRESULT WINAPI CheckDepthStencilMatch(D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
+    HRESULT WINAPI CheckDeviceFormatConversion(D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
+    HRESULT WINAPI GetDeviceCaps(D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps);
+    HRESULT WINAPI CreateDevice(UINT RealAdapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3D9 *pD3D9, ID3DPresentGroup *pPresentationFactory, IDirect3DDevice9 **ppReturnedDeviceInterface);
+    HRESULT WINAPI CreateDeviceEx(UINT RealAdapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3D9Ex *pD3D9Ex, ID3DPresentGroup *pPresentationFactory, IDirect3DDevice9Ex **ppReturnedDeviceInterface);
+};
+
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* acquire a const struct D3DAdapter9* structure describing the interface
+ * queried. See  */
+const void * WINAPI
+D3DAdapter9GetProc( const char *name );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _D3DADAPTER9_H_ */
diff --git a/mesalib/include/d3dadapter/drm.h b/mesalib/include/d3dadapter/drm.h
new file mode 100644
index 0000000..9ec3e60
--- /dev/null
+++ b/mesalib/include/d3dadapter/drm.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+#ifndef _D3DADAPTER9_DRM_H_
+#define _D3DADAPTER9_DRM_H_
+
+#include "d3dadapter9.h"
+
+/* query driver support name */
+#define D3DADAPTER9DRM_NAME "drm"
+/* current version */
+#define D3DADAPTER9DRM_MAJOR 0
+#define D3DADAPTER9DRM_MINOR 0
+
+struct D3DAdapter9DRM
+{
+    unsigned major_version; /* ABI break */
+    unsigned minor_version; /* backwards compatible feature additions */
+
+    /* NOTE: upon passing an fd to this function, it's now owned by this
+        function. If this function fails, the fd will be closed here as well */
+    HRESULT (WINAPI *create_adapter)(int fd, ID3DAdapter9 **ppAdapter);
+};
+
+#endif /* _D3DADAPTER9_DRM_H_ */
diff --git a/mesalib/include/d3dadapter/present.h b/mesalib/include/d3dadapter/present.h
new file mode 100644
index 0000000..08a9729
--- /dev/null
+++ b/mesalib/include/d3dadapter/present.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2011 Joakim Sindholt <opensource at zhasha.com>
+ *
+ * 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
+ * on 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
+ * THE AUTHOR(S) AND/OR THEIR 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. */
+
+#ifndef _D3DADAPTER_PRESENT_H_
+#define _D3DADAPTER_PRESENT_H_
+
+#include <d3d9.h>
+
+#ifndef D3DOK_WINDOW_OCCLUDED
+#define D3DOK_WINDOW_OCCLUDED MAKE_D3DSTATUS(2531)
+#endif /* D3DOK_WINDOW_OCCLUDED */
+
+#ifndef __cplusplus
+typedef struct ID3DPresent ID3DPresent;
+typedef struct ID3DPresentGroup ID3DPresentGroup;
+typedef struct ID3DAdapter9 ID3DAdapter9;
+typedef struct D3DWindowBuffer D3DWindowBuffer;
+
+/* Presentation backend for drivers to display their brilliant work */
+typedef struct ID3DPresentVtbl
+{
+    /* IUnknown */
+    HRESULT (WINAPI *QueryInterface)(ID3DPresent *This, REFIID riid, void **ppvObject);
+    ULONG (WINAPI *AddRef)(ID3DPresent *This);
+    ULONG (WINAPI *Release)(ID3DPresent *This);
+
+    /* ID3DPresent */
+    /* This function initializes the screen and window provided at creation.
+     * Hence why this should always be called as the one of first things a new
+     * swap chain does */
+    HRESULT (WINAPI *SetPresentParameters)(ID3DPresent *This, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode);
+    /* Make a buffer visible to the window system via dma-buf fd.
+     * For better compatibility, it must be 32bpp and format ARGB/XRGB */
+    HRESULT (WINAPI *NewD3DWindowBufferFromDmaBuf)(ID3DPresent *This, int dmaBufFd, int width, int height, int stride, int depth, int bpp, D3DWindowBuffer **out);
+    HRESULT (WINAPI *DestroyD3DWindowBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer);
+    /* After presenting a buffer to the window system, the buffer
+     * may be used as is (no copy of the content) by the window system.
+     * You must not use a non-released buffer, else the user may see undefined content. */
+    HRESULT (WINAPI *WaitBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer);
+    HRESULT (WINAPI *FrontBufferCopy)(ID3DPresent *This, D3DWindowBuffer *buffer);
+    /* It is possible to do partial copy, but impossible to do resizing, which must
+     * be done by the client after checking the front buffer size */
+    HRESULT (WINAPI *PresentBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer, HWND hWndOverride, const RECT *pSourceRect, const RECT *pDestRect, const RGNDATA *pDirtyRegion, DWORD Flags);
+    HRESULT (WINAPI *GetRasterStatus)(ID3DPresent *This, D3DRASTER_STATUS *pRasterStatus);
+    HRESULT (WINAPI *GetDisplayMode)(ID3DPresent *This, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
+    HRESULT (WINAPI *GetPresentStats)(ID3DPresent *This, D3DPRESENTSTATS *pStats);
+    HRESULT (WINAPI *GetCursorPos)(ID3DPresent *This, POINT *pPoint);
+    HRESULT (WINAPI *SetCursorPos)(ID3DPresent *This, POINT *pPoint);
+    /* Cursor size is always 32x32. pBitmap and pHotspot can be NULL. */
+    HRESULT (WINAPI *SetCursor)(ID3DPresent *This, void *pBitmap, POINT *pHotspot, BOOL bShow);
+    HRESULT (WINAPI *SetGammaRamp)(ID3DPresent *This, const D3DGAMMARAMP *pRamp, HWND hWndOverride);
+    HRESULT (WINAPI *GetWindowInfo)(ID3DPresent *This,  HWND hWnd, int *width, int *height, int *depth);
+} ID3DPresentVtbl;
+
+struct ID3DPresent
+{
+    ID3DPresentVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define ID3DPresent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ID3DPresent_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ID3DPresent_Release(p) (p)->lpVtbl->Release(p)
+/* ID3DPresent macros */
+#define ID3DPresent_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
+#define ID3DPresent_SetPresentParameters(p,a,b) (p)->lpVtbl->SetPresentParameters(p,a,b)
+#define ID3DPresent_NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) (p)->lpVtbl->NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g)
+#define ID3DPresent_DestroyD3DWindowBuffer(p,a) (p)->lpVtbl->DestroyD3DWindowBuffer(p,a)
+#define ID3DPresent_WaitBufferReleased(p,a) (p)->lpVtbl->WaitBufferReleased(p,a)
+#define ID3DPresent_FrontBufferCopy(p,a) (p)->lpVtbl->FrontBufferCopy(p,a)
+#define ID3DPresent_PresentBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->PresentBuffer(p,a,b,c,d,e,f)
+#define ID3DPresent_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
+#define ID3DPresent_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
+#define ID3DPresent_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a)
+#define ID3DPresent_GetCursorPos(p,a) (p)->lpVtbl->GetCursorPos(p,a)
+#define ID3DPresent_SetCursorPos(p,a) (p)->lpVtbl->SetCursorPos(p,a)
+#define ID3DPresent_SetCursor(p,a,b,c) (p)->lpVtbl->SetCursor(p,a,b,c)
+#define ID3DPresent_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b)
+#define ID3DPresent_GetWindowInfo(p,a,b,c,d) (p)->lpVtbl->GetWindowSize(p,a,b,c,d)
+
+typedef struct ID3DPresentGroupVtbl
+{
+    /* IUnknown */
+    HRESULT (WINAPI *QueryInterface)(ID3DPresentGroup *This, REFIID riid, void **ppvObject);
+    ULONG (WINAPI *AddRef)(ID3DPresentGroup *This);
+    ULONG (WINAPI *Release)(ID3DPresentGroup *This);
+
+    /* ID3DPresentGroup */
+    /* When creating a device, it's relevant for the driver to know how many
+     * implicit swap chains to create. It has to create one per monitor in a
+     * multi-monitor setup */
+    UINT (WINAPI *GetMultiheadCount)(ID3DPresentGroup *This);
+    /* returns only the implicit present interfaces */
+    HRESULT (WINAPI *GetPresent)(ID3DPresentGroup *This, UINT Index, ID3DPresent **ppPresent);
+    /* used to create additional presentation interfaces along the way */
+    HRESULT (WINAPI *CreateAdditionalPresent)(ID3DPresentGroup *This, D3DPRESENT_PARAMETERS *pPresentationParameters, ID3DPresent **ppPresent);
+    void (WINAPI *GetVersion) (ID3DPresentGroup *This, int *major, int *minor);
+} ID3DPresentGroupVtbl;
+
+struct ID3DPresentGroup
+{
+    ID3DPresentGroupVtbl *lpVtbl;
+};
+
+/* IUnknown macros */
+#define ID3DPresentGroup_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define ID3DPresentGroup_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define ID3DPresentGroup_Release(p) (p)->lpVtbl->Release(p)
+/* ID3DPresentGroup */
+#define ID3DPresentGroup_GetMultiheadCount(p) (p)->lpVtbl->GetMultiheadCount(p)
+#define ID3DPresentGroup_GetPresent(p,a,b) (p)->lpVtbl->GetPresent(p,a,b)
+#define ID3DPresentGroup_CreateAdditionalPresent(p,a,b) (p)->lpVtbl->CreateAdditionalPresent(p,a,b)
+#define ID3DPresentGroup_GetVersion(p,a,b) (p)->lpVtbl->GetVersion(p,a,b)
+
+#endif /* __cplusplus */
+
+#endif /* _D3DADAPTER_PRESENT_H_ */
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index dd5ca56..8e2090b 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -301,6 +301,10 @@ def generate(env):
             cppdefines += ['HAVE_ALIAS']
         else:
             cppdefines += ['GLX_ALIAS_UNSUPPORTED']
+
+        if env['platform'] in ('linux', 'darwin'):
+            cppdefines += ['HAVE_XLOCALE_H']
+
     if env['platform'] == 'haiku':
         cppdefines += [
             'HAVE_PTHREAD',
@@ -374,22 +378,19 @@ def generate(env):
                 #'-march=pentium4',
             ]
             if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
-               and (platform != 'windows' or env['build'] == 'debug' or True) \
                and platform != 'haiku':
                 # NOTE: We need to ensure stack is realigned given that we
                 # produce shared objects, and have no control over the stack
                 # alignment policy of the application. Therefore we need
                 # -mstackrealign ore -mincoming-stack-boundary=2.
                 #
-                # XXX: -O and -mstackrealign causes stack corruption on MinGW
-                #
                 # XXX: We could have SSE without -mstackrealign if we always used
                 # __attribute__((force_align_arg_pointer)), but that's not
                 # always the case.
                 ccflags += [
                     '-mstackrealign', # ensure stack is aligned
-                    '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
-                    #'-mfpmath=sse',
+                    '-msse', '-msse2', # enable SIMD intrinsics
+                    '-mfpmath=sse', # generate SSE floating-point arithmetic
                 ]
             if platform in ['windows', 'darwin']:
                 # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
@@ -468,7 +469,7 @@ def generate(env):
         ]
         if env['machine'] == 'x86':
             ccflags += [
-                #'/arch:SSE2', # use the SSE2 instructions
+                '/arch:SSE2', # use the SSE2 instructions (default since MSVC 2012)
             ]
         if platform == 'windows':
             ccflags += [
@@ -617,7 +618,7 @@ def generate(env):
     env.Tool('custom')
     createInstallMethods(env)
 
-    env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
+    env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes', 'glproto >= 1.4.13'])
     env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx >= 1.8.1', 'xcb-dri2 >= 1.8'])
     env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
     env.PkgCheckModules('DRM', ['libdrm >= 2.4.38'])
diff --git a/mesalib/src/gallium/Automake.inc b/mesalib/src/gallium/Automake.inc
index c43f735..9b312b1 100644
--- a/mesalib/src/gallium/Automake.inc
+++ b/mesalib/src/gallium/Automake.inc
@@ -58,7 +58,8 @@ GALLIUM_WINSYS_CFLAGS = \
 
 
 GALLIUM_PIPE_LOADER_WINSYS_LIBS = \
-	$(top_builddir)/src/gallium/winsys/sw/null/libws_null.la
+	$(top_builddir)/src/gallium/winsys/sw/null/libws_null.la \
+	$(top_builddir)/src/gallium/winsys/sw/wrapper/libwsw.la
 
 if HAVE_DRISW
 GALLIUM_PIPE_LOADER_WINSYS_LIBS += \
diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am
index 21595a1..81840b2 100644
--- a/mesalib/src/gallium/Makefile.am
+++ b/mesalib/src/gallium/Makefile.am
@@ -138,14 +138,6 @@ if HAVE_OPENVG
 SUBDIRS += state_trackers/vega
 endif
 
-if HAVE_GALLIUM_EGL
-SUBDIRS += state_trackers/egl targets/egl-static
-endif
-
-if HAVE_GALLIUM_GBM
-SUBDIRS += state_trackers/gbm targets/gbm
-endif
-
 if HAVE_X11_DRIVER
 SUBDIRS += state_trackers/glx/xlib targets/libgl-xlib
 endif
@@ -174,11 +166,16 @@ if HAVE_ST_XVMC
 SUBDIRS += state_trackers/xvmc targets/xvmc
 endif
 
+if HAVE_ST_NINE
+SUBDIRS += state_trackers/nine targets/d3dadapter9
+endif
+
 ##
 ## Don't forget to bundle the remaining (non autotools) state-trackers/targets
 ##
 
 EXTRA_DIST += \
+	include \
 	state_trackers/README \
 	state_trackers/wgl targets/libgl-gdi \
 	targets/graw-gdi targets/graw-null  targets/graw-xlib \
diff --git a/mesalib/src/gallium/auxiliary/Android.mk b/mesalib/src/gallium/auxiliary/Android.mk
index 8046943..0bc1831 100644
--- a/mesalib/src/gallium/auxiliary/Android.mk
+++ b/mesalib/src/gallium/auxiliary/Android.mk
@@ -28,7 +28,9 @@ include $(LOCAL_PATH)/Makefile.sources
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(C_SOURCES)
+LOCAL_SRC_FILES := \
+	$(C_SOURCES) \
+	$(VL_STUB_SOURCES)
 
 LOCAL_C_INCLUDES := \
 	$(GALLIUM_TOP)/auxiliary/util \
diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am
index 4d8ba89..4085e51 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.am
+++ b/mesalib/src/gallium/auxiliary/Makefile.am
@@ -30,8 +30,7 @@ AM_CXXFLAGS += \
 	$(LLVM_CXXFLAGS)
 
 libgallium_la_SOURCES += \
-	$(GALLIVM_SOURCES) \
-	$(GALLIVM_CPP_SOURCES)
+	$(GALLIVM_SOURCES)
 
 endif
 
@@ -46,3 +45,42 @@ indices/u_unfilled_gen.c: $(srcdir)/indices/u_unfilled_gen.py
 util/u_format_table.c: $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format_pack.py $(srcdir)/util/u_format_parse.py $(srcdir)/util/u_format.csv
 	$(AM_V_at)$(MKDIR_P) util
 	$(AM_V_GEN) $(PYTHON2) $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format.csv > $@
+
+
+noinst_LTLIBRARIES += libgalliumvl_stub.la
+libgalliumvl_stub_la_SOURCES = \
+	$(VL_STUB_SOURCES)
+
+if NEED_GALLIUM_VL
+
+noinst_LTLIBRARIES += libgalliumvl.la
+
+libgalliumvl_la_CFLAGS = \
+	$(AM_CFLAGS) \
+	$(VL_CFLAGS) \
+	$(LIBDRM_CFLAGS) \
+	$(GALLIUM_PIPE_LOADER_DEFINES) \
+	-DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+
+if HAVE_GALLIUM_STATIC_TARGETS
+libgalliumvl_la_CFLAGS += \
+	-DGALLIUM_STATIC_TARGETS=1
+
+endif # HAVE_GALLIUM_STATIC_TARGETS
+
+libgalliumvl_la_SOURCES = \
+	$(VL_SOURCES)
+
+endif
+
+EXTRA_DIST = \
+	Android.mk SConscript \
+	indices/u_indices.c \
+	indices/u_unfilled_indices.c \
+	indices/u_indices_gen.py \
+	indices/u_unfilled_gen.py \
+	target-helpers \
+	util/u_format.csv \
+	util/u_format_pack.py \
+	util/u_format_parse.py \
+	util/u_format_table.py
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index f6621ef..8626264 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -1,13 +1,23 @@
 C_SOURCES := \
 	cso_cache/cso_cache.c \
+	cso_cache/cso_cache.h \
 	cso_cache/cso_context.c \
+	cso_cache/cso_context.h \
 	cso_cache/cso_hash.c \
+	cso_cache/cso_hash.h \
+	draw/draw_cliptest_tmp.h \
 	draw/draw_context.c \
+	draw/draw_context.h \
+	draw/draw_decompose_tmp.h \
 	draw/draw_fs.c \
+	draw/draw_fs.h \
 	draw/draw_gs.c \
-	draw/draw_pipe.c \
+	draw/draw_gs.h \
+	draw/draw_gs_tmp.h \
 	draw/draw_pipe_aaline.c \
 	draw/draw_pipe_aapoint.c \
+	draw/draw_pipe.c \
+	draw/draw_pipe.h \
 	draw/draw_pipe_clip.c \
 	draw/draw_pipe_cull.c \
 	draw/draw_pipe_flatshade.c \
@@ -22,142 +32,315 @@ C_SOURCES := \
 	draw/draw_pipe_wide_line.c \
 	draw/draw_pipe_wide_point.c \
 	draw/draw_prim_assembler.c \
+	draw/draw_prim_assembler.h \
+	draw/draw_prim_assembler_tmp.h \
+	draw/draw_private.h \
 	draw/draw_pt.c \
+	draw/draw_pt_decompose.h \
 	draw/draw_pt_emit.c \
 	draw/draw_pt_fetch.c \
 	draw/draw_pt_fetch_emit.c \
 	draw/draw_pt_fetch_shade_emit.c \
 	draw/draw_pt_fetch_shade_pipeline.c \
+	draw/draw_pt.h \
 	draw/draw_pt_post_vs.c \
 	draw/draw_pt_so_emit.c \
 	draw/draw_pt_util.c \
 	draw/draw_pt_vsplit.c \
+	draw/draw_pt_vsplit_tmp.h \
+	draw/draw_so_emit_tmp.h \
+	draw/draw_split_tmp.h \
+	draw/draw_vbuf.h \
 	draw/draw_vertex.c \
+	draw/draw_vertex.h \
 	draw/draw_vs.c \
 	draw/draw_vs_exec.c \
+	draw/draw_vs.h \
 	draw/draw_vs_variant.c \
 	hud/font.c \
+	hud/font.h \
 	hud/hud_context.c \
+	hud/hud_context.h \
 	hud/hud_cpu.c \
+	hud/hud_driver_query.c \
 	hud/hud_fps.c \
-        hud/hud_driver_query.c \
+	hud/hud_private.h \
+	indices/u_indices.h \
+	indices/u_indices_priv.h \
 	indices/u_primconvert.c \
+	indices/u_primconvert.h \
+	os/os_memory_aligned.h \
+	os/os_memory_debug.h \
+	os/os_memory_stdc.h \
+	os/os_memory.h \
 	os/os_misc.c \
+	os/os_misc.h \
+	os/os_mman.h \
 	os/os_process.c \
+	os/os_process.h \
+	os/os_thread.h \
 	os/os_time.c \
+	os/os_time.h \
 	pipebuffer/pb_buffer_fenced.c \
+	pipebuffer/pb_buffer_fenced.h \
+	pipebuffer/pb_buffer.h \
 	pipebuffer/pb_buffer_malloc.c \
 	pipebuffer/pb_bufmgr_alt.c \
 	pipebuffer/pb_bufmgr_cache.c \
 	pipebuffer/pb_bufmgr_debug.c \
+	pipebuffer/pb_bufmgr.h \
 	pipebuffer/pb_bufmgr_mm.c \
 	pipebuffer/pb_bufmgr_ondemand.c \
 	pipebuffer/pb_bufmgr_pool.c \
 	pipebuffer/pb_bufmgr_slab.c \
 	pipebuffer/pb_validate.c \
+	pipebuffer/pb_validate.h \
+	postprocess/filters.h \
+	postprocess/postprocess.h \
 	postprocess/pp_celshade.c \
+	postprocess/pp_celshade.h \
 	postprocess/pp_colors.c \
+	postprocess/pp_colors.h \
+	postprocess/pp_filters.h \
 	postprocess/pp_init.c \
+	postprocess/pp_mlaa_areamap.h \
 	postprocess/pp_mlaa.c \
-	postprocess/pp_run.c \
+	postprocess/pp_mlaa.h \
+	postprocess/pp_private.h \
 	postprocess/pp_program.c \
+	postprocess/pp_run.c \
 	rbug/rbug_connection.c \
+	rbug/rbug_connection.h \
 	rbug/rbug_context.c \
+	rbug/rbug_context.h \
 	rbug/rbug_core.c \
+	rbug/rbug_core.h \
 	rbug/rbug_demarshal.c \
-	rbug/rbug_texture.c \
+	rbug/rbug.h \
+	rbug/rbug_internal.h \
+	rbug/rbug_proto.h \
 	rbug/rbug_shader.c \
+	rbug/rbug_shader.h \
+	rbug/rbug_texture.c \
+	rbug/rbug_texture.h \
 	rtasm/rtasm_cpu.c \
+	rtasm/rtasm_cpu.h \
 	rtasm/rtasm_execmem.c \
+	rtasm/rtasm_execmem.h \
 	rtasm/rtasm_x86sse.c \
+	rtasm/rtasm_x86sse.h \
 	tgsi/tgsi_build.c \
+	tgsi/tgsi_build.h \
 	tgsi/tgsi_dump.c \
+	tgsi/tgsi_dump.h \
 	tgsi/tgsi_exec.c \
+	tgsi/tgsi_exec.h \
 	tgsi/tgsi_info.c \
+	tgsi/tgsi_info.h \
 	tgsi/tgsi_iterate.c \
+	tgsi/tgsi_iterate.h \
 	tgsi/tgsi_lowering.c \
+	tgsi/tgsi_lowering.h \
+	tgsi/tgsi_opcode_tmp.h \
 	tgsi/tgsi_parse.c \
+	tgsi/tgsi_parse.h \
 	tgsi/tgsi_sanity.c \
+	tgsi/tgsi_sanity.h \
 	tgsi/tgsi_scan.c \
+	tgsi/tgsi_scan.h \
 	tgsi/tgsi_strings.c \
+	tgsi/tgsi_strings.h \
 	tgsi/tgsi_text.c \
+	tgsi/tgsi_text.h \
 	tgsi/tgsi_transform.c \
+	tgsi/tgsi_transform.h \
 	tgsi/tgsi_ureg.c \
+	tgsi/tgsi_ureg.h \
 	tgsi/tgsi_util.c \
+	tgsi/tgsi_util.h \
 	translate/translate.c \
+	translate/translate.h \
 	translate/translate_cache.c \
+	translate/translate_cache.h \
 	translate/translate_generic.c \
 	translate/translate_sse.c \
+	util/dbghelp.h \
+	util/u_atomic.h \
+	util/u_bitmask.c \
+	util/u_bitmask.h \
+	util/u_blit.c \
+	util/u_blit.h \
+	util/u_blitter.c \
+	util/u_blitter.h \
+	util/u_box.h \
+	util/u_cache.c \
+	util/u_cache.h \
+	util/u_caps.c \
+	util/u_caps.h \
+	util/u_clear.h \
+	util/u_cpu_detect.c \
+	util/u_cpu_detect.h \
 	util/u_debug.c \
 	util/u_debug_describe.c \
+	util/u_debug_describe.h \
 	util/u_debug_flush.c \
+	util/u_debug_flush.h \
+	util/u_debug.h \
 	util/u_debug_memory.c \
 	util/u_debug_refcnt.c \
+	util/u_debug_refcnt.h \
 	util/u_debug_stack.c \
+	util/u_debug_stack.h \
 	util/u_debug_symbol.c \
-	util/u_dump_defines.c \
-	util/u_dump_state.c \
-	util/u_bitmask.c \
-	util/u_blit.c \
-	util/u_blitter.c \
-	util/u_cache.c \
-	util/u_caps.c \
-	util/u_cpu_detect.c \
+	util/u_debug_symbol.h \
+	util/u_dirty_flags.h \
+	util/u_dirty_surfaces.h \
 	util/u_dl.c \
+	util/u_dl.h \
+	util/u_double_list.h \
 	util/u_draw.c \
+	util/u_draw.h \
 	util/u_draw_quad.c \
+	util/u_draw_quad.h \
+	util/u_dual_blend.h \
+	util/u_dump_defines.c \
+	util/u_dump.h \
+	util/u_dump_state.c \
+	util/u_dynarray.h \
+	util/u_fifo.h \
+	util/u_format_bptc.c \
+	util/u_format_bptc.h \
 	util/u_format.c \
-	util/u_format_other.c \
+	util/u_format_etc.c \
+	util/u_format_etc.h \
+	util/u_format.h \
 	util/u_format_latc.c \
-	util/u_format_s3tc.c \
+	util/u_format_latc.h \
+	util/u_format_other.c \
+	util/u_format_other.h \
+	util/u_format_r11g11b10f.h \
+	util/u_format_rgb9e5.h \
 	util/u_format_rgtc.c \
-	util/u_format_etc.c \
-	util/u_format_bptc.c \
+	util/u_format_rgtc.h \
+	util/u_format_s3tc.c \
+	util/u_format_s3tc.h \
 	util/u_format_tests.c \
+	util/u_format_tests.h \
 	util/u_format_yuv.c \
+	util/u_format_yuv.h \
 	util/u_format_zs.c \
+	util/u_format_zs.h \
 	util/u_framebuffer.c \
+	util/u_framebuffer.h \
 	util/u_gen_mipmap.c \
+	util/u_gen_mipmap.h \
+	util/u_half.h \
 	util/u_handle_table.c \
+	util/u_handle_table.h \
 	util/u_hash.c \
+	util/u_hash.h \
 	util/u_hash_table.c \
+	util/u_hash_table.h \
 	util/u_helpers.c \
+	util/u_helpers.h \
 	util/u_index_modify.c \
+	util/u_index_modify.h \
+	util/u_init.h \
+	util/u_inlines.h \
 	util/u_keymap.c \
+	util/u_keymap.h \
 	util/u_linear.c \
+	util/u_linear.h \
 	util/u_linkage.c \
-	util/u_network.c \
+	util/u_linkage.h \
 	util/u_math.c \
+	util/u_math.h \
+	util/u_memory.h \
 	util/u_mm.c \
+	util/u_mm.h \
+	util/u_network.c \
+	util/u_network.h \
+	util/u_pack_color.h \
+	util/u_pointer.h \
+	util/u_prim.h \
 	util/u_pstipple.c \
+	util/u_pstipple.h \
+	util/u_range.h \
+	util/u_rect.h \
+	util/u_resource.c \
+	util/u_resource.h \
 	util/u_ringbuffer.c \
+	util/u_ringbuffer.h \
 	util/u_sampler.c \
+	util/u_sampler.h \
+	util/u_simple_list.h \
 	util/u_simple_shaders.c \
+	util/u_simple_shaders.h \
 	util/u_slab.c \
+	util/u_slab.h \
 	util/u_snprintf.c \
+	util/u_split_prim.h \
+	util/u_sse.h \
 	util/u_staging.c \
+	util/u_staging.h \
+	util/u_string.h \
 	util/u_suballoc.c \
+	util/u_suballoc.h \
 	util/u_surface.c \
+	util/u_surface.h \
 	util/u_surfaces.c \
+	util/u_surfaces.h \
+	util/u_tests.c \
+	util/u_tests.h \
 	util/u_texture.c \
+	util/u_texture.h \
 	util/u_tile.c \
+	util/u_tile.h \
+	util/u_time.h \
 	util/u_transfer.c \
-	util/u_resource.c \
+	util/u_transfer.h \
 	util/u_upload_mgr.c \
+	util/u_upload_mgr.h \
 	util/u_vbuf.c \
-	vl/vl_csc.c \
+	util/u_vbuf.h \
+	util/u_video.h
+
+VL_SOURCES := \
 	vl/vl_compositor.c \
+	vl/vl_compositor.h \
+	vl/vl_csc.c \
+	vl/vl_csc.h \
+	vl/vl_decoder.c \
+	vl/vl_decoder.h \
+	vl/vl_defines.h \
+	vl/vl_deint_filter.c \
+	vl/vl_deint_filter.h \
+	vl/vl_idct.c \
+	vl/vl_idct.h \
 	vl/vl_matrix_filter.c \
+	vl/vl_matrix_filter.h \
+	vl/vl_mc.c \
+	vl/vl_mc.h \
 	vl/vl_median_filter.c \
-	vl/vl_decoder.c \
-	vl/vl_mpeg12_decoder.c \
+	vl/vl_median_filter.h \
 	vl/vl_mpeg12_bitstream.c \
+	vl/vl_mpeg12_bitstream.h \
+	vl/vl_mpeg12_decoder.c \
+	vl/vl_mpeg12_decoder.h \
+	vl/vl_rbsp.h \
+	vl/vl_types.h \
+	vl/vl_vertex_buffers.c \
+	vl/vl_vertex_buffers.h \
+	vl/vl_video_buffer.c \
+	vl/vl_video_buffer.h \
+	vl/vl_vlc.h \
+	vl/vl_winsys.h \
+	vl/vl_winsys_dri.c \
 	vl/vl_zscan.c \
-        vl/vl_idct.c \
-	vl/vl_mc.c \
-        vl/vl_vertex_buffers.c \
-        vl/vl_video_buffer.c \
-	vl/vl_deint_filter.c
+	vl/vl_zscan.h
+
+VL_STUB_SOURCES := \
+	vl/vl_stubs.c
 
 GENERATED_SOURCES := \
 	indices/u_indices_gen.c \
@@ -165,42 +348,67 @@ GENERATED_SOURCES := \
 	util/u_format_table.c
 
 GALLIVM_SOURCES := \
-        gallivm/lp_bld_arit.c \
-        gallivm/lp_bld_arit_overflow.c \
-        gallivm/lp_bld_assert.c \
-        gallivm/lp_bld_bitarit.c \
-        gallivm/lp_bld_const.c \
-        gallivm/lp_bld_conv.c \
-        gallivm/lp_bld_flow.c \
-        gallivm/lp_bld_format_aos.c \
-        gallivm/lp_bld_format_aos_array.c \
-	gallivm/lp_bld_format_float.c \
-        gallivm/lp_bld_format_srgb.c \
-        gallivm/lp_bld_format_soa.c \
-        gallivm/lp_bld_format_yuv.c \
-        gallivm/lp_bld_gather.c \
-        gallivm/lp_bld_init.c \
-        gallivm/lp_bld_intr.c \
-        gallivm/lp_bld_logic.c \
-        gallivm/lp_bld_pack.c \
-        gallivm/lp_bld_printf.c \
-        gallivm/lp_bld_quad.c \
-        gallivm/lp_bld_sample.c \
-        gallivm/lp_bld_sample_aos.c \
-        gallivm/lp_bld_sample_soa.c \
-        gallivm/lp_bld_struct.c \
-        gallivm/lp_bld_swizzle.c \
-        gallivm/lp_bld_tgsi.c \
-        gallivm/lp_bld_tgsi_action.c \
-        gallivm/lp_bld_tgsi_aos.c \
-        gallivm/lp_bld_tgsi_info.c \
-        gallivm/lp_bld_tgsi_soa.c \
-        gallivm/lp_bld_type.c \
-        draw/draw_llvm.c \
-        draw/draw_llvm_sample.c \
-        draw/draw_vs_llvm.c \
-        draw/draw_pt_fetch_shade_pipeline_llvm.c
-
-GALLIVM_CPP_SOURCES := \
+	gallivm/lp_bld_arit.c \
+	gallivm/lp_bld_arit.h \
+	gallivm/lp_bld_arit_overflow.c \
+	gallivm/lp_bld_arit_overflow.h \
+	gallivm/lp_bld_assert.c \
+	gallivm/lp_bld_assert.h \
+	gallivm/lp_bld_bitarit.c \
+	gallivm/lp_bld_bitarit.h \
+	gallivm/lp_bld_const.c \
+	gallivm/lp_bld_const.h \
+	gallivm/lp_bld_conv.c \
+	gallivm/lp_bld_conv.h \
 	gallivm/lp_bld_debug.cpp \
-	gallivm/lp_bld_misc.cpp
+	gallivm/lp_bld_debug.h \
+	gallivm/lp_bld_flow.c \
+	gallivm/lp_bld_flow.h \
+	gallivm/lp_bld_format_aos_array.c \
+	gallivm/lp_bld_format_aos.c \
+	gallivm/lp_bld_format_float.c \
+	gallivm/lp_bld_format.h \
+	gallivm/lp_bld_format_soa.c \
+	gallivm/lp_bld_format_srgb.c \
+	gallivm/lp_bld_format_yuv.c \
+	gallivm/lp_bld_gather.c \
+	gallivm/lp_bld_gather.h \
+	gallivm/lp_bld.h \
+	gallivm/lp_bld_init.c \
+	gallivm/lp_bld_init.h \
+	gallivm/lp_bld_intr.c \
+	gallivm/lp_bld_intr.h \
+	gallivm/lp_bld_limits.h \
+	gallivm/lp_bld_logic.c \
+	gallivm/lp_bld_logic.h \
+	gallivm/lp_bld_misc.cpp \
+	gallivm/lp_bld_misc.h \
+	gallivm/lp_bld_pack.c \
+	gallivm/lp_bld_pack.h \
+	gallivm/lp_bld_printf.c \
+	gallivm/lp_bld_printf.h \
+	gallivm/lp_bld_quad.c \
+	gallivm/lp_bld_quad.h \
+	gallivm/lp_bld_sample_aos.c \
+	gallivm/lp_bld_sample_aos.h \
+	gallivm/lp_bld_sample.c \
+	gallivm/lp_bld_sample.h \
+	gallivm/lp_bld_sample_soa.c \
+	gallivm/lp_bld_struct.c \
+	gallivm/lp_bld_struct.h \
+	gallivm/lp_bld_swizzle.c \
+	gallivm/lp_bld_swizzle.h \
+	gallivm/lp_bld_tgsi_action.c \
+	gallivm/lp_bld_tgsi_action.h \
+	gallivm/lp_bld_tgsi_aos.c \
+	gallivm/lp_bld_tgsi.c \
+	gallivm/lp_bld_tgsi.h \
+	gallivm/lp_bld_tgsi_info.c \
+	gallivm/lp_bld_tgsi_soa.c \
+	gallivm/lp_bld_type.c \
+	gallivm/lp_bld_type.h \
+	draw/draw_llvm.c \
+	draw/draw_llvm.h \
+	draw/draw_llvm_sample.c \
+	draw/draw_pt_fetch_shade_pipeline_llvm.c \
+	draw/draw_vs_llvm.c
diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript
index 94041d2..6cb6b8c 100644
--- a/mesalib/src/gallium/auxiliary/SConscript
+++ b/mesalib/src/gallium/auxiliary/SConscript
@@ -36,13 +36,13 @@ env.Depends('util/u_format_table.c', [
 
 source = env.ParseSourceList('Makefile.sources', [
     'C_SOURCES',
+    'VL_STUB_SOURCES',
     'GENERATED_SOURCES'
 ])
 
 if env['llvm']:
     source += env.ParseSourceList('Makefile.sources', [
         'GALLIVM_SOURCES',
-        'GALLIVM_CPP_SOURCES'
     ])
 
 gallium = env.ConvenienceLibrary(
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c
index 18a8781..98678fc 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_context.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c
@@ -444,11 +444,9 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
    viewport.scale[0] = 0.5f * hud->fb_width;
    viewport.scale[1] = 0.5f * hud->fb_height;
    viewport.scale[2] = 1.0f;
-   viewport.scale[3] = 1.0f;
    viewport.translate[0] = 0.5f * hud->fb_width;
    viewport.translate[1] = 0.5f * hud->fb_height;
    viewport.translate[2] = 0.0f;
-   viewport.translate[3] = 0.0f;
 
    cso_set_framebuffer(cso, &fb);
    cso_set_sample_mask(cso, ~0);
diff --git a/mesalib/src/gallium/auxiliary/util/u_atomic.h b/mesalib/src/gallium/auxiliary/util/u_atomic.h
index 2f2b42b..2500bc7 100644
--- a/mesalib/src/gallium/auxiliary/util/u_atomic.h
+++ b/mesalib/src/gallium/auxiliary/util/u_atomic.h
@@ -24,12 +24,12 @@
 #define PIPE_ATOMIC_MSVC_INTRINSIC
 #elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
 #define PIPE_ATOMIC_ASM_MSVC_X86                
+#elif defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 401)
+#define PIPE_ATOMIC_GCC_INTRINSIC
 #elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
 #define PIPE_ATOMIC_ASM_GCC_X86
 #elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64))
 #define PIPE_ATOMIC_ASM_GCC_X86_64
-#elif defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 401)
-#define PIPE_ATOMIC_GCC_INTRINSIC
 #else
 #error "Unsupported platform"
 #endif
@@ -69,6 +69,18 @@ p_atomic_dec(int32_t *v)
 }
 
 static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+   return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+   return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
 p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
 {
    return __sync_val_compare_and_swap(v, old, _new);
@@ -116,6 +128,18 @@ p_atomic_dec(int32_t *v)
 }
 
 static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+   return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+   return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
 p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
 {
    return __sync_val_compare_and_swap(v, old, _new);
@@ -161,6 +185,18 @@ p_atomic_dec(int32_t *v)
 }
 
 static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+   return __sync_add_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+   return __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
 p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
 {
    return __sync_val_compare_and_swap(v, old, _new);
@@ -186,6 +222,8 @@ p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
 #define p_atomic_dec_zero(_v) ((boolean) --(*(_v)))
 #define p_atomic_inc(_v) ((void) (*(_v))++)
 #define p_atomic_dec(_v) ((void) (*(_v))--)
+#define p_atomic_inc_return(_v) ((*(_v))++)
+#define p_atomic_dec_return(_v) ((*(_v))--)
 #define p_atomic_cmpxchg(_v, old, _new) (*(_v) == old ? *(_v) = (_new) : *(_v))
 
 #endif
@@ -288,6 +326,12 @@ p_atomic_inc(int32_t *v)
    _InterlockedIncrement((long *)v);
 }
 
+static INLINE int32_t
+p_atomic_inc_return(int32_t *v)
+{
+   return _InterlockedIncrement((long *)v);
+}
+
 static INLINE void
 p_atomic_dec(int32_t *v)
 {
@@ -295,6 +339,12 @@ p_atomic_dec(int32_t *v)
 }
 
 static INLINE int32_t
+p_atomic_dec_return(int32_t *v)
+{
+   return _InterlockedDecrement((long *)v);
+}
+
+static INLINE int32_t
 p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
 {
    return _InterlockedCompareExchange((long *)v, _new, old);
@@ -329,6 +379,8 @@ p_atomic_dec_zero(int32_t *v)
 
 #define p_atomic_inc(_v) atomic_inc_32((uint32_t *) _v)
 #define p_atomic_dec(_v) atomic_dec_32((uint32_t *) _v)
+#define p_atomic_inc_return(_v) atomic_inc_32_nv((uint32_t *) _v)
+#define p_atomic_dec_return(_v) atomic_dec_32_nv((uint32_t *) _v)
 
 #define p_atomic_cmpxchg(_v, _old, _new) \
 	atomic_cas_32( (uint32_t *) _v, (uint32_t) _old, (uint32_t) _new)
diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c
index 2573bed..90408ff 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blit.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blit.c
@@ -188,7 +188,7 @@ set_vertex_shader(struct blit_state *ctx)
       const uint semantic_indexes[] = { 0, 0 };
       ctx->vs = util_make_vertex_passthrough_shader(ctx->pipe, 2,
                                                     semantic_names,
-                                                    semantic_indexes);
+                                                    semantic_indexes, FALSE);
    }
 
    cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
@@ -559,11 +559,9 @@ util_blit_pixels_tex(struct blit_state *ctx,
    ctx->viewport.scale[0] = 0.5f * dst->width;
    ctx->viewport.scale[1] = 0.5f * dst->height;
    ctx->viewport.scale[2] = 0.5f;
-   ctx->viewport.scale[3] = 1.0f;
    ctx->viewport.translate[0] = 0.5f * dst->width;
    ctx->viewport.translate[1] = 0.5f * dst->height;
    ctx->viewport.translate[2] = 0.5f;
-   ctx->viewport.translate[3] = 0.0f;
    cso_set_viewport(ctx->cso, &ctx->viewport);
 
    /* texture */
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index e59fa04..9d087fe 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -319,7 +319,8 @@ static void bind_vs_pos_only(struct blitter_context_priv *ctx)
 
       ctx->vs_pos_only =
          util_make_vertex_passthrough_shader_with_so(pipe, 1, semantic_names,
-                                                     semantic_indices, &so);
+                                                     semantic_indices, FALSE,
+                                                     &so);
    }
 
    pipe->bind_vs_state(pipe, ctx->vs_pos_only);
@@ -335,7 +336,7 @@ static void bind_vs_passthrough(struct blitter_context_priv *ctx)
       const uint semantic_indices[] = { 0, 0 };
       ctx->vs =
          util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
-                                             semantic_indices);
+                                             semantic_indices, FALSE);
    }
 
    pipe->bind_vs_state(pipe, ctx->vs);
@@ -682,11 +683,9 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
    ctx->viewport.scale[0] = 0.5f * ctx->dst_width;
    ctx->viewport.scale[1] = 0.5f * ctx->dst_height;
    ctx->viewport.scale[2] = 1.0f;
-   ctx->viewport.scale[3] = 1.0f;
    ctx->viewport.translate[0] = 0.5f * ctx->dst_width;
    ctx->viewport.translate[1] = 0.5f * ctx->dst_height;
    ctx->viewport.translate[2] = 0.0f;
-   ctx->viewport.translate[3] = 0.0f;
    ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, &ctx->viewport);
 }
 
diff --git a/mesalib/src/gallium/auxiliary/util/u_box.h b/mesalib/src/gallium/auxiliary/util/u_box.h
index 0b28d0f..520a3d5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_box.h
+++ b/mesalib/src/gallium/auxiliary/util/u_box.h
@@ -2,6 +2,7 @@
 #define UTIL_BOX_INLINES_H
 
 #include "pipe/p_state.h"
+#include "util/u_math.h"
 
 static INLINE
 void u_box_1d( unsigned x,
@@ -77,4 +78,121 @@ void u_box_3d( unsigned x,
    box->depth = d;
 }
 
+/* Clips @dst to width @w and height @h.
+ * Returns -1 if the resulting box would be empty (then @dst is left unchanged).
+ *          0 if nothing has been reduced.
+ *          1 if width has been reduced.
+ *          2 if height has been reduced.
+ *          3 if both width and height have been reduced.
+ * Aliasing permitted.
+ */
+static INLINE int
+u_box_clip_2d(struct pipe_box *dst,
+              const struct pipe_box *box, int w, int h)
+{
+   unsigned i;
+   int a[2], b[2], dim[2];
+   int *start, *end;
+   int res = 0;
+
+   if (!box->width || !box->height)
+      return -1;
+   dim[0] = w;
+   dim[1] = h;
+   a[0] = box->x;
+   a[1] = box->y;
+   b[0] = box->x + box->width;
+   b[1] = box->y + box->height;
+
+   for (i = 0; i < 2; ++i) {
+      start = (a[i] <= b[i]) ? &a[i] : &b[i];
+      end = (a[i] <= b[i]) ? &b[i] : &a[i];
+
+      if (*end < 0 || *start >= dim[i])
+         return -1;
+      if (*start < 0) {
+         *start = 0;
+         res |= (1 << i);
+      }
+      if (*end > dim[i]) {
+         *end = dim[i];
+         res |= (1 << i);
+      }
+   }
+
+   if (res) {
+      dst->x = a[0];
+      dst->y = a[1];
+      dst->width = b[0] - a[0];
+      dst->height = b[1] - a[1];
+   }
+   return res;
+}
+
+static INLINE int64_t
+u_box_volume_3d(const struct pipe_box *box)
+{
+   return (int64_t)box->width * box->height * box->depth;
+}
+
+/* Aliasing of @dst permitted. */
+static INLINE void
+u_box_union_2d(struct pipe_box *dst,
+               const struct pipe_box *a, const struct pipe_box *b)
+{
+   dst->x = MIN2(a->x, b->x);
+   dst->y = MIN2(a->y, b->y);
+
+   dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x;
+   dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y;
+}
+
+/* Aliasing of @dst permitted. */
+static INLINE void
+u_box_union_3d(struct pipe_box *dst,
+               const struct pipe_box *a, const struct pipe_box *b)
+{
+   dst->x = MIN2(a->x, b->x);
+   dst->y = MIN2(a->y, b->y);
+   dst->z = MIN2(a->z, b->z);
+
+   dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x;
+   dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y;
+   dst->depth = MAX2(a->z + a->depth, b->z + b->depth) - dst->z;
+}
+
+static INLINE boolean
+u_box_test_intersection_2d(const struct pipe_box *a,
+                           const struct pipe_box *b)
+{
+   unsigned i;
+   int a_l[2], a_r[2], b_l[2], b_r[2];
+
+   a_l[0] = MIN2(a->x, a->x + a->width);
+   a_r[0] = MAX2(a->x, a->x + a->width);
+   a_l[1] = MIN2(a->y, a->y + a->height);
+   a_r[1] = MAX2(a->y, a->y + a->height);
+
+   b_l[0] = MIN2(b->x, b->x + b->width);
+   b_r[0] = MAX2(b->x, b->x + b->width);
+   b_l[1] = MIN2(b->y, b->y + b->height);
+   b_r[1] = MAX2(b->y, b->y + b->height);
+
+   for (i = 0; i < 2; ++i) {
+      if (a_l[i] > b_r[i] || a_r[i] < b_l[i])
+         return FALSE;
+   }
+   return TRUE;
+}
+
+static INLINE void
+u_box_minify_2d(struct pipe_box *dst,
+                const struct pipe_box *src, unsigned l)
+{
+   dst->x = src->x >> l;
+   dst->y = src->y >> l;
+   dst->width = MAX2(src->width >> l, 1);
+   dst->height = MAX2(src->height >> l, 1);
+}
+
 #endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index 6ccf04c..d5138cc 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -207,9 +207,36 @@ def get_one_shift(type):
     assert False
 
 
+def truncate_mantissa(x, bits):
+    '''Truncate an integer so it can be represented exactly with a floating
+    point mantissa'''
+
+    assert isinstance(x, (int, long))
+
+    s = 1
+    if x < 0:
+        s = -1
+        x = -x
+
+    # We can represent integers up to mantissa + 1 bits exactly
+    mask = (1 << (bits + 1)) - 1
+
+    # Slide the mask until the MSB matches
+    shift = 0
+    while (x >> shift) & ~mask:
+        shift += 1
+
+    x &= mask << shift
+    x *= s
+    return x
+
+
 def value_to_native(type, value):
     '''Get the value of unity for this type.'''
     if type.type == FLOAT:
+        if type.size <= 32 \
+            and isinstance(value, (int, long)):
+            return truncate_mantissa(value, 23)
         return value
     if type.type == FIXED:
         return int(value * (1 << (type.size/2)))
@@ -226,9 +253,9 @@ def native_to_constant(type, value):
     '''Get the value of unity for this type.'''
     if type.type == FLOAT:
         if type.size <= 32:
-            return "%ff" % value 
+            return "%.1ff" % float(value)
         else:
-            return "%ff" % value 
+            return "%.1f" % float(value)
     else:
         return str(int(value))
 
@@ -251,8 +278,8 @@ def clamp_expr(src_channel, dst_channel, dst_native_type, value):
     dst_max = dst_channel.max()
     
     # Translate the destination range to the src native value
-    dst_min_native = value_to_native(src_channel, dst_min)
-    dst_max_native = value_to_native(src_channel, dst_max)
+    dst_min_native = native_to_constant(src_channel, value_to_native(src_channel, dst_min))
+    dst_max_native = native_to_constant(src_channel, value_to_native(src_channel, dst_max))
 
     if src_min < dst_min and src_max > dst_max:
         return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native)
diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.c b/mesalib/src/gallium/auxiliary/util/u_pstipple.c
index 509f815..1e1ec4a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_pstipple.c
+++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.c
@@ -180,9 +180,7 @@ struct pstip_transform_context {
    int maxInput;
    uint samplersUsed;  /**< bitfield of samplers used */
    int freeSampler;  /** an available sampler for the pstipple */
-   int texTemp;  /**< temp registers */
    int numImmed;
-   boolean firstInstruction;
    uint coordOrigin;
 };
 
@@ -243,7 +241,7 @@ free_bit(uint bitfield)
 
 
 /**
- * TGSI instruction transform callback.
+ * TGSI transform prolog
  * Before the first instruction, insert our new code to sample the
  * stipple texture (using the fragment coord register) then kill the
  * fragment if the stipple texture bit is off.
@@ -256,165 +254,95 @@ free_bit(uint bitfield)
  *   [...original code...]
  */
 static void
-pstip_transform_inst(struct tgsi_transform_context *ctx,
-                     struct tgsi_full_instruction *inst)
+pstip_transform_prolog(struct tgsi_transform_context *ctx)
 {
    struct pstip_transform_context *pctx =
       (struct pstip_transform_context *) ctx;
+   int wincoordInput;
+   int texTemp;
+
+   /* find free texture sampler */
+   pctx->freeSampler = free_bit(pctx->samplersUsed);
+   if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
+      pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
+
+   if (pctx->wincoordInput < 0)
+      wincoordInput = pctx->maxInput + 1;
+   else
+      wincoordInput = pctx->wincoordInput;
+
+   if (pctx->wincoordInput < 0) {
+      /* declare new position input reg */
+      tgsi_transform_input_decl(ctx, wincoordInput,
+                                TGSI_SEMANTIC_POSITION, 1,
+                                TGSI_INTERPOLATE_LINEAR);
+   }
 
-   if (pctx->firstInstruction) {
-      /* emit our new declarations before the first instruction */
-
-      struct tgsi_full_declaration decl;
-      struct tgsi_full_instruction newInst;
-      uint i;
-      int wincoordInput;
-
-      /* find free texture sampler */
-      pctx->freeSampler = free_bit(pctx->samplersUsed);
-      if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
-         pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
-
-      if (pctx->wincoordInput < 0)
-         wincoordInput = pctx->maxInput + 1;
-      else
-         wincoordInput = pctx->wincoordInput;
-
-      /* find one free temp register */
-      for (i = 0; i < 32; i++) {
-         if ((pctx->tempsUsed & (1 << i)) == 0) {
-            /* found a free temp */
-            if (pctx->texTemp < 0)
-               pctx->texTemp  = i;
-            else
-               break;
-         }
-      }
-      assert(pctx->texTemp >= 0);
-
-      if (pctx->wincoordInput < 0) {
-         /* declare new position input reg */
-         decl = tgsi_default_full_declaration();
-         decl.Declaration.File = TGSI_FILE_INPUT;
-         decl.Declaration.Interpolate = 1;
-         decl.Declaration.Semantic = 1;
-         decl.Semantic.Name = TGSI_SEMANTIC_POSITION;
-         decl.Semantic.Index = 0;
-         decl.Range.First = 
-            decl.Range.Last = wincoordInput;
-         decl.Interp.Interpolate = TGSI_INTERPOLATE_LINEAR;
-         ctx->emit_declaration(ctx, &decl);
-      }
+   /* declare new sampler */
+   tgsi_transform_sampler_decl(ctx, pctx->freeSampler);
 
-      /* declare new sampler */
-      decl = tgsi_default_full_declaration();
-      decl.Declaration.File = TGSI_FILE_SAMPLER;
-      decl.Range.First = 
-      decl.Range.Last = pctx->freeSampler;
-      ctx->emit_declaration(ctx, &decl);
-
-      /* declare new temp regs */
-      decl = tgsi_default_full_declaration();
-      decl.Declaration.File = TGSI_FILE_TEMPORARY;
-      decl.Range.First = 
-      decl.Range.Last = pctx->texTemp;
-      ctx->emit_declaration(ctx, &decl);
-
-      /* emit immediate = {1/32, 1/32, 1, 1}
-       * The index/position of this immediate will be pctx->numImmed
-       */
-      {
-         static const float value[4] = { 1.0/32, 1.0/32, 1.0, 1.0 };
-         struct tgsi_full_immediate immed;
-         uint size = 4;
-         immed = tgsi_default_full_immediate();
-         immed.Immediate.NrTokens = 1 + size; /* one for the token itself */
-         immed.u[0].Float = value[0];
-         immed.u[1].Float = value[1];
-         immed.u[2].Float = value[2];
-         immed.u[3].Float = value[3];
-         ctx->emit_immediate(ctx, &immed);
-      }
-
-      pctx->firstInstruction = FALSE;
-
-
-      /* 
-       * Insert new MUL/TEX/KILL_IF instructions at start of program
-       * Take gl_FragCoord, divide by 32 (stipple size), sample the
-       * texture and kill fragment if needed.
-       *
-       * We'd like to use non-normalized texcoords to index into a RECT
-       * texture, but we can only use REPEAT wrap mode with normalized
-       * texcoords.  Darn.
-       */
-
-      /* XXX invert wincoord if origin isn't lower-left... */
-
-      /* MUL texTemp, INPUT[wincoord], 1/32; */
-      newInst = tgsi_default_full_instruction();
-      newInst.Instruction.Opcode = TGSI_OPCODE_MUL;
-      newInst.Instruction.NumDstRegs = 1;
-      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
-      newInst.Dst[0].Register.Index = pctx->texTemp;
-      newInst.Instruction.NumSrcRegs = 2;
-      newInst.Src[0].Register.File = TGSI_FILE_INPUT;
-      newInst.Src[0].Register.Index = wincoordInput;
-      newInst.Src[1].Register.File = TGSI_FILE_IMMEDIATE;
-      newInst.Src[1].Register.Index = pctx->numImmed;
-      ctx->emit_instruction(ctx, &newInst);
-
-      /* TEX texTemp, texTemp, sampler; */
-      newInst = tgsi_default_full_instruction();
-      newInst.Instruction.Opcode = TGSI_OPCODE_TEX;
-      newInst.Instruction.NumDstRegs = 1;
-      newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
-      newInst.Dst[0].Register.Index = pctx->texTemp;
-      newInst.Instruction.NumSrcRegs = 2;
-      newInst.Instruction.Texture = TRUE;
-      newInst.Texture.Texture = TGSI_TEXTURE_2D;
-      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
-      newInst.Src[0].Register.Index = pctx->texTemp;
-      newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
-      newInst.Src[1].Register.Index = pctx->freeSampler;
-      ctx->emit_instruction(ctx, &newInst);
-
-      /* KILL_IF -texTemp;   # if -texTemp < 0, kill fragment */
-      newInst = tgsi_default_full_instruction();
-      newInst.Instruction.Opcode = TGSI_OPCODE_KILL_IF;
-      newInst.Instruction.NumDstRegs = 0;
-      newInst.Instruction.NumSrcRegs = 1;
-      newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
-      newInst.Src[0].Register.Index = pctx->texTemp;
-      newInst.Src[0].Register.Negate = 1;
-      ctx->emit_instruction(ctx, &newInst);
+   /* Declare temp[0] reg if not already declared.
+    * We can always use temp[0] since this code is before
+    * the rest of the shader.
+    */
+   texTemp = 0;
+   if ((pctx->tempsUsed & (1 << texTemp)) == 0) {
+      tgsi_transform_temp_decl(ctx, texTemp);
    }
 
-   /* emit this instruction */
-   ctx->emit_instruction(ctx, inst);
+   /* emit immediate = {1/32, 1/32, 1, 1}
+    * The index/position of this immediate will be pctx->numImmed
+    */
+   tgsi_transform_immediate_decl(ctx, 1.0/32.0, 1.0/32.0, 1.0, 1.0);
+
+   /* 
+    * Insert new MUL/TEX/KILL_IF instructions at start of program
+    * Take gl_FragCoord, divide by 32 (stipple size), sample the
+    * texture and kill fragment if needed.
+    *
+    * We'd like to use non-normalized texcoords to index into a RECT
+    * texture, but we can only use REPEAT wrap mode with normalized
+    * texcoords.  Darn.
+    */
+
+   /* XXX invert wincoord if origin isn't lower-left... */
+
+   /* MUL texTemp, INPUT[wincoord], 1/32; */
+   tgsi_transform_op2_inst(ctx, TGSI_OPCODE_MUL,
+                           TGSI_FILE_TEMPORARY, texTemp,
+                           TGSI_WRITEMASK_XYZW,
+                           TGSI_FILE_INPUT, wincoordInput,
+                           TGSI_FILE_IMMEDIATE, pctx->numImmed);
+
+   /* TEX texTemp, texTemp, sampler; */
+   tgsi_transform_tex_2d_inst(ctx,
+                              TGSI_FILE_TEMPORARY, texTemp,
+                              TGSI_FILE_TEMPORARY, texTemp,
+                              pctx->freeSampler);
+
+   /* KILL_IF -texTemp;   # if -texTemp < 0, kill fragment */
+   tgsi_transform_kill_inst(ctx,
+                            TGSI_FILE_TEMPORARY, texTemp,
+                            TGSI_SWIZZLE_W);
 }
 
 
 /**
  * Given a fragment shader, return a new fragment shader which
  * samples a stipple texture and executes KILL.
+ * \param samplerUnitOut  returns the index of the sampler unit which
+ *                        will be used to sample the stipple texture
  */
-struct pipe_shader_state *
-util_pstipple_create_fragment_shader(struct pipe_context *pipe,
-                                     struct pipe_shader_state *fs,
+struct tgsi_token *
+util_pstipple_create_fragment_shader(const struct tgsi_token *tokens,
                                      unsigned *samplerUnitOut)
 {
-   struct pipe_shader_state *new_fs;
    struct pstip_transform_context transform;
-   const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
-
-   new_fs = MALLOC(sizeof(*new_fs));
-   if (!new_fs)
-      return NULL;
+   const uint newLen = tgsi_num_tokens(tokens) + NUM_NEW_TOKENS;
+   struct tgsi_token *new_tokens;
 
-   new_fs->tokens = tgsi_alloc_tokens(newLen);
-   if (!new_fs->tokens) {
-      FREE(new_fs);
+   new_tokens = tgsi_alloc_tokens(newLen);
+   if (!new_tokens) {
       return NULL;
    }
 
@@ -423,21 +351,17 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
    memset(&transform, 0, sizeof(transform));
    transform.wincoordInput = -1;
    transform.maxInput = -1;
-   transform.texTemp = -1;
-   transform.firstInstruction = TRUE;
    transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT;
-   transform.base.transform_instruction = pstip_transform_inst;
+   transform.base.prolog = pstip_transform_prolog;
    transform.base.transform_declaration = pstip_transform_decl;
    transform.base.transform_immediate = pstip_transform_immed;
 
-   tgsi_scan_shader(fs->tokens, &transform.info);
+   tgsi_scan_shader(tokens, &transform.info);
 
    transform.coordOrigin =
       transform.info.properties[TGSI_PROPERTY_FS_COORD_ORIGIN];
 
-   tgsi_transform_shader(fs->tokens,
-                         (struct tgsi_token *) new_fs->tokens,
-                         newLen, &transform.base);
+   tgsi_transform_shader(tokens, new_tokens, newLen, &transform.base);
 
 #if 0 /* DEBUG */
    tgsi_dump(fs->tokens, 0);
@@ -447,6 +371,6 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
    assert(transform.freeSampler < PIPE_MAX_SAMPLERS);
    *samplerUnitOut = transform.freeSampler;
 
-   return new_fs;
+   return new_tokens;
 }
 
diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.h b/mesalib/src/gallium/auxiliary/util/u_pstipple.h
index 6fbed80..13155e7 100644
--- a/mesalib/src/gallium/auxiliary/util/u_pstipple.h
+++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.h
@@ -47,9 +47,8 @@ util_pstipple_create_sampler_view(struct pipe_context *pipe,
 extern void *
 util_pstipple_create_sampler(struct pipe_context *pipe);
 
-extern struct pipe_shader_state *
-util_pstipple_create_fragment_shader(struct pipe_context *pipe,
-                                     struct pipe_shader_state *fs,
+struct tgsi_token *
+util_pstipple_create_fragment_shader(const struct tgsi_token *tokens,
                                      unsigned *samplerUnitOut);
 
 
diff --git a/mesalib/src/gallium/auxiliary/util/u_rect.h b/mesalib/src/gallium/auxiliary/util/u_rect.h
index dd87f81..cf29dff 100644
--- a/mesalib/src/gallium/auxiliary/util/u_rect.h
+++ b/mesalib/src/gallium/auxiliary/util/u_rect.h
@@ -30,6 +30,7 @@
 #define U_RECT_H
 
 #include "pipe/p_compiler.h"
+#include "util/u_math.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -67,6 +68,12 @@ u_rect_find_intersection(const struct u_rect *a,
 }
 
 
+static INLINE int
+u_rect_area(const struct u_rect *r)
+{
+   return (r->x1 - r->x0) * (r->y1 - r->y0);
+}
+
 static INLINE void
 u_rect_possible_intersection(const struct u_rect *a,
                              struct u_rect *b)
@@ -79,6 +86,17 @@ u_rect_possible_intersection(const struct u_rect *a,
    }
 }
 
+/* Set @d to a rectangle that covers both @a and @b.
+ */
+static INLINE void
+u_rect_union(struct u_rect *d, const struct u_rect *a, const struct u_rect *b)
+{
+   d->x0 = MIN2(a->x0, b->x0);
+   d->y0 = MIN2(a->y0, b->y0);
+   d->x1 = MAX2(a->x1, b->x1);
+   d->y1 = MAX2(a->y1, b->y1);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
index adf4887..edb3037 100644
--- a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -59,11 +59,13 @@ void *
 util_make_vertex_passthrough_shader(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
-                                    const uint *semantic_indexes)
+                                    const uint *semantic_indexes,
+                                    bool window_space)
 {
    return util_make_vertex_passthrough_shader_with_so(pipe, num_attribs,
                                                       semantic_names,
-                                                      semantic_indexes, NULL);
+                                                      semantic_indexes,
+                                                      window_space, NULL);
 }
 
 void *
@@ -71,6 +73,7 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
                                     const uint *semantic_indexes,
+                                    bool window_space,
 				    const struct pipe_stream_output_info *so)
 {
    struct ureg_program *ureg;
@@ -80,6 +83,9 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
    if (ureg == NULL)
       return NULL;
 
+   if (window_space)
+      ureg_property(ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, TRUE);
+
    for (i = 0; i < num_attribs; i++) {
       struct ureg_src src;
       struct ureg_dst dst;
@@ -124,6 +130,76 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe)
    return pipe->create_vs_state(pipe, &state);
 }
 
+/**
+ * Takes position and color, and outputs position, color, and instance id.
+ */
+void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe)
+{
+   static const char text[] =
+         "VERT\n"
+         "DCL IN[0]\n"
+         "DCL IN[1]\n"
+         "DCL SV[0], INSTANCEID\n"
+         "DCL OUT[0], POSITION\n"
+         "DCL OUT[1], GENERIC[0]\n"
+         "DCL OUT[2], GENERIC[1]\n"
+
+         "MOV OUT[0], IN[0]\n"
+         "MOV OUT[1], IN[1]\n"
+         "MOV OUT[2].x, SV[0].xxxx\n"
+         "END\n";
+   struct tgsi_token tokens[1000];
+   struct pipe_shader_state state = {tokens};
+
+   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+      assert(0);
+      return NULL;
+   }
+   return pipe->create_vs_state(pipe, &state);
+}
+
+/**
+ * Takes position, color, and target layer, and emits vertices on that target
+ * layer, with the specified color.
+ */
+void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
+{
+   static const char text[] =
+      "GEOM\n"
+      "PROPERTY GS_INPUT_PRIMITIVE TRIANGLES\n"
+      "PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP\n"
+      "PROPERTY GS_MAX_OUTPUT_VERTICES 3\n"
+      "PROPERTY GS_INVOCATIONS 1\n"
+      "DCL IN[][0], POSITION\n" /* position */
+      "DCL IN[][1], GENERIC[0]\n" /* color */
+      "DCL IN[][2], GENERIC[1]\n" /* vs invocation */
+      "DCL OUT[0], POSITION\n"
+      "DCL OUT[1], GENERIC[0]\n"
+      "DCL OUT[2], LAYER\n"
+      "IMM[0] INT32 {0, 0, 0, 0}\n"
+
+      "MOV OUT[0], IN[0][0]\n"
+      "MOV OUT[1], IN[0][1]\n"
+      "MOV OUT[2].x, IN[0][2].xxxx\n"
+      "EMIT IMM[0].xxxx\n"
+      "MOV OUT[0], IN[1][0]\n"
+      "MOV OUT[1], IN[1][1]\n"
+      "MOV OUT[2].x, IN[1][2].xxxx\n"
+      "EMIT IMM[0].xxxx\n"
+      "MOV OUT[0], IN[2][0]\n"
+      "MOV OUT[1], IN[2][1]\n"
+      "MOV OUT[2].x, IN[2][2].xxxx\n"
+      "EMIT IMM[0].xxxx\n"
+      "END\n";
+   struct tgsi_token tokens[1000];
+   struct pipe_shader_state state = {tokens};
+
+   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+      assert(0);
+      return NULL;
+   }
+   return pipe->create_gs_state(pipe, &state);
+}
 
 /**
  * Make simple fragment texture shader:
diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
index c1d14aa..dd282e0 100644
--- a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -47,19 +47,27 @@ extern void *
 util_make_vertex_passthrough_shader(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
-                                    const uint *semantic_indexes);
+                                    const uint *semantic_indexes,
+                                    bool window_space);
 
 extern void *
 util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
                                     const uint *semantic_indexes,
+                                    bool window_space,
                                     const struct pipe_stream_output_info *so);
 
 extern void *
 util_make_layered_clear_vertex_shader(struct pipe_context *pipe);
 
 extern void *
+util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe);
+
+extern void *
+util_make_layered_clear_geometry_shader(struct pipe_context *pipe);
+
+extern void *
 util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, 
                                         unsigned tex_target,
                                         unsigned interp_mode,
diff --git a/mesalib/src/gallium/auxiliary/util/u_snprintf.c b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
index 7a2bf2a..39e9b70 100644
--- a/mesalib/src/gallium/auxiliary/util/u_snprintf.c
+++ b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
@@ -176,7 +176,7 @@
 #define HAVE_ASPRINTF 1 /* not needed */
 #define HAVE_STDARG_H 1
 #define HAVE_STDDEF_H 1
-#define HAVE_STDINT_H 0
+#define HAVE_STDINT_H 1
 #define HAVE_STDLIB_H 1
 #define HAVE_INTTYPES_H 0
 #define HAVE_LOCALE_H 0
diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.c b/mesalib/src/gallium/auxiliary/util/u_tests.c
new file mode 100644
index 0000000..c0f6327
--- /dev/null
+++ b/mesalib/src/gallium/auxiliary/util/u_tests.c
@@ -0,0 +1,268 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Advanced Micro Devices, 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ **************************************************************************/
+
+#include "util/u_tests.h"
+
+#include "util/u_draw_quad.h"
+#include "util/u_format.h"
+#include "util/u_inlines.h"
+#include "util/u_simple_shaders.h"
+#include "util/u_surface.h"
+#include "util/u_tile.h"
+#include "cso_cache/cso_context.h"
+#include <stdio.h>
+
+#define TOLERANCE 0.01
+
+static struct pipe_resource *
+util_create_texture2d(struct pipe_screen *screen, unsigned width,
+                      unsigned height, enum pipe_format format)
+{
+   struct pipe_resource templ = {{0}};
+
+   templ.target = PIPE_TEXTURE_2D;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+   templ.format = format;
+   templ.usage = PIPE_USAGE_DEFAULT;
+   templ.bind = PIPE_BIND_SAMPLER_VIEW |
+                (util_format_is_depth_or_stencil(format) ?
+                    PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET);
+
+   return screen->resource_create(screen, &templ);
+}
+
+static void
+util_set_framebuffer_cb0(struct cso_context *cso, struct pipe_context *ctx,
+			 struct pipe_resource *tex)
+{
+   struct pipe_surface templ = {{0}}, *surf;
+   struct pipe_framebuffer_state fb = {0};
+
+   templ.format = tex->format;
+   surf = ctx->create_surface(ctx, tex, &templ);
+
+   fb.width = tex->width0;
+   fb.height = tex->height0;
+   fb.cbufs[0] = surf;
+   fb.nr_cbufs = 1;
+
+   cso_set_framebuffer(cso, &fb);
+   pipe_surface_reference(&surf, NULL);
+}
+
+static void
+util_set_blend_normal(struct cso_context *cso)
+{
+   struct pipe_blend_state blend = {0};
+
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   cso_set_blend(cso, &blend);
+}
+
+static void
+util_set_dsa_disable(struct cso_context *cso)
+{
+   struct pipe_depth_stencil_alpha_state dsa = {{0}};
+
+   cso_set_depth_stencil_alpha(cso, &dsa);
+}
+
+static void
+util_set_rasterizer_normal(struct cso_context *cso)
+{
+   struct pipe_rasterizer_state rs = {0};
+
+   rs.half_pixel_center = 1;
+   rs.bottom_edge_rule = 1;
+   rs.depth_clip = 1;
+
+   cso_set_rasterizer(cso, &rs);
+}
+
+static void
+util_set_max_viewport(struct cso_context *cso, struct pipe_resource *tex)
+{
+   struct pipe_viewport_state viewport;
+
+   viewport.scale[0] = 0.5f * tex->width0;
+   viewport.scale[1] = 0.5f * tex->height0;
+   viewport.scale[2] = 1.0f;
+   viewport.translate[0] = 0.5f * tex->width0;
+   viewport.translate[1] = 0.5f * tex->height0;
+   viewport.translate[2] = 0.0f;
+
+   cso_set_viewport(cso, &viewport);
+}
+
+static void
+util_set_interleaved_vertex_elements(struct cso_context *cso,
+                                     unsigned num_elements)
+{
+   int i;
+   struct pipe_vertex_element *velem =
+      calloc(1, num_elements * sizeof(struct pipe_vertex_element));
+
+   for (i = 0; i < num_elements; i++) {
+      velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+      velem[i].src_offset = i * 16;
+   }
+
+   cso_set_vertex_elements(cso, num_elements, velem);
+   free(velem);
+}
+
+static bool
+util_probe_rect_rgba(struct pipe_context *ctx, struct pipe_resource *tex,
+                     unsigned offx, unsigned offy, unsigned w, unsigned h,
+                     const float *expected)
+{
+   struct pipe_transfer *transfer;
+   void *map;
+   float *pixels = malloc(w * h * 4 * sizeof(float));
+   int x,y,c;
+   bool pass = true;
+
+   map = pipe_transfer_map(ctx, tex, 0, 0, PIPE_TRANSFER_READ,
+                           offx, offy, w, h, &transfer);
+   pipe_get_tile_rgba(transfer, map, 0, 0, w, h, pixels);
+   pipe_transfer_unmap(ctx, transfer);
+
+   for (y = 0; y < h; y++) {
+      for (x = 0; x < w; x++) {
+         float *probe = &pixels[(y*w + x)*4];
+
+         for (c = 0; c < 4; c++)
+            if (fabs(probe[c] - expected[c]) >= TOLERANCE) {
+               printf("Probe color at (%i,%i),  ", offx+x, offy+y);
+               printf("Expected: %.3f, %.3f, %.3f, %.3f,  ",
+                      expected[0], expected[1], expected[2], expected[3]);
+               printf("Got: %.3f, %.3f, %.3f, %.3f\n",
+                      probe[0], probe[1], probe[2], probe[2]);
+               pass = false;
+               goto done;
+            }
+      }
+   }
+done:
+
+   free(pixels);
+   return pass;
+}
+
+/**
+ * Test TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION.
+ *
+ * The viewport state is set as usual, but it should have no effect.
+ * Clipping should also be disabled.
+ *
+ * POSITION.xyz should already be multiplied by 1/w and POSITION.w should
+ * contain 1/w. By setting w=0, we can test that POSITION.xyz isn't
+ * multiplied by 1/w (otherwise nothing would be rendered).
+ *
+ * TODO: Whether the value of POSITION.w is correctly interpreted as 1/w
+ *       during perspective interpolation is not tested.
+ */
+static void
+tgsi_vs_window_space_position(struct pipe_context *ctx)
+{
+   struct cso_context *cso;
+   struct pipe_resource *cb;
+   void *fs, *vs;
+   bool pass = true;
+
+   static uint vs_attribs[] = {
+      TGSI_SEMANTIC_POSITION,
+      TGSI_SEMANTIC_GENERIC
+   };
+   static uint vs_indices[] = {0, 0};
+   static float vertices[] = {
+       0,   0, 0, 0,   1,  0, 0, 1,
+       0, 256, 0, 0,   1,  0, 0, 1,
+     256, 256, 0, 0,   1,  0, 0, 1,
+     256,   0, 0, 0,   1,  0, 0, 1,
+   };
+   static float red[] = {1, 0, 0, 1};
+   static float clear_color[] = {0.1, 0.1, 0.1, 0.1};
+
+   if (!ctx->screen->get_param(ctx->screen,
+                               PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION)) {
+      printf("Test(%s) = skip\n", __func__);
+      return;
+   }
+
+   cso = cso_create_context(ctx);
+   cb = util_create_texture2d(ctx->screen, 256, 256,
+                              PIPE_FORMAT_R8G8B8A8_UNORM);
+
+   /* Set states. */
+   util_set_framebuffer_cb0(cso, ctx, cb);
+   util_set_blend_normal(cso);
+   util_set_dsa_disable(cso);
+   util_set_rasterizer_normal(cso);
+   util_set_max_viewport(cso, cb);
+   util_set_interleaved_vertex_elements(cso, 2);
+
+   /* Fragment shader. */
+   fs = util_make_fragment_passthrough_shader(ctx, TGSI_SEMANTIC_GENERIC,
+                                       TGSI_INTERPOLATE_LINEAR, TRUE);
+   cso_set_fragment_shader_handle(cso, fs);
+
+   /* Vertex shader. */
+   vs = util_make_vertex_passthrough_shader(ctx, 2, vs_attribs, vs_indices,
+                                            TRUE);
+   cso_set_vertex_shader_handle(cso, vs);
+
+   /* Clear and draw. */
+   ctx->clear(ctx, PIPE_CLEAR_COLOR0, (void*)clear_color, 0, 0);
+   util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2);
+
+   /* Probe pixels. */
+   pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0,
+                                       cb->width0, cb->height0, red);
+
+   /* Cleanup. */
+   cso_release_all(cso);
+   cso_destroy_context(cso);
+   ctx->delete_vs_state(ctx, vs);
+   ctx->delete_fs_state(ctx, fs);
+   pipe_resource_reference(&cb, NULL);
+
+   printf("Test(%s) = %s\n", __func__, pass ? "pass" : "fail");
+}
+
+/**
+ * Run all tests. This should be run with a clean context after
+ * context_create.
+ */
+void
+util_run_tests(struct pipe_context *ctx)
+{
+   tgsi_vs_window_space_position(ctx);
+}
diff --git a/mesalib/src/glsl/strtod.h b/mesalib/src/gallium/auxiliary/util/u_tests.h
similarity index 72%
copy from mesalib/src/glsl/strtod.h
copy to mesalib/src/gallium/auxiliary/util/u_tests.h
index ad847db..a143934 100644
--- a/mesalib/src/glsl/strtod.h
+++ b/mesalib/src/gallium/auxiliary/util/u_tests.h
@@ -1,5 +1,6 @@
-/*
- * Copyright 2010 VMware, Inc.
+/**************************************************************************
+ *
+ * Copyright 2014 Advanced Micro Devices, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -17,30 +18,20 @@
  * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- */
-
-
-#ifndef STRTOD_H
-#define STRTOD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern double
-glsl_strtod(const char *s, char **end);
+ *
+ **************************************************************************/
 
-extern float
-glsl_strtof(const char *s, char **end);
+#ifndef U_TESTS_H
+#define U_TESTS_H
 
+#include "pipe/p_compiler.h"
 
-#ifdef __cplusplus
-}
-#endif
+struct pipe_context;
 
+void util_run_tests(struct pipe_context *ctx);
 
 #endif
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index 0c55327..676fa0d 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -59,6 +59,7 @@ LIBGLSL_FILES = \
 	$(GLSL_SRCDIR)/loop_controls.cpp \
 	$(GLSL_SRCDIR)/loop_unroll.cpp \
 	$(GLSL_SRCDIR)/lower_clip_distance.cpp \
+	$(GLSL_SRCDIR)/lower_const_arrays_to_uniforms.cpp \
 	$(GLSL_SRCDIR)/lower_discard.cpp \
 	$(GLSL_SRCDIR)/lower_discard_flow.cpp \
 	$(GLSL_SRCDIR)/lower_if_to_cond_assign.cpp \
@@ -104,8 +105,7 @@ LIBGLSL_FILES = \
 	$(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \
 	$(GLSL_SRCDIR)/opt_tree_grafting.cpp \
 	$(GLSL_SRCDIR)/opt_vectorize.cpp \
-	$(GLSL_SRCDIR)/s_expression.cpp \
-	$(GLSL_SRCDIR)/strtod.c
+	$(GLSL_SRCDIR)/s_expression.cpp
 
 # glsl_compiler
 
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index 15bf086..6995ae8 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -640,19 +640,6 @@ class ast_declarator_list;
 
 class ast_struct_specifier : public ast_node {
 public:
-   /**
-    * \brief Make a shallow copy of an ast_struct_specifier.
-    *
-    * Use only if the objects are allocated from the same context and will not
-    * be modified. Zeros the inherited ast_node's fields.
-    */
-   ast_struct_specifier(const ast_struct_specifier& that):
-      ast_node(), name(that.name), declarations(that.declarations),
-      is_declaration(that.is_declaration)
-   {
-      /* empty */
-   }
-
    ast_struct_specifier(const char *identifier,
 			ast_declarator_list *declarator_list);
    virtual void print(void) const;
@@ -670,22 +657,6 @@ public:
 
 class ast_type_specifier : public ast_node {
 public:
-   /**
-    * \brief Make a shallow copy of an ast_type_specifier, specifying array
-    *        fields.
-    *
-    * Use only if the objects are allocated from the same context and will not
-    * be modified. Zeros the inherited ast_node's fields.
-    */
-   ast_type_specifier(const ast_type_specifier *that,
-                      ast_array_specifier *array_specifier)
-      : ast_node(), type_name(that->type_name), structure(that->structure),
-        array_specifier(array_specifier),
-        default_precision(that->default_precision)
-   {
-      /* empty */
-   }
-
    /** Construct a type specifier from a type name */
    ast_type_specifier(const char *name) 
       : type_name(name), structure(NULL), array_specifier(NULL),
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index e66a935..57c46be 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -23,7 +23,7 @@
  */
 #include <ctype.h>
 #include <limits.h>
-#include "strtod.h"
+#include "util/strtod.h"
 #include "ast.h"
 #include "glsl_parser_extras.h"
 #include "glsl_parser.h"
@@ -450,24 +450,11 @@ layout		{
 			    return LITERAL_INTEGER(8);
 			}
 
-[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?	{
-			    yylval->real = glsl_strtof(yytext, NULL);
-			    return FLOATCONSTANT;
-			}
-\.[0-9]+([eE][+-]?[0-9]+)?[fF]?		{
-			    yylval->real = glsl_strtof(yytext, NULL);
-			    return FLOATCONSTANT;
-			}
-[0-9]+\.([eE][+-]?[0-9]+)?[fF]?		{
-			    yylval->real = glsl_strtof(yytext, NULL);
-			    return FLOATCONSTANT;
-			}
+[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?	|
+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?		|
+[0-9]+\.([eE][+-]?[0-9]+)?[fF]?		|
 [0-9]+[eE][+-]?[0-9]+[fF]?		{
-			    yylval->real = glsl_strtof(yytext, NULL);
-			    return FLOATCONSTANT;
-			}
-[0-9]+[fF]		{
-			    yylval->real = glsl_strtof(yytext, NULL);
+			    yylval->real = _mesa_strtof(yytext, NULL);
 			    return FLOATCONSTANT;
 			}
 
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 79f8494..27e3301 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -1350,9 +1350,15 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier,
 					   ast_declarator_list *declarator_list)
 {
    if (identifier == NULL) {
+      static mtx_t mutex = _MTX_INITIALIZER_NP;
       static unsigned anon_count = 1;
-      identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count);
-      anon_count++;
+      unsigned count;
+
+      mtx_lock(&mutex);
+      count = anon_count++;
+      mtx_unlock(&mutex);
+
+      identifier = ralloc_asprintf(this, "#anon_struct_%04x", count);
    }
    name = identifier;
    this->declarations.push_degenerate_list_at_head(&declarator_list->link);
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index c11d864..5f99193 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -29,6 +29,7 @@ extern "C" {
 #include "program/hash_table.h"
 }
 
+mtx_t glsl_type::mutex = _MTX_INITIALIZER_NP;
 hash_table *glsl_type::array_types = NULL;
 hash_table *glsl_type::record_types = NULL;
 hash_table *glsl_type::interface_types = NULL;
@@ -53,9 +54,14 @@ glsl_type::glsl_type(GLenum gl_type,
    vector_elements(vector_elements), matrix_columns(matrix_columns),
    length(0)
 {
+   mtx_lock(&glsl_type::mutex);
+
    init_ralloc_type_ctx();
    assert(name != NULL);
    this->name = ralloc_strdup(this->mem_ctx, name);
+
+   mtx_unlock(&glsl_type::mutex);
+
    /* Neither dimension is zero or both dimensions are zero.
     */
    assert((vector_elements == 0) == (matrix_columns == 0));
@@ -71,9 +77,14 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type,
    sampler_array(array), sampler_type(type), interface_packing(0),
    length(0)
 {
+   mtx_lock(&glsl_type::mutex);
+
    init_ralloc_type_ctx();
    assert(name != NULL);
    this->name = ralloc_strdup(this->mem_ctx, name);
+
+   mtx_unlock(&glsl_type::mutex);
+
    memset(& fields, 0, sizeof(fields));
 
    if (base_type == GLSL_TYPE_SAMPLER) {
@@ -95,11 +106,14 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
 {
    unsigned int i;
 
+   mtx_lock(&glsl_type::mutex);
+
    init_ralloc_type_ctx();
    assert(name != NULL);
    this->name = ralloc_strdup(this->mem_ctx, name);
    this->fields.structure = ralloc_array(this->mem_ctx,
 					 glsl_struct_field, length);
+
    for (i = 0; i < length; i++) {
       this->fields.structure[i].type = fields[i].type;
       this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
@@ -110,6 +124,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
       this->fields.structure[i].sample = fields[i].sample;
       this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
    }
+
+   mtx_unlock(&glsl_type::mutex);
 }
 
 glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
@@ -123,6 +139,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
 {
    unsigned int i;
 
+   mtx_lock(&glsl_type::mutex);
+
    init_ralloc_type_ctx();
    assert(name != NULL);
    this->name = ralloc_strdup(this->mem_ctx, name);
@@ -138,6 +156,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
       this->fields.structure[i].sample = fields[i].sample;
       this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
    }
+
+   mtx_unlock(&glsl_type::mutex);
 }
 
 
@@ -285,6 +305,8 @@ const glsl_type *glsl_type::get_scalar_type() const
 void
 _mesa_glsl_release_types(void)
 {
+   mtx_lock(&glsl_type::mutex);
+
    if (glsl_type::array_types != NULL) {
       hash_table_dtor(glsl_type::array_types);
       glsl_type::array_types = NULL;
@@ -294,6 +316,8 @@ _mesa_glsl_release_types(void)
       hash_table_dtor(glsl_type::record_types);
       glsl_type::record_types = NULL;
    }
+
+   mtx_unlock(&glsl_type::mutex);
 }
 
 
@@ -302,7 +326,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
    sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
    sampler_type(0), interface_packing(0),
    vector_elements(0), matrix_columns(0),
-   name(NULL), length(length)
+   length(length), name(NULL)
 {
    this->fields.array = array;
    /* Inherit the gl type of the base. The GL type is used for
@@ -316,7 +340,10 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
     * NUL.
     */
    const unsigned name_length = strlen(array->name) + 10 + 3;
+
+   mtx_lock(&glsl_type::mutex);
    char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
+   mtx_unlock(&glsl_type::mutex);
 
    if (length == 0)
       snprintf(n, name_length, "%s[]", array->name);
@@ -452,12 +479,6 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
 const glsl_type *
 glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
 {
-
-   if (array_types == NULL) {
-      array_types = hash_table_ctor(64, hash_table_string_hash,
-				    hash_table_string_compare);
-   }
-
    /* Generate a name using the base type pointer in the key.  This is
     * done because the name of the base type may not be unique across
     * shaders.  For example, two shaders may have different record types
@@ -466,9 +487,19 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
    char key[128];
    snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
 
+   mtx_lock(&glsl_type::mutex);
+
+   if (array_types == NULL) {
+      array_types = hash_table_ctor(64, hash_table_string_hash,
+				    hash_table_string_compare);
+   }
+
    const glsl_type *t = (glsl_type *) hash_table_find(array_types, key);
+
    if (t == NULL) {
+      mtx_unlock(&glsl_type::mutex);
       t = new glsl_type(base, array_size);
+      mtx_lock(&glsl_type::mutex);
 
       hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
    }
@@ -477,6 +508,8 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
    assert(t->length == array_size);
    assert(t->fields.array == base);
 
+   mtx_unlock(&glsl_type::mutex);
+
    return t;
 }
 
@@ -575,13 +608,17 @@ glsl_type::get_record_instance(const glsl_struct_field *fields,
 {
    const glsl_type key(fields, num_fields, name);
 
+   mtx_lock(&glsl_type::mutex);
+
    if (record_types == NULL) {
       record_types = hash_table_ctor(64, record_key_hash, record_key_compare);
    }
 
    const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key);
    if (t == NULL) {
+      mtx_unlock(&glsl_type::mutex);
       t = new glsl_type(fields, num_fields, name);
+      mtx_lock(&glsl_type::mutex);
 
       hash_table_insert(record_types, (void *) t, t);
    }
@@ -590,6 +627,8 @@ glsl_type::get_record_instance(const glsl_struct_field *fields,
    assert(t->length == num_fields);
    assert(strcmp(t->name, name) == 0);
 
+   mtx_unlock(&glsl_type::mutex);
+
    return t;
 }
 
@@ -602,13 +641,17 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
 {
    const glsl_type key(fields, num_fields, packing, block_name);
 
+   mtx_lock(&glsl_type::mutex);
+
    if (interface_types == NULL) {
       interface_types = hash_table_ctor(64, record_key_hash, record_key_compare);
    }
 
    const glsl_type *t = (glsl_type *) hash_table_find(interface_types, & key);
    if (t == NULL) {
+      mtx_unlock(&glsl_type::mutex);
       t = new glsl_type(fields, num_fields, packing, block_name);
+      mtx_lock(&glsl_type::mutex);
 
       hash_table_insert(interface_types, (void *) t, t);
    }
@@ -617,6 +660,8 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
    assert(t->length == num_fields);
    assert(strcmp(t->name, block_name) == 0);
 
+   mtx_unlock(&glsl_type::mutex);
+
    return t;
 }
 
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index eeb14c2..474b129 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -122,16 +122,18 @@ struct glsl_type {
     * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
    static void* operator new(size_t size)
    {
-      if (glsl_type::mem_ctx == NULL) {
-	 glsl_type::mem_ctx = ralloc_context(NULL);
-	 assert(glsl_type::mem_ctx != NULL);
-      }
+      mtx_lock(&glsl_type::mutex);
+
+      /* mem_ctx should have been created by the static members */
+      assert(glsl_type::mem_ctx != NULL);
 
       void *type;
 
       type = ralloc_size(glsl_type::mem_ctx, size);
       assert(type != NULL);
 
+      mtx_unlock(&glsl_type::mutex);
+
       return type;
    }
 
@@ -139,7 +141,9 @@ struct glsl_type {
     * ralloc_free in that case. */
    static void operator delete(void *type)
    {
+      mtx_lock(&glsl_type::mutex);
       ralloc_free(type);
+      mtx_unlock(&glsl_type::mutex);
    }
 
    /**
@@ -149,18 +153,11 @@ struct glsl_type {
     * these will be 0.
     */
    /*@{*/
-   unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
-   unsigned matrix_columns:3;  /**< 1, 2, 3, or 4 matrix columns. */
+   uint8_t vector_elements;    /**< 1, 2, 3, or 4 vector elements. */
+   uint8_t matrix_columns;     /**< 1, 2, 3, or 4 matrix columns. */
    /*@}*/
 
    /**
-    * Name of the data type
-    *
-    * Will never be \c NULL.
-    */
-   const char *name;
-
-   /**
     * For \c GLSL_TYPE_ARRAY, this is the length of the array.  For
     * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
     * elements in the structure and the number of values pointed to by
@@ -169,6 +166,13 @@ struct glsl_type {
    unsigned length;
 
    /**
+    * Name of the data type
+    *
+    * Will never be \c NULL.
+    */
+   const char *name;
+
+   /**
     * Subtype of composite data types.
     */
    union {
@@ -618,6 +622,9 @@ struct glsl_type {
    bool record_compare(const glsl_type *b) const;
 
 private:
+
+   static mtx_t mutex;
+
    /**
     * ralloc context for all glsl_type allocations
     *
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index c712c6a..fe5601a 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -46,11 +46,6 @@ bool ir_rvalue::is_negative_one() const
    return false;
 }
 
-bool ir_rvalue::is_basis() const
-{
-   return false;
-}
-
 /**
  * Modify the swizzle make to move one component to another
  *
@@ -1191,49 +1186,6 @@ ir_constant::is_negative_one() const
 }
 
 bool
-ir_constant::is_basis() const
-{
-   if (!this->type->is_scalar() && !this->type->is_vector())
-      return false;
-
-   if (this->type->is_boolean())
-      return false;
-
-   unsigned ones = 0;
-   for (unsigned c = 0; c < this->type->vector_elements; c++) {
-      switch (this->type->base_type) {
-      case GLSL_TYPE_FLOAT:
-	 if (this->value.f[c] == 1.0)
-	    ones++;
-	 else if (this->value.f[c] != 0.0)
-	    return false;
-	 break;
-      case GLSL_TYPE_INT:
-	 if (this->value.i[c] == 1)
-	    ones++;
-	 else if (this->value.i[c] != 0)
-	    return false;
-	 break;
-      case GLSL_TYPE_UINT:
-	 if (int(this->value.u[c]) == 1)
-	    ones++;
-	 else if (int(this->value.u[c]) != 0)
-	    return false;
-	 break;
-      default:
-	 /* The only other base types are structures, arrays, samplers, and
-	  * booleans.  Samplers cannot be constants, and the others should
-	  * have been filtered out above.
-	  */
-	 assert(!"Should not get here.");
-	 return false;
-      }
-   }
-
-   return ones == 1;
-}
-
-bool
 ir_constant::is_uint16_constant() const
 {
    if (!type->is_integer())
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 90c443c..a0f48b2 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -251,8 +251,7 @@ public:
     * for vector and scalar types that have all elements set to the value
     * zero (or \c false for booleans).
     *
-    * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one,
-    *     ir_constant::is_basis
+    * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one
     */
    virtual bool is_zero() const;
 
@@ -264,8 +263,7 @@ public:
     * for vector and scalar types that have all elements set to the value
     * one (or \c true for booleans).
     *
-    * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one,
-    *     ir_constant::is_basis
+    * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one
     */
    virtual bool is_one() const;
 
@@ -278,25 +276,10 @@ public:
     * negative one.  For boolean types, the result is always \c false.
     *
     * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one
-    *     ir_constant::is_basis
     */
    virtual bool is_negative_one() const;
 
    /**
-    * Determine if an r-value is a basis vector
-    *
-    * The base implementation of this function always returns \c false.  The
-    * \c ir_constant class over-rides this function to return \c true \b only
-    * for vector and scalar types that have one element set to the value one,
-    * and the other elements set to the value zero.  For boolean types, the
-    * result is always \c false.
-    *
-    * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one,
-    *     is_constant::is_negative_one
-    */
-   virtual bool is_basis() const;
-
-   /**
     * Determine if an r-value is an unsigned integer constant which can be
     * stored in 16 bits.
     *
@@ -359,6 +342,12 @@ enum ir_var_declaration_type {
     * re-declared by the shader.
     */
    ir_var_declared_implicitly,
+
+   /**
+    * Variable is implicitly generated by the compiler and should not be
+    * visible via the API.
+    */
+   ir_var_hidden,
 };
 
 /**
@@ -2257,7 +2246,7 @@ public:
     * Determine whether a constant has the same value as another constant
     *
     * \sa ir_constant::is_zero, ir_constant::is_one,
-    * ir_constant::is_negative_one, ir_constant::is_basis
+    * ir_constant::is_negative_one
     */
    bool has_value(const ir_constant *) const;
 
@@ -2270,7 +2259,6 @@ public:
    virtual bool is_zero() const;
    virtual bool is_one() const;
    virtual bool is_negative_one() const;
-   virtual bool is_basis() const;
 
    /**
     * Return true for constants that could be stored as 16-bit unsigned values.
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index e25857a..34e0b4b 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -114,6 +114,7 @@ bool lower_noise(exec_list *instructions);
 bool lower_variable_index_to_cond_assign(exec_list *instructions,
     bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
+bool lower_const_arrays_to_uniforms(exec_list *instructions);
 bool lower_clip_distance(gl_shader *shader);
 void lower_output_reads(exec_list *instructions);
 bool lower_packing_builtins(exec_list *instructions, int op_mask);
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index ae00e79..fd318c0 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -972,7 +972,7 @@ ir_reader::read_texture(s_expression *expr)
       op = ir_query_levels;
    } else if (MATCH(expr, other_pattern)) {
       op = ir_texture::get_opcode(tag->value());
-      if (op == -1)
+      if (op == (ir_texture_opcode) -1)
 	 return NULL;
    } else {
       ir_read_error(NULL, "unexpected texture pattern %s", tag->value());
diff --git a/mesalib/src/glsl/ir_uniform.h b/mesalib/src/glsl/ir_uniform.h
index b9ecf7c..21b5d05 100644
--- a/mesalib/src/glsl/ir_uniform.h
+++ b/mesalib/src/glsl/ir_uniform.h
@@ -175,6 +175,12 @@ struct gl_uniform_storage {
     * arrays this is the first element in the array.
     */
    unsigned remap_location;
+
+   /**
+    * This is a compiler-generated uniform that should not be advertised
+    * via the API.
+    */
+   bool hidden;
 };
 
 #ifdef __cplusplus
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 400e134..de2f6c9 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -585,6 +585,8 @@ private:
       this->uniforms[id].driver_storage = NULL;
       this->uniforms[id].storage = this->values;
       this->uniforms[id].atomic_buffer_index = -1;
+      this->uniforms[id].hidden =
+         current_var->data.how_declared == ir_var_hidden;
       if (this->ubo_block_index != -1) {
 	 this->uniforms[id].block_index = this->ubo_block_index;
 
@@ -806,6 +808,50 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog)
    }
 }
 
+/**
+ * Sort the array of uniform storage so that the non-hidden uniforms are first
+ *
+ * This function sorts the list "in place."  This is important because some of
+ * the storage accessible from \c uniforms has \c uniforms as its \c ralloc
+ * context.  If \c uniforms is freed, some other storage will also be freed.
+ */
+static unsigned
+move_hidden_uniforms_to_end(struct gl_shader_program *prog,
+                            struct gl_uniform_storage *uniforms,
+                            unsigned num_elements)
+{
+   struct gl_uniform_storage *sorted_uniforms =
+      ralloc_array(prog, struct gl_uniform_storage, num_elements);
+   unsigned hidden_uniforms = 0;
+   unsigned j = 0;
+
+   /* Add the non-hidden uniforms. */
+   for (unsigned i = 0; i < num_elements; i++) {
+      if (!uniforms[i].hidden)
+         sorted_uniforms[j++] = uniforms[i];
+   }
+
+   /* Add and count the hidden uniforms. */
+   for (unsigned i = 0; i < num_elements; i++) {
+      if (uniforms[i].hidden) {
+         sorted_uniforms[j++] = uniforms[i];
+         hidden_uniforms++;
+      }
+   }
+
+   assert(prog->UniformHash != NULL);
+   prog->UniformHash->clear();
+   for (unsigned i = 0; i < num_elements; i++) {
+      if (sorted_uniforms[i].name != NULL)
+         prog->UniformHash->put(i, sorted_uniforms[i].name);
+   }
+
+   memcpy(uniforms, sorted_uniforms, sizeof(uniforms[0]) * num_elements);
+   ralloc_free(sorted_uniforms);
+
+   return hidden_uniforms;
+}
+
 void
 link_assign_uniform_locations(struct gl_shader_program *prog,
                               unsigned int boolean_true)
@@ -926,6 +972,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
              sizeof(prog->_LinkedShaders[i]->SamplerTargets));
    }
 
+   const unsigned hidden_uniforms =
+      move_hidden_uniforms_to_end(prog, uniforms, num_user_uniforms);
+
    /* Reserve all the explicit locations of the active uniforms. */
    for (unsigned i = 0; i < num_user_uniforms; i++) {
       if (uniforms[i].remap_location != UNMAPPED_UNIFORM_LOC) {
@@ -978,6 +1027,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
 #endif
 
    prog->NumUserUniformStorage = num_user_uniforms;
+   prog->NumHiddenUniforms = hidden_uniforms;
    prog->UniformStorage = uniforms;
 
    link_set_image_access_qualifiers(prog);
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 2d31801..de6b1fb 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -642,7 +642,7 @@ validate_geometry_shader_emissions(struct gl_context *ctx,
       emit_vertex.run(prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir);
       if (emit_vertex.error()) {
          linker_error(prog, "Invalid call %s(%d). Accepted values for the "
-                      "stream parameter are in the range [0, %d].",
+                      "stream parameter are in the range [0, %d].\n",
                       emit_vertex.error_func(),
                       emit_vertex.error_stream(),
                       ctx->Const.MaxVertexStreams - 1);
@@ -676,7 +676,7 @@ validate_geometry_shader_emissions(struct gl_context *ctx,
        */
       if (prog->Geom.UsesStreams && prog->Geom.OutputType != GL_POINTS) {
          linker_error(prog, "EmitStreamVertex(n) and EndStreamPrimitive(n) "
-                      "with n>0 requires point output");
+                      "with n>0 requires point output\n");
       }
    }
 }
@@ -808,7 +808,7 @@ cross_validate_globals(struct gl_shader_program *prog,
 		  linker_error(prog,
 			       "All redeclarations of gl_FragDepth in all "
 			       "fragment shaders in a single program must have "
-			       "the same set of qualifiers.");
+			       "the same set of qualifiers.\n");
 	       }
 
 	       if (var->data.used && layout_differs) {
@@ -817,7 +817,7 @@ cross_validate_globals(struct gl_shader_program *prog,
 			       "qualifier in any fragment shader, it must be "
 			       "redeclared with the same layout qualifier in "
 			       "all fragment shaders that have assignments to "
-			       "gl_FragDepth");
+			       "gl_FragDepth\n");
 	       }
 	    }
 
@@ -948,7 +948,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
 						       &sh->UniformBlocks[j]);
 
 	 if (index == -1) {
-	    linker_error(prog, "uniform block `%s' has mismatching definitions",
+	    linker_error(prog, "uniform block `%s' has mismatching definitions\n",
 			 sh->UniformBlocks[j].Name);
 	    return false;
 	 }
@@ -1635,7 +1635,7 @@ link_intrastage_shaders(void *mem_ctx,
 
 	       if ((other_sig != NULL) && other_sig->is_defined
 		   && !other_sig->is_builtin()) {
-		  linker_error(prog, "function `%s' is multiply defined",
+		  linker_error(prog, "function `%s' is multiply defined\n",
 			       f->name);
 		  return NULL;
 	       }
@@ -2086,7 +2086,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
             if (attr + slots > max_index) {
                linker_error(prog,
                            "insufficient contiguous locations "
-                           "available for %s `%s' %d %d %d", string,
+                           "available for %s `%s' %d %d %d\n", string,
                            var->name, used_locations, use_mask, attr);
                return false;
             }
@@ -2155,7 +2155,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
 
 	 linker_error(prog,
 		      "insufficient contiguous locations "
-		      "available for %s `%s'",
+		      "available for %s `%s'\n",
 		      string, to_assign[i].var->name);
 	 return false;
       }
@@ -2257,7 +2257,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 	 continue;
 
       if (sh->num_samplers > ctx->Const.Program[i].MaxTextureImageUnits) {
-	 linker_error(prog, "Too many %s shader texture samplers",
+	 linker_error(prog, "Too many %s shader texture samplers\n",
 		      _mesa_shader_stage_to_string(i));
       }
 
@@ -2271,7 +2271,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
                            _mesa_shader_stage_to_string(i));
          } else {
             linker_error(prog, "Too many %s shader default uniform block "
-			 "components",
+			 "components\n",
                          _mesa_shader_stage_to_string(i));
          }
       }
@@ -2284,7 +2284,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
                            "this is non-portable out-of-spec behavior\n",
                            _mesa_shader_stage_to_string(i));
          } else {
-            linker_error(prog, "Too many %s shader uniform components",
+            linker_error(prog, "Too many %s shader uniform components\n",
                          _mesa_shader_stage_to_string(i));
          }
       }
@@ -2302,7 +2302,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       }
 
       if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
-	 linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+	 linker_error(prog, "Too many combined uniform blocks (%d/%d)\n",
 		      prog->NumUniformBlocks,
 		      ctx->Const.MaxCombinedUniformBlocks);
       } else {
@@ -2310,7 +2310,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
             const unsigned max_uniform_blocks =
                ctx->Const.Program[i].MaxUniformBlocks;
 	    if (blocks[i] > max_uniform_blocks) {
-	       linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+	       linker_error(prog, "Too many %s uniform blocks (%d/%d)\n",
 			    _mesa_shader_stage_to_string(i),
 			    blocks[i],
 			    max_uniform_blocks);
@@ -2338,7 +2338,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 
       if (sh) {
          if (sh->NumImages > ctx->Const.Program[i].MaxImageUniforms)
-            linker_error(prog, "Too many %s shader image uniforms",
+            linker_error(prog, "Too many %s shader image uniforms\n",
                          _mesa_shader_stage_to_string(i));
 
          total_image_units += sh->NumImages;
@@ -2354,11 +2354,11 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
    }
 
    if (total_image_units > ctx->Const.MaxCombinedImageUniforms)
-      linker_error(prog, "Too many combined image uniforms");
+      linker_error(prog, "Too many combined image uniforms\n");
 
    if (total_image_units + fragment_outputs >
        ctx->Const.MaxCombinedImageUnitsAndFragmentOutputs)
-      linker_error(prog, "Too many combined image uniforms and fragment outputs");
+      linker_error(prog, "Too many combined image uniforms and fragment outputs\n");
 }
 
 
@@ -2382,7 +2382,7 @@ reserve_explicit_locations(struct gl_shader_program *prog,
                   max_loc + 1);
 
       if (!prog->UniformRemapTable) {
-         linker_error(prog, "Out of memory during linking.");
+         linker_error(prog, "Out of memory during linking.\n");
          return false;
       }
 
@@ -2411,8 +2411,8 @@ reserve_explicit_locations(struct gl_shader_program *prog,
           *     or linker error will be generated."
           */
          linker_error(prog,
-                      "location qualifier for uniform %s overlaps"
-                      "previously used location",
+                      "location qualifier for uniform %s overlaps "
+                      "previously used location\n",
                       var->name);
          return false;
       }
@@ -2447,7 +2447,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
    string_to_uint_map *uniform_map = new string_to_uint_map;
 
    if (!uniform_map) {
-      linker_error(prog, "Out of memory during linking.");
+      linker_error(prog, "Out of memory during linking.\n");
       return;
    }
 
@@ -2678,6 +2678,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
                                     &ctx->Const.ShaderCompilerOptions[i],
                                     ctx->Const.NativeIntegers))
 	 ;
+
+      lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir);
    }
 
    /* Check and validate stream emissions in geometry shaders */
@@ -2719,7 +2721,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
        */
       if (first == MESA_SHADER_FRAGMENT) {
          linker_error(prog, "Transform feedback varyings specified, but "
-                      "no vertex or geometry shader is present.");
+                      "no vertex or geometry shader is present.\n");
          goto done;
       }
 
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h
index b6c32bc..995c666 100644
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -521,6 +521,27 @@ exec_node_insert_list_before(struct exec_node *n, struct exec_list *before)
    exec_list_make_empty(before);
 }
 
+static inline void
+exec_list_validate(const struct exec_list *list)
+{
+   const struct exec_node *node;
+
+   assert(list->head->prev == (const struct exec_node *) &list->head);
+   assert(list->tail == NULL);
+   assert(list->tail_pred->next == (const struct exec_node *) &list->tail);
+
+   /* We could try to use one of the interators below for this but they all
+    * either require C++ or assume the exec_node is embedded in a structure
+    * which is not the case for this function.
+    */
+   for (node = exec_list_get_head_const(list);
+        !exec_node_is_tail_sentinel(node);
+        node = exec_node_get_next_const(node)) {
+      assert(node->next->prev == node);
+      assert(node->prev->next == node);
+   }
+}
+
 #ifdef __cplusplus
 inline void exec_list::make_empty()
 {
diff --git a/mesalib/src/glsl/loop_unroll.cpp b/mesalib/src/glsl/loop_unroll.cpp
index ce795f6..635e1dd 100644
--- a/mesalib/src/glsl/loop_unroll.cpp
+++ b/mesalib/src/glsl/loop_unroll.cpp
@@ -64,6 +64,7 @@ class loop_unroll_count : public ir_hierarchical_visitor {
 public:
    int nodes;
    bool unsupported_variable_indexing;
+   bool array_indexed_by_induction_var_with_exact_iterations;
    /* If there are nested loops, the node count will be inaccurate. */
    bool nested_loop;
 
@@ -74,6 +75,7 @@ public:
       nodes = 0;
       nested_loop = false;
       unsupported_variable_indexing = false;
+      array_indexed_by_induction_var_with_exact_iterations = false;
 
       run(list);
    }
@@ -112,6 +114,14 @@ public:
          ir_variable *array = ir->array->variable_referenced();
          loop_variable *lv = ls->get(ir->array_index->variable_referenced());
          if (array && lv && lv->is_induction_var()) {
+            /* If an array is indexed by a loop induction variable, and the
+             * array size is exactly the number of loop iterations, this is
+             * probably a simple for-loop trying to access each element in
+             * turn; the application may expect it to be unrolled.
+             */
+            if (int(array->type->length) == ls->limiting_terminator->iterations)
+               array_indexed_by_induction_var_with_exact_iterations = true;
+
             switch (array->data.mode) {
             case ir_var_auto:
             case ir_var_temporary:
@@ -314,7 +324,8 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
    bool loop_too_large =
       count.nested_loop || count.nodes * iterations > max_iterations * 5;
 
-   if (loop_too_large && !count.unsupported_variable_indexing)
+   if (loop_too_large && !count.unsupported_variable_indexing &&
+       !count.array_indexed_by_induction_var_with_exact_iterations)
       return visit_continue;
 
    /* Note: the limiting terminator contributes 1 to ls->num_loop_jumps.
diff --git a/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp b/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp
new file mode 100644
index 0000000..2243f47
--- /dev/null
+++ b/mesalib/src/glsl/lower_const_arrays_to_uniforms.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * \file lower_const_arrays_to_uniforms.cpp
+ *
+ * Lower constant arrays to uniform arrays.
+ *
+ * Some driver backends (such as i965 and nouveau) don't handle constant arrays
+ * gracefully, instead treating them as ordinary writable temporary arrays.
+ * Since arrays can be large, this often means spilling them to scratch memory,
+ * which usually involves a large number of instructions.
+ *
+ * This must be called prior to link_set_uniform_initializers(); we need the
+ * linker to process our new uniform's constant initializer.
+ *
+ * This should be called after optimizations, since those can result in
+ * splitting and removing arrays that are indexed by constant expressions.
+ */
+#include "ir.h"
+#include "ir_visitor.h"
+#include "ir_rvalue_visitor.h"
+#include "glsl_types.h"
+
+namespace {
+class lower_const_array_visitor : public ir_rvalue_visitor {
+public:
+   lower_const_array_visitor(exec_list *insts)
+   {
+      instructions = insts;
+      progress = false;
+      index = 0;
+   }
+
+   bool run()
+   {
+      visit_list_elements(this, instructions);
+      return progress;
+   }
+
+   void handle_rvalue(ir_rvalue **rvalue);
+
+private:
+   exec_list *instructions;
+   bool progress;
+   unsigned index;
+};
+
+void
+lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
+{
+   if (!*rvalue)
+      return;
+
+   ir_dereference_array *dra = (*rvalue)->as_dereference_array();
+   if (!dra)
+      return;
+
+   ir_constant *con = dra->array->as_constant();
+   if (!con || !con->type->is_array())
+      return;
+
+   void *mem_ctx = ralloc_parent(con);
+
+   char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%d", index++);
+
+   ir_variable *uni =
+      new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
+   uni->constant_initializer = con;
+   uni->constant_value = con;
+   uni->data.has_initializer = true;
+   uni->data.how_declared = ir_var_hidden;
+   uni->data.read_only = true;
+   /* Assume the whole thing is accessed. */
+   uni->data.max_array_access = uni->type->length - 1;
+   instructions->push_head(uni);
+
+   ir_dereference_variable *varref = new(mem_ctx) ir_dereference_variable(uni);
+   *rvalue = new(mem_ctx) ir_dereference_array(varref, dra->array_index);
+
+   progress = true;
+}
+
+} /* anonymous namespace */
+
+bool
+lower_const_arrays_to_uniforms(exec_list *instructions)
+{
+   lower_const_array_visitor v(instructions);
+   return v.run();
+}
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 9b36a1f..91e457a 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -35,6 +35,7 @@
 #include "glsl_parser_extras.h"
 #include "ir_optimization.h"
 #include "program.h"
+#include "program/hash_table.h"
 #include "loop_analysis.h"
 #include "standalone_scaffolding.h"
 
@@ -357,6 +358,11 @@ main(int argc, char **argv)
    assert(whole_program != NULL);
    whole_program->InfoLog = ralloc_strdup(whole_program, "");
 
+   /* Created just to avoid segmentation faults */
+   whole_program->AttributeBindings = new string_to_uint_map;
+   whole_program->FragDataBindings = new string_to_uint_map;
+   whole_program->FragDataIndexBindings = new string_to_uint_map;
+
    for (/* empty */; argc > optind; optind++) {
       whole_program->Shaders =
 	 reralloc(whole_program, whole_program->Shaders,
@@ -415,6 +421,10 @@ main(int argc, char **argv)
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++)
       ralloc_free(whole_program->_LinkedShaders[i]);
 
+   delete whole_program->AttributeBindings;
+   delete whole_program->FragDataBindings;
+   delete whole_program->FragDataIndexBindings;
+
    ralloc_free(whole_program);
    _mesa_glsl_release_types();
    _mesa_glsl_release_builtin_functions();
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp
index 0cdb8ec..430f5cb 100644
--- a/mesalib/src/glsl/opt_algebraic.cpp
+++ b/mesalib/src/glsl/opt_algebraic.cpp
@@ -105,12 +105,6 @@ is_vec_negative_one(ir_constant *ir)
 }
 
 static inline bool
-is_vec_basis(ir_constant *ir)
-{
-   return (ir == NULL) ? false : ir->is_basis();
-}
-
-static inline bool
 is_valid_vec_const(ir_constant *ir)
 {
    if (ir == NULL)
@@ -537,21 +531,34 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1]))
 	 return ir_constant::zero(mem_ctx, ir->type);
 
-      if (is_vec_basis(op_const[0])) {
-	 unsigned component = 0;
-	 for (unsigned c = 0; c < op_const[0]->type->vector_elements; c++) {
-	    if (op_const[0]->value.f[c] == 1.0)
-	       component = c;
-	 }
-	 return new(mem_ctx) ir_swizzle(ir->operands[1], component, 0, 0, 0, 1);
-      }
-      if (is_vec_basis(op_const[1])) {
-	 unsigned component = 0;
-	 for (unsigned c = 0; c < op_const[1]->type->vector_elements; c++) {
-	    if (op_const[1]->value.f[c] == 1.0)
-	       component = c;
-	 }
-	 return new(mem_ctx) ir_swizzle(ir->operands[0], component, 0, 0, 0, 1);
+      for (int i = 0; i < 2; i++) {
+         if (!op_const[i])
+            continue;
+
+         unsigned components[4] = { 0 }, count = 0;
+
+         for (unsigned c = 0; c < op_const[i]->type->vector_elements; c++) {
+            if (op_const[i]->value.f[c] == 0.0)
+               continue;
+
+            components[count] = c;
+            count++;
+         }
+
+         /* No channels had zero values; bail. */
+         if (count >= op_const[i]->type->vector_elements)
+            break;
+
+         ir_expression_operation op = count == 1 ?
+            ir_binop_mul : ir_binop_dot;
+
+         /* Swizzle both operands to remove the channels that were zero. */
+         return new(mem_ctx)
+            ir_expression(op, glsl_type::float_type,
+                          new(mem_ctx) ir_swizzle(ir->operands[0],
+                                                  components, count),
+                          new(mem_ctx) ir_swizzle(ir->operands[1],
+                                                  components, count));
       }
       break;
 
diff --git a/mesalib/src/glsl/opt_cse.cpp b/mesalib/src/glsl/opt_cse.cpp
index 9c96835..b0b67f4 100644
--- a/mesalib/src/glsl/opt_cse.cpp
+++ b/mesalib/src/glsl/opt_cse.cpp
@@ -194,6 +194,8 @@ is_cse_candidate_visitor::visit(ir_dereference_variable *ir)
    if (ir->var->data.read_only) {
       return visit_continue;
    } else {
+      if (debug)
+         printf("CSE: non-candidate: var %s is not read only\n", ir->var->name);
       ok = false;
       return visit_stop;
    }
@@ -220,8 +222,11 @@ is_cse_candidate(ir_rvalue *ir)
    /* Our temporary variable assignment generation isn't ready to handle
     * anything bigger than a vector.
     */
-   if (!ir->type->is_vector() && !ir->type->is_scalar())
+   if (!ir->type->is_vector() && !ir->type->is_scalar()) {
+      if (debug)
+         printf("CSE: non-candidate: not a vector/scalar\n");
       return false;
+   }
 
    /* Only handle expressions and textures currently.  We may want to extend
     * to variable-index array dereferences at some point.
@@ -231,6 +236,8 @@ is_cse_candidate(ir_rvalue *ir)
    case ir_type_texture:
       break;
    default:
+      if (debug)
+         printf("CSE: non-candidate: not an expression/texture\n");
       return false;
    }
 
diff --git a/mesalib/src/glsl/s_expression.cpp b/mesalib/src/glsl/s_expression.cpp
index 1a28e1d..2928a4d 100644
--- a/mesalib/src/glsl/s_expression.cpp
+++ b/mesalib/src/glsl/s_expression.cpp
@@ -73,7 +73,7 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer)
    } else {
       // Check if the atom is a number.
       char *float_end = NULL;
-      float f = glsl_strtof(src, &float_end);
+      float f = _mesa_strtof(src, &float_end);
       if (float_end != src) {
          char *int_end = NULL;
          int i = strtol(src, &int_end, 10);
diff --git a/mesalib/src/glsl/s_expression.h b/mesalib/src/glsl/s_expression.h
index 642af19..1d47535 100644
--- a/mesalib/src/glsl/s_expression.h
+++ b/mesalib/src/glsl/s_expression.h
@@ -27,7 +27,7 @@
 #define S_EXPRESSION_H
 
 #include "main/core.h" /* for Elements */
-#include "strtod.h"
+#include "util/strtod.h"
 #include "list.h"
 
 /* Type-safe downcasting macros (also safe to pass NULL) */
diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript
index bc1c43a..97ebfe6 100644
--- a/mesalib/src/mapi/glapi/SConscript
+++ b/mesalib/src/mapi/glapi/SConscript
@@ -16,6 +16,7 @@ if env['platform'] == 'windows':
     env.Append(CPPDEFINES = [
         '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
         'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
+        'KHRONOS_DLL_EXPORTS', # declare gl* as __declspec(dllexport) in Khronos headers
     ])
     if env['gles']:
         env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])
diff --git a/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml b/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml
new file mode 100644
index 0000000..bc72435
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/KHR_context_flush_control.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_KHR_context_flush_control" number="168">
+    <enum name="CONTEXT_RELEASE_BEHAVIOR"            value="0x82FB"/>
+    <enum name="CONTEXT_RELEASE_BEHAVIOR_FLUSH"      value="0x82FC"/>
+</category>
+
+</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am
index 72e5095..7f76f19 100644
--- a/mesalib/src/mapi/glapi/gen/Makefile.am
+++ b/mesalib/src/mapi/glapi/gen/Makefile.am
@@ -61,12 +61,10 @@ EXTRA_DIST= \
 	$(MESA_GLAPI_DIR)/glapi_x86-64.S \
 	$(MESA_GLAPI_DIR)/glapi_sparc.S \
 	$(COMMON_GLX) \
-	extension_helper.py \
 	gl_apitemp.py \
 	gl_enums.py \
 	gl_genexec.py \
 	gl_gentable.py \
-	gl_offsets.py \
 	gl_procs.py \
 	gl_SPARC_asm.py \
 	gl_table.py \
@@ -76,7 +74,6 @@ EXTRA_DIST= \
 	glX_proto_send.py \
 	glX_proto_size.py \
 	glX_server_table.py \
-	mesadef.py \
 	remap_helper.py \
 	gl_API.dtd
 
diff --git a/mesalib/src/mapi/glapi/gen/extension_helper.py b/mesalib/src/mapi/glapi/gen/extension_helper.py
deleted file mode 100644
index da633dc..0000000
--- a/mesalib/src/mapi/glapi/gen/extension_helper.py
+++ /dev/null
@@ -1,324 +0,0 @@
-#!/usr/bin/env python
-
-# (C) Copyright IBM Corporation 2005
-# 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
-# on 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
-# IBM 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:
-#    Ian Romanick <idr at us.ibm.com>
-
-import gl_XML
-import license
-import sys, getopt, string
-
-vtxfmt = [
-    "ArrayElement", \
-    "Color3f", \
-    "Color3fv", \
-    "Color4f", \
-    "Color4fv", \
-    "EdgeFlag", \
-    "EdgeFlagv", \
-    "EvalCoord1f", \
-    "EvalCoord1fv", \
-    "EvalCoord2f", \
-    "EvalCoord2fv", \
-    "EvalPoint1", \
-    "EvalPoint2", \
-    "FogCoordfEXT", \
-    "FogCoordfvEXT", \
-    "Indexf", \
-    "Indexfv", \
-    "Materialfv", \
-    "MultiTexCoord1fARB", \
-    "MultiTexCoord1fvARB", \
-    "MultiTexCoord2fARB", \
-    "MultiTexCoord2fvARB", \
-    "MultiTexCoord3fARB", \
-    "MultiTexCoord3fvARB", \
-    "MultiTexCoord4fARB", \
-    "MultiTexCoord4fvARB", \
-    "Normal3f", \
-    "Normal3fv", \
-    "SecondaryColor3fEXT", \
-    "SecondaryColor3fvEXT", \
-    "TexCoord1f", \
-    "TexCoord1fv", \
-    "TexCoord2f", \
-    "TexCoord2fv", \
-    "TexCoord3f", \
-    "TexCoord3fv", \
-    "TexCoord4f", \
-    "TexCoord4fv", \
-    "Vertex2f", \
-    "Vertex2fv", \
-    "Vertex3f", \
-    "Vertex3fv", \
-    "Vertex4f", \
-    "Vertex4fv", \
-    "CallList", \
-    "CallLists", \
-    "Begin", \
-    "End", \
-    "VertexAttrib1fNV", \
-    "VertexAttrib1fvNV", \
-    "VertexAttrib2fNV", \
-    "VertexAttrib2fvNV", \
-    "VertexAttrib3fNV", \
-    "VertexAttrib3fvNV", \
-    "VertexAttrib4fNV", \
-    "VertexAttrib4fvNV", \
-    "VertexAttrib1fARB", \
-    "VertexAttrib1fvARB", \
-    "VertexAttrib2fARB", \
-    "VertexAttrib2fvARB", \
-    "VertexAttrib3fARB", \
-    "VertexAttrib3fvARB", \
-    "VertexAttrib4fARB", \
-    "VertexAttrib4fvARB", \
-    "Rectf", \
-    "DrawArrays", \
-    "DrawElements", \
-    "DrawRangeElements", \
-    "EvalMesh1", \
-    "EvalMesh2", \
-]
-
-def all_entrypoints_in_abi(f, abi, api):
-    for n in f.entry_points:
-        [category, num] = api.get_category_for_name( n )
-        if category not in abi:
-            return 0
-
-    return 1
-
-
-def any_entrypoints_in_abi(f, abi, api):
-    for n in f.entry_points:
-        [category, num] = api.get_category_for_name( n )
-        if category in abi:
-            return 1
-
-    return 0
-
-
-def condition_for_function(f, abi, all_not_in_ABI):
-    """Create a C-preprocessor condition for the function.
-
-    There are two modes of operation.  If all_not_in_ABI is set, a
-    condition is only created is all of the entry-point names for f are
-    not in the selected ABI.  If all_not_in_ABI is not set, a condition
-    is created if any entryp-point name is not in the selected ABI.
-    """
-
-    condition = []
-    for n in f.entry_points:
-        [category, num] = api.get_category_for_name( n )
-        if category not in abi:
-            condition.append( 'defined(need_%s)' % (gl_XML.real_category_name( category )) )
-        elif all_not_in_ABI:
-            return []
-
-    return condition
-
-
-class PrintGlExtensionGlue(gl_XML.gl_print_base):
-    def __init__(self):
-        gl_XML.gl_print_base.__init__(self)
-
-        self.name = "extension_helper.py (from Mesa)"
-        self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
-        return
-
-
-    def printRealHeader(self):
-        print '#include "utils.h"'
-        print '#include "main/dispatch.h"'
-        print ''
-        return
-
-
-    def printBody(self, api):
-        abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
-
-        category_list = {}
-
-        print '#ifndef NULL'
-        print '# define NULL 0'
-        print '#endif'
-        print ''
-
-        for f in api.functionIterateAll():
-            condition = condition_for_function(f, abi, 0)
-            if len(condition):
-                print '#if %s' % (string.join(condition, " || "))
-                print 'static const char %s_names[] =' % (f.name)
-
-                parameter_signature = ''
-                for p in f.parameterIterator():
-                    if p.is_padding:
-                        continue
-
-                    # FIXME: This is a *really* ugly hack. :(
-
-                    tn = p.type_expr.get_base_type_node()
-                    if p.is_pointer():
-                        parameter_signature += 'p'
-                    elif tn.integer:
-                        parameter_signature += 'i'
-                    elif tn.size == 4:
-                        parameter_signature += 'f'
-                    else:
-                        parameter_signature += 'd'
-
-                print '    "%s\\0" /* Parameter signature */' % (parameter_signature)
-
-                for n in f.entry_points:
-                    print '    "gl%s\\0"' % (n)
-
-                    [category, num] = api.get_category_for_name( n )
-                    if category not in abi:
-                        c = gl_XML.real_category_name(category)
-                        if not category_list.has_key(c):
-                            category_list[ c ] = []
-
-                        category_list[ c ].append( f )
-
-                print '    "";'
-                print '#endif'
-                print ''
-
-        keys = category_list.keys()
-        keys.sort()
-
-        for category in keys:
-            print '#if defined(need_%s)' % (category)
-            print 'static const struct dri_extension_function %s_functions[] = {' % (category)
-
-            for f in category_list[ category ]:
-                # A function either has an offset that is
-                # assigned by the ABI, or it has a remap
-                # index.
-                if any_entrypoints_in_abi(f, abi, api):
-                    index_name = "-1"
-                    offset = f.offset
-                else:
-                    index_name = "%s_remap_index" % (f.name)
-                    offset = -1
-
-                print '    { %s_names, %s, %d },' % (f.name, index_name, offset)
-
-
-            print '    { NULL, 0, 0 }'
-            print '};'
-            print '#endif'
-            print ''
-
-        return
-
-
-class PrintInitDispatch(gl_XML.gl_print_base):
-    def __init__(self):
-        gl_XML.gl_print_base.__init__(self)
-
-        self.name = "extension_helper.py (from Mesa)"
-        self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
-        return
-
-
-    def do_function_body(self, api, abi, vtxfmt_only):
-        last_condition_string = None
-        for f in api.functionIterateByOffset():
-            if (f.name in vtxfmt) and not vtxfmt_only:
-                continue
-
-            if (f.name not in vtxfmt) and vtxfmt_only:
-                continue
-
-            condition = condition_for_function(f, abi, 1)
-            condition_string = string.join(condition, " || ")
-
-            if condition_string != last_condition_string:
-                if last_condition_string:
-                    print '#endif /* %s */' % (last_condition_string)
-
-                if condition_string:
-                    print '#if %s' % (condition_string)
-
-            if vtxfmt_only:
-                print '   disp->%s = vfmt->%s;' % (f.name, f.name)
-            else:
-                print '   disp->%s = _mesa_%s;' % (f.name, f.name)
-
-            last_condition_string = condition_string
-
-        if last_condition_string:
-            print '#endif /* %s */' % (last_condition_string)
-
-
-
-    def printBody(self, api):
-        abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
-
-        print 'void driver_init_exec_table(struct _glapi_table *disp)'
-        print '{'
-        self.do_function_body(api, abi, 0)
-        print '}'
-        print ''
-        print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'
-        print '{'
-        self.do_function_body(api, abi, 1)
-        print '}'
-
-        return
-
-
-def show_usage():
-    print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
-    print "    -m output_mode   Output mode can be one of 'extensions' or 'exec_init'."
-    sys.exit(1)
-
-if __name__ == '__main__':
-    file_name = "gl_API.xml"
-
-    try:
-        (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
-    except Exception,e:
-        show_usage()
-
-    mode = "extensions"
-    for (arg,val) in args:
-        if arg == "-f":
-            file_name = val
-        if arg == '-m':
-            mode = val
-
-
-    api = gl_XML.parse_GL_API( file_name )
-
-    if mode == "extensions":
-        printer = PrintGlExtensionGlue()
-    elif mode == "exec_init":
-        printer = PrintInitDispatch()
-    else:
-        show_usage()
-
-    printer.Print( api )
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index 534e6a0..e1b1246 100644
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -8379,6 +8379,8 @@
 
 <xi:include href="ARB_texture_barrier.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="KHR_context_flush_control.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 <!-- Non-ARB extensions sorted by extension number. -->
 
 <category name="GL_EXT_blend_color" number="2">
diff --git a/mesalib/src/mapi/glapi/gen/gl_offsets.py b/mesalib/src/mapi/glapi/gen/gl_offsets.py
deleted file mode 100644
index 897ac18..0000000
--- a/mesalib/src/mapi/glapi/gen/gl_offsets.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-
-# (C) Copyright IBM Corporation 2004, 2005
-# 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
-# on 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
-# IBM 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:
-#    Ian Romanick <idr at us.ibm.com>
-
-import gl_XML
-import license
-import sys, getopt
-
-class PrintGlOffsets(gl_XML.gl_print_base):
-    def __init__(self, es=False):
-        gl_XML.gl_print_base.__init__(self)
-
-        self.es = es
-        self.name = "gl_offsets.py (from Mesa)"
-        self.header_tag = '_GLAPI_OFFSETS_H_'
-        self.license = license.bsd_license_template % ( \
-"""Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
-(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
-        return
-
-    def printBody(self, api):
-        print '/* this file should not be included directly in mesa */'
-        print ''
-
-        functions = []
-        abi_functions = []
-        alias_functions = []
-        count = 0
-        for f in api.functionIterateByOffset():
-            if not f.is_abi():
-                functions.append( [f, count] )
-                count += 1
-            else:
-                abi_functions.append( f )
-
-            if self.es:
-                # remember functions with aliases
-                if len(f.entry_points) > 1:
-                    alias_functions.append(f)
-
-        for f in abi_functions:
-            print '#define _gloffset_%s %d' % (f.name, f.offset)
-            last_static = f.offset
-
-        print ''
-        print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
-        print ''
-
-        for [f, index] in functions:
-            print '#define _gloffset_%s %d' % (f.name, f.offset)
-
-        print '#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)
-
-        print ''
-        print '#else'
-        print ''
-
-        for [f, index] in functions:
-            print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
-
-        print ''
-        print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
-
-        if alias_functions:
-            print ''
-            print '/* define aliases for compatibility */'
-            for f in alias_functions:
-                for name in f.entry_points:
-                    if name != f.name:
-                        print '#define _gloffset_%s _gloffset_%s' % (name, f.name)
-        return
-
-
-def show_usage():
-    print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
-    print "    -c        Enable compatibility with OpenGL ES."
-    sys.exit(1)
-
-if __name__ == '__main__':
-    file_name = "gl_API.xml"
-
-    try:
-        (args, trail) = getopt.getopt(sys.argv[1:], "f:c")
-    except Exception,e:
-        show_usage()
-
-    es = False
-    for (arg,val) in args:
-        if arg == "-f":
-            file_name = val
-        elif arg == "-c":
-            es = True
-
-    api = gl_XML.parse_GL_API( file_name )
-
-    printer = PrintGlOffsets(es)
-    printer.Print( api )
diff --git a/mesalib/src/mapi/glapi/gen/mesadef.py b/mesalib/src/mapi/glapi/gen/mesadef.py
deleted file mode 100644
index 77cc4a3..0000000
--- a/mesalib/src/mapi/glapi/gen/mesadef.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/env python
-
-
-# Mesa 3-D graphics library
-# 
-# Copyright (C) 1999-2001  Brian Paul   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, sublicense,
-# 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS 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.
-
-
-# Generate the mesa.def file for Windows.
-#
-# Usage:
-#    mesadef.py >mesa.def
-#    Then copy to src/mesa/drivers/windows/gdi
-#
-# Dependencies:
-#    The apispec file must be in the current directory.
-
-
-
-import apiparser
-import string
-
-
-def PrintHead():
-    print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
-    print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
-    print 'VERSION 6.0'
-    print ';'
-    print '; Module definition file for Mesa (OPENGL32.DLL)'
-    print ';'
-    print '; Note: The OpenGL functions use the STDCALL'
-    print '; function calling convention.  Microsoft\'s'
-    print '; OPENGL32 uses this convention and so must the'
-    print '; Mesa OPENGL32 so that the Mesa DLL can be used'
-    print '; as a drop-in replacement.'
-    print ';'
-    print '; The linker exports STDCALL entry points with'
-    print '; \'decorated\' names; e.g., _glBegin at 0, where the'
-    print '; trailing number is the number of bytes of '
-    print '; parameter data pushed onto the stack.  The'
-    print '; callee is responsible for popping this data'
-    print '; off the stack, usually via a RETF n instruction.'
-    print ';'
-    print '; However, the Microsoft OPENGL32.DLL does not export'
-    print '; the decorated names, even though the calling convention'
-    print '; is STDCALL.  So, this module definition file is'
-    print '; needed to force the Mesa OPENGL32.DLL to export the'
-    print '; symbols in the same manner as the Microsoft DLL.'
-    print '; Were it not for this problem, this file would not'
-    print '; be needed (for the gl* functions) since the entry'
-    print '; points are compiled with dllexport declspec.'
-    print ';'
-    print '; However, this file is still needed to export "internal"'
-    print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
-    print ';'
-    print 'EXPORTS'
-    return
-#enddef
-
-
-def PrintTail():
-    print ';'
-    print '; WGL API'
-    print '\twglChoosePixelFormat'
-    print '\twglCopyContext'
-    print '\twglCreateContext'
-    print '\twglCreateLayerContext'
-    print '\twglDeleteContext'
-    print '\twglDescribeLayerPlane'
-    print '\twglDescribePixelFormat'
-    print '\twglGetCurrentContext'
-    print '\twglGetCurrentDC'
-    print '\twglGetExtensionsStringARB'
-    print '\twglGetLayerPaletteEntries'
-    print '\twglGetPixelFormat'
-    print '\twglGetProcAddress'
-    print '\twglMakeCurrent'
-    print '\twglRealizeLayerPalette'
-    print '\twglSetLayerPaletteEntries'
-    print '\twglSetPixelFormat'
-    print '\twglShareLists'
-    print '\twglSwapBuffers'
-    print '\twglSwapLayerBuffers'
-    print '\twglUseFontBitmapsA'
-    print '\twglUseFontBitmapsW'
-    print '\twglUseFontOutlinesA'
-    print '\twglUseFontOutlinesW'
-    print ';'
-    print '; Mesa internals - mostly for OSMESA'
-    print '\t_ac_CreateContext'
-    print '\t_ac_DestroyContext'
-    print '\t_ac_InvalidateState'
-    print '\t_glapi_get_context'
-    print '\t_glapi_get_proc_address'
-    print '\t_mesa_buffer_data'
-    print '\t_mesa_buffer_map'
-    print '\t_mesa_buffer_subdata'
-    print '\t_mesa_choose_tex_format'
-    print '\t_mesa_compressed_texture_size'
-    print '\t_mesa_create_framebuffer'
-    print '\t_mesa_create_visual'
-    print '\t_mesa_delete_buffer_object'
-    print '\t_mesa_delete_texture_object'
-    print '\t_mesa_destroy_framebuffer'
-    print '\t_mesa_destroy_visual'
-    print '\t_mesa_enable_1_3_extensions'
-    print '\t_mesa_enable_1_4_extensions'
-    print '\t_mesa_enable_1_5_extensions'
-    print '\t_mesa_enable_sw_extensions'
-    print '\t_mesa_error'
-    print '\t_mesa_free_context_data'
-    print '\t_mesa_get_current_context'
-    print '\t_mesa_init_default_imports'
-    print '\t_mesa_initialize_context'
-    print '\t_mesa_make_current'
-    print '\t_mesa_new_buffer_object'
-    print '\t_mesa_new_texture_object'
-    print '\t_mesa_problem'
-    print '\t_mesa_store_compressed_teximage1d'
-    print '\t_mesa_store_compressed_teximage2d'
-    print '\t_mesa_store_compressed_teximage3d'
-    print '\t_mesa_store_compressed_texsubimage1d'
-    print '\t_mesa_store_compressed_texsubimage2d'
-    print '\t_mesa_store_compressed_texsubimage3d'
-    print '\t_mesa_store_teximage1d'
-    print '\t_mesa_store_teximage2d'
-    print '\t_mesa_store_teximage3d'
-    print '\t_mesa_store_texsubimage1d'
-    print '\t_mesa_store_texsubimage2d'
-    print '\t_mesa_store_texsubimage3d'
-    print '\t_mesa_test_proxy_teximage'
-    print '\t_mesa_Viewport'
-    print '\t_mesa_meta_CopyColorSubTable'
-    print '\t_mesa_meta_CopyColorTable'
-    print '\t_mesa_meta_CopyConvolutionFilter1D'
-    print '\t_mesa_meta_CopyConvolutionFilter2D'
-    print '\t_mesa_meta_CopyTexImage1D'
-    print '\t_mesa_meta_CopyTexImage2D'
-    print '\t_mesa_meta_CopyTexSubImage1D'
-    print '\t_mesa_meta_CopyTexSubImage2D'
-    print '\t_mesa_meta_CopyTexSubImage3D'
-    print '\t_swrast_Accum'
-    print '\t_swrast_alloc_buffers'
-    print '\t_swrast_Bitmap'
-    print '\t_swrast_CopyPixels'
-    print '\t_swrast_DrawPixels'
-    print '\t_swrast_GetDeviceDriverReference'
-    print '\t_swrast_Clear'
-    print '\t_swrast_choose_line'
-    print '\t_swrast_choose_triangle'
-    print '\t_swrast_CreateContext'
-    print '\t_swrast_DestroyContext'
-    print '\t_swrast_InvalidateState'
-    print '\t_swrast_ReadPixels'
-    print '\t_swrast_zbuffer_address'
-    print '\t_swsetup_Wakeup'
-    print '\t_swsetup_CreateContext'
-    print '\t_swsetup_DestroyContext'
-    print '\t_swsetup_InvalidateState'
-    print '\t_tnl_CreateContext'
-    print '\t_tnl_DestroyContext'
-    print '\t_tnl_InvalidateState'
-    print '\t_tnl_MakeCurrent'
-    print '\t_tnl_run_pipeline'
-#enddef
-
-
-records = []
-
-def FindOffset(funcName):
-    for (name, alias, offset) in records:
-        if name == funcName:
-            return offset
-        #endif
-    #endfor
-    return -1
-#enddef
-
-
-def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset):
-    if alias == '':
-        dispatchName = name
-    else:
-        dispatchName = alias
-    if offset < 0:
-        offset = FindOffset(dispatchName)
-    if offset >= 0 and string.find(name, "unused") == -1:
-        print '\tgl%s' % (name)
-        # save this info in case we need to look up an alias later
-        records.append((name, dispatchName, offset))
-
-#enddef
-
-
-PrintHead()
-apiparser.ProcessSpecFile("APIspec", EmitEntry)
-PrintTail()
diff --git a/mesalib/src/mesa/Android.libmesa_dricore.mk b/mesalib/src/mesa/Android.libmesa_dricore.mk
index 1e6d948..2ab593d 100644
--- a/mesalib/src/mesa/Android.libmesa_dricore.mk
+++ b/mesalib/src/mesa/Android.libmesa_dricore.mk
@@ -51,10 +51,16 @@ endif # MESA_ENABLE_ASM
 
 ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
 LOCAL_SRC_FILES += \
-	$(SRCDIR)main/streaming-load-memcpy.c
+	$(SRCDIR)main/streaming-load-memcpy.c \
+	$(SRCDIR)main/sse_minmax.c
 LOCAL_CFLAGS := -msse4.1
 endif
 
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+LOCAL_CFLAGS += \
+       -DUSE_SSE41
+endif
+
 LOCAL_C_INCLUDES := \
 	$(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
 	$(MESA_TOP)/src \
diff --git a/mesalib/src/mesa/Android.libmesa_st_mesa.mk b/mesalib/src/mesa/Android.libmesa_st_mesa.mk
index 8b8d652..618d6bf 100644
--- a/mesalib/src/mesa/Android.libmesa_st_mesa.mk
+++ b/mesalib/src/mesa/Android.libmesa_st_mesa.mk
@@ -48,6 +48,11 @@ ifeq ($(TARGET_ARCH),x86)
 endif # x86
 endif # MESA_ENABLE_ASM
 
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+LOCAL_CFLAGS := \
+       -DUSE_SSE41
+endif
+
 LOCAL_C_INCLUDES := \
 	$(call intermediates-dir-for STATIC_LIBRARIES,libmesa_program,,) \
 	$(MESA_TOP)/src/gallium/auxiliary \
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index e71bccb..932db4f 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -151,7 +151,8 @@ libmesagallium_la_LIBADD = \
 	$(ARCH_LIBS)
 
 libmesa_sse41_la_SOURCES = \
-	main/streaming-load-memcpy.c
+	main/streaming-load-memcpy.c \
+	main/sse_minmax.c
 libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1
 
 pkgconfigdir = $(libdir)/pkgconfig
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index 6c78928..d6e875f 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -376,19 +376,17 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
        return NULL;
     }
 
-    /* The EGL_KHR_create_context spec says:
+    /* The latest version of EGL_KHR_create_context spec says:
      *
-     *     "Flags are only defined for OpenGL context creation, and specifying
-     *     a flags value other than zero for other types of contexts,
-     *     including OpenGL ES contexts, will generate an error."
+     *     "If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
+     *     EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created.
+     *     [...] This bit is supported for OpenGL and OpenGL ES contexts.
      *
-     * The GLX_EXT_create_context_es2_profile specification doesn't say
-     * anything specific about this case.  However, none of the known flags
-     * have any meaning in an ES context, so this seems safe.
+     * None of the other flags have any meaning in an ES context, so this seems safe.
      */
     if (mesa_api != API_OPENGL_COMPAT
         && mesa_api != API_OPENGL_CORE
-        && flags != 0) {
+        && (flags & ~__DRI_CTX_FLAG_DEBUG)) {
 	*error = __DRI_CTX_ERROR_BAD_FLAG;
 	return NULL;
     }
@@ -569,6 +567,12 @@ static int driUnbindContext(__DRIcontext *pcp)
     if (pcp == NULL)
 	return GL_FALSE;
 
+    /*
+    ** Call driUnbindContext before checking for valid drawables
+    ** to handle surfaceless contexts properly.
+    */
+    pcp->driScreenPriv->driver->UnbindContext(pcp);
+
     pdp = pcp->driDrawablePriv;
     prp = pcp->driReadablePriv;
 
@@ -576,8 +580,6 @@ static int driUnbindContext(__DRIcontext *pcp)
     if (!pdp && !prp)
 	return GL_TRUE;
 
-    pcp->driScreenPriv->driver->UnbindContext(pcp);
-
     assert(pdp);
     if (pdp->refcount == 0) {
 	/* ERROR!!! */
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h b/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
index b73a662..4e5a721 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -340,3 +340,21 @@ DRI_CONF_SECTION_BEGIN \
 DRI_CONF_OPT_BEGIN(device_id, string, def) \
         DRI_CONF_DESC(en,gettext("Define the graphic device to use if possible")) \
 DRI_CONF_OPT_END
+
+/**
+ * \brief Gallium-Nine specific configuration options
+ */
+
+#define DRI_CONF_SECTION_NINE \
+DRI_CONF_SECTION_BEGIN \
+        DRI_CONF_DESC(en,gettext("Gallium Nine"))
+
+#define DRI_CONF_NINE_THROTTLE(def) \
+DRI_CONF_OPT_BEGIN(throttle_value, int, def) \
+        DRI_CONF_DESC(en,gettext("Define the throttling value. -1 for no throttling, -2 for default (usually 2), 0 for glfinish behaviour")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_THREADSUBMIT(def) \
+DRI_CONF_OPT_BEGIN_B(thread_submit, def) \
+        DRI_CONF_DESC(en,gettext("Use an additional thread to submit buffers.")) \
+DRI_CONF_OPT_END
diff --git a/mesalib/src/mesa/drivers/windows/gdi/mesa.def b/mesalib/src/mesa/drivers/windows/gdi/mesa.def
index 92736b3..a52207b 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/mesa.def
+++ b/mesalib/src/mesa/drivers/windows/gdi/mesa.def
@@ -1,6 +1,3 @@
-; DO NOT EDIT - This file generated automatically by mesadef.py script
-;DESCRIPTION 'Mesa (OpenGL work-alike) for Win32'
-VERSION 6.5
 ;
 ; Module definition file for Mesa (OPENGL32.DLL)
 ;
@@ -27,15 +24,23 @@ VERSION 6.5
 ; points are compiled with dllexport declspec.
 ;
 EXPORTS
-	glNewList
-	glEndList
-	glCallList
-	glCallLists
-	glDeleteLists
-	glGenLists
-	glListBase
+	glAccum
+	glAlphaFunc
+	glAreTexturesResident
+	glArrayElement
 	glBegin
+	glBindTexture
 	glBitmap
+	glBlendFunc
+	glCallList
+	glCallLists
+	glClear
+	glClearAccum
+	glClearColor
+	glClearDepth
+	glClearIndex
+	glClearStencil
+	glClipPlane
 	glColor3b
 	glColor3bv
 	glColor3d
@@ -68,9 +73,88 @@ EXPORTS
 	glColor4uiv
 	glColor4us
 	glColor4usv
+	glColorMask
+	glColorMaterial
+	glColorPointer
+	glCopyPixels
+	glCopyTexImage1D
+	glCopyTexImage2D
+	glCopyTexSubImage1D
+	glCopyTexSubImage2D
+	glCullFace
+	glDeleteLists
+	glDeleteTextures
+	glDepthFunc
+	glDepthMask
+	glDepthRange
+	glDisable
+	glDisableClientState
+	glDrawArrays
+	glDrawBuffer
+	glDrawElements
+	glDrawPixels
 	glEdgeFlag
+	glEdgeFlagPointer
 	glEdgeFlagv
+	glEnable
+	glEnableClientState
 	glEnd
+	glEndList
+	glEvalCoord1d
+	glEvalCoord1dv
+	glEvalCoord1f
+	glEvalCoord1fv
+	glEvalCoord2d
+	glEvalCoord2dv
+	glEvalCoord2f
+	glEvalCoord2fv
+	glEvalMesh1
+	glEvalMesh2
+	glEvalPoint1
+	glEvalPoint2
+	glFeedbackBuffer
+	glFinish
+	glFlush
+	glFogf
+	glFogfv
+	glFogi
+	glFogiv
+	glFrontFace
+	glFrustum
+	glGenLists
+	glGenTextures
+	glGetBooleanv
+	glGetClipPlane
+	glGetDoublev
+	glGetError
+	glGetFloatv
+	glGetIntegerv
+	glGetLightfv
+	glGetLightiv
+	glGetMapdv
+	glGetMapfv
+	glGetMapiv
+	glGetMaterialfv
+	glGetMaterialiv
+	glGetPixelMapfv
+	glGetPixelMapuiv
+	glGetPixelMapusv
+	glGetPointerv
+	glGetPolygonStipple
+	glGetString
+	glGetTexEnvfv
+	glGetTexEnviv
+	glGetTexGendv
+	glGetTexGenfv
+	glGetTexGeniv
+	glGetTexImage
+	glGetTexLevelParameterfv
+	glGetTexLevelParameteriv
+	glGetTexParameterfv
+	glGetTexParameteriv
+	glHint
+	glIndexMask
+	glIndexPointer
 	glIndexd
 	glIndexdv
 	glIndexf
@@ -79,6 +163,45 @@ EXPORTS
 	glIndexiv
 	glIndexs
 	glIndexsv
+	glIndexub
+	glIndexubv
+	glInitNames
+	glInterleavedArrays
+	glIsEnabled
+	glIsList
+	glIsTexture
+	glLightModelf
+	glLightModelfv
+	glLightModeli
+	glLightModeliv
+	glLightf
+	glLightfv
+	glLighti
+	glLightiv
+	glLineStipple
+	glLineWidth
+	glListBase
+	glLoadIdentity
+	glLoadMatrixd
+	glLoadMatrixf
+	glLoadName
+	glLogicOp
+	glMap1d
+	glMap1f
+	glMap2d
+	glMap2f
+	glMapGrid1d
+	glMapGrid1f
+	glMapGrid2d
+	glMapGrid2f
+	glMaterialf
+	glMaterialfv
+	glMateriali
+	glMaterialiv
+	glMatrixMode
+	glMultMatrixd
+	glMultMatrixf
+	glNewList
 	glNormal3b
 	glNormal3bv
 	glNormal3d
@@ -89,6 +212,30 @@ EXPORTS
 	glNormal3iv
 	glNormal3s
 	glNormal3sv
+	glNormalPointer
+	glOrtho
+	glPassThrough
+	glPixelMapfv
+	glPixelMapuiv
+	glPixelMapusv
+	glPixelStoref
+	glPixelStorei
+	glPixelTransferf
+	glPixelTransferi
+	glPixelZoom
+	glPointSize
+	glPolygonMode
+	glPolygonOffset
+	glPolygonStipple
+	glPopAttrib
+	glPopClientAttrib
+	glPopMatrix
+	glPopName
+	glPrioritizeTextures
+	glPushAttrib
+	glPushClientAttrib
+	glPushMatrix
+	glPushName
 	glRasterPos2d
 	glRasterPos2dv
 	glRasterPos2f
@@ -113,6 +260,8 @@ EXPORTS
 	glRasterPos4iv
 	glRasterPos4s
 	glRasterPos4sv
+	glReadBuffer
+	glReadPixels
 	glRectd
 	glRectdv
 	glRectf
@@ -121,6 +270,17 @@ EXPORTS
 	glRectiv
 	glRects
 	glRectsv
+	glRenderMode
+	glRotated
+	glRotatef
+	glScaled
+	glScalef
+	glScissor
+	glSelectBuffer
+	glShadeModel
+	glStencilFunc
+	glStencilMask
+	glStencilOp
 	glTexCoord1d
 	glTexCoord1dv
 	glTexCoord1f
@@ -153,6 +313,27 @@ EXPORTS
 	glTexCoord4iv
 	glTexCoord4s
 	glTexCoord4sv
+	glTexCoordPointer
+	glTexEnvf
+	glTexEnvfv
+	glTexEnvi
+	glTexEnviv
+	glTexGend
+	glTexGendv
+	glTexGenf
+	glTexGenfv
+	glTexGeni
+	glTexGeniv
+	glTexImage1D
+	glTexImage2D
+	glTexParameterf
+	glTexParameterfv
+	glTexParameteri
+	glTexParameteriv
+	glTexSubImage1D
+	glTexSubImage2D
+	glTranslated
+	glTranslatef
 	glVertex2d
 	glVertex2dv
 	glVertex2f
@@ -177,643 +358,8 @@ EXPORTS
 	glVertex4iv
 	glVertex4s
 	glVertex4sv
-	glClipPlane
-	glColorMaterial
-	glCullFace
-	glFogf
-	glFogfv
-	glFogi
-	glFogiv
-	glFrontFace
-	glHint
-	glLightf
-	glLightfv
-	glLighti
-	glLightiv
-	glLightModelf
-	glLightModelfv
-	glLightModeli
-	glLightModeliv
-	glLineStipple
-	glLineWidth
-	glMaterialf
-	glMaterialfv
-	glMateriali
-	glMaterialiv
-	glPointSize
-	glPolygonMode
-	glPolygonStipple
-	glScissor
-	glShadeModel
-	glTexParameterf
-	glTexParameterfv
-	glTexParameteri
-	glTexParameteriv
-	glTexImage1D
-	glTexImage2D
-	glTexEnvf
-	glTexEnvfv
-	glTexEnvi
-	glTexEnviv
-	glTexGend
-	glTexGendv
-	glTexGenf
-	glTexGenfv
-	glTexGeni
-	glTexGeniv
-	glFeedbackBuffer
-	glSelectBuffer
-	glRenderMode
-	glInitNames
-	glLoadName
-	glPassThrough
-	glPopName
-	glPushName
-	glDrawBuffer
-	glClear
-	glClearAccum
-	glClearIndex
-	glClearColor
-	glClearStencil
-	glClearDepth
-	glStencilMask
-	glColorMask
-	glDepthMask
-	glIndexMask
-	glAccum
-	glDisable
-	glEnable
-	glFinish
-	glFlush
-	glPopAttrib
-	glPushAttrib
-	glMap1d
-	glMap1f
-	glMap2d
-	glMap2f
-	glMapGrid1d
-	glMapGrid1f
-	glMapGrid2d
-	glMapGrid2f
-	glEvalCoord1d
-	glEvalCoord1dv
-	glEvalCoord1f
-	glEvalCoord1fv
-	glEvalCoord2d
-	glEvalCoord2dv
-	glEvalCoord2f
-	glEvalCoord2fv
-	glEvalMesh1
-	glEvalPoint1
-	glEvalMesh2
-	glEvalPoint2
-	glAlphaFunc
-	glBlendFunc
-	glLogicOp
-	glStencilFunc
-	glStencilOp
-	glDepthFunc
-	glPixelZoom
-	glPixelTransferf
-	glPixelTransferi
-	glPixelStoref
-	glPixelStorei
-	glPixelMapfv
-	glPixelMapuiv
-	glPixelMapusv
-	glReadBuffer
-	glCopyPixels
-	glReadPixels
-	glDrawPixels
-	glGetBooleanv
-	glGetClipPlane
-	glGetDoublev
-	glGetError
-	glGetFloatv
-	glGetIntegerv
-	glGetLightfv
-	glGetLightiv
-	glGetMapdv
-	glGetMapfv
-	glGetMapiv
-	glGetMaterialfv
-	glGetMaterialiv
-	glGetPixelMapfv
-	glGetPixelMapuiv
-	glGetPixelMapusv
-	glGetPolygonStipple
-	glGetString
-	glGetTexEnvfv
-	glGetTexEnviv
-	glGetTexGendv
-	glGetTexGenfv
-	glGetTexGeniv
-	glGetTexImage
-	glGetTexParameterfv
-	glGetTexParameteriv
-	glGetTexLevelParameterfv
-	glGetTexLevelParameteriv
-	glIsEnabled
-	glIsList
-	glDepthRange
-	glFrustum
-	glLoadIdentity
-	glLoadMatrixf
-	glLoadMatrixd
-	glMatrixMode
-	glMultMatrixf
-	glMultMatrixd
-	glOrtho
-	glPopMatrix
-	glPushMatrix
-	glRotated
-	glRotatef
-	glScaled
-	glScalef
-	glTranslated
-	glTranslatef
-	glViewport
-	glArrayElement
-	glColorPointer
-	glDisableClientState
-	glDrawArrays
-	glDrawElements
-	glEdgeFlagPointer
-	glEnableClientState
-	glGetPointerv
-	glIndexPointer
-	glInterleavedArrays
-	glNormalPointer
-	glTexCoordPointer
 	glVertexPointer
-	glPolygonOffset
-	glCopyTexImage1D
-	glCopyTexImage2D
-	glCopyTexSubImage1D
-	glCopyTexSubImage2D
-	glTexSubImage1D
-	glTexSubImage2D
-	glAreTexturesResident
-	glBindTexture
-	glDeleteTextures
-	glGenTextures
-	glIsTexture
-	glPrioritizeTextures
-	glIndexub
-	glIndexubv
-	glPopClientAttrib
-	glPushClientAttrib
-	glBlendColor
-	glBlendEquation
-	glDrawRangeElements
-	glColorTable
-	glColorTableParameterfv
-	glColorTableParameteriv
-	glCopyColorTable
-	glGetColorTable
-	glGetColorTableParameterfv
-	glGetColorTableParameteriv
-	glColorSubTable
-	glCopyColorSubTable
-	glConvolutionFilter1D
-	glConvolutionFilter2D
-	glConvolutionParameterf
-	glConvolutionParameterfv
-	glConvolutionParameteri
-	glConvolutionParameteriv
-	glCopyConvolutionFilter1D
-	glCopyConvolutionFilter2D
-	glGetConvolutionFilter
-	glGetConvolutionParameterfv
-	glGetConvolutionParameteriv
-	glGetSeparableFilter
-	glSeparableFilter2D
-	glGetHistogram
-	glGetHistogramParameterfv
-	glGetHistogramParameteriv
-	glGetMinmax
-	glGetMinmaxParameterfv
-	glGetMinmaxParameteriv
-	glHistogram
-	glMinmax
-	glResetHistogram
-	glResetMinmax
-	glTexImage3D
-	glTexSubImage3D
-	glCopyTexSubImage3D
-	glActiveTextureARB
-	glClientActiveTextureARB
-	glMultiTexCoord1dARB
-	glMultiTexCoord1dvARB
-	glMultiTexCoord1fARB
-	glMultiTexCoord1fvARB
-	glMultiTexCoord1iARB
-	glMultiTexCoord1ivARB
-	glMultiTexCoord1sARB
-	glMultiTexCoord1svARB
-	glMultiTexCoord2dARB
-	glMultiTexCoord2dvARB
-	glMultiTexCoord2fARB
-	glMultiTexCoord2fvARB
-	glMultiTexCoord2iARB
-	glMultiTexCoord2ivARB
-	glMultiTexCoord2sARB
-	glMultiTexCoord2svARB
-	glMultiTexCoord3dARB
-	glMultiTexCoord3dvARB
-	glMultiTexCoord3fARB
-	glMultiTexCoord3fvARB
-	glMultiTexCoord3iARB
-	glMultiTexCoord3ivARB
-	glMultiTexCoord3sARB
-	glMultiTexCoord3svARB
-	glMultiTexCoord4dARB
-	glMultiTexCoord4dvARB
-	glMultiTexCoord4fARB
-	glMultiTexCoord4fvARB
-	glMultiTexCoord4iARB
-	glMultiTexCoord4ivARB
-	glMultiTexCoord4sARB
-	glMultiTexCoord4svARB
-	glLoadTransposeMatrixfARB
-	glLoadTransposeMatrixdARB
-	glMultTransposeMatrixfARB
-	glMultTransposeMatrixdARB
-	glSampleCoverageARB
-	glCompressedTexImage3DARB
-	glCompressedTexImage2DARB
-	glCompressedTexImage1DARB
-	glCompressedTexSubImage3DARB
-	glCompressedTexSubImage2DARB
-	glCompressedTexSubImage1DARB
-	glGetCompressedTexImageARB
-	glActiveTexture
-	glClientActiveTexture
-	glMultiTexCoord1d
-	glMultiTexCoord1dv
-	glMultiTexCoord1f
-	glMultiTexCoord1fv
-	glMultiTexCoord1i
-	glMultiTexCoord1iv
-	glMultiTexCoord1s
-	glMultiTexCoord1sv
-	glMultiTexCoord2d
-	glMultiTexCoord2dv
-	glMultiTexCoord2f
-	glMultiTexCoord2fv
-	glMultiTexCoord2i
-	glMultiTexCoord2iv
-	glMultiTexCoord2s
-	glMultiTexCoord2sv
-	glMultiTexCoord3d
-	glMultiTexCoord3dv
-	glMultiTexCoord3f
-	glMultiTexCoord3fv
-	glMultiTexCoord3i
-	glMultiTexCoord3iv
-	glMultiTexCoord3s
-	glMultiTexCoord3sv
-	glMultiTexCoord4d
-	glMultiTexCoord4dv
-	glMultiTexCoord4f
-	glMultiTexCoord4fv
-	glMultiTexCoord4i
-	glMultiTexCoord4iv
-	glMultiTexCoord4s
-	glMultiTexCoord4sv
-	glLoadTransposeMatrixf
-	glLoadTransposeMatrixd
-	glMultTransposeMatrixf
-	glMultTransposeMatrixd
-	glSampleCoverage
-	glCompressedTexImage3D
-	glCompressedTexImage2D
-	glCompressedTexImage1D
-	glCompressedTexSubImage3D
-	glCompressedTexSubImage2D
-	glCompressedTexSubImage1D
-	glGetCompressedTexImage
-	glBlendColorEXT
-	glPolygonOffsetEXT
-	glTexImage3DEXT
-	glTexSubImage3DEXT
-	glTexSubImage1DEXT
-	glTexSubImage2DEXT
-	glCopyTexImage1DEXT
-	glCopyTexImage2DEXT
-	glCopyTexSubImage1DEXT
-	glCopyTexSubImage2DEXT
-	glCopyTexSubImage3DEXT
-	glAreTexturesResidentEXT
-	glBindTextureEXT
-	glDeleteTexturesEXT
-	glGenTexturesEXT
-	glIsTextureEXT
-	glPrioritizeTexturesEXT
-	glArrayElementEXT
-	glColorPointerEXT
-	glDrawArraysEXT
-	glEdgeFlagPointerEXT
-	glGetPointervEXT
-	glIndexPointerEXT
-	glNormalPointerEXT
-	glTexCoordPointerEXT
-	glVertexPointerEXT
-	glBlendEquationEXT
-	glPointParameterfEXT
-	glPointParameterfvEXT
-	glPointParameterfARB
-	glPointParameterfvARB
-	glColorTableEXT
-	glGetColorTableEXT
-	glGetColorTableParameterivEXT
-	glGetColorTableParameterfvEXT
-	glLockArraysEXT
-	glUnlockArraysEXT
-	glDrawRangeElementsEXT
-	glSecondaryColor3bEXT
-	glSecondaryColor3bvEXT
-	glSecondaryColor3dEXT
-	glSecondaryColor3dvEXT
-	glSecondaryColor3fEXT
-	glSecondaryColor3fvEXT
-	glSecondaryColor3iEXT
-	glSecondaryColor3ivEXT
-	glSecondaryColor3sEXT
-	glSecondaryColor3svEXT
-	glSecondaryColor3ubEXT
-	glSecondaryColor3ubvEXT
-	glSecondaryColor3uiEXT
-	glSecondaryColor3uivEXT
-	glSecondaryColor3usEXT
-	glSecondaryColor3usvEXT
-	glSecondaryColorPointerEXT
-	glMultiDrawArraysEXT
-	glMultiDrawElementsEXT
-	glFogCoordfEXT
-	glFogCoordfvEXT
-	glFogCoorddEXT
-	glFogCoorddvEXT
-	glFogCoordPointerEXT
-	glBlendFuncSeparateEXT
-	glWindowPos2dMESA
-	glWindowPos2dvMESA
-	glWindowPos2fMESA
-	glWindowPos2fvMESA
-	glWindowPos2iMESA
-	glWindowPos2ivMESA
-	glWindowPos2sMESA
-	glWindowPos2svMESA
-	glWindowPos3dMESA
-	glWindowPos3dvMESA
-	glWindowPos3fMESA
-	glWindowPos3fvMESA
-	glWindowPos3iMESA
-	glWindowPos3ivMESA
-	glWindowPos3sMESA
-	glWindowPos3svMESA
-	glWindowPos4dMESA
-	glWindowPos4dvMESA
-	glWindowPos4fMESA
-	glWindowPos4fvMESA
-	glWindowPos4iMESA
-	glWindowPos4ivMESA
-	glWindowPos4sMESA
-	glWindowPos4svMESA
-	glWindowPos2dARB
-	glWindowPos2fARB
-	glWindowPos2iARB
-	glWindowPos2sARB
-	glWindowPos2dvARB
-	glWindowPos2fvARB
-	glWindowPos2ivARB
-	glWindowPos2svARB
-	glWindowPos3dARB
-	glWindowPos3fARB
-	glWindowPos3iARB
-	glWindowPos3sARB
-	glWindowPos3dvARB
-	glWindowPos3fvARB
-	glWindowPos3ivARB
-	glWindowPos3svARB
-	glAreProgramsResidentNV
-	glBindProgramNV
-	glDeleteProgramsNV
-	glExecuteProgramNV
-	glGenProgramsNV
-	glGetProgramParameterdvNV
-	glGetProgramParameterfvNV
-	glGetProgramivNV
-	glGetProgramStringNV
-	glGetTrackMatrixivNV
-	glGetVertexAttribdvNV
-	glGetVertexAttribfvNV
-	glGetVertexAttribivNV
-	glGetVertexAttribPointervNV
-	glIsProgramNV
-	glLoadProgramNV
-	glProgramParameter4dNV
-	glProgramParameter4dvNV
-	glProgramParameter4fNV
-	glProgramParameter4fvNV
-	glProgramParameters4dvNV
-	glProgramParameters4fvNV
-	glRequestResidentProgramsNV
-	glTrackMatrixNV
-	glVertexAttribPointerNV
-	glVertexAttrib1dNV
-	glVertexAttrib1dvNV
-	glVertexAttrib1fNV
-	glVertexAttrib1fvNV
-	glVertexAttrib1sNV
-	glVertexAttrib1svNV
-	glVertexAttrib2dNV
-	glVertexAttrib2dvNV
-	glVertexAttrib2fNV
-	glVertexAttrib2fvNV
-	glVertexAttrib2sNV
-	glVertexAttrib2svNV
-	glVertexAttrib3dNV
-	glVertexAttrib3dvNV
-	glVertexAttrib3fNV
-	glVertexAttrib3fvNV
-	glVertexAttrib3sNV
-	glVertexAttrib3svNV
-	glVertexAttrib4dNV
-	glVertexAttrib4dvNV
-	glVertexAttrib4fNV
-	glVertexAttrib4fvNV
-	glVertexAttrib4sNV
-	glVertexAttrib4svNV
-	glVertexAttrib4ubNV
-	glVertexAttrib4ubvNV
-	glVertexAttribs1dvNV
-	glVertexAttribs1fvNV
-	glVertexAttribs1svNV
-	glVertexAttribs2dvNV
-	glVertexAttribs2fvNV
-	glVertexAttribs2svNV
-	glVertexAttribs3dvNV
-	glVertexAttribs3fvNV
-	glVertexAttribs3svNV
-	glVertexAttribs4dvNV
-	glVertexAttribs4fvNV
-	glVertexAttribs4svNV
-	glVertexAttribs4ubvNV
-	glPointParameteriNV
-	glPointParameterivNV
-	glFogCoordf
-	glFogCoordfv
-	glFogCoordd
-	glFogCoorddv
-	glFogCoordPointer
-	glMultiDrawArrays
-	glMultiDrawElements
-	glPointParameterf
-	glPointParameterfv
-	glPointParameteri
-	glPointParameteriv
-	glSecondaryColor3b
-	glSecondaryColor3bv
-	glSecondaryColor3d
-	glSecondaryColor3dv
-	glSecondaryColor3f
-	glSecondaryColor3fv
-	glSecondaryColor3i
-	glSecondaryColor3iv
-	glSecondaryColor3s
-	glSecondaryColor3sv
-	glSecondaryColor3ub
-	glSecondaryColor3ubv
-	glSecondaryColor3ui
-	glSecondaryColor3uiv
-	glSecondaryColor3us
-	glSecondaryColor3usv
-	glSecondaryColorPointer
-	glWindowPos2d
-	glWindowPos2dv
-	glWindowPos2f
-	glWindowPos2fv
-	glWindowPos2i
-	glWindowPos2iv
-	glWindowPos2s
-	glWindowPos2sv
-	glWindowPos3d
-	glWindowPos3dv
-	glWindowPos3f
-	glWindowPos3fv
-	glWindowPos3i
-	glWindowPos3iv
-	glWindowPos3s
-	glWindowPos3sv
-	glVertexAttrib1sARB
-	glVertexAttrib1fARB
-	glVertexAttrib1dARB
-	glVertexAttrib2sARB
-	glVertexAttrib2fARB
-	glVertexAttrib2dARB
-	glVertexAttrib3sARB
-	glVertexAttrib3fARB
-	glVertexAttrib3dARB
-	glVertexAttrib4sARB
-	glVertexAttrib4fARB
-	glVertexAttrib4dARB
-	glVertexAttrib4NubARB
-	glVertexAttrib1svARB
-	glVertexAttrib1fvARB
-	glVertexAttrib1dvARB
-	glVertexAttrib2svARB
-	glVertexAttrib2fvARB
-	glVertexAttrib2dvARB
-	glVertexAttrib3svARB
-	glVertexAttrib3fvARB
-	glVertexAttrib3dvARB
-	glVertexAttrib4bvARB
-	glVertexAttrib4svARB
-	glVertexAttrib4ivARB
-	glVertexAttrib4ubvARB
-	glVertexAttrib4usvARB
-	glVertexAttrib4uivARB
-	glVertexAttrib4fvARB
-	glVertexAttrib4dvARB
-	glVertexAttrib4NbvARB
-	glVertexAttrib4NsvARB
-	glVertexAttrib4NivARB
-	glVertexAttrib4NubvARB
-	glVertexAttrib4NusvARB
-	glVertexAttrib4NuivARB
-	glVertexAttribPointerARB
-	glEnableVertexAttribArrayARB
-	glDisableVertexAttribArrayARB
-	glProgramStringARB
-	glBindProgramARB
-	glDeleteProgramsARB
-	glGenProgramsARB
-	glIsProgramARB
-	glProgramEnvParameter4dARB
-	glProgramEnvParameter4dvARB
-	glProgramEnvParameter4fARB
-	glProgramEnvParameter4fvARB
-	glProgramLocalParameter4dARB
-	glProgramLocalParameter4dvARB
-	glProgramLocalParameter4fARB
-	glProgramLocalParameter4fvARB
-	glGetProgramEnvParameterdvARB
-	glGetProgramEnvParameterfvARB
-	glGetProgramLocalParameterdvARB
-	glGetProgramLocalParameterfvARB
-	glGetProgramivARB
-	glGetProgramStringARB
-	glGetVertexAttribdvARB
-	glGetVertexAttribfvARB
-	glGetVertexAttribivARB
-	glGetVertexAttribPointervARB
-	glProgramNamedParameter4fNV
-	glProgramNamedParameter4dNV
-	glProgramNamedParameter4fvNV
-	glProgramNamedParameter4dvNV
-	glGetProgramNamedParameterfvNV
-	glGetProgramNamedParameterdvNV
-	glBindBufferARB
-	glBufferDataARB
-	glBufferSubDataARB
-	glDeleteBuffersARB
-	glGenBuffersARB
-	glGetBufferParameterivARB
-	glGetBufferPointervARB
-	glGetBufferSubDataARB
-	glIsBufferARB
-	glMapBufferARB
-	glUnmapBufferARB
-	glGenQueriesARB
-	glDeleteQueriesARB
-	glIsQueryARB
-	glBeginQueryARB
-	glEndQueryARB
-	glGetQueryivARB
-	glGetQueryObjectivARB
-	glGetQueryObjectuivARB
-	glBindBuffer
-	glBufferData
-	glBufferSubData
-	glDeleteBuffers
-	glGenBuffers
-	glGetBufferParameteriv
-	glGetBufferPointerv
-	glGetBufferSubData
-	glIsBuffer
-	glMapBuffer
-	glUnmapBuffer
-	glGenQueries
-	glDeleteQueries
-	glIsQuery
-	glBeginQuery
-	glEndQuery
-	glGetQueryiv
-	glGetQueryObjectiv
-	glGetQueryObjectuiv
-;
-; WGL API
+	glViewport
 	wglChoosePixelFormat
 	wglCopyContext
 	wglCreateContext
@@ -837,4 +383,3 @@ EXPORTS
 	wglUseFontBitmapsW
 	wglUseFontOutlinesA
 	wglUseFontOutlinesW
-	wglGetExtensionsStringARB
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 9b80600..bf4fa3e 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -55,52 +55,6 @@ index_bytes(GLenum type, GLsizei count)
 
 
 /**
- * Find the max index in the given element/index buffer
- */
-GLuint
-_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
-                       const void *indices,
-                       struct gl_buffer_object *elementBuf)
-{
-   const GLubyte *map = NULL;
-   GLuint max = 0;
-   GLuint i;
-
-   if (_mesa_is_bufferobj(elementBuf)) {
-      /* elements are in a user-defined buffer object.  need to map it */
-      map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size,
-				       GL_MAP_READ_BIT, elementBuf,
-                                       MAP_INTERNAL);
-      /* Actual address is the sum of pointers */
-      indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
-   }
-
-   if (type == GL_UNSIGNED_INT) {
-      for (i = 0; i < count; i++)
-         if (((GLuint *) indices)[i] > max)
-            max = ((GLuint *) indices)[i];
-   }
-   else if (type == GL_UNSIGNED_SHORT) {
-      for (i = 0; i < count; i++)
-         if (((GLushort *) indices)[i] > max)
-            max = ((GLushort *) indices)[i];
-   }
-   else {
-      ASSERT(type == GL_UNSIGNED_BYTE);
-      for (i = 0; i < count; i++)
-         if (((GLubyte *) indices)[i] > max)
-            max = ((GLubyte *) indices)[i];
-   }
-
-   if (map) {
-      ctx->Driver.UnmapBuffer(ctx, elementBuf, MAP_INTERNAL);
-   }
-
-   return max;
-}
-
-
-/**
  * Check if OK to draw arrays/elements.
  */
 static GLboolean
@@ -749,17 +703,17 @@ _mesa_validate_DrawTransformFeedback(struct gl_context *ctx,
       return GL_FALSE;
    }
 
-   if (!obj->EndedAnytime) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
-      return GL_FALSE;
-   }
-
    if (stream >= ctx->Const.MaxVertexStreams) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "glDrawTransformFeedbackStream*(index>=MaxVertexStream)");
       return GL_FALSE;
    }
 
+   if (!obj->EndedAnytime) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawTransformFeedback*");
+      return GL_FALSE;
+   }
+
    if (numInstances <= 0) {
       if (numInstances < 0)
          _mesa_error(ctx, GL_INVALID_VALUE,
diff --git a/mesalib/src/mesa/main/api_validate.h b/mesalib/src/mesa/main/api_validate.h
index 8238df1..0bb91c6 100644
--- a/mesalib/src/mesa/main/api_validate.h
+++ b/mesalib/src/mesa/main/api_validate.h
@@ -35,12 +35,6 @@ struct gl_context;
 struct gl_transform_feedback_object;
 
 
-extern GLuint
-_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
-                       const void *indices,
-                       struct gl_buffer_object *elementBuf);
-
-
 extern bool
 _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode);
 
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 5345339..4684615 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1345,7 +1345,8 @@ _mesa_PopAttrib(void)
                if (xform->DepthClamp != ctx->Transform.DepthClamp)
                   _mesa_set_enable(ctx, GL_DEPTH_CLAMP,
                                    ctx->Transform.DepthClamp);
-               _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode);
+               if (ctx->Extensions.ARB_clip_control)
+                  _mesa_ClipControl(xform->ClipOrigin, xform->ClipDepthMode);
             }
             break;
          case GL_TEXTURE_BIT:
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 25b9bfc..400c158 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -719,6 +719,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
    /** GL_ARB_gpu_shader5 */
    consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET;
    consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET;
+
+   /** GL_KHR_context_flush_control */
+   consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
 }
 
 
@@ -729,6 +732,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
 static void
 check_context_limits(struct gl_context *ctx)
 {
+   (void) ctx;
+
    /* check that we don't exceed the size of various bitfields */
    assert(VARYING_SLOT_MAX <=
 	  (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
@@ -1622,9 +1627,11 @@ _mesa_make_current( struct gl_context *newCtx,
    }
 
    if (curCtx && 
-      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
+       (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
        /* make sure this context is valid for flushing */
-      curCtx != newCtx)
+       curCtx != newCtx &&
+       curCtx->Const.ContextReleaseBehavior ==
+       GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
       _mesa_flush(curCtx);
 
    /* We used to call _glapi_check_multithread() here.  Now do it in drivers */
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 25171f0..7d622bb 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -676,22 +676,41 @@ debug_pop_group(struct gl_debug_state *debug)
 
 
 /**
- * Return debug state for the context.  The debug state will be allocated
- * and initialized upon the first call.
+ * Lock and return debug state for the context.  The debug state will be
+ * allocated and initialized upon the first call.  When NULL is returned, the
+ * debug state is not locked.
  */
 static struct gl_debug_state *
-_mesa_get_debug_state(struct gl_context *ctx)
+_mesa_lock_debug_state(struct gl_context *ctx)
 {
+   mtx_lock(&ctx->DebugMutex);
+
    if (!ctx->Debug) {
       ctx->Debug = debug_create();
       if (!ctx->Debug) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
+         GET_CURRENT_CONTEXT(cur);
+         mtx_unlock(&ctx->DebugMutex);
+
+         /*
+          * This function may be called from other threads.  When that is the
+          * case, we cannot record this OOM error.
+          */
+         if (ctx == cur)
+            _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
+
+         return NULL;
       }
    }
 
    return ctx->Debug;
 }
 
+static void
+_mesa_unlock_debug_state(struct gl_context *ctx)
+{
+   mtx_unlock(&ctx->DebugMutex);
+}
+
 /**
  * Set the integer debug state specified by \p pname.  This can be called from
  * _mesa_set_enable for example.
@@ -699,7 +718,7 @@ _mesa_get_debug_state(struct gl_context *ctx)
 bool
 _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val)
 {
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+   struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
 
    if (!debug)
       return false;
@@ -716,6 +735,8 @@ _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val)
       break;
    }
 
+   _mesa_unlock_debug_state(ctx);
+
    return true;
 }
 
@@ -729,9 +750,12 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
    struct gl_debug_state *debug;
    GLint val;
 
+   mtx_lock(&ctx->DebugMutex);
    debug = ctx->Debug;
-   if (!debug)
+   if (!debug) {
+      mtx_unlock(&ctx->DebugMutex);
       return 0;
+   }
 
    switch (pname) {
    case GL_DEBUG_OUTPUT:
@@ -756,6 +780,8 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
       break;
    }
 
+   mtx_unlock(&ctx->DebugMutex);
+
    return val;
 }
 
@@ -769,9 +795,12 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
    struct gl_debug_state *debug;
    void *val;
 
+   mtx_lock(&ctx->DebugMutex);
    debug = ctx->Debug;
-   if (!debug)
+   if (!debug) {
+      mtx_unlock(&ctx->DebugMutex);
       return NULL;
+   }
 
    switch (pname) {
    case GL_DEBUG_CALLBACK_FUNCTION_ARB:
@@ -786,9 +815,49 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
       break;
    }
 
+   mtx_unlock(&ctx->DebugMutex);
+
    return val;
 }
 
+/**
+ * Insert a debug message.  The mutex is assumed to be locked, and will be
+ * unlocked by this call.
+ */
+static void
+log_msg_locked_and_unlock(struct gl_context *ctx,
+                          enum mesa_debug_source source,
+                          enum mesa_debug_type type, GLuint id,
+                          enum mesa_debug_severity severity,
+                          GLint len, const char *buf)
+{
+   struct gl_debug_state *debug = ctx->Debug;
+
+   if (!debug_is_message_enabled(debug, source, type, id, severity)) {
+      _mesa_unlock_debug_state(ctx);
+      return;
+   }
+
+   if (ctx->Debug->Callback) {
+      GLenum gl_source = debug_source_enums[source];
+      GLenum gl_type = debug_type_enums[type];
+      GLenum gl_severity = debug_severity_enums[severity];
+      GLDEBUGPROC callback = ctx->Debug->Callback;
+      const void *data = ctx->Debug->CallbackData;
+
+      /*
+       * When ctx->Debug->SyncOutput is GL_FALSE, the client is prepared for
+       * unsynchronous calls.  When it is GL_TRUE, we will not spawn threads.
+       * In either case, we can call the callback unlocked.
+       */
+      _mesa_unlock_debug_state(ctx);
+      callback(gl_source, gl_type, id, gl_severity, len, buf, data);
+   }
+   else {
+      debug_log_message(ctx->Debug, source, type, id, severity, len, buf);
+      _mesa_unlock_debug_state(ctx);
+   }
+}
 
 /**
  * Log a client or driver debug message.
@@ -798,24 +867,12 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
         enum mesa_debug_type type, GLuint id,
         enum mesa_debug_severity severity, GLint len, const char *buf)
 {
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+   struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
 
    if (!debug)
       return;
 
-   if (!debug_is_message_enabled(debug, source, type, id, severity))
-      return;
-
-   if (debug->Callback) {
-       GLenum gl_type = debug_type_enums[type];
-       GLenum gl_severity = debug_severity_enums[severity];
-
-      debug->Callback(debug_source_enums[source], gl_type, id, gl_severity,
-                      len, buf, debug->CallbackData);
-      return;
-   }
-
-   debug_log_message(debug, source, type, id, severity, len, buf);
+   log_msg_locked_and_unlock(ctx, source, type, id, severity, len, buf);
 }
 
 
@@ -956,7 +1013,7 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
       return 0;
    }
 
-   debug = _mesa_get_debug_state(ctx);
+   debug = _mesa_lock_debug_state(ctx);
    if (!debug)
       return 0;
 
@@ -991,6 +1048,8 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
       debug_delete_messages(debug, 1);
    }
 
+   _mesa_unlock_debug_state(ctx);
+
    return ret;
 }
 
@@ -1027,7 +1086,7 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
       return;
    }
 
-   debug = _mesa_get_debug_state(ctx);
+   debug = _mesa_lock_debug_state(ctx);
    if (!debug)
       return;
 
@@ -1039,6 +1098,8 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
    else {
       debug_set_message_enable_all(debug, source, type, severity, enabled);
    }
+
+   _mesa_unlock_debug_state(ctx);
 }
 
 
@@ -1046,10 +1107,11 @@ void GLAPIENTRY
 _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
+   struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
    if (debug) {
       debug->Callback = callback;
       debug->CallbackData = userParam;
+      _mesa_unlock_debug_state(ctx);
    }
 }
 
@@ -1059,18 +1121,10 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
                      const GLchar *message)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
    const char *callerstr = "glPushDebugGroup";
+   struct gl_debug_state *debug;
    struct gl_debug_message *emptySlot;
 
-   if (!debug)
-      return;
-
-   if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
-      _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr);
-      return;
-   }
-
    switch(source) {
    case GL_DEBUG_SOURCE_APPLICATION:
    case GL_DEBUG_SOURCE_THIRD_PARTY:
@@ -1086,10 +1140,15 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
    if (!validate_length(ctx, callerstr, length))
       return; /* GL_INVALID_VALUE */
 
-   log_msg(ctx, gl_enum_to_debug_source(source),
-           MESA_DEBUG_TYPE_PUSH_GROUP, id,
-           MESA_DEBUG_SEVERITY_NOTIFICATION, length,
-           message);
+   debug = _mesa_lock_debug_state(ctx);
+   if (!debug)
+      return;
+
+   if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
+      _mesa_unlock_debug_state(ctx);
+      _mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr);
+      return;
+   }
 
    /* pop reuses the message details from push so we store this */
    emptySlot = debug_get_group_message(debug);
@@ -1101,6 +1160,12 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
                        length, message);
 
    debug_push_group(debug);
+
+   log_msg_locked_and_unlock(ctx,
+         gl_enum_to_debug_source(source),
+         MESA_DEBUG_TYPE_PUSH_GROUP, id,
+         MESA_DEBUG_SEVERITY_NOTIFICATION, length,
+         message);
 }
 
 
@@ -1108,35 +1173,43 @@ void GLAPIENTRY
 _mesa_PopDebugGroup(void)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
    const char *callerstr = "glPopDebugGroup";
-   struct gl_debug_message *gdmessage;
+   struct gl_debug_state *debug;
+   struct gl_debug_message *gdmessage, msg;
 
+   debug = _mesa_lock_debug_state(ctx);
    if (!debug)
       return;
 
    if (debug->GroupStackDepth <= 0) {
+      _mesa_unlock_debug_state(ctx);
       _mesa_error(ctx, GL_STACK_UNDERFLOW, "%s", callerstr);
       return;
    }
 
    debug_pop_group(debug);
 
+   /* make a shallow copy */
    gdmessage = debug_get_group_message(debug);
-   log_msg(ctx, gdmessage->source,
-           gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
-           gdmessage->id,
-           gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
-           gdmessage->length, gdmessage->message);
-
-   debug_message_clear(gdmessage);
+   msg = *gdmessage;
+   gdmessage->message = NULL;
+   gdmessage->length = 0;
+
+   log_msg_locked_and_unlock(ctx,
+         msg.source,
+         gl_enum_to_debug_type(GL_DEBUG_TYPE_POP_GROUP),
+         msg.id,
+         gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
+         msg.length, msg.message);
+
+   debug_message_clear(&msg);
 }
 
 
 void
 _mesa_init_errors(struct gl_context *ctx)
 {
-   /* no-op */
+   mtx_init(&ctx->DebugMutex, mtx_plain);
 }
 
 
@@ -1148,6 +1221,8 @@ _mesa_free_errors_data(struct gl_context *ctx)
       /* set to NULL just in case it is used before context is completely gone. */
       ctx->Debug = NULL;
    }
+
+   mtx_destroy(&ctx->DebugMutex);
 }
 
 
@@ -1362,6 +1437,8 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
    debug_get_id(&error_msg_id);
 
    do_output = should_output(ctx, error, fmtString);
+
+   mtx_lock(&ctx->DebugMutex);
    if (ctx->Debug) {
       do_log = debug_is_message_enabled(ctx->Debug,
                                         MESA_DEBUG_SOURCE_API,
@@ -1372,6 +1449,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
    else {
       do_log = GL_FALSE;
    }
+   mtx_unlock(&ctx->DebugMutex);
 
    if (do_output || do_log) {
       char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH];
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 15d66a7..0df04c2 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -320,6 +320,7 @@ static const struct extension extension_table[] = {
 
    /* KHR extensions */
    { "GL_KHR_debug",                               o(dummy_true),                              GL,             2012 },
+   { "GL_KHR_context_flush_control",               o(dummy_true),                              GL       | ES2, 2014 },
 
    /* Vendor extensions */
    { "GL_3DFX_texture_compression_FXT1",           o(TDFX_texture_compression_FXT1),           GL,             1999 },
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index aa9f282..09a61ac 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -318,6 +318,9 @@ descriptor=[
   [ "PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_NAME_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_DESC_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", "CONST(PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS), extra_INTEL_performance_query" ],
+
+# GL_KHR_context_flush_control
+  [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ],
 ]},
 
 # GLES3 is not a typo.
@@ -624,7 +627,7 @@ descriptor=[
 # == GL_CURRENT_MATRIX_NV
   [ "CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
 # == GL_CURRENT_MATRIX_NV
-  [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
+  [ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX_T, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
 # == GL_PROGRAM_ERROR_POSITION_NV
   [ "PROGRAM_ERROR_POSITION_ARB", "CONTEXT_INT(Program.ErrorPos), extra_ARB_vertex_program_ARB_fragment_program" ],
 
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index b8c7548..4f5a2d1 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -499,25 +499,6 @@ _mesa_strdup( const char *s )
    }
 }
 
-/** Wrapper around strtof() */
-float
-_mesa_strtof( const char *s, char **end )
-{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
-   !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
-   !defined(__NetBSD__)
-   static locale_t loc = NULL;
-   if (!loc) {
-      loc = newlocale(LC_CTYPE_MASK, "C", NULL);
-   }
-   return strtof_l(s, end, loc);
-#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
-   return strtof(s, end);
-#else
-   return (float)strtod(s, end);
-#endif
-}
-
 /** Compute simple checksum/hash for a string */
 unsigned int
 _mesa_str_checksum(const char *str)
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 436d165..0fcba4f 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -540,9 +540,6 @@ _mesa_half_is_negative(GLhalfARB h)
 extern char *
 _mesa_strdup( const char *s );
 
-extern float
-_mesa_strtof( const char *s, char **end );
-
 extern unsigned int
 _mesa_str_checksum(const char *str);
 
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index e1f1f1d..7389baa 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2843,6 +2843,7 @@ struct gl_shader_program
 
    /* post-link info: */
    unsigned NumUserUniformStorage;
+   unsigned NumHiddenUniforms;
    struct gl_uniform_storage *UniformStorage;
 
    /**
@@ -3680,6 +3681,9 @@ struct gl_constants
 
    GLboolean FakeSWMSAA;
 
+   /** GL_KHR_context_flush_control */
+   GLenum ContextReleaseBehavior;
+
    struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
 };
 
@@ -4390,6 +4394,7 @@ struct gl_context
    GLuint ErrorDebugCount;
 
    /* GL_ARB_debug_output/GL_KHR_debug */
+   mtx_t DebugMutex;
    struct gl_debug_state *Debug;
 
    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 2be9092..6657820 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -565,13 +565,15 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       *params = _mesa_longest_attribute_name_length(shProg);
       return;
    case GL_ACTIVE_UNIFORMS:
-      *params = shProg->NumUserUniformStorage;
+      *params = shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
       return;
    case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
       unsigned i;
       GLint max_len = 0;
+      const unsigned num_uniforms =
+         shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
 
-      for (i = 0; i < shProg->NumUserUniformStorage; i++) {
+      for (i = 0; i < num_uniforms; i++) {
 	 /* Add one for the terminating NUL character for a non-array, and
 	  * 4 for the "[0]" and the NUL for an array.
 	  */
diff --git a/mesalib/src/mesa/main/sse_minmax.c b/mesalib/src/mesa/main/sse_minmax.c
new file mode 100644
index 0000000..222ac14
--- /dev/null
+++ b/mesalib/src/mesa/main/sse_minmax.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2014 Timothy Arceri
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Author:
+ *    Timothy Arceri <t_arceri at yahoo.com.au>
+ *
+ */
+
+#ifdef __SSE4_1__
+#include "main/sse_minmax.h"
+#include <smmintrin.h>
+#include <stdint.h>
+
+void
+_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
+                         unsigned *max_index, const unsigned count)
+{
+   unsigned max_ui = 0;
+   unsigned min_ui = ~0U;
+   unsigned i = 0;
+   unsigned aligned_count = count;
+
+   /* handle the first few values without SSE until the pointer is aligned */
+   while (((uintptr_t)ui_indices & 15) && aligned_count) {
+      if (*ui_indices > max_ui)
+         max_ui = *ui_indices;
+      if (*ui_indices < min_ui)
+         min_ui = *ui_indices;
+
+      aligned_count--;
+      ui_indices++;
+   }
+
+   /* TODO: The actual threshold for SSE begin useful may be higher than 8.
+    * Some careful microbenchmarks and measurement are required to
+    * find the actual tipping point.
+    */
+   if (aligned_count >= 8) {
+      unsigned max_arr[4] __attribute__ ((aligned (16)));
+      unsigned min_arr[4] __attribute__ ((aligned (16)));
+      unsigned vec_count;
+      __m128i max_ui4 = _mm_setzero_si128();
+      __m128i min_ui4 = _mm_set1_epi32(~0U);
+      __m128i ui_indices4;
+      __m128i *ui_indices_ptr;
+
+      vec_count = aligned_count & ~0x3;
+      ui_indices_ptr = (__m128i *)ui_indices;
+      for (i = 0; i < vec_count / 4; i++) {
+         ui_indices4 = _mm_load_si128(&ui_indices_ptr[i]);
+         max_ui4 = _mm_max_epu32(ui_indices4, max_ui4);
+         min_ui4 = _mm_min_epu32(ui_indices4, min_ui4);
+      }
+
+      _mm_store_si128((__m128i *)max_arr, max_ui4);
+      _mm_store_si128((__m128i *)min_arr, min_ui4);
+
+      for (i = 0; i < 4; i++) {
+         if (max_arr[i] > max_ui)
+            max_ui = max_arr[i];
+         if (min_arr[i] < min_ui)
+            min_ui = min_arr[i];
+      }
+      i = vec_count;
+   }
+
+   for (; i < aligned_count; i++) {
+      if (ui_indices[i] > max_ui)
+         max_ui = ui_indices[i];
+      if (ui_indices[i] < min_ui)
+         min_ui = ui_indices[i];
+   }
+
+   *min_index = min_ui;
+   *max_index = max_ui;
+}
+
+#endif
diff --git a/xorg-server/include/dbus-core.h b/mesalib/src/mesa/main/sse_minmax.h
similarity index 57%
copy from xorg-server/include/dbus-core.h
copy to mesalib/src/mesa/main/sse_minmax.h
index b2d6d1b..953c4e9 100644
--- a/xorg-server/include/dbus-core.h
+++ b/mesalib/src/mesa/main/sse_minmax.h
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2013 Red Hat, Inc.
+ * Copyright © 2014 Timothy Arceri
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -17,40 +17,14 @@
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Author:
+ *    Timothy Arceri <t_arceri at yahoo.com.au>
  *
- * Author: Hans de Goede <hdegoede at redhat.com>
  */
 
-#ifndef DBUS_CORE_H
-#define DBUS_CORE_H
-
-#ifdef NEED_DBUS
-typedef struct DBusConnection DBusConnection;
-
-typedef void (*dbus_core_connect_hook) (DBusConnection * connection,
-                                               void *data);
-typedef void (*dbus_core_disconnect_hook) (void *data);
-
-struct dbus_core_hook {
-    dbus_core_connect_hook connect;
-    dbus_core_disconnect_hook disconnect;
-    void *data;
-
-    struct dbus_core_hook *next;
-};
-
-int dbus_core_init(void);
-void dbus_core_fini(void);
-int dbus_core_add_hook(struct dbus_core_hook *hook);
-void dbus_core_remove_hook(struct dbus_core_hook *hook);
-
-#else
-
-#define dbus_core_init()
-#define dbus_core_fini()
-
-#endif
-
-#endif
+void
+_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
+                         unsigned *max_index, const unsigned count);
diff --git a/mesalib/src/mesa/main/streaming-load-memcpy.c b/mesalib/src/mesa/main/streaming-load-memcpy.c
index 8427149..d7147af 100644
--- a/mesalib/src/mesa/main/streaming-load-memcpy.c
+++ b/mesalib/src/mesa/main/streaming-load-memcpy.c
@@ -26,7 +26,6 @@
  *
  */
 
-#ifdef __SSE4_1__
 #include "main/macros.h"
 #include "main/streaming-load-memcpy.h"
 #include <smmintrin.h>
@@ -84,5 +83,3 @@ _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len)
       memcpy(d, s, len);
    }
 }
-
-#endif
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 832e661..ec16af9 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -155,12 +155,14 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
    case GL_ALPHA4:
    case GL_ALPHA8:
       RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+      RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
       break;
 
    case GL_ALPHA12:
    case GL_ALPHA16:
       RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM16);
       RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+      RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
       break;
 
    /* Luminance formats */
@@ -224,6 +226,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
 
    case GL_COMPRESSED_ALPHA_ARB:
       RETURN_IF_SUPPORTED(MESA_FORMAT_A_UNORM8);
+      RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_UNORM);
       break;
    case GL_COMPRESSED_LUMINANCE_ARB:
       RETURN_IF_SUPPORTED(MESA_FORMAT_L_UNORM8);
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index f913e42..f858cef 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -1667,8 +1667,10 @@ texstore_rgba_integer(TEXSTORE_PARAMS)
 
    assert(is_array && !normalized);
 
-   if (!is_array)
+   if (!is_array) {
+      free(tmp_row);
       return GL_FALSE;
+   }
 
    invert_swizzle(dst2rgba, rgba2dst);
    compute_component_mapping(GL_RGBA, baseInternalFormat, base2rgba);
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index fcb14c4..32870d0 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -176,46 +176,13 @@ validate_uniform_parameters(struct gl_context *ctx,
 			    struct gl_shader_program *shProg,
 			    GLint location, GLsizei count,
 			    unsigned *array_index,
-			    const char *caller,
-			    bool negative_one_is_not_valid)
+			    const char *caller)
 {
-   if (!shProg || !shProg->LinkStatus) {
+   if (shProg == NULL) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller);
       return NULL;
    }
 
-   if (location == -1) {
-      /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1
-       * spec says:
-       *
-       *     "The error INVALID_OPERATION is generated if program has not been
-       *     linked successfully, or if location is not a valid location for
-       *     program."
-       *
-       * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec
-       * says:
-       *
-       *     "If the value of location is -1, the Uniform* commands will
-       *     silently ignore the data passed in, and the current uniform
-       *     values will not be changed."
-       *
-       * Allowing -1 for the location parameter of glUniform allows
-       * applications to avoid error paths in the case that, for example, some
-       * uniform variable is removed by the compiler / linker after
-       * optimization.  In this case, the new value of the uniform is dropped
-       * on the floor.  For the case of glGetUniform, there is nothing
-       * sensible to do for a location of -1.
-       *
-       * The negative_one_is_not_valid flag selects between the two behaviors.
-       */
-      if (negative_one_is_not_valid) {
-	 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
-		     caller, location);
-      }
-
-      return NULL;
-   }
-
    /* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec:
     *
     *     "If a negative number is provided where an argument of type sizei or
@@ -226,10 +193,26 @@ validate_uniform_parameters(struct gl_context *ctx,
       return NULL;
    }
 
-   /* Check that the given location is in bounds of uniform remap table. */
-   if (location >= (GLint) shProg->NumUniformRemapTable) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
-                  caller, location);
+   /* Check that the given location is in bounds of uniform remap table.
+    * Unlinked programs will have NumUniformRemapTable == 0, so we can take
+    * the shProg->LinkStatus check out of the main path.
+    */
+   if (unlikely(location >= (GLint) shProg->NumUniformRemapTable)) {
+      if (!shProg->LinkStatus)
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+                     caller);
+      else
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+                     caller, location);
+
+      return NULL;
+   }
+
+   if (location == -1) {
+      if (!shProg->LinkStatus)
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+                     caller);
+
       return NULL;
    }
 
@@ -269,27 +252,30 @@ validate_uniform_parameters(struct gl_context *ctx,
 
    struct gl_uniform_storage *const uni = shProg->UniformRemapTable[location];
 
-   if (uni->array_elements == 0 && count > 1) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-		  "%s(count > 1 for non-array, location=%d)",
-		  caller, location);
-      return NULL;
-   }
+   if (uni->array_elements == 0) {
+      if (count > 1) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "%s(count > 1 for non-array, location=%d)",
+                     caller, location);
+         return NULL;
+      }
 
-   /* The array index specified by the uniform location is just the uniform
-    * location minus the base location of of the uniform.
-    */
-   *array_index = location - uni->remap_location;
+      assert((location - uni->remap_location) == 0);
+      *array_index = 0;
+   } else {
+      /* The array index specified by the uniform location is just the uniform
+       * location minus the base location of of the uniform.
+       */
+      *array_index = location - uni->remap_location;
 
-   /* If the uniform is an array, check that array_index is in bounds.
-    * If not an array, check that array_index is zero.
-    * array_index is unsigned so no need to check for less than zero.
-    */
-   const unsigned limit = MAX2(uni->array_elements, 1);
-   if (*array_index >= limit) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
-		  caller, location);
-      return NULL;
+      /* If the uniform is an array, check that array_index is in bounds.
+       * array_index is unsigned so no need to check for less than zero.
+       */
+      if (*array_index >= uni->array_elements) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+                     caller, location);
+         return NULL;
+      }
    }
    return uni;
 }
@@ -308,9 +294,39 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
 
    struct gl_uniform_storage *const uni =
       validate_uniform_parameters(ctx, shProg, location, 1,
-                                  &offset, "glGetUniform", true);
-   if (uni == NULL)
+                                  &offset, "glGetUniform");
+   if (uni == NULL) {
+      /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1
+       * spec says:
+       *
+       *     "The error INVALID_OPERATION is generated if program has not been
+       *     linked successfully, or if location is not a valid location for
+       *     program."
+       *
+       * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec
+       * says:
+       *
+       *     "If the value of location is -1, the Uniform* commands will
+       *     silently ignore the data passed in, and the current uniform
+       *     values will not be changed."
+       *
+       * Allowing -1 for the location parameter of glUniform allows
+       * applications to avoid error paths in the case that, for example, some
+       * uniform variable is removed by the compiler / linker after
+       * optimization.  In this case, the new value of the uniform is dropped
+       * on the floor.  For the case of glGetUniform, there is nothing
+       * sensible to do for a location of -1.
+       *
+       * If the location was -1, validate_unfirom_parameters will return NULL
+       * without raising an error.  Raise the error here.
+       */
+      if (location == -1) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniform(location=%d)",
+                     location);
+      }
+
       return;
+   }
 
    {
       unsigned elements = (uni->type->is_sampler())
@@ -342,8 +358,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
        */
       if (returnType == uni->type->base_type
 	  || ((returnType == GLSL_TYPE_INT
-	       || returnType == GLSL_TYPE_UINT
-	       || returnType == GLSL_TYPE_SAMPLER)
+	       || returnType == GLSL_TYPE_UINT)
 	      &&
 	      (uni->type->base_type == GLSL_TYPE_INT
 	       || uni->type->base_type == GLSL_TYPE_UINT
@@ -583,93 +598,22 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
 extern "C" void
 _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
 	      GLint location, GLsizei count,
-              const GLvoid *values, GLenum type)
+              const GLvoid *values,
+              enum glsl_base_type basicType,
+              unsigned src_components)
 {
    unsigned offset;
-   unsigned components;
-   unsigned src_components;
-   enum glsl_base_type basicType;
 
    struct gl_uniform_storage *const uni =
       validate_uniform_parameters(ctx, shProg, location, count,
-                                  &offset, "glUniform", false);
+                                  &offset, "glUniform");
    if (uni == NULL)
       return;
 
    /* Verify that the types are compatible.
     */
-   switch (type) {
-   case GL_FLOAT:
-      basicType = GLSL_TYPE_FLOAT;
-      src_components = 1;
-      break;
-   case GL_FLOAT_VEC2:
-      basicType = GLSL_TYPE_FLOAT;
-      src_components = 2;
-      break;
-   case GL_FLOAT_VEC3:
-      basicType = GLSL_TYPE_FLOAT;
-      src_components = 3;
-      break;
-   case GL_FLOAT_VEC4:
-      basicType = GLSL_TYPE_FLOAT;
-      src_components = 4;
-      break;
-   case GL_UNSIGNED_INT:
-      basicType = GLSL_TYPE_UINT;
-      src_components = 1;
-      break;
-   case GL_UNSIGNED_INT_VEC2:
-      basicType = GLSL_TYPE_UINT;
-      src_components = 2;
-      break;
-   case GL_UNSIGNED_INT_VEC3:
-      basicType = GLSL_TYPE_UINT;
-      src_components = 3;
-      break;
-   case GL_UNSIGNED_INT_VEC4:
-      basicType = GLSL_TYPE_UINT;
-      src_components = 4;
-      break;
-   case GL_INT:
-      basicType = GLSL_TYPE_INT;
-      src_components = 1;
-      break;
-   case GL_INT_VEC2:
-      basicType = GLSL_TYPE_INT;
-      src_components = 2;
-      break;
-   case GL_INT_VEC3:
-      basicType = GLSL_TYPE_INT;
-      src_components = 3;
-      break;
-   case GL_INT_VEC4:
-      basicType = GLSL_TYPE_INT;
-      src_components = 4;
-      break;
-   case GL_BOOL:
-   case GL_BOOL_VEC2:
-   case GL_BOOL_VEC3:
-   case GL_BOOL_VEC4:
-   case GL_FLOAT_MAT2:
-   case GL_FLOAT_MAT2x3:
-   case GL_FLOAT_MAT2x4:
-   case GL_FLOAT_MAT3x2:
-   case GL_FLOAT_MAT3:
-   case GL_FLOAT_MAT3x4:
-   case GL_FLOAT_MAT4x2:
-   case GL_FLOAT_MAT4x3:
-   case GL_FLOAT_MAT4:
-   default:
-      _mesa_problem(NULL, "Invalid type in %s", __func__);
-      return;
-   }
-
-   if (uni->type->is_sampler()) {
-      components = 1;
-   } else {
-      components = uni->type->vector_elements;
-   }
+   const unsigned components = uni->type->is_sampler()
+      ? 1 : uni->type->vector_elements;
 
    bool match;
    switch (uni->type->base_type) {
@@ -690,7 +634,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
       return;
    }
 
-   if (ctx->_Shader->Flags & GLSL_UNIFORMS) {
+   if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
       log_uniform(values, basicType, components, 1, count,
 		  false, shProg, location, uni);
    }
@@ -713,9 +657,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
     * GL_INVALID_VALUE error and ignore the command.
     */
    if (uni->type->is_sampler()) {
-      int i;
-
-      for (i = 0; i < count; i++) {
+      for (int i = 0; i < count; i++) {
 	 const unsigned texUnit = ((unsigned *) values)[i];
 
          /* check that the sampler (tex unit index) is legal */
@@ -730,9 +672,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
    }
 
    if (uni->type->is_image()) {
-      int i;
-
-      for (i = 0; i < count; i++) {
+      for (int i = 0; i < count; i++) {
          const int unit = ((GLint *) values)[i];
 
          /* check that the image unit is legal */
@@ -772,9 +712,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
 	 (const union gl_constant_value *) values;
       union gl_constant_value *dst = &uni->storage[components * offset];
       const unsigned elems = components * count;
-      unsigned i;
 
-      for (i = 0; i < elems; i++) {
+      for (unsigned i = 0; i < elems; i++) {
 	 if (basicType == GLSL_TYPE_FLOAT) {
             dst[i].i = src[i].f != 0.0f ? ctx->Const.UniformBooleanTrue : 0;
 	 } else {
@@ -791,19 +730,16 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
     * the changes through.
     */
    if (uni->type->is_sampler()) {
-      int i;
-
       bool flushed = false;
-      for (i = 0; i < MESA_SHADER_STAGES; i++) {
+      for (int i = 0; i < MESA_SHADER_STAGES; i++) {
 	 struct gl_shader *const sh = shProg->_LinkedShaders[i];
-         int j;
 
 	 /* If the shader stage doesn't use the sampler uniform, skip this.
 	  */
 	 if (sh == NULL || !uni->sampler[i].active)
 	    continue;
 
-         for (j = 0; j < count; j++) {
+         for (int j = 0; j < count; j++) {
             sh->SamplerUnits[uni->sampler[i].index + offset + j] =
                ((unsigned *) values)[j];
          }
@@ -845,13 +781,11 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
     * uniforms to image units present in the shader data structure.
     */
    if (uni->type->is_image()) {
-      int i, j;
-
-      for (i = 0; i < MESA_SHADER_STAGES; i++) {
+      for (int i = 0; i < MESA_SHADER_STAGES; i++) {
 	 if (uni->image[i].active) {
             struct gl_shader *sh = shProg->_LinkedShaders[i];
 
-            for (j = 0; j < count; j++)
+            for (int j = 0; j < count; j++)
                sh->ImageUnits[uni->image[i].index + offset + j] =
                   ((GLint *) values)[j];
          }
@@ -878,7 +812,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
 
    struct gl_uniform_storage *const uni =
       validate_uniform_parameters(ctx, shProg, location, count,
-                                  &offset, "glUniformMatrix", false);
+                                  &offset, "glUniformMatrix");
    if (uni == NULL)
       return;
 
@@ -902,17 +836,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
    }
 
    /* GL_INVALID_VALUE is generated if `transpose' is not GL_FALSE.
-    * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml */
-   if (ctx->API == API_OPENGLES
-       || (ctx->API == API_OPENGLES2 && ctx->Version < 30)) {
-      if (transpose) {
+    * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml
+    */
+   if (transpose) {
+      if (ctx->API == API_OPENGLES2 && ctx->Version < 30) {
 	 _mesa_error(ctx, GL_INVALID_VALUE,
 		     "glUniformMatrix(matrix transpose is not GL_FALSE)");
 	 return;
       }
    }
 
-   if (ctx->_Shader->Flags & GLSL_UNIFORMS) {
+   if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
       log_uniform(values, GLSL_TYPE_FLOAT, components, vectors, count,
 		  bool(transpose), shProg, location, uni);
    }
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index c307107..d2d70e7f 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -151,7 +151,7 @@ void GLAPIENTRY
 _mesa_Uniform1f(GLint location, GLfloat v0)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_FLOAT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_FLOAT, 1);
 }
 
 void GLAPIENTRY
@@ -161,7 +161,7 @@ _mesa_Uniform2f(GLint location, GLfloat v0, GLfloat v1)
    GLfloat v[2];
    v[0] = v0;
    v[1] = v1;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 2);
 }
 
 void GLAPIENTRY
@@ -172,7 +172,7 @@ _mesa_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
    v[0] = v0;
    v[1] = v1;
    v[2] = v2;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 3);
 }
 
 void GLAPIENTRY
@@ -185,14 +185,14 @@ _mesa_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
    v[1] = v1;
    v[2] = v2;
    v[3] = v3;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_FLOAT, 4);
 }
 
 void GLAPIENTRY
 _mesa_Uniform1i(GLint location, GLint v0)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_INT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_INT, 1);
 }
 
 void GLAPIENTRY
@@ -202,7 +202,7 @@ _mesa_Uniform2i(GLint location, GLint v0, GLint v1)
    GLint v[2];
    v[0] = v0;
    v[1] = v1;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 2);
 }
 
 void GLAPIENTRY
@@ -213,7 +213,7 @@ _mesa_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2)
    v[0] = v0;
    v[1] = v1;
    v[2] = v2;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 3);
 }
 
 void GLAPIENTRY
@@ -225,63 +225,63 @@ _mesa_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
    v[1] = v1;
    v[2] = v2;
    v[3] = v3;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_INT, 4);
 }
 
 void GLAPIENTRY
 _mesa_Uniform1fv(GLint location, GLsizei count, const GLfloat * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 1);
 }
 
 void GLAPIENTRY
 _mesa_Uniform2fv(GLint location, GLsizei count, const GLfloat * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 2);
 }
 
 void GLAPIENTRY
 _mesa_Uniform3fv(GLint location, GLsizei count, const GLfloat * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 3);
 }
 
 void GLAPIENTRY
 _mesa_Uniform4fv(GLint location, GLsizei count, const GLfloat * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_FLOAT, 4);
 }
 
 void GLAPIENTRY
 _mesa_Uniform1iv(GLint location, GLsizei count, const GLint * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 1);
 }
 
 void GLAPIENTRY
 _mesa_Uniform2iv(GLint location, GLsizei count, const GLint * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 2);
 }
 
 void GLAPIENTRY
 _mesa_Uniform3iv(GLint location, GLsizei count, const GLint * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 3);
 }
 
 void GLAPIENTRY
 _mesa_Uniform4iv(GLint location, GLsizei count, const GLint * value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_INT, 4);
 }
 
 /** Same as above with direct state access **/
@@ -292,7 +292,7 @@ _mesa_ProgramUniform1f(GLuint program, GLint location, GLfloat v0)
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1f");
-   _mesa_uniform(ctx, shProg, location, 1, &v0, GL_FLOAT);
+   _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_FLOAT, 1);
 }
 
 void GLAPIENTRY
@@ -304,7 +304,7 @@ _mesa_ProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1)
    v[0] = v0;
    v[1] = v1;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2f");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC2);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 2);
 }
 
 void GLAPIENTRY
@@ -318,7 +318,7 @@ _mesa_ProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
    v[1] = v1;
    v[2] = v2;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3f");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC3);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 3);
 }
 
 void GLAPIENTRY
@@ -333,7 +333,7 @@ _mesa_ProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
    v[2] = v2;
    v[3] = v3;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4f");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_FLOAT_VEC4);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_FLOAT, 4);
 }
 
 void GLAPIENTRY
@@ -343,7 +343,7 @@ _mesa_ProgramUniform1i(GLuint program, GLint location, GLint v0)
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1i");
-   _mesa_uniform(ctx, shProg, location, 1, &v0, GL_INT);
+   _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_INT, 1);
 }
 
 void GLAPIENTRY
@@ -355,7 +355,7 @@ _mesa_ProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1)
    v[0] = v0;
    v[1] = v1;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2i");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC2);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 2);
 }
 
 void GLAPIENTRY
@@ -369,7 +369,7 @@ _mesa_ProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1,
    v[1] = v1;
    v[2] = v2;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3i");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC3);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 3);
 }
 
 void GLAPIENTRY
@@ -384,7 +384,7 @@ _mesa_ProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1,
    v[2] = v2;
    v[3] = v3;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4i");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_INT_VEC4);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_INT, 4);
 }
 
 void GLAPIENTRY
@@ -395,7 +395,7 @@ _mesa_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1fv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 1);
 }
 
 void GLAPIENTRY
@@ -406,7 +406,7 @@ _mesa_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform2fv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC2);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 2);
 }
 
 void GLAPIENTRY
@@ -417,7 +417,7 @@ _mesa_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform3fv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC3);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 3);
 }
 
 void GLAPIENTRY
@@ -428,7 +428,7 @@ _mesa_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform4fv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_FLOAT_VEC4);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_FLOAT, 4);
 }
 
 void GLAPIENTRY
@@ -439,7 +439,7 @@ _mesa_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1iv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_INT);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 1);
 }
 
 void GLAPIENTRY
@@ -450,7 +450,7 @@ _mesa_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform2iv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC2);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 2);
 }
 
 void GLAPIENTRY
@@ -461,7 +461,7 @@ _mesa_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform3iv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC3);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 3);
 }
 
 void GLAPIENTRY
@@ -472,7 +472,7 @@ _mesa_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform4iv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_INT_VEC4);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_INT, 4);
 }
 
 
@@ -481,7 +481,7 @@ void GLAPIENTRY
 _mesa_Uniform1ui(GLint location, GLuint v0)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GLSL_TYPE_UINT, 1);
 }
 
 void GLAPIENTRY
@@ -491,7 +491,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1)
    GLuint v[2];
    v[0] = v0;
    v[1] = v1;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 2);
 }
 
 void GLAPIENTRY
@@ -502,7 +502,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
    v[0] = v0;
    v[1] = v1;
    v[2] = v2;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 3);
 }
 
 void GLAPIENTRY
@@ -514,35 +514,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
    v[1] = v1;
    v[2] = v2;
    v[3] = v3;
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GLSL_TYPE_UINT, 4);
 }
 
 void GLAPIENTRY
 _mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 1);
 }
 
 void GLAPIENTRY
 _mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 2);
 }
 
 void GLAPIENTRY
 _mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 3);
 }
 
 void GLAPIENTRY
 _mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
-   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4);
+   _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GLSL_TYPE_UINT, 4);
 }
 
 
@@ -583,7 +583,7 @@ _mesa_ProgramUniform1ui(GLuint program, GLint location, GLuint v0)
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1ui");
-   _mesa_uniform(ctx, shProg, location, 1, &v0, GL_UNSIGNED_INT);
+   _mesa_uniform(ctx, shProg, location, 1, &v0, GLSL_TYPE_UINT, 1);
 }
 
 void GLAPIENTRY
@@ -596,7 +596,7 @@ _mesa_ProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1)
    v[1] = v1;
    shProg = _mesa_lookup_shader_program_err(ctx, program,
                                             "glProgramUniform2ui");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC2);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 2);
 }
 
 void GLAPIENTRY
@@ -611,7 +611,7 @@ _mesa_ProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1,
    v[2] = v2;
    shProg = _mesa_lookup_shader_program_err(ctx, program,
                                             "glProgramUniform3ui");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC3);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 3);
 }
 
 void GLAPIENTRY
@@ -626,7 +626,7 @@ _mesa_ProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1,
    v[2] = v2;
    v[3] = v3;
    shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4ui");
-   _mesa_uniform(ctx, shProg, location, 1, v, GL_UNSIGNED_INT_VEC4);
+   _mesa_uniform(ctx, shProg, location, 1, v, GLSL_TYPE_UINT, 4);
 }
 
 void GLAPIENTRY
@@ -637,7 +637,7 @@ _mesa_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform1uiv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 1);
 }
 
 void GLAPIENTRY
@@ -648,7 +648,7 @@ _mesa_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform2uiv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC2);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 2);
 }
 
 void GLAPIENTRY
@@ -659,7 +659,7 @@ _mesa_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform3uiv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC3);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 3);
 }
 
 void GLAPIENTRY
@@ -670,7 +670,7 @@ _mesa_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
    struct gl_shader_program *shProg =
       _mesa_lookup_shader_program_err(ctx, program,
             "glProgramUniform4uiv");
-   _mesa_uniform(ctx, shProg, location, count, value, GL_UNSIGNED_INT_VEC4);
+   _mesa_uniform(ctx, shProg, location, count, value, GLSL_TYPE_UINT, 4);
 }
 
 
@@ -1208,7 +1208,7 @@ _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
    struct gl_shader_program *shProg;
 
    if (!ctx->Extensions.ARB_uniform_buffer_object) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformName");
       return;
    }
 
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 6575a52..0a9ee7d 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -265,7 +265,9 @@ _mesa_get_uniform_location(struct gl_shader_program *shProg,
 void
 _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program,
 	      GLint location, GLsizei count,
-              const GLvoid *values, GLenum type);
+              const GLvoid *values,
+              enum glsl_base_type basicType,
+              unsigned src_components);
 
 void
 _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c
index d6a9e29..0adce9c 100644
--- a/mesalib/src/mesa/main/viewport.c
+++ b/mesalib/src/mesa/main/viewport.c
@@ -459,15 +459,14 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
        ctx->Transform.ClipDepthMode == depth)
       return;
 
-   FLUSH_VERTICES(ctx, 0);
+   /* Affects transform state and the viewport transform */
+   FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_VIEWPORT);
 
    if (ctx->Transform.ClipOrigin != origin) {
       ctx->Transform.ClipOrigin = origin;
 
       /* Affects the winding order of the front face. */
       ctx->NewState |= _NEW_POLYGON;
-      /* Affects the y component of the viewport transform. */
-      ctx->NewState |= _NEW_VIEWPORT;
 
       if (ctx->Driver.FrontFace)
          ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
@@ -476,9 +475,6 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
    if (ctx->Transform.ClipDepthMode != depth) {
       ctx->Transform.ClipDepthMode = depth;
 
-      /* Affects the z part of the viewpoint transform. */
-      ctx->NewState |= _NEW_VIEWPORT;
-
       if (ctx->Driver.DepthRange)
          ctx->Driver.DepthRange(ctx);
    }
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index fcc9ed5..650c40f 100644
--- a/mesalib/src/mesa/program/prog_execute.c
+++ b/mesalib/src/mesa/program/prog_execute.c
@@ -1119,77 +1119,6 @@ _mesa_execute_program(struct gl_context * ctx,
          break;
       case OPCODE_NOP:
          break;
-      case OPCODE_PK2H:        /* pack two 16-bit floats in one 32-bit float */
-         {
-            GLfloat a[4];
-            GLuint result[4];
-            GLhalfNV hx, hy;
-            fetch_vector4(&inst->SrcReg[0], machine, a);
-            hx = _mesa_float_to_half(a[0]);
-            hy = _mesa_float_to_half(a[1]);
-            result[0] =
-            result[1] =
-            result[2] =
-            result[3] = hx | (hy << 16);
-            store_vector4ui(inst, machine, result);
-         }
-         break;
-      case OPCODE_PK2US:       /* pack two GLushorts into one 32-bit float */
-         {
-            GLfloat a[4];
-            GLuint result[4], usx, usy;
-            fetch_vector4(&inst->SrcReg[0], machine, a);
-            a[0] = CLAMP(a[0], 0.0F, 1.0F);
-            a[1] = CLAMP(a[1], 0.0F, 1.0F);
-            usx = F_TO_I(a[0] * 65535.0F);
-            usy = F_TO_I(a[1] * 65535.0F);
-            result[0] =
-            result[1] =
-            result[2] =
-            result[3] = usx | (usy << 16);
-            store_vector4ui(inst, machine, result);
-         }
-         break;
-      case OPCODE_PK4B:        /* pack four GLbytes into one 32-bit float */
-         {
-            GLfloat a[4];
-            GLuint result[4], ubx, uby, ubz, ubw;
-            fetch_vector4(&inst->SrcReg[0], machine, a);
-            a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F);
-            a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F);
-            a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F);
-            a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F);
-            ubx = F_TO_I(127.0F * a[0] + 128.0F);
-            uby = F_TO_I(127.0F * a[1] + 128.0F);
-            ubz = F_TO_I(127.0F * a[2] + 128.0F);
-            ubw = F_TO_I(127.0F * a[3] + 128.0F);
-            result[0] =
-            result[1] =
-            result[2] =
-            result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
-            store_vector4ui(inst, machine, result);
-         }
-         break;
-      case OPCODE_PK4UB:       /* pack four GLubytes into one 32-bit float */
-         {
-            GLfloat a[4];
-            GLuint result[4], ubx, uby, ubz, ubw;
-            fetch_vector4(&inst->SrcReg[0], machine, a);
-            a[0] = CLAMP(a[0], 0.0F, 1.0F);
-            a[1] = CLAMP(a[1], 0.0F, 1.0F);
-            a[2] = CLAMP(a[2], 0.0F, 1.0F);
-            a[3] = CLAMP(a[3], 0.0F, 1.0F);
-            ubx = F_TO_I(255.0F * a[0]);
-            uby = F_TO_I(255.0F * a[1]);
-            ubz = F_TO_I(255.0F * a[2]);
-            ubw = F_TO_I(255.0F * a[3]);
-            result[0] =
-            result[1] =
-            result[2] =
-            result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
-            store_vector4ui(inst, machine, result);
-         }
-         break;
       case OPCODE_POW:
          {
             GLfloat a[4], b[4], result[4];
@@ -1224,20 +1153,6 @@ _mesa_execute_program(struct gl_context * ctx,
             pc = machine->CallStack[--machine->StackDepth] - 1;
          }
          break;
-      case OPCODE_RFL:         /* reflection vector */
-         {
-            GLfloat axis[4], dir[4], result[4], tmpX, tmpW;
-            fetch_vector4(&inst->SrcReg[0], machine, axis);
-            fetch_vector4(&inst->SrcReg[1], machine, dir);
-            tmpW = DOT3(axis, axis);
-            tmpX = (2.0F * DOT3(axis, dir)) / tmpW;
-            result[0] = tmpX * axis[0] - dir[0];
-            result[1] = tmpX * axis[1] - dir[1];
-            result[2] = tmpX * axis[2] - dir[2];
-            /* result[3] is never written! XXX enforce in parser! */
-            store_vector4(inst, machine, result);
-         }
-         break;
       case OPCODE_RSQ:         /* 1 / sqrt() */
          {
             GLfloat a[4], result[4];
@@ -1279,12 +1194,6 @@ _mesa_execute_program(struct gl_context * ctx,
             }
          }
          break;
-      case OPCODE_SFL:         /* set false, operands ignored */
-         {
-            static const GLfloat result[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
-            store_vector4(inst, machine, result);
-         }
-         break;
       case OPCODE_SGE:         /* set on greater or equal */
          {
             GLfloat a[4], b[4], result[4];
@@ -1395,12 +1304,6 @@ _mesa_execute_program(struct gl_context * ctx,
             store_vector4(inst, machine, result);
          }
          break;
-      case OPCODE_STR:         /* set true, operands ignored */
-         {
-            static const GLfloat result[4] = { 1.0F, 1.0F, 1.0F, 1.0F };
-            store_vector4(inst, machine, result);
-         }
-         break;
       case OPCODE_SUB:
          {
             GLfloat a[4], b[4], result[4];
@@ -1574,52 +1477,6 @@ _mesa_execute_program(struct gl_context * ctx,
             store_vector4(inst, machine, result);
          }
          break;
-      case OPCODE_UP2H:        /* unpack two 16-bit floats */
-         {
-            const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
-            GLfloat result[4];
-            GLushort hx, hy;
-            hx = raw & 0xffff;
-            hy = raw >> 16;
-            result[0] = result[2] = _mesa_half_to_float(hx);
-            result[1] = result[3] = _mesa_half_to_float(hy);
-            store_vector4(inst, machine, result);
-         }
-         break;
-      case OPCODE_UP2US:       /* unpack two GLushorts */
-         {
-            const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
-            GLfloat result[4];
-            GLushort usx, usy;
-            usx = raw & 0xffff;
-            usy = raw >> 16;
-            result[0] = result[2] = usx * (1.0f / 65535.0f);
-            result[1] = result[3] = usy * (1.0f / 65535.0f);
-            store_vector4(inst, machine, result);
-         }
-         break;
-      case OPCODE_UP4B:        /* unpack four GLbytes */
-         {
-            const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
-            GLfloat result[4];
-            result[0] = (((raw >> 0) & 0xff) - 128) / 127.0F;
-            result[1] = (((raw >> 8) & 0xff) - 128) / 127.0F;
-            result[2] = (((raw >> 16) & 0xff) - 128) / 127.0F;
-            result[3] = (((raw >> 24) & 0xff) - 128) / 127.0F;
-            store_vector4(inst, machine, result);
-         }
-         break;
-      case OPCODE_UP4UB:       /* unpack four GLubytes */
-         {
-            const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine);
-            GLfloat result[4];
-            result[0] = ((raw >> 0) & 0xff) / 255.0F;
-            result[1] = ((raw >> 8) & 0xff) / 255.0F;
-            result[2] = ((raw >> 16) & 0xff) / 255.0F;
-            result[3] = ((raw >> 24) & 0xff) / 255.0F;
-            store_vector4(inst, machine, result);
-         }
-         break;
       case OPCODE_XPD:         /* cross product */
          {
             GLfloat a[4], b[4], result[4];
@@ -1637,19 +1494,6 @@ _mesa_execute_program(struct gl_context * ctx,
             }
          }
          break;
-      case OPCODE_X2D:         /* 2-D matrix transform */
-         {
-            GLfloat a[4], b[4], c[4], result[4];
-            fetch_vector4(&inst->SrcReg[0], machine, a);
-            fetch_vector4(&inst->SrcReg[1], machine, b);
-            fetch_vector4(&inst->SrcReg[2], machine, c);
-            result[0] = a[0] + b[0] * c[0] + b[1] * c[1];
-            result[1] = a[1] + b[0] * c[2] + b[1] * c[3];
-            result[2] = a[2] + b[0] * c[0] + b[1] * c[1];
-            result[3] = a[3] + b[0] * c[2] + b[1] * c[3];
-            store_vector4(inst, machine, result);
-         }
-         break;
       case OPCODE_END:
          return GL_TRUE;
       default:
diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index e2eadc3..976024e 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -191,18 +191,12 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
    { OPCODE_NOISE2, "NOISE2",  1, 1 },
    { OPCODE_NOISE3, "NOISE3",  1, 1 },
    { OPCODE_NOISE4, "NOISE4",  1, 1 },
-   { OPCODE_PK2H,   "PK2H",    1, 1 },
-   { OPCODE_PK2US,  "PK2US",   1, 1 },
-   { OPCODE_PK4B,   "PK4B",    1, 1 },
-   { OPCODE_PK4UB,  "PK4UB",   1, 1 },
    { OPCODE_POW,    "POW",     2, 1 },
    { OPCODE_RCP,    "RCP",     1, 1 },
    { OPCODE_RET,    "RET",     0, 0 },
-   { OPCODE_RFL,    "RFL",     1, 1 },
    { OPCODE_RSQ,    "RSQ",     1, 1 },
    { OPCODE_SCS,    "SCS",     1, 1 },
    { OPCODE_SEQ,    "SEQ",     2, 1 },
-   { OPCODE_SFL,    "SFL",     0, 1 },
    { OPCODE_SGE,    "SGE",     2, 1 },
    { OPCODE_SGT,    "SGT",     2, 1 },
    { OPCODE_SIN,    "SIN",     1, 1 },
@@ -210,7 +204,6 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
    { OPCODE_SLT,    "SLT",     2, 1 },
    { OPCODE_SNE,    "SNE",     2, 1 },
    { OPCODE_SSG,    "SSG",     1, 1 },
-   { OPCODE_STR,    "STR",     0, 1 },
    { OPCODE_SUB,    "SUB",     2, 1 },
    { OPCODE_SWZ,    "SWZ",     1, 1 },
    { OPCODE_TEX,    "TEX",     1, 1 },
@@ -220,11 +213,6 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
    { OPCODE_TXP,    "TXP",     1, 1 },
    { OPCODE_TXP_NV, "TXP_NV",  1, 1 },
    { OPCODE_TRUNC,  "TRUNC",   1, 1 },
-   { OPCODE_UP2H,   "UP2H",    1, 1 },
-   { OPCODE_UP2US,  "UP2US",   1, 1 },
-   { OPCODE_UP4B,   "UP4B",    1, 1 },
-   { OPCODE_UP4UB,  "UP4UB",   1, 1 },
-   { OPCODE_X2D,    "X2D",     3, 1 },
    { OPCODE_XPD,    "XPD",     2, 1 }
 };
 
diff --git a/mesalib/src/mesa/program/prog_instruction.h b/mesalib/src/mesa/program/prog_instruction.h
index b9604e5..de78804 100644
--- a/mesalib/src/mesa/program/prog_instruction.h
+++ b/mesalib/src/mesa/program/prog_instruction.h
@@ -187,18 +187,12 @@ typedef enum prog_opcode {
    OPCODE_NOISE2,    /*                                      X   */
    OPCODE_NOISE3,    /*                                      X   */
    OPCODE_NOISE4,    /*                                      X   */
-   OPCODE_PK2H,      /*                            X             */
-   OPCODE_PK2US,     /*                            X             */
-   OPCODE_PK4B,      /*                            X             */
-   OPCODE_PK4UB,     /*                            X             */
    OPCODE_POW,       /*   X        X               X         X   */
    OPCODE_RCP,       /*   X        X       X       X         X   */
    OPCODE_RET,       /*                    2       2        opt  */
-   OPCODE_RFL,       /*                            X             */
    OPCODE_RSQ,       /*   X        X       X       X         X   */
    OPCODE_SCS,       /*            X                         X   */
    OPCODE_SEQ,       /*                    2       X         X   */
-   OPCODE_SFL,       /*                    2       X             */
    OPCODE_SGE,       /*   X        X       X       X         X   */
    OPCODE_SGT,       /*                    2       X         X   */
    OPCODE_SIN,       /*            X       2       X         X   */
@@ -206,7 +200,6 @@ typedef enum prog_opcode {
    OPCODE_SLT,       /*   X        X       X       X         X   */
    OPCODE_SNE,       /*                    2       X         X   */
    OPCODE_SSG,       /*                    2                 X   */
-   OPCODE_STR,       /*                    2       X             */
    OPCODE_SUB,       /*   X        X       1.1     X         X   */
    OPCODE_SWZ,       /*   X        X                         X   */
    OPCODE_TEX,       /*            X       3       X         X   */
@@ -216,11 +209,6 @@ typedef enum prog_opcode {
    OPCODE_TXP,       /*            X                         X   */
    OPCODE_TXP_NV,    /*                    3       X             */
    OPCODE_TRUNC,     /*                                      X   */
-   OPCODE_UP2H,      /*                            X             */
-   OPCODE_UP2US,     /*                            X             */
-   OPCODE_UP4B,      /*                            X             */
-   OPCODE_UP4UB,     /*                            X             */
-   OPCODE_X2D,       /*                            X             */
    OPCODE_XPD,       /*   X        X                             */
    MAX_OPCODE
 } gl_inst_opcode;
diff --git a/mesalib/src/mesa/program/program_lexer.l b/mesalib/src/mesa/program/program_lexer.l
index d5dbcf3..2fcd71f 100644
--- a/mesalib/src/mesa/program/program_lexer.l
+++ b/mesalib/src/mesa/program/program_lexer.l
@@ -28,6 +28,7 @@
 #include "program/symbol_table.h"
 #include "program/program_parser.h"
 #include "program/program_parse.tab.h"
+#include "util/strtod.h"
 
 #define require_ARB_vp (yyextra->mode == ARB_vertex)
 #define require_ARB_fp (yyextra->mode == ARB_fragment)
@@ -216,26 +217,19 @@ MIN{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MIN, 3); }
 MOV{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, MOV, 3); }
 MUL{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MUL, 3); }
 
-PK2H               { return_opcode(require_NV_fp,  VECTOR_OP, PK2H, 4); }
-PK2US              { return_opcode(require_NV_fp,  VECTOR_OP, PK2US, 5); }
-PK4B               { return_opcode(require_NV_fp,  VECTOR_OP, PK4B, 4); }
-PK4UB              { return_opcode(require_NV_fp,  VECTOR_OP, PK4UB, 5); }
 POW{szf}{cc}{sat}  { return_opcode(             1, BINSC_OP, POW, 3); }
 
 RCP{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RCP, 3); }
-RFL{szf}{cc}{sat}  { return_opcode(require_NV_fp,  BIN_OP,    RFL, 3); }
 RSQ{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RSQ, 3); }
 
 SCS{sat}           { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); }
 SEQ{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SEQ, 3); }
-SFL{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SFL, 3); }
 SGE{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SGE, 3); }
 SGT{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SGT, 3); }
 SIN{szf}{cc}{sat}  { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); }
 SLE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SLE, 3); }
 SLT{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SLT, 3); }
 SNE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SNE, 3); }
-STR{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, STR, 3); }
 SUB{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SUB, 3); }
 SWZ{sat}           { return_opcode(             1, SWZ, SWZ, 3); }
 
@@ -244,12 +238,6 @@ TXB{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); }
 TXD{cc}{sat}       { return_opcode(require_NV_fp,  TXD_OP, TXD, 3); }
 TXP{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); }
 
-UP2H{cc}{sat}      { return_opcode(require_NV_fp,  SCALAR_OP, UP2H, 4); }
-UP2US{cc}{sat}     { return_opcode(require_NV_fp,  SCALAR_OP, UP2US, 5); }
-UP4B{cc}{sat}      { return_opcode(require_NV_fp,  SCALAR_OP, UP4B, 4); }
-UP4UB{cc}{sat}     { return_opcode(require_NV_fp,  SCALAR_OP, UP4UB, 5); }
-
-X2D{szf}{cc}{sat}  { return_opcode(require_NV_fp,  TRI_OP, X2D, 3); }
 XPD{sat}           { return_opcode(             1, BIN_OP, XPD, 3); }
 
 vertex                    { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); }
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index 5020978..606f19a 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -72,7 +72,7 @@ static void update_raster_state( struct st_context *st )
    {
       raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW);
 
-      /* _NEW_VIEWPORT */
+      /* _NEW_TRANSFORM */
       if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT) {
          raster->front_ccw ^= 1;
       }
@@ -246,13 +246,10 @@ static void update_raster_state( struct st_context *st )
    raster->half_pixel_center = 1;
    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
       raster->bottom_edge_rule = 1;
-   /* _NEW_VIEWPORT */
+   /* _NEW_TRANSFORM */
    if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT)
       raster->bottom_edge_rule ^= 1;
 
-   /* _NEW_VIEWPORT */
-   raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
-
    /* ST_NEW_RASTERIZER */
    raster->rasterizer_discard = ctx->RasterDiscard;
 
@@ -267,6 +264,7 @@ static void update_raster_state( struct st_context *st )
    /* _NEW_TRANSFORM */
    raster->depth_clip = !ctx->Transform.DepthClamp;
    raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
+   raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
 
    cso_set_rasterizer(st->cso_context, raster);
 }
@@ -283,8 +281,7 @@ const struct st_tracked_state st_update_rasterizer = {
        _NEW_PROGRAM |
        _NEW_SCISSOR |
        _NEW_FRAG_CLAMP |
-       _NEW_TRANSFORM |
-       _NEW_VIEWPORT),      /* mesa state dependencies*/
+       _NEW_TRANSFORM),     /* mesa state dependencies*/
       (ST_NEW_VERTEX_PROGRAM |
        ST_NEW_RASTERIZER),  /* state tracker dependencies */
    },
diff --git a/mesalib/src/mesa/state_tracker/st_atom_viewport.c b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
index 5b99208..efa056e 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_viewport.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
@@ -70,12 +70,10 @@ update_viewport( struct st_context *st )
       st->state.viewport[i].scale[0] = scale[0];
       st->state.viewport[i].scale[1] = scale[1] * yScale;
       st->state.viewport[i].scale[2] = scale[2];
-      st->state.viewport[i].scale[3] = 1.0;
 
       st->state.viewport[i].translate[0] = translate[0];
       st->state.viewport[i].translate[1] = translate[1] * yScale + yBias;
       st->state.viewport[i].translate[2] = translate[2];
-      st->state.viewport[i].translate[3] = 0.0;
    }
 
    cso_set_viewport(st->cso_context, &st->state.viewport[0]);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index e3ba5a8..2107ab1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -504,11 +504,9 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       vp.scale[0] =  0.5f * width;
       vp.scale[1] = height * (invert ? -0.5f : 0.5f);
       vp.scale[2] = 0.5f;
-      vp.scale[3] = 1.0f;
       vp.translate[0] = 0.5f * width;
       vp.translate[1] = 0.5f * height;
       vp.translate[2] = 0.5f;
-      vp.translate[3] = 0.0f;
       cso_set_viewport(cso, &vp);
    }
 
@@ -769,7 +767,8 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
       const uint semantic_indexes[] = { 0, 0, 0 };
       st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3,
                                                           semantic_names,
-                                                          semantic_indexes);
+                                                          semantic_indexes,
+                                                          FALSE);
    }
 
    if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap))
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 2c1414e..45dea59 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -88,6 +88,14 @@ st_destroy_clear(struct st_context *st)
       cso_delete_vertex_shader(st->cso_context, st->clear.vs);
       st->clear.vs = NULL;
    }
+   if (st->clear.vs_layered) {
+      cso_delete_vertex_shader(st->cso_context, st->clear.vs_layered);
+      st->clear.vs_layered = NULL;
+   }
+   if (st->clear.gs_layered) {
+      cso_delete_geometry_shader(st->cso_context, st->clear.gs_layered);
+      st->clear.gs_layered = NULL;
+   }
 }
 
 
@@ -123,10 +131,12 @@ set_vertex_shader(struct st_context *st)
       const uint semantic_indexes[] = { 0, 0 };
       st->clear.vs = util_make_vertex_passthrough_shader(st->pipe, 2,
                                                          semantic_names,
-                                                         semantic_indexes);
+                                                         semantic_indexes,
+                                                         FALSE);
    }
 
    cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
+   cso_set_geometry_shader_handle(st->cso_context, NULL);
 }
 
 
@@ -135,18 +145,25 @@ set_vertex_shader_layered(struct st_context *st)
 {
    struct pipe_context *pipe = st->pipe;
 
-   if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) ||
-       !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
-      assert(!"Got layered clear, but the VS layer output is unsupported");
+   if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID)) {
+      assert(!"Got layered clear, but VS instancing is unsupported");
       set_vertex_shader(st);
       return;
    }
 
    if (!st->clear.vs_layered) {
-      st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+      bool vs_layer =
+         pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT);
+      if (vs_layer) {
+         st->clear.vs_layered = util_make_layered_clear_vertex_shader(pipe);
+      } else {
+         st->clear.vs_layered = util_make_layered_clear_helper_vertex_shader(pipe);
+         st->clear.gs_layered = util_make_layered_clear_geometry_shader(pipe);
+      }
    }
 
    cso_set_vertex_shader_handle(st->cso_context, st->clear.vs_layered);
+   cso_set_geometry_shader_handle(st->cso_context, st->clear.gs_layered);
 }
 
 
@@ -323,16 +340,13 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
       vp.scale[0] = 0.5f * fb_width;
       vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
       vp.scale[2] = 0.5f;
-      vp.scale[3] = 1.0f;
       vp.translate[0] = 0.5f * fb_width;
       vp.translate[1] = 0.5f * fb_height;
       vp.translate[2] = 0.5f;
-      vp.translate[3] = 0.0f;
       cso_set_viewport(st->cso_context, &vp);
    }
 
    set_fragment_shader(st);
-   cso_set_geometry_shader_handle(st->cso_context, NULL);
 
    if (num_layers > 1)
       set_vertex_shader_layered(st);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 5ae092b..939fc20 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -776,11 +776,9 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
       vp.scale[0] =  0.5f * w;
       vp.scale[1] = -0.5f * h;
       vp.scale[2] = 0.5f;
-      vp.scale[3] = 1.0f;
       vp.translate[0] = 0.5f * w;
       vp.translate[1] = 0.5f * h;
       vp.translate[2] = 0.5f;
-      vp.translate[3] = 0.0f;
       cso_set_viewport(cso, &vp);
    }
 
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
index f997e6b..d057ff6 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
@@ -91,7 +91,7 @@ lookup_shader(struct pipe_context *pipe,
       util_make_vertex_passthrough_shader(pipe,
                                           num_attribs,
                                           semantic_names,
-                                          semantic_indexes);
+                                          semantic_indexes, FALSE);
    NumCachedShaders++;
 
    return CachedShaders[i].handle;
@@ -258,11 +258,9 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
       vp.scale[0] =  0.5f * width;
       vp.scale[1] = height * (invert ? -0.5f : 0.5f);
       vp.scale[2] = 1.0f;
-      vp.scale[3] = 1.0f;
       vp.translate[0] = 0.5f * width;
       vp.translate[1] = 0.5f * height;
       vp.translate[2] = 0.0f;
-      vp.translate[3] = 0.0f;
       cso_set_viewport(cso, &vp);
    }
 
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 58f14f9..15f9df4 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -181,6 +181,7 @@ struct st_context
       void *vs;
       void *fs;
       void *vs_layered;
+      void *gs_layered;
    } clear;
 
    /** used for anything using util_draw_vertex_buffer */
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index aff3dde..bdfab8b 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -241,8 +241,7 @@ void st_init_limits(struct pipe_screen *screen,
 
       if (options->EmitNoLoops)
          options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
-      else
-         options->MaxUnrollIterations = 255; /* SM3 limit */
+
       options->LowerClipDistance = true;
    }
 
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index a4e2c8d..8e91c4b 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4022,6 +4022,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
 
       newinst = v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
       newinst->tex_target = inst->tex_target;
+      newinst->sampler_array_size = inst->sampler_array_size;
    }
 
    /* Make modifications to fragment program info. */
@@ -4101,6 +4102,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
 
       newinst = v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
       newinst->tex_target = inst->tex_target;
+      newinst->sampler_array_size = inst->sampler_array_size;
    }
 
    /* Make modifications to fragment program info. */
@@ -4524,8 +4526,10 @@ compile_tgsi_instruction(struct st_translate *t,
                              inst->saturate,
                              clamp_dst_color_output);
 
-   for (i = 0; i < num_src; i++) 
+   for (i = 0; i < num_src; i++) {
+      assert(inst->src[i].file != PROGRAM_UNDEFINED);
       src[i] = translate_src(t, &inst->src[i]);
+   }
 
    switch(inst->op) {
    case TGSI_OPCODE_BGNLOOP:
@@ -4555,6 +4559,7 @@ compile_tgsi_instruction(struct st_translate *t,
    case TGSI_OPCODE_TG4:
    case TGSI_OPCODE_LODQ:
       src[num_src] = t->samplers[inst->sampler.index];
+      assert(src[num_src].File != TGSI_FILE_NULL);
       if (inst->sampler.reladdr)
          src[num_src] =
             ureg_src_indirect(src[num_src], ureg_src(t->address[2]));
@@ -4721,7 +4726,8 @@ emit_wpos(struct st_context *st,
       }
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {
          /* the driver supports lower-left origin, need to invert Y */
-         ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+                       TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
          invert = TRUE;
       }
       else
@@ -4731,7 +4737,8 @@ emit_wpos(struct st_context *st,
       /* Fragment shader wants origin in lower-left */
       if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))
          /* the driver supports lower-left origin */
-         ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+                       TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))
          /* the driver supports upper-left origin, need to invert Y */
          invert = TRUE;
@@ -4744,7 +4751,8 @@ emit_wpos(struct st_context *st,
       if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          /* the driver supports pixel center integer */
          adjY[1] = 1.0f;
-         ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+                       TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
       }
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {
          /* the driver supports pixel center half integer, need to bias X,Y */
@@ -4763,7 +4771,8 @@ emit_wpos(struct st_context *st,
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          /* the driver supports pixel center integer, need to bias X,Y */
          adjX = adjY[0] = adjY[1] = 0.5f;
-         ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+                       TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
       }
       else
          assert(0);
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index df6de73..606d678 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -452,7 +452,8 @@ st_framebuffer_create(struct st_context *st,
           st_pipe_format_to_mesa_format(srgb_format) != MESA_FORMAT_NONE &&
           screen->is_format_supported(screen, srgb_format,
                                       PIPE_TEXTURE_2D, stfbi->visual->samples,
-                                      PIPE_BIND_RENDER_TARGET))
+                                      (PIPE_BIND_DISPLAY_TARGET |
+                                       PIPE_BIND_RENDER_TARGET)))
          mode.sRGBCapable = GL_TRUE;
    }
 
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 26a5f51..2c9d9a5 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -891,7 +891,8 @@ emit_wpos(struct st_context *st,
       }
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) {
          /* the driver supports lower-left origin, need to invert Y */
-         ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+                       TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
          invert = TRUE;
       }
       else
@@ -901,7 +902,8 @@ emit_wpos(struct st_context *st,
       /* Fragment shader wants origin in lower-left */
       if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT))
          /* the driver supports lower-left origin */
-         ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
+                       TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT))
          /* the driver supports upper-left origin, need to invert Y */
          invert = TRUE;
@@ -914,7 +916,8 @@ emit_wpos(struct st_context *st,
       if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          /* the driver supports pixel center integer */
          adjY[1] = 1.0f;
-         ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+                       TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
       }
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) {
          /* the driver supports pixel center half integer, need to bias X,Y */
@@ -933,7 +936,8 @@ emit_wpos(struct st_context *st,
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          /* the driver supports pixel center integer, need to bias X,Y */
          adjX = adjY[0] = adjY[1] = 0.5f;
-         ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+         ureg_property(ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER,
+                       TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
       }
       else
          assert(0);
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 926086b..737c269 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -742,21 +742,25 @@ st_translate_fragment_program(struct st_context *st,
       debug_printf("\n");
    }
    if (write_all == GL_TRUE)
-      ureg_property_fs_color0_writes_all_cbufs(ureg, 1);
+      ureg_property(ureg, TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS, 1);
 
    if (stfp->Base.FragDepthLayout != FRAG_DEPTH_LAYOUT_NONE) {
       switch (stfp->Base.FragDepthLayout) {
       case FRAG_DEPTH_LAYOUT_ANY:
-         ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_ANY);
+         ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+                       TGSI_FS_DEPTH_LAYOUT_ANY);
          break;
       case FRAG_DEPTH_LAYOUT_GREATER:
-         ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_GREATER);
+         ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+                       TGSI_FS_DEPTH_LAYOUT_GREATER);
          break;
       case FRAG_DEPTH_LAYOUT_LESS:
-         ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_LESS);
+         ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+                       TGSI_FS_DEPTH_LAYOUT_LESS);
          break;
       case FRAG_DEPTH_LAYOUT_UNCHANGED:
-         ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
+         ureg_property(ureg, TGSI_PROPERTY_FS_DEPTH_LAYOUT,
+                       TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
          break;
       default:
          assert(0);
@@ -1122,10 +1126,11 @@ st_translate_geometry_program(struct st_context *st,
       stgp->tgsi.tokens = NULL;
    }
 
-   ureg_property_gs_input_prim(ureg, stgp->Base.InputType);
-   ureg_property_gs_output_prim(ureg, stgp->Base.OutputType);
-   ureg_property_gs_max_vertices(ureg, stgp->Base.VerticesOut);
-   ureg_property_gs_invocations(ureg, stgp->Base.Invocations);
+   ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);
+   ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);
+   ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,
+                 stgp->Base.VerticesOut);
+   ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);
 
    if (stgp->glsl_to_tgsi)
       st_translate_program(st->ctx,
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 045dbb5..e623b36 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -36,6 +36,8 @@
 #include "main/enums.h"
 #include "main/macros.h"
 #include "main/transformfeedback.h"
+#include "main/sse_minmax.h"
+#include "x86/common_x86_asm.h"
 
 #include "vbo_context.h"
 
@@ -119,10 +121,16 @@ vbo_get_minmax_index(struct gl_context *ctx,
          }
       }
       else {
-         for (i = 0; i < count; i++) {
-            if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
-            if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+#if defined(USE_SSE41)
+         if (cpu_has_sse4_1) {
+            _mesa_uint_array_min_max(ui_indices, &min_ui, &max_ui, count);
          }
+         else
+#endif
+            for (i = 0; i < count; i++) {
+               if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
+               if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+            }
       }
       *min_index = min_ui;
       *max_index = max_ui;
diff --git a/mesalib/src/mesa/x86/common_x86_features.h b/mesalib/src/mesa/x86/common_x86_features.h
index 66f2cf6..65634aa 100644
--- a/mesalib/src/mesa/x86/common_x86_features.h
+++ b/mesalib/src/mesa/x86/common_x86_features.h
@@ -59,13 +59,39 @@
 #define X86_CPUEXT_3DNOW_EXT	(1<<30)
 #define X86_CPUEXT_3DNOW	(1<<31)
 
+#ifdef __MMX__
+#define cpu_has_mmx		1
+#else
 #define cpu_has_mmx		(_mesa_x86_cpu_features & X86_FEATURE_MMX)
+#endif
+
 #define cpu_has_mmxext		(_mesa_x86_cpu_features & X86_FEATURE_MMXEXT)
+
+#ifdef __SSE__
+#define cpu_has_xmm		1
+#else
 #define cpu_has_xmm		(_mesa_x86_cpu_features & X86_FEATURE_XMM)
+#endif
+
+#ifdef __SSE2__
+#define cpu_has_xmm2		1
+#else
 #define cpu_has_xmm2		(_mesa_x86_cpu_features & X86_FEATURE_XMM2)
+#endif
+
+#ifdef __3dNOW__
+#define cpu_has_3dnow		1
+#else
 #define cpu_has_3dnow		(_mesa_x86_cpu_features & X86_FEATURE_3DNOW)
+#endif
+
 #define cpu_has_3dnowext	(_mesa_x86_cpu_features & X86_FEATURE_3DNOWEXT)
+
+#ifdef __SSE4_1__
+#define cpu_has_sse4_1		1
+#else
 #define cpu_has_sse4_1		(_mesa_x86_cpu_features & X86_FEATURE_SSE4_1)
+#endif
 
 #endif
 
diff --git a/mesalib/src/util/Makefile.sources b/mesalib/src/util/Makefile.sources
index 952b799..9e27424 100644
--- a/mesalib/src/util/Makefile.sources
+++ b/mesalib/src/util/Makefile.sources
@@ -3,7 +3,8 @@ MESA_UTIL_FILES :=	\
 	ralloc.c \
 	register_allocate.c \
 	register_allocate.h \
-	rgtc.c
+	rgtc.c \
+	strtod.cpp
 
 MESA_UTIL_GENERATED_FILES = \
 	format_srgb.c
diff --git a/mesalib/src/util/hash_table.c b/mesalib/src/util/hash_table.c
index 1b6726c..920bdfd 100644
--- a/mesalib/src/util/hash_table.c
+++ b/mesalib/src/util/hash_table.c
@@ -385,12 +385,12 @@ _mesa_hash_table_random_entry(struct hash_table *ht,
 
 
 /**
- * Quick FNV-1 hash implementation based on:
+ * Quick FNV-1a hash implementation based on:
  * http://www.isthe.com/chongo/tech/comp/fnv/
  *
- * FNV-1 is not be the best hash out there -- Jenkins's lookup3 is supposed to
- * be quite good, and it probably beats FNV.  But FNV has the advantage that
- * it involves almost no code.  For an improvement on both, see Paul
+ * FNV-1a is not be the best hash out there -- Jenkins's lookup3 is supposed
+ * to be quite good, and it probably beats FNV.  But FNV has the advantage
+ * that it involves almost no code.  For an improvement on both, see Paul
  * Hsieh's http://www.azillionmonkeys.com/qed/hash.html
  */
 uint32_t
@@ -408,7 +408,7 @@ _mesa_hash_data(const void *data, size_t size)
    return hash;
 }
 
-/** FNV-1 string hash implementation */
+/** FNV-1a string hash implementation */
 uint32_t
 _mesa_hash_string(const char *key)
 {
diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h
index ff37a7d..5fc6729 100644
--- a/mesalib/src/util/macros.h
+++ b/mesalib/src/util/macros.h
@@ -29,6 +29,10 @@
 #  define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 #endif
 
+/* For compatibility with Clang's __has_builtin() */
+#ifndef __has_builtin
+#  define __has_builtin(x) 0
+#endif
 
 /**
  * __builtin_expect macros
@@ -69,6 +73,12 @@ do {                        \
    assert(!str);            \
    __builtin_unreachable(); \
 } while (0)
+#elif _MSC_VER >= 1200
+#define unreachable(str)    \
+do {                        \
+   assert(!str);            \
+   __assume(0);             \
+} while (0)
 #endif
 
 #ifndef unreachable
@@ -79,7 +89,13 @@ do {                        \
  * Assume macro. Useful for expressing our assumptions to the compiler,
  * typically for purposes of silencing warnings.
  */
-#ifdef HAVE___BUILTIN_UNREACHABLE
+#if __has_builtin(__builtin_assume)
+#define assume(expr)       \
+do {                       \
+   assert(expr);           \
+   __builtin_assume(expr); \
+} while (0)
+#elif defined HAVE___BUILTIN_UNREACHABLE
 #define assume(expr) ((expr) ? ((void) 0) \
                              : (assert(!"assumption failed"), \
                                 __builtin_unreachable()))
diff --git a/mesalib/src/glsl/strtod.c b/mesalib/src/util/strtod.cpp
similarity index 71%
rename from mesalib/src/glsl/strtod.c
rename to mesalib/src/util/strtod.cpp
index 5d4346b..2b4dd98 100644
--- a/mesalib/src/glsl/strtod.c
+++ b/mesalib/src/util/strtod.cpp
@@ -28,7 +28,7 @@
 
 #ifdef _GNU_SOURCE
 #include <locale.h>
-#ifdef __APPLE__
+#ifdef HAVE_XLOCALE_H
 #include <xlocale.h>
 #endif
 #endif
@@ -36,21 +36,22 @@
 #include "strtod.h"
 
 
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+static struct locale_initializer {
+   locale_initializer() { loc = newlocale(LC_CTYPE_MASK, "C", NULL); }
+   locale_t loc;
+} loc_init;
+#endif
 
 /**
  * Wrapper around strtod which uses the "C" locale so the decimal
  * point is always '.'
  */
 double
-glsl_strtod(const char *s, char **end)
+_mesa_strtod(const char *s, char **end)
 {
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
-   !defined(__HAIKU__) && !defined(__UCLIBC__)
-   static locale_t loc = NULL;
-   if (!loc) {
-      loc = newlocale(LC_CTYPE_MASK, "C", NULL);
-   }
-   return strtod_l(s, end, loc);
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+   return strtod_l(s, end, loc_init.loc);
 #else
    return strtod(s, end);
 #endif
@@ -62,16 +63,11 @@ glsl_strtod(const char *s, char **end)
  * point is always '.'
  */
 float
-glsl_strtof(const char *s, char **end)
+_mesa_strtof(const char *s, char **end)
 {
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
-   !defined(__HAIKU__) && !defined(__UCLIBC__)
-   static locale_t loc = NULL;
-   if (!loc) {
-      loc = newlocale(LC_CTYPE_MASK, "C", NULL);
-   }
-   return strtof_l(s, end, loc);
-#elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+   return strtof_l(s, end, loc_init.loc);
+#elif defined(HAVE_STRTOF)
    return strtof(s, end);
 #else
    return (float) strtod(s, end);
diff --git a/mesalib/src/glsl/strtod.h b/mesalib/src/util/strtod.h
similarity index 94%
rename from mesalib/src/glsl/strtod.h
rename to mesalib/src/util/strtod.h
index ad847db..02c25dd 100644
--- a/mesalib/src/glsl/strtod.h
+++ b/mesalib/src/util/strtod.h
@@ -32,10 +32,10 @@ extern "C" {
 #endif
 
 extern double
-glsl_strtod(const char *s, char **end);
+_mesa_strtod(const char *s, char **end);
 
 extern float
-glsl_strtof(const char *s, char **end);
+_mesa_strtof(const char *s, char **end);
 
 
 #ifdef __cplusplus
diff --git a/xkbcomp/configure.ac b/xkbcomp/configure.ac
index fb71294..8937d84 100644
--- a/xkbcomp/configure.ac
+++ b/xkbcomp/configure.ac
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to create configure.
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([xkbcomp], [1.2.4],
+AC_INIT([xkbcomp], [1.3.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xkbcomp])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
diff --git a/xkbcomp/xkbcomp.c b/xkbcomp/xkbcomp.c
index 956e79c..adfa89a 100644
--- a/xkbcomp/xkbcomp.c
+++ b/xkbcomp/xkbcomp.c
@@ -576,17 +576,37 @@ parseArgs(int argc, char *argv[])
         }
         else if (strncmp(argv[i], "-w", 2) == 0)
         {
-            if ((i >= (argc - 1)) || (!isdigit(argv[i + 1][0])))
+            unsigned long utmp;
+            char *tmp2;
+            /* If text is just after "-w" in the same word, then it must
+             * be a number and it is the warning level. Otherwise, if the
+             * next argument is a number, then it is the warning level,
+             * else the warning level is assumed to be 0.
+             */
+            if (argv[i][2] == '\0')
             {
                 warningLevel = 0;
-                if (isdigit(argv[i][2]))
-                    if (sscanf(&argv[i][2], "%i", &itmp) == 1)
-                        warningLevel = itmp;
+                if (i < argc - 1)
+                {
+                    utmp = strtoul(argv[i+1], &tmp2, 10);
+                    if (argv[i+1][0] != '\0' && *tmp2 == '\0')
+                    {
+                        warningLevel = utmp > 10 ? 10 : utmp;
+                        i++;
+                    }
+                }
             }
             else
             {
-                if (sscanf(argv[++i], "%i", &itmp) == 1)
-                    warningLevel = itmp;
+                utmp = strtoul(&argv[i][2], &tmp2, 10);
+                if (*tmp2 == '\0')
+                    warningLevel = utmp > 10 ? 10 : utmp;
+                else
+                {
+                    ERROR1("Unknown flag \"%s\" on command line\n", argv[i]);
+                    Usage(argc, argv);
+                    return False;
+                }
             }
         }
         else if ((strcmp(argv[i], "-xkb") == 0) && (!xkblist))
diff --git a/xorg-server/Xext/dpms.c b/xorg-server/Xext/dpms.c
index 5f1a35d..cdfaa97 100644
--- a/xorg-server/Xext/dpms.c
+++ b/xorg-server/Xext/dpms.c
@@ -14,14 +14,14 @@ 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 NONINFRINGEMENT.  IN NO EVENT SHALL
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, 
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, 
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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.
 
-Except as contained in this notice, the name of Digital Equipment Corporation 
+Except as contained in this notice, the name of Digital Equipment Corporation
 shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital 
+dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 
 ******************************************************************/
diff --git a/xorg-server/Xext/dpmsstubs.c b/xorg-server/Xext/dpmsstubs.c
index 80f13f5..f05d1e9 100644
--- a/xorg-server/Xext/dpmsstubs.c
+++ b/xorg-server/Xext/dpmsstubs.c
@@ -14,14 +14,14 @@ 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 NONINFRINGEMENT.  IN NO EVENT SHALL
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, 
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, 
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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.
 
-Except as contained in this notice, the name of Digital Equipment Corporation 
+Except as contained in this notice, the name of Digital Equipment Corporation
 shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital 
+dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 
 ******************************************************************/
diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c
index 4d79c46..2bbae2f 100644
--- a/xorg-server/Xext/panoramiX.c
+++ b/xorg-server/Xext/panoramiX.c
@@ -427,7 +427,7 @@ XineramaReinitData(void)
 
 /*
  *	PanoramiXExtensionInit():
- *		Called from InitExtensions in main().  
+ *		Called from InitExtensions in main().
  *		Register PanoramiXeen Extension
  *		Initialize global variables.
  */
diff --git a/xorg-server/Xext/panoramiX.h b/xorg-server/Xext/panoramiX.h
index 6578dfa..c16b9a5 100644
--- a/xorg-server/Xext/panoramiX.h
+++ b/xorg-server/Xext/panoramiX.h
@@ -28,7 +28,7 @@ Equipment Corporation.
 
 /* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */
 
-/*  
+/*
  *	PanoramiX definitions
  */
 
diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c
index 0122ff3..413a66a 100644
--- a/xorg-server/Xext/panoramiXprocs.c
+++ b/xorg-server/Xext/panoramiXprocs.c
@@ -509,7 +509,7 @@ PanoramiXConfigureWindow(ClientPtr client)
         }
     }
 
-    /* have to go forward or you get expose events before 
+    /* have to go forward or you get expose events before
        ConfigureNotify events */
     FOR_NSCREENS_FORWARD(j) {
         stuff->window = win->info[j].id;
@@ -1037,7 +1037,7 @@ PanoramiXClearToBackground(ClientPtr client)
     return result;
 }
 
-/* 
+/*
     For Window to Pixmap copies you're screwed since each screen's
     pixmap will look like what it sees on its screen.  Unless the
     screens overlap and the window lies on each, the two copies
diff --git a/xorg-server/Xext/security.c b/xorg-server/Xext/security.c
index bf2ab2e..cce7c46 100644
--- a/xorg-server/Xext/security.c
+++ b/xorg-server/Xext/security.c
@@ -928,12 +928,12 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
  * Returns: nothing.
  *
  * Side Effects:
- * 
+ *
  * If a new client is connecting, its authorization ID is copied to
  * client->authID.  If this is a generated authorization, its reference
  * count is bumped, its timer is cancelled if it was running, and its
  * trustlevel is copied to TRUSTLEVEL(client).
- * 
+ *
  * If a client is disconnecting and the client was using a generated
  * authorization, the authorization's reference count is decremented, and
  * if it is now zero, the timer for this authorization is started.
diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c
index 4dad8b6..db9d474 100644
--- a/xorg-server/Xext/shm.c
+++ b/xorg-server/Xext/shm.c
@@ -248,21 +248,20 @@ ShmDestroyPixmap(PixmapPtr pPixmap)
 {
     ScreenPtr pScreen = pPixmap->drawable.pScreen;
     ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
+    void *shmdesc = NULL;
     Bool ret;
 
-    if (pPixmap->refcnt == 1) {
-        ShmDescPtr shmdesc;
-
-        shmdesc = (ShmDescPtr) dixLookupPrivate(&pPixmap->devPrivates,
-                                                shmPixmapPrivateKey);
-        if (shmdesc)
-            ShmDetachSegment((void *) shmdesc, pPixmap->drawable.id);
-    }
+    if (pPixmap->refcnt == 1)
+        shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey);
 
     pScreen->DestroyPixmap = screen_priv->destroyPixmap;
     ret = (*pScreen->DestroyPixmap) (pPixmap);
     screen_priv->destroyPixmap = pScreen->DestroyPixmap;
     pScreen->DestroyPixmap = ShmDestroyPixmap;
+
+    if (shmdesc)
+	ShmDetachSegment(shmdesc, pPixmap->drawable.id);
+
     return ret;
 }
 
@@ -405,7 +404,7 @@ ProcShmAttach(ClientPtr client)
         }
 
         /* The attach was performed with root privs. We must
-         * do manual checking of access rights for the credentials 
+         * do manual checking of access rights for the credentials
          * of the client */
 
         if (shm_access(client, &(SHM_PERM(buf)), stuff->readOnly) == -1) {
@@ -1148,7 +1147,7 @@ ProcShmAttachFd(ClientPtr client)
                          fd, 0);
 
     close(fd);
-    if ((shmdesc->addr == ((char *) -1))) {
+    if (shmdesc->addr == ((char *) -1)) {
         free(shmdesc);
         return BadAccess;
     }
@@ -1238,7 +1237,7 @@ ProcShmCreateSegment(ClientPtr client)
                          MAP_SHARED,
                          fd, 0);
 
-    if ((shmdesc->addr == ((char *) -1))) {
+    if (shmdesc->addr == ((char *) -1)) {
         close(fd);
         free(shmdesc);
         return BadAccess;
diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c
index 755ed94..ba08cd1 100644
--- a/xorg-server/Xext/sync.c
+++ b/xorg-server/Xext/sync.c
@@ -2715,7 +2715,7 @@ IdleTimeBlockHandler(void *pCounter, struct timeval **wt, void *LastSelectMask)
                 break;
             }
         }
-        /* 
+        /*
          * We've been called exactly on the idle time, but we have a
          * NegativeTransition trigger which requires a transition from an
          * idle time greater than this.  Schedule a wakeup for the next
diff --git a/xorg-server/Xext/syncsrv.h b/xorg-server/Xext/syncsrv.h
index 8c2c00d..a8062d1 100644
--- a/xorg-server/Xext/syncsrv.h
+++ b/xorg-server/Xext/syncsrv.h
@@ -30,13 +30,13 @@ and Olivetti Research Limited, Cambridge, England.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the names of Digital or Olivetti
 not be used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
diff --git a/xorg-server/Xext/xres.c b/xorg-server/Xext/xres.c
index 546b942..2737938 100644
--- a/xorg-server/Xext/xres.c
+++ b/xorg-server/Xext/xres.c
@@ -358,8 +358,8 @@ ResGetApproxPixmapBytes(PixmapPtr pix)
     bytesPerPixel = (float)pix->drawable.bitsPerPixel / 8.0;
     nPixels = pix->drawable.width * pix->drawable.height;
 
-    /* Divide by refcnt as pixmap could be shared between clients,  
-     * so total pixmap mem is shared between these. 
+    /* Divide by refcnt as pixmap could be shared between clients,
+     * so total pixmap mem is shared between these.
      */
     return (nPixels * bytesPerPixel) / pix->refcnt;
 }
@@ -375,7 +375,7 @@ ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
     *bytes += size.pixmapRefSize;
 }
 
-static void 
+static void
 ResFindPixmaps(void *value, XID id, void *cdata)
 {
     unsigned long *bytes = (unsigned long *) cdata;
@@ -448,13 +448,13 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
     FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
                               (void *) (&bytes));
 
-    /* 
-     * Make sure win background pixmaps also held to account. 
+    /*
+     * Make sure win background pixmaps also held to account.
      */
     FindClientResourcesByType(clients[clientID], RT_WINDOW,
                               ResFindWindowPixmaps, (void *) (&bytes));
 
-    /* 
+    /*
      * GC Tile & Stipple pixmaps too.
      */
     FindClientResourcesByType(clients[clientID], RT_GC,
diff --git a/xorg-server/Xext/xvdisp.c b/xorg-server/Xext/xvdisp.c
index 0bdfed3..86f982a 100644
--- a/xorg-server/Xext/xvdisp.c
+++ b/xorg-server/Xext/xvdisp.c
@@ -4,13 +4,13 @@ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the names of Digital or MIT not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/Xext/xvdix.h b/xorg-server/Xext/xvdix.h
index e67a3c7..621a1e3 100644
--- a/xorg-server/Xext/xvdix.h
+++ b/xorg-server/Xext/xvdix.h
@@ -4,13 +4,13 @@ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the names of Digital or MIT not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -25,18 +25,18 @@ SOFTWARE.
 #ifndef XVDIX_H
 #define XVDIX_H
 /*
-** File: 
+** File:
 **
 **   xvdix.h --- Xv device independent header file
 **
-** Author: 
+** Author:
 **
 **   David Carver (Digital Workstation Engineering/Project Athena)
 **
 ** Revisions:
 **
 **   29.08.91 Carver
-**     - removed UnrealizeWindow wrapper unrealizing windows no longer 
+**     - removed UnrealizeWindow wrapper unrealizing windows no longer
 **       preempts video
 **
 **   11.06.91 Carver
diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c
index bc176c8..0abf190 100644
--- a/xorg-server/Xext/xvmain.c
+++ b/xorg-server/Xext/xvmain.c
@@ -4,13 +4,13 @@ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the names of Digital or MIT not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -23,11 +23,11 @@ SOFTWARE.
 ******************************************************************/
 
 /*
-** File: 
+** File:
 **
 **   xvmain.c --- Xv server extension main device independent module.
-**   
-** Author: 
+**
+** Author:
 **
 **   David Carver (Digital Workstation Engineering/Project Athena)
 **
@@ -58,7 +58,7 @@ SOFTWARE.
 **
 **   24.01.91 Carver
 **     - version 1.4 upgrade
-**       
+**
 ** Notes:
 **
 **   Port structures reference client structures in a two different
@@ -86,7 +86,7 @@ SOFTWARE.
 #include "scrnintstr.h"
 #include "windowstr.h"
 #include "pixmapstr.h"
-#include "gc.h"
+#include "gcstruct.h"
 #include "extnsionst.h"
 #include "extinit.h"
 #include "dixstruct.h"
@@ -915,7 +915,7 @@ XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff)
         return Success;
     }
 
-    /* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE 
+    /* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE
        CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
 
     if (!tpn) {
diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c
index dfbff06..8daded0 100644
--- a/xorg-server/composite/compalloc.c
+++ b/xorg-server/composite/compalloc.c
@@ -156,7 +156,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
                 return BadAccess;
 
     /*
-     * Allocate per-client per-window structure 
+     * Allocate per-client per-window structure
      * The client *could* allocate multiple, but while supported,
      * it is not expected to be common
      */
@@ -353,7 +353,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
             if (ccw->update == CompositeRedirectManual)
                 return BadAccess;
     /*
-     * Allocate per-client per-window structure 
+     * Allocate per-client per-window structure
      * The client *could* allocate multiple, but while supported,
      * it is not expected to be common
      */
@@ -401,7 +401,7 @@ compRedirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
         return BadAlloc;
     if (ccw->update == CompositeRedirectManual) {
         csw->update = CompositeRedirectManual;
-        /* 
+        /*
          * tell damage extension that damage events for this client are
          * critical output
          */
@@ -430,7 +430,7 @@ compFreeClientSubwindows(WindowPtr pWin, XID id)
 
             *prev = ccw->next;
             if (ccw->update == CompositeRedirectManual) {
-                /* 
+                /*
                  * tell damage extension that damage events for this client are
                  * critical output
                  */
diff --git a/xorg-server/composite/compext.c b/xorg-server/composite/compext.c
index fcfc349..f1a8255 100644
--- a/xorg-server/composite/compext.c
+++ b/xorg-server/composite/compext.c
@@ -299,7 +299,7 @@ ProcCompositeGetOverlayWindow(ClientPtr client)
     VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
     pScreen = pWin->drawable.pScreen;
 
-    /* 
+    /*
      * Create an OverlayClient structure to mark this client's
      * interest in the overlay window
      */
@@ -351,7 +351,7 @@ ProcCompositeReleaseOverlayWindow(ClientPtr client)
     REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
     VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess);
 
-    /* 
+    /*
      * Has client queried a reference to the overlay window
      * on this screen? If not, generate an error.
      */
diff --git a/xorg-server/composite/compinit.c b/xorg-server/composite/compinit.c
index 111c16e..3ac075a 100644
--- a/xorg-server/composite/compinit.c
+++ b/xorg-server/composite/compinit.c
@@ -78,6 +78,7 @@ compCloseScreen(ScreenPtr pScreen)
     pScreen->PositionWindow = cs->PositionWindow;
 
     pScreen->GetImage = cs->GetImage;
+    pScreen->GetSpans = cs->GetSpans;
     pScreen->SourceValidate = cs->SourceValidate;
 
     free(cs);
@@ -151,6 +152,21 @@ compGetImage(DrawablePtr pDrawable,
 }
 
 static void
+compGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
+             int nspans, char *pdstStart)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    CompScreenPtr cs = GetCompScreen(pScreen);
+
+    pScreen->GetSpans = cs->GetSpans;
+    if (pDrawable->type == DRAWABLE_WINDOW)
+        compPaintChildrenToWindow((WindowPtr) pDrawable);
+    (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+    cs->GetSpans = pScreen->GetSpans;
+    pScreen->GetSpans = compGetSpans;
+}
+
+static void
 compSourceValidate(DrawablePtr pDrawable,
                    int x, int y,
                    int width, int height, unsigned int subWindowMode)
@@ -193,7 +209,7 @@ compFindVisuallessDepth(ScreenPtr pScreen, int d)
         }
     }
     /*
-     * If there isn't one, then it's gonna be hard to have 
+     * If there isn't one, then it's gonna be hard to have
      * an associated visual
      */
     return 0;
@@ -432,6 +448,9 @@ compScreenInit(ScreenPtr pScreen)
     cs->GetImage = pScreen->GetImage;
     pScreen->GetImage = compGetImage;
 
+    cs->GetSpans = pScreen->GetSpans;
+    pScreen->GetSpans = compGetSpans;
+
     cs->SourceValidate = pScreen->SourceValidate;
     pScreen->SourceValidate = compSourceValidate;
 
diff --git a/xorg-server/composite/compint.h b/xorg-server/composite/compint.h
index 56b76c5..09241f2 100644
--- a/xorg-server/composite/compint.h
+++ b/xorg-server/composite/compint.h
@@ -76,7 +76,7 @@
 
 /*
  *  enable this for debugging
- 
+
     #define COMPOSITE_DEBUG
  */
 
@@ -168,6 +168,7 @@ typedef struct _CompScreen {
     CompOverlayClientPtr pOverlayClients;
 
     GetImageProcPtr GetImage;
+    GetSpansProcPtr GetSpans;
     SourceValidateProcPtr SourceValidate;
 } CompScreenRec, *CompScreenPtr;
 
diff --git a/xorg-server/composite/compoverlay.c b/xorg-server/composite/compoverlay.c
index 7932dda..20c860d 100644
--- a/xorg-server/composite/compoverlay.c
+++ b/xorg-server/composite/compoverlay.c
@@ -52,7 +52,7 @@
 #include "panoramiXsrv.h"
 #endif
 
-/* 
+/*
  * Delete the given overlay client list element from its screen list.
  */
 void
@@ -110,7 +110,7 @@ compCreateOverlayClient(ScreenPtr pScreen, ClientPtr pClient)
     pOc->pNext = cs->pOverlayClients;
     cs->pOverlayClients = pOc;
 
-    /* 
+    /*
      * Create a resource for this element so it can be deleted
      * when the client goes away.
      */
diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c
index 9a6b2da..77bdfa2 100644
--- a/xorg-server/composite/compwindow.c
+++ b/xorg-server/composite/compwindow.c
@@ -567,10 +567,11 @@ compCreateWindow(WindowPtr pWin)
     if (pWin->parent && ret) {
         CompSubwindowsPtr csw = GetCompSubwindows(pWin->parent);
         CompClientWindowPtr ccw;
+        PixmapPtr parent_pixmap = (*pScreen->GetWindowPixmap)(pWin->parent);
+        PixmapPtr window_pixmap = (*pScreen->GetWindowPixmap)(pWin);
 
-        (*pScreen->SetWindowPixmap) (pWin,
-                                     (*pScreen->GetWindowPixmap) (pWin->
-                                                                  parent));
+        if (window_pixmap != parent_pixmap)
+            (*pScreen->SetWindowPixmap) (pWin, parent_pixmap);
         if (csw)
             for (ccw = csw->clients; ccw; ccw = ccw->next)
                 compRedirectWindow(clients[CLIENT_ID(ccw->id)],
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index ac68f17..140e33e 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.16.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2014-07-17"
-RELEASE_NAME="Baba Ghanouj"
+AC_INIT([xorg-server], 1.16.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2014-10-28"
+RELEASE_NAME="Chanterelle"
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
@@ -698,6 +698,7 @@ case $host_os in
 		CONFIG_UDEV=no
 		CONFIG_UDEV_KMS=no
 		DGA=no
+		DRM=no
 		DRI2=no
 		DRI3=no
 		INT10MODULE=no
@@ -1993,11 +1994,13 @@ if test "x$XORG" = xyes; then
 	  gnu*)
 		XORG_OS_SUBDIR="hurd"
 		;;
+	  cygwin*)
+		XORG_OS_SUBDIR="stub"
+		;;
 	  *)
 		XORG_OS_SUBDIR="stub"
 		AC_MSG_NOTICE([m4_text_wrap(m4_join([ ],
-		[Your OS is unknown. Xorg currently only supports Linux,],
-		[Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
+		[Your OS is unknown.],
 		[If you are interested in porting Xorg to your platform,],
 		[please email xorg at lists.freedesktop.org.]))])
 		;;
@@ -2553,6 +2556,7 @@ hw/xfree86/dixmods/Makefile
 hw/xfree86/doc/Makefile
 hw/xfree86/dri/Makefile
 hw/xfree86/dri2/Makefile
+hw/xfree86/dri2/pci_ids/Makefile
 hw/xfree86/drivers/Makefile
 hw/xfree86/drivers/modesetting/Makefile
 hw/xfree86/exa/Makefile
diff --git a/xorg-server/dbe/dbe.c b/xorg-server/dbe/dbe.c
index 8896720..527588c 100644
--- a/xorg-server/dbe/dbe.c
+++ b/xorg-server/dbe/dbe.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * 
+ *
  * Copyright (c) 1994, 1995  Hewlett-Packard Company
  *
  * Permission is hereby granted, free of charge, to any person obtaining
@@ -9,10 +9,10 @@
  * distribute, sublicense, 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 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 NONINFRINGEMENT.
@@ -20,12 +20,12 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Hewlett-Packard
  * Company shall not be used in advertising or otherwise to promote the
  * sale, use or other dealings in this Software without prior written
  * authorization from the Hewlett-Packard Company.
- * 
+ *
  *     DIX DBE code
  *
  *****************************************************************************/
@@ -152,7 +152,7 @@ ProcDbeGetVersion(ClientPtr client)
  *     BadIDChoice - id is out of range for client; id is already in use
  *     BadMatch    - window is not an InputOutput window;
  *                   visual of window is not on list returned by
- *                   DBEGetVisualInfo; 
+ *                   DBEGetVisualInfo;
  *     BadValue    - invalid swap action is specified
  *     BadWindow   - window is not a valid window
  *     Success
@@ -835,7 +835,7 @@ SProcDbeGetVersion(ClientPtr client)
  *     BadIDChoice - id is out of range for client; id is already in use
  *     BadMatch    - window is not an InputOutput window;
  *                   visual of window is not on list returned by
- *                   DBEGetVisualInfo; 
+ *                   DBEGetVisualInfo;
  *     BadValue    - invalid swap action is specified
  *     BadWindow   - window is not a valid window
  *     Success
@@ -1058,7 +1058,7 @@ SProcDbeDispatch(ClientPtr client)
  *
  *     TRUE  - setup was successful
  *     FALSE - the window's background state is NONE
- * 
+ *
  *****************************************************************************/
 
 static Bool
diff --git a/xorg-server/dbe/dbestruct.h b/xorg-server/dbe/dbestruct.h
index 2002066..fe2ef0a 100644
--- a/xorg-server/dbe/dbestruct.h
+++ b/xorg-server/dbe/dbestruct.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * 
+ *
  * Copyright (c) 1994, 1995  Hewlett-Packard Company
  *
  * Permission is hereby granted, free of charge, to any person obtaining
@@ -9,10 +9,10 @@
  * distribute, sublicense, 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 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 NONINFRINGEMENT.
@@ -20,12 +20,12 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Hewlett-Packard
  * Company shall not be used in advertising or otherwise to promote the
  * sale, use or other dealings in this Software without prior written
  * authorization from the Hewlett-Packard Company.
- * 
+ *
  *     Header file for DIX-related DBE
  *
  *****************************************************************************/
@@ -139,7 +139,7 @@ typedef struct _DbeWindowPrivRec {
      * possibly resulting in a page swap and loss of performance.  Initially we
      * will use this array to store buffer IDs.  For situations where we have
      * more IDs than can fit in this static array, we will allocate a larger
-     * array to use, possibly suffering a performance loss. 
+     * array to use, possibly suffering a performance loss.
      */
     XID initIDs[DBE_INIT_MAX_IDS];
 
diff --git a/xorg-server/dbe/midbe.c b/xorg-server/dbe/midbe.c
index 0479ecc..8f75910 100644
--- a/xorg-server/dbe/midbe.c
+++ b/xorg-server/dbe/midbe.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * 
+ *
  * Copyright (c) 1994, 1995  Hewlett-Packard Company
  *
  * Permission is hereby granted, free of charge, to any person obtaining
@@ -9,10 +9,10 @@
  * distribute, sublicense, 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 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 NONINFRINGEMENT.
@@ -20,12 +20,12 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Hewlett-Packard
  * Company shall not be used in advertising or otherwise to promote the
  * sale, use or other dealings in this Software without prior written
  * authorization from the Hewlett-Packard Company.
- * 
+ *
  *     Machine-independent DBE code
  *
  *****************************************************************************/
@@ -396,7 +396,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
  *     resource deletion easier.  It is not guaranteed which delete function is
  *     called first.  Hence, we will let miDbeWinPrivDelete() free all DBE
  *     resources.
- *     
+ *
  *     This function deletes/frees the following stuff associated with
  *     the window private:
  *
@@ -443,7 +443,7 @@ miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
  *
  * Description:
  *
- *     This function was cloned from miMbxPositionWindow() in mimultibuf.c. 
+ *     This function was cloned from miMbxPositionWindow() in mimultibuf.c.
  *     This function resizes the buffer when the window is resized.
  *
  *****************************************************************************/
diff --git a/xorg-server/dbe/midbe.h b/xorg-server/dbe/midbe.h
index 4eed538..67320ea 100644
--- a/xorg-server/dbe/midbe.h
+++ b/xorg-server/dbe/midbe.h
@@ -8,10 +8,10 @@
  * distribute, sublicense, 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 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 NONINFRINGEMENT.
@@ -19,12 +19,12 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Hewlett-Packard
  * Company shall not be used in advertising or otherwise to promote the
  * sale, use or other dealings in this Software without prior written
  * authorization from the Hewlett-Packard Company.
- * 
+ *
  *     Header file for users of machine-independent DBE code
  *
  *****************************************************************************/
diff --git a/xorg-server/dix/atom.c b/xorg-server/dix/atom.c
index 6f85968..22cd0dc 100644
--- a/xorg-server/dix/atom.c
+++ b/xorg-server/dix/atom.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/colormap.c b/xorg-server/dix/colormap.c
index c1ff88e..4d408d5 100644
--- a/xorg-server/dix/colormap.c
+++ b/xorg-server/dix/colormap.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -181,11 +181,11 @@ static void FindColorInRootCmap(ColormapPtr /* pmap */ ,
 
 #define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis))
 
-/* GetNextBitsOrBreak(bits, mask, base)  -- 
+/* GetNextBitsOrBreak(bits, mask, base)  --
  * (Suggestion: First read the macro, then read this explanation.
  *
  * Either generate the next value to OR in to a pixel or break out of this
- * while loop 
+ * while loop
  *
  * This macro is used when we're trying to generate all 2^n combinations of
  * bits in mask.  What we're doing here is counting in binary, except that
@@ -197,11 +197,11 @@ static void FindColorInRootCmap(ColormapPtr /* pmap */ ,
  * base has 1 bit set where the least significant bit of mask is set
  *
  * For example,if mask is 01010, base should be 0010 and we count like this:
- * 00010 (see this isn't so hard), 
+ * 00010 (see this isn't so hard),
  *     then we add base to bits and get 0100. (bits & ~mask) is (0100 & 0100) so
  *      we add that to bits getting (0100 + 0100) =
  * 01000 for our next value.
- *      then we add 0010 to get 
+ *      then we add 0010 to get
  * 01010 and we're done (easy as 1, 2, 3)
  */
 #define GetNextBitsOrBreak(bits, mask, base)	\
@@ -225,9 +225,9 @@ typedef struct _colorResource {
  * fShared should only be set if refcnt == AllocPrivate, and only in red map
  */
 
-/** 
- * Create and initialize the color map 
- * 
+/**
+ * Create and initialize the color map
+ *
  * \param mid    resource to use for this colormap
  * \param alloc  1 iff all entries are allocated writable
  */
@@ -370,7 +370,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
     if (!AddResource(mid, RT_COLORMAP, (void *) pmap))
         return BadAlloc;
 
-    /*  
+    /*
      * Security creation/labeling check
      */
     i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP,
@@ -1456,7 +1456,7 @@ FreePixels(ColormapPtr pmap, int client)
     }
 }
 
-/** 
+/**
  * Frees all of a client's colors and cells.
  *
  *  \param value  must conform to DeleteType
@@ -1574,7 +1574,7 @@ AllocColorPlanes(int client, ColormapPtr pmap, int colors,
         /* Allocate the proper pixels */
         /* XXX This is sort of bad, because of contig is set, we force all
          * r + g + b bits to be contiguous.  Should only force contiguity
-         * per mask 
+         * per mask
          */
         ok = AllocPseudo(client, pmap, colors, r + g + b, contig, pixels,
                          &mask, &ppixFirst);
@@ -1786,7 +1786,7 @@ AllocPseudo(int client, ColormapPtr pmap, int c, int r, Bool contig,
  * pixels are the unique pixels.  *pMask has the mask to Or with the
  * unique pixels to get the rest of them.
  *
- * Returns True iff all pixels could be allocated 
+ * Returns True iff all pixels could be allocated
  * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE
  * (see AllocShared for why we care)
  */
@@ -2056,7 +2056,7 @@ AllocShared(ColormapPtr pmap, Pixel * ppix, int c, int r, int g, int b,
 }
 
 /** FreeColors
- * Free colors and/or cells (probably slow for large numbers) 
+ * Free colors and/or cells (probably slow for large numbers)
  */
 int
 FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask)
@@ -2097,7 +2097,7 @@ FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask)
 /**
  * Helper for FreeColors -- frees all combinations of *newpixels and mask bits
  * which the client has allocated in channel colormap cells of pmap.
- * doesn't change newpixels if it doesn't need to 
+ * doesn't change newpixels if it doesn't need to
  *
  *  \param pmap   which colormap head
  *  \param color  which sub-map, eg, RED, BLUE, PSEUDO
diff --git a/xorg-server/dix/cursor.c b/xorg-server/dix/cursor.c
index 56c5606..1525857 100644
--- a/xorg-server/dix/cursor.c
+++ b/xorg-server/dix/cursor.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 3fb7ca0..c4fdbe1 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -2622,7 +2622,7 @@ GetPairedDevice(DeviceIntPtr dev)
  *   slave.
  * - MASTER_KEYBOARD: the master keyboard for this device or NULL for a
  *   floating slave
- * - MASTER_POINTER: the master keyboard for this device or NULL for a
+ * - MASTER_POINTER: the master pointer for this device or NULL for a
  *   floating slave
  * - POINTER_OR_FLOAT: the master pointer for this device or the device for
  *   a floating slave
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index 74abecd..d844a09 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -26,13 +26,13 @@ Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -364,9 +364,9 @@ Dispatch(void)
             clientReady[0] = SmartScheduleClient(clientReady, nready);
             nready = 1;
         }
-       /***************** 
-	*  Handle events in round robin fashion, doing input between 
-	*  each round 
+       /*****************
+	*  Handle events in round robin fashion, doing input between
+	*  each round
 	*****************/
 
         while (!dispatchException && (--nready >= 0)) {
@@ -3198,7 +3198,7 @@ ProcChangeAccessControl(ClientPtr client)
 /*********************
  * CloseDownRetainedResources
  *
- *    Find all clients that are gone and have terminated in RetainTemporary 
+ *    Find all clients that are gone and have terminated in RetainTemporary
  *    and destroy their resources.
  *********************/
 
diff --git a/xorg-server/dix/dispatch.h b/xorg-server/dix/dispatch.h
index 3f3f3a2..939a6b9 100644
--- a/xorg-server/dix/dispatch.h
+++ b/xorg-server/dix/dispatch.h
@@ -26,7 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 /*
  * This prototypes the dispatch.c module (except for functions declared in
  * global headers), plus related dispatch procedures from devices.c, events.c,
- * extension.c, property.c. 
+ * extension.c, property.c.
  */
 
 #ifdef HAVE_DIX_CONFIG_H
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index 1c6442c..bc2732f 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -806,7 +806,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
     int i;
     LFclosurePtr c;
 
-    /* 
+    /*
      * The right error to return here would be BadName, however the
      * specification does not allow for a Name error on this request.
      * Perhaps a better solution would be to return a nil list, i.e.
@@ -1057,7 +1057,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
     int i;
     LFWIclosurePtr c;
 
-    /* 
+    /*
      * The right error to return here would be BadName, however the
      * specification does not allow for a Name error on this request.
      * Perhaps a better solution would be to return a nil list, i.e.
@@ -1851,7 +1851,7 @@ GetClientResolutions(int *num)
     pScreen = screenInfo.screens[0];
     res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
     /*
-     * XXX - we'll want this as long as bitmap instances are prevalent 
+     * XXX - we'll want this as long as bitmap instances are prevalent
      so that we can match them from scalable fonts
      */
     if (res.x_resolution < 88)
diff --git a/xorg-server/dix/dixutils.c b/xorg-server/dix/dixutils.c
index cdd370b..205550e 100644
--- a/xorg-server/dix/dixutils.c
+++ b/xorg-server/dix/dixutils.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -352,7 +352,7 @@ DeleteWindowFromAnySaveSet(WindowPtr pWin)
 /* No-op Don't Do Anything : sometimes we need to be able to call a procedure
  * that doesn't do anything.  For example, on screen with only static
  * colormaps, if someone calls install colormap, it's easier to have a dummy
- * procedure to call than to check if there's a procedure 
+ * procedure to call than to check if there's a procedure
  */
 void
 NoopDDA(void)
@@ -373,7 +373,7 @@ static Bool inHandler;
 static Bool handlerDeleted;
 
 /**
- * 
+ *
  *  \param pTimeout   DIX doesn't want to know how OS represents time
  *  \param pReadMask  nor how it represents the det of descriptors
  */
diff --git a/xorg-server/dix/extension.c b/xorg-server/dix/extension.c
index e43291e..56e3abc 100644
--- a/xorg-server/dix/extension.c
+++ b/xorg-server/dix/extension.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/gc.c b/xorg-server/dix/gc.c
index 88d6501..78f3be2 100644
--- a/xorg-server/dix/gc.c
+++ b/xorg-server/dix/gc.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -87,22 +87,22 @@ ValidateGC(DrawablePtr pDraw, GC * pGC)
  * specified.  ddxen can call this too; they should normally pass
  * NullClient for the client since any access checking should have
  * already been done at a higher level.
- * 
+ *
  * If you have any XIDs, you must use ChangeGCXIDs:
- * 
+ *
  *     CARD32 v[2];
  *     v[0] = FillTiled;
  *     v[1] = pid;
  *     ChangeGCXIDs(client, pGC, GCFillStyle|GCTile, v);
- * 
+ *
  * However, if you need to pass a pointer to a pixmap or font, you must
  * use ChangeGC:
- * 
+ *
  *     ChangeGCVal v[2];
  *     v[0].val = FillTiled;
  *     v[1].ptr = pPixmap;
  *     ChangeGC(client, pGC, GCFillStyle|GCTile, v);
- * 
+ *
  * If you have neither XIDs nor pointers, you can use either function,
  * but ChangeGC will do less work.
  *
@@ -495,7 +495,6 @@ NewGCObject(ScreenPtr pScreen, int depth)
     pGC->graphicsExposures = TRUE;
     pGC->clipOrg.x = 0;
     pGC->clipOrg.y = 0;
-    pGC->clientClipType = CT_NONE;
     pGC->clientClip = (void *) NULL;
     pGC->numInDashList = 2;
     pGC->dash = DefaultDash;
@@ -791,7 +790,7 @@ since we can't create them without already having a GC.  any code
 using the tile or stipple has to set them explicitly anyway,
 since the state of the scratch gc is unknown.  This is OK
 because ChangeGC() has to be able to deal with NULL tiles and
-stipples anyway (in case the CreateGC() call has provided a 
+stipples anyway (in case the CreateGC() call has provided a
 value for them -- we can't set the default tile until the
 client-supplied attributes are installed, since the fgPixel
 is what fills the default tile.  (maybe this comment should
@@ -1033,7 +1032,7 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects,
 }
 
 /*
-   sets reasonable defaults 
+   sets reasonable defaults
    if we can get a pre-allocated one, use it and mark it as used.
    if we can't, create one out of whole cloth (The Velveteen GC -- if
    you use it often enough it will become real.)
@@ -1067,7 +1066,7 @@ GetScratchGC(unsigned depth, ScreenPtr pScreen)
             pGC->graphicsExposures = FALSE;
             pGC->clipOrg.x = 0;
             pGC->clipOrg.y = 0;
-            if (pGC->clientClipType != CT_NONE)
+            if (pGC->clientClip)
                 (*pGC->funcs->ChangeClip) (pGC, CT_NONE, NULL, 0);
             pGC->stateChanges = GCAllBits;
             return pGC;
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index ffa89fa..dd96265 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -1248,8 +1248,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
     double x, y, ox, oy;
     int has_x, has_y;
 
-    has_x = valuator_mask_fetch_double(mask, 0, &ox);
-    has_y = valuator_mask_fetch_double(mask, 1, &oy);
+    has_x = valuator_mask_isset(mask, 0);
+    has_y = valuator_mask_isset(mask, 1);
 
     if (!has_x && !has_y)
         return;
@@ -1263,23 +1263,23 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 
         pixman_f_transform_invert(&invert, &dev->scale_and_transform);
         transform(&invert, &ox, &oy);
-
-        x = ox;
-        y = oy;
     }
 
-    if (valuator_mask_isset(mask, 0))
-        ox = x = valuator_mask_get_double(mask, 0);
+    if (has_x)
+        ox = valuator_mask_get_double(mask, 0);
 
-    if (valuator_mask_isset(mask, 1))
-        oy = y = valuator_mask_get_double(mask, 1);
+    if (has_y)
+        oy = valuator_mask_get_double(mask, 1);
+
+    x = ox;
+    y = oy;
 
     transform(&dev->scale_and_transform, &x, &y);
 
-    if (valuator_mask_isset(mask, 0) || ox != x)
+    if (has_x || ox != x)
         valuator_mask_set_double(mask, 0, x);
 
-    if (valuator_mask_isset(mask, 1) || oy != y)
+    if (has_y || oy != y)
         valuator_mask_set_double(mask, 1, y);
 }
 
diff --git a/xorg-server/dix/globals.c b/xorg-server/dix/globals.c
index eaa2afe..f36a938 100644
--- a/xorg-server/dix/globals.c
+++ b/xorg-server/dix/globals.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/glyphcurs.c b/xorg-server/dix/glyphcurs.c
index 5404025..eca6a4c 100644
--- a/xorg-server/dix/glyphcurs.c
+++ b/xorg-server/dix/glyphcurs.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c
index e3fc38b..b92f1e7 100644
--- a/xorg-server/dix/grabs.c
+++ b/xorg-server/dix/grabs.c
@@ -28,13 +28,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
@@ -419,9 +419,9 @@ GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
 
 /**
  * Compares two grabs and returns TRUE if the first grab matches the second
- * grab. 
- * 
- * A match is when 
+ * grab.
+ *
+ * A match is when
  *  - the devices set for the grab are equal (this is optional).
  *  - the event types for both grabs are equal.
  *  - XXX
@@ -522,7 +522,7 @@ GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
  * Any previously existing grab that matches the new grab will be removed.
  * Adding a new grab that would override another client's grab will result in
  * a BadAccess.
- * 
+ *
  * @return Success or X error code on failure.
  */
 int
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c
index e5bcc31..5c2a32d 100644
--- a/xorg-server/dix/inpututils.c
+++ b/xorg-server/dix/inpututils.c
@@ -239,8 +239,10 @@ build_modmap_from_modkeymap(CARD8 *modmap, KeyCode *modkeymap,
         if (!modkeymap[i])
             continue;
 
+#if MAP_LENGTH < 256
         if (modkeymap[i] >= MAP_LENGTH)
             return BadValue;
+#endif
 
         if (modmap[modkeymap[i]])
             return BadValue;
diff --git a/xorg-server/dix/main.c b/xorg-server/dix/main.c
index 930a85f..09f9504 100644
--- a/xorg-server/dix/main.c
+++ b/xorg-server/dix/main.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/property.c b/xorg-server/dix/property.c
index 9f51cd0..ff7f31a 100644
--- a/xorg-server/dix/property.c
+++ b/xorg-server/dix/property.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/region.c b/xorg-server/dix/region.c
index 15f3d01..ce1014e 100644
--- a/xorg-server/dix/region.c
+++ b/xorg-server/dix/region.c
@@ -21,20 +21,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 Except as contained in this notice, the name of The Open Group shall not be
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
- 
 
-Copyright 1987, 1988, 1989 by 
-Digital Equipment Corporation, Maynard, Massachusetts. 
+
+Copyright 1987, 1988, 1989 by
+Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -118,9 +118,9 @@ Equipment Corporation.
  * there is no separate list of band start pointers.
  *
  * The y-x band representation does not minimize rectangles.  In particular,
- * if a rectangle vertically crosses a band (the rectangle has scanlines in 
+ * if a rectangle vertically crosses a band (the rectangle has scanlines in
  * the y1 to y2 area spanned by the band), then the rectangle may be broken
- * down into two or more smaller rectangles stacked one atop the other. 
+ * down into two or more smaller rectangles stacked one atop the other.
  *
  *  -----------				    -----------
  *  |         |				    |         |		    band 0
@@ -944,7 +944,7 @@ RegionUnionO(RegionPtr pReg,
 /*-
  *-----------------------------------------------------------------------
  * RegionAppend --
- * 
+ *
  *      "Append" the rgn rectangles onto the end of dstrgn, maintaining
  *      knowledge of YX-banding when it's easy.  Otherwise, dstrgn just
  *      becomes a non-y-x-banded random collection of rectangles, and not
@@ -1099,7 +1099,7 @@ QuickSortRects(BoxRec rects[], int numRects)
 /*-
  *-----------------------------------------------------------------------
  * RegionValidate --
- * 
+ *
  *      Take a ``region'' which is a non-y-x-banded random collection of
  *      rectangles, and compute a nice region which is the union of all the
  *      rectangles.
diff --git a/xorg-server/dix/resource.c b/xorg-server/dix/resource.c
index c254244..26debdb 100644
--- a/xorg-server/dix/resource.c
+++ b/xorg-server/dix/resource.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -101,7 +101,7 @@ Equipment Corporation.
  *	FreeAllResources, LookupIDByType, LookupIDByClass, GetXIDRange
  */
 
-/* 
+/*
  *      A resource ID is a 32 bit quantity, the upper 2 bits of which are
  *	off-limits for client-visible resources.  The next 8 bits are
  *      used as client ID, and the low 22 bits come from the client.
@@ -725,7 +725,7 @@ GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
 
 /**
  *  GetXIDList is called by the XC-MISC extension's MiscGetXIDList function.
- *  This function tries to find count unused XIDs for the given client.  It 
+ *  This function tries to find count unused XIDs for the given client.  It
  *  puts the IDs in the array pids and returns the number found, which should
  *  almost always be the number requested.
  *
@@ -1118,8 +1118,8 @@ FreeClientResources(ClientPtr client)
     resources = clientTable[client->index].resources;
     for (j = 0; j < clientTable[client->index].buckets; j++) {
         /* It may seem silly to update the head of this resource list as
-           we delete the members, since the entire list will be deleted any way, 
-           but there are some resource deletion functions "FreeClientPixels" for 
+           we delete the members, since the entire list will be deleted any way,
+           but there are some resource deletion functions "FreeClientPixels" for
            one which do a LookupID on another resource id (a Colormap id in this
            case), so the resource list must be kept valid up to the point that
            it is deleted, so every time we delete a resource, we must update the
diff --git a/xorg-server/dix/selection.c b/xorg-server/dix/selection.c
index e905b1e..4e994b1 100644
--- a/xorg-server/dix/selection.c
+++ b/xorg-server/dix/selection.c
@@ -26,13 +26,13 @@ Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -176,7 +176,7 @@ ProcSetSelectionOwner(ClientPtr client)
     if (rc == Success) {
         /* If the timestamp in client's request is in the past relative
            to the time stamp indicating the last time the owner of the
-           selection was set, do not set the selection, just return 
+           selection was set, do not set the selection, just return
            success. */
         if (CompareTimeStamps(time, pSel->lastTimeChanged) == EARLIER)
             return Success;
diff --git a/xorg-server/dix/swaprep.c b/xorg-server/dix/swaprep.c
index 559fe27..905fef7 100644
--- a/xorg-server/dix/swaprep.c
+++ b/xorg-server/dix/swaprep.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/swapreq.c b/xorg-server/dix/swapreq.c
index 0f6d49e..61d3ce0 100644
--- a/xorg-server/dix/swapreq.c
+++ b/xorg-server/dix/swapreq.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/tables.c b/xorg-server/dix/tables.c
index 686cddd..88b372e 100644
--- a/xorg-server/dix/tables.c
+++ b/xorg-server/dix/tables.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c
index d43ef03..d49276c 100644
--- a/xorg-server/dix/window.c
+++ b/xorg-server/dix/window.c
@@ -49,13 +49,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
 
 			All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -135,7 +135,7 @@ Equipment Corporation.
 #include <X11/Xatom.h>          /* must come after server includes */
 
 /******
- * Window stuff for server 
+ * Window stuff for server
  *
  *    CreateRootWindow, CreateWindow, ChangeWindowAttributes,
  *    GetWindowAttributes, DeleteWindow, DestroySubWindows,
@@ -633,7 +633,7 @@ RealChildHead(WindowPtr pWin)
 
 /*****
  * CreateWindow
- *    Makes a window in response to client request 
+ *    Makes a window in response to client request
  *****/
 
 WindowPtr
@@ -1038,10 +1038,10 @@ SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2)
 
 /*****
  *  ChangeWindowAttributes
- *   
+ *
  *  The value-mask specifies which attributes are to be changed; the
  *  value-list contains one value for each one bit in the mask, from least
- *  to most significant bit in the mask.  
+ *  to most significant bit in the mask.
  *****/
 
 int
@@ -1459,8 +1459,8 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
     /* We SHOULD check for an error value here XXX */
     (*pScreen->ChangeWindowAttributes) (pWin, vmaskCopy);
 
-    /* 
-       If the border contents have changed, redraw the border. 
+    /*
+       If the border contents have changed, redraw the border.
        Note that this has to be done AFTER pScreen->ChangeWindowAttributes
        for the tile to be rotated, and the correct function selected.
      */
@@ -1814,7 +1814,7 @@ ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh)
 
 /*
  * IsSiblingAboveMe
- *     returns Above if pSib above pMe in stack or Below otherwise 
+ *     returns Above if pSib above pMe in stack or Below otherwise
  */
 
 static int
@@ -1914,7 +1914,7 @@ IOverlapAnyWindow(WindowPtr pWin, BoxPtr box)
 }
 
 /*
- *   WhereDoIGoInTheStack() 
+ *   WhereDoIGoInTheStack()
  *	  Given pWin and pSib and the relationshipe smode, return
  *	  the window that pWin should go ABOVE.
  *	  If a pSib is specified:
@@ -1922,7 +1922,7 @@ IOverlapAnyWindow(WindowPtr pWin, BoxPtr box)
  *	      Below:  pWin is placed just below pSib
  *	      TopIf:  if pSib occludes pWin, then pWin is placed
  *		      at the top of the stack
- *	      BottomIf:	 if pWin occludes pSib, then pWin is 
+ *	      BottomIf:	 if pWin occludes pSib, then pWin is
  *			 placed at the bottom of the stack
  *	      Opposite: if pSib occludes pWin, then pWin is placed at the
  *			top of the stack, else if pWin occludes pSib, then
@@ -2316,7 +2316,7 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
  *    For RaiseLowest, raises the lowest mapped child (if any) that is
  *    obscured by another child to the top of the stack.  For LowerHighest,
  *    lowers the highest mapped child (if any) that is obscuring another
- *    child to the bottom of the stack.	 Exposure processing is performed 
+ *    child to the bottom of the stack.	 Exposure processing is performed
  *
  ******/
 
@@ -3243,7 +3243,7 @@ CheckWindowOptionalNeed(WindowPtr w)
         return;
     if (optional->userProps != NULL)
         return;
-    if (optional->backingBitPlanes != ~0L)
+    if (optional->backingBitPlanes != (CARD32)~0L)
         return;
     if (optional->backingPixel != 0)
         return;
@@ -3327,9 +3327,9 @@ MakeWindowOptional(WindowPtr pWin)
  * changing the window cursor (e.g. using XDefineCursor()) will not have any
  * visible effect. Only when one of the device cursors is set to None again,
  * this device's cursor will display the changed standard cursor.
- * 
+ *
  * CursorIsNone of the window struct is NOT modified if you set a device
- * cursor. 
+ * cursor.
  *
  * Assumption: If there is a node for a device in the list, the device has a
  * cursor. If the cursor is set to None, it is inherited by the parent.
@@ -3424,7 +3424,7 @@ ChangeWindowDeviceCursor(WindowPtr pWin, DeviceIntPtr pDev, CursorPtr pCursor)
     if (pOldCursor)
         FreeCursor(pOldCursor, (Cursor) 0);
 
-    /* FIXME: We SHOULD check for an error value here XXX  
+    /* FIXME: We SHOULD check for an error value here XXX
        (comment taken from ChangeWindowAttributes) */
     (*pScreen->ChangeWindowAttributes) (pWin, CWCursor);
 
@@ -3491,7 +3491,7 @@ WindowSeekDeviceCursor(WindowPtr pWin,
 }
 
 /* Return True if a parent has the same device cursor set or False if
- * otherwise 
+ * otherwise
  */
 static Bool
 WindowParentHasDeviceCursor(WindowPtr pWin,
diff --git a/xorg-server/exa/exa.c b/xorg-server/exa/exa.c
index a2995db..51d36f3 100644
--- a/xorg-server/exa/exa.c
+++ b/xorg-server/exa/exa.c
@@ -719,7 +719,7 @@ ExaBlockHandler(ScreenPtr pScreen, void *pTimeout,
     if (pExaScr->info->flags & EXA_HANDLES_PIXMAPS)
         return;
 
-    /* Try and keep the offscreen memory area tidy every now and then (at most 
+    /* Try and keep the offscreen memory area tidy every now and then (at most
      * once per second) when the server has been idle for at least 100ms.
      */
     if (pExaScr->numOffscreenAvailable > 1) {
diff --git a/xorg-server/exa/exa.h b/xorg-server/exa/exa.h
index 98d094d..949ea3a 100644
--- a/xorg-server/exa/exa.h
+++ b/xorg-server/exa/exa.h
@@ -233,7 +233,7 @@ typedef struct _ExaDriver {
      * @{
      */
     /**
-     * PrepareCopy() sets up the driver for doing a copy within video 
+     * PrepareCopy() sets up the driver for doing a copy within video
      * memory.
      *
      * @param pSrcPixmap source pixmap
@@ -471,7 +471,7 @@ typedef struct _ExaDriver {
      * UploadToScreen() can aid in pixmap migration, but is most important for
      * the performance of exaGlyphs() (antialiased font drawing) by allowing
      * pipelining of data uploads, avoiding a sync of the card after each glyph.
-     * 
+     *
      * @return TRUE if the driver successfully uploaded the data.  FALSE
      * indicates that EXA should fall back to doing the upload in software.
      *
@@ -512,7 +512,7 @@ typedef struct _ExaDriver {
      * migration, which is the read from framebuffer when evicting pixmaps from
      * framebuffer memory.  Thus, it is highly recommended, even though
      * implementations are typically complicated.
-     * 
+     *
      * @return TRUE if the driver successfully downloaded the data.  FALSE
      * indicates that EXA should fall back to doing the download in software.
      *
@@ -704,7 +704,7 @@ typedef struct _ExaDriver {
  * @{
  */
 /**
- * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support 
+ * EXA_OFFSCREEN_PIXMAPS indicates to EXA that the driver can support
  * offscreen pixmaps.
  */
 #define EXA_OFFSCREEN_PIXMAPS		(1 << 0)
diff --git a/xorg-server/exa/exa_accel.c b/xorg-server/exa/exa_accel.c
index 9c742bd..5aa7d10 100644
--- a/xorg-server/exa/exa_accel.c
+++ b/xorg-server/exa/exa_accel.c
@@ -413,7 +413,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable,
 
         if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
                                            pGC->fillStyle, pGC->alu,
-                                           pGC->clientClipType)) {
+                                           pGC->clientClip != NULL)) {
             dstregion = RegionCreate(NullBox, 0);
             RegionCopy(dstregion, srcregion);
             RegionTranslate(dstregion, dst_off_x - dx - src_off_x,
@@ -771,7 +771,7 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
 
 static Bool exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion,
                                Pixel pixel, CARD32 planemask, CARD32 alu,
-                               unsigned int clientClipType);
+                               Bool hasClientClip);
 
 static void
 exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect)
@@ -816,11 +816,11 @@ exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect)
         if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) &&
              exaFillRegionSolid(pDrawable, pReg, pGC->fillStyle == FillSolid ?
                                 pGC->fgPixel : pGC->tile.pixel, pGC->planemask,
-                                pGC->alu, pGC->clientClipType)) ||
+                                pGC->alu, pGC->clientClip != NULL)) ||
             (pGC->fillStyle == FillTiled && !pGC->tileIsPixel &&
              exaFillRegionTiled(pDrawable, pReg, pGC->tile.pixmap, &pGC->patOrg,
                                 pGC->planemask, pGC->alu,
-                                pGC->clientClipType))) {
+                                pGC->clientClip != NULL))) {
             goto out;
         }
     }
@@ -990,7 +990,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
 static Bool
 exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
-                   CARD32 planemask, CARD32 alu, unsigned int clientClipType)
+                   CARD32 planemask, CARD32 alu, Bool hasClientClip)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
@@ -1013,8 +1013,7 @@ exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
         pixmaps[0].pPix = pPixmap;
         pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillSolid,
                                                 alu,
-                                                clientClipType) ? NULL :
-            pRegion;
+                                                hasClientClip) ? NULL : pRegion;
 
         exaDoMigration(pixmaps, 1, TRUE);
     }
@@ -1074,7 +1073,7 @@ exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
 Bool
 exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
                    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu,
-                   unsigned int clientClipType)
+                   Bool hasClientClip)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap;
@@ -1096,7 +1095,7 @@ exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
     if (tileWidth == 1 && tileHeight == 1)
         return exaFillRegionSolid(pDrawable, pRegion,
                                   exaGetPixmapFirstPixel(pTile), planemask,
-                                  alu, clientClipType);
+                                  alu, hasClientClip);
 
     pPixmap = exaGetDrawablePixmap(pDrawable);
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
@@ -1113,8 +1112,7 @@ exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
         pixmaps[0].pPix = pPixmap;
         pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillTiled,
                                                 alu,
-                                                clientClipType) ? NULL :
-            pRegion;
+                                                hasClientClip) ? NULL : pRegion;
         pixmaps[1].as_dst = FALSE;
         pixmaps[1].as_src = TRUE;
         pixmaps[1].pPix = pTile;
diff --git a/xorg-server/exa/exa_glyphs.c b/xorg-server/exa/exa_glyphs.c
index aa71b21..41f3694 100644
--- a/xorg-server/exa/exa_glyphs.c
+++ b/xorg-server/exa/exa_glyphs.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Red Hat
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -33,7 +33,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author: Owen Taylor <otaylor at fishsoup.net>
@@ -318,8 +318,8 @@ exaGlyphCacheHashRemove(ExaGlyphCachePtr cache, int pos)
              * are:
              *
              * |   XXXXXXXXXX             |
-             *     i         j            
-             *                            
+             *     i         j
+             *
              * |XXX                   XXXX|
              *     j                  i
              *
diff --git a/xorg-server/exa/exa_priv.h b/xorg-server/exa/exa_priv.h
index 88bfd37..ca4db72 100644
--- a/xorg-server/exa/exa_priv.h
+++ b/xorg-server/exa/exa_priv.h
@@ -455,12 +455,11 @@ ExaCheckAddTraps(PicturePtr pPicture,
 static _X_INLINE Bool
 exaGCReadsDestination(DrawablePtr pDrawable, unsigned long planemask,
                       unsigned int fillStyle, unsigned char alu,
-                      unsigned int clientClipType)
+                      Bool clientClip)
 {
     return ((alu != GXcopy && alu != GXclear && alu != GXset &&
              alu != GXcopyInverted) || fillStyle == FillStippled ||
-            clientClipType != CT_NONE ||
-            !EXA_PM_IS_SOLID(pDrawable, planemask));
+            clientClip != FALSE || !EXA_PM_IS_SOLID(pDrawable, planemask));
 }
 
 void
@@ -470,7 +469,7 @@ Bool
 
 exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
                    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu,
-                   unsigned int clientClipType);
+                   Bool clientClip);
 
 void
 
diff --git a/xorg-server/exa/exa_render.c b/xorg-server/exa/exa_render.c
index c4edf40..e3e5526 100644
--- a/xorg-server/exa/exa_render.c
+++ b/xorg-server/exa/exa_render.c
@@ -559,7 +559,7 @@ exaCompositeRects(CARD8 op,
         box.y2 = y2 < MAXSHORT ? y2 : MAXSHORT;
 
         /* The pixmap migration code relies on pendingDamage indicating
-         * the bounds of the current rendering, so we need to force 
+         * the bounds of the current rendering, so we need to force
          * the actual damage into that region before we do anything, and
          * (see use of DamagePendingRegion in exaCopyDirty)
          */
@@ -613,7 +613,7 @@ exaCompositeRects(CARD8 op,
     /************************************************************/
 
     if (!pMask) {
-        /* Now we have to flush the damage out from pendingDamage => damage 
+        /* Now we have to flush the damage out from pendingDamage => damage
          * Calling DamageRegionProcessPending has that effect.
          */
 
diff --git a/xorg-server/exa/exa_unaccel.c b/xorg-server/exa/exa_unaccel.c
index b0c6344..73eada9 100644
--- a/xorg-server/exa/exa_unaccel.c
+++ b/xorg-server/exa/exa_unaccel.c
@@ -107,7 +107,7 @@ ExaCheckPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
     if (!pExaScr->prepare_access_reg || !pExaPixmap->pDamage ||
         exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
-                              pGC->alu, pGC->clientClipType))
+                              pGC->alu, pGC->clientClip != NULL))
         exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
     else
         pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST,
@@ -143,7 +143,7 @@ ExaCheckCopyNtoN(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
     if (pExaScr->prepare_access_reg &&
         !exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
-                               pGC->alu, pGC->clientClipType) &&
+                               pGC->alu, pGC->clientClip != NULL) &&
         RegionInitBoxes(&reg, pbox, nbox)) {
         PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
 
@@ -179,10 +179,9 @@ ExaFallbackPrepareReg(DrawablePtr pDrawable,
     ExaScreenPriv(pScreen);
 
     if (pExaScr->prepare_access_reg &&
-        !(checkReads && exaGCReadsDestination(pDrawable,
-                                              pGC->planemask,
-                                              pGC->fillStyle,
-                                              pGC->alu, pGC->clientClipType))) {
+        !(checkReads && exaGCReadsDestination(pDrawable, pGC->planemask,
+                                              pGC->fillStyle, pGC->alu,
+                                              pGC->clientClip != NULL))) {
         BoxRec box;
         RegionRec reg;
         int xoff, yoff;
diff --git a/xorg-server/fb/Makefile.am b/xorg-server/fb/Makefile.am
index 752eabe..65b5d94 100644
--- a/xorg-server/fb/Makefile.am
+++ b/xorg-server/fb/Makefile.am
@@ -44,8 +44,6 @@ libfb_la_SOURCES = 	\
 	fbseg.c		\
 	fbsetsp.c	\
 	fbsolid.c	\
-	fbstipple.c	\
-	fbtile.c	\
 	fbtrap.c	\
 	fbutil.c	\
 	fbwindow.c
diff --git a/xorg-server/fb/fb.h b/xorg-server/fb/fb.h
index d176bb3..ab110f3 100644
--- a/xorg-server/fb/fb.h
+++ b/xorg-server/fb/fb.h
@@ -83,11 +83,7 @@
 #define FB_SHIFT    LOG2_BITMAP_PAD
 #endif
 
-#if FB_SHIFT < LOG2_BITMAP_PAD
-error FB_SHIFT must be >= LOG2_BITMAP_PAD
-#endif
 #define FB_UNIT	    (1 << FB_SHIFT)
-#define FB_HALFUNIT (1 << (FB_SHIFT-1))
 #define FB_MASK	    (FB_UNIT - 1)
 #define FB_ALLONES  ((FbBits) -1)
 #if GLYPHPADBYTES != 4
@@ -105,37 +101,15 @@ error FB_SHIFT must be >= LOG2_BITMAP_PAD
 #define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
 #define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
 #define FbFullMask(n)   ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
-#if FB_SHIFT == 6
-#ifdef WIN32
-typedef unsigned __int64 FbBits;
-#else
-#if defined(__alpha__) || defined(__alpha) || \
-      defined(ia64) || defined(__ia64__) || \
-      defined(__sparc64__) || defined(_LP64) || \
-      defined(__s390x__) || \
-      defined(amd64) || defined (__amd64__) || \
-      defined (__powerpc64__)
-typedef unsigned long FbBits;
-#else
-typedef unsigned long long FbBits;
-#endif
-#endif
-#endif
 
 #if FB_SHIFT == 5
 typedef CARD32 FbBits;
-#endif
-
-#if FB_SHIFT == 4
-typedef CARD16 FbBits;
+#else
+#error "Unsupported FB_SHIFT"
 #endif
 
 #if LOG2_BITMAP_PAD == FB_SHIFT
 typedef FbBits FbStip;
-#else
-#if LOG2_BITMAP_PAD == 5
-typedef CARD32 FbStip;
-#endif
 #endif
 
 typedef int FbStride;
@@ -264,122 +238,8 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
     n >>= FB_SHIFT; \
 }
 
-#if FB_SHIFT == 6
-#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
-    case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 4): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break;
-
-#define FbDoRightMaskByteRRop6Cases(dst,xor) \
-    case 4: \
-	FbStorePart(dst,0,CARD32,xor); \
-	break; \
-    case 5: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD8,xor); \
-	break; \
-    case 6: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD16,xor); \
-	break; \
-    case 7: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD16,xor); \
-	FbStorePart(dst,6,CARD8,xor); \
-	break;
-#else
-#define FbDoLeftMaskByteRRop6Cases(dst,xor)
-#define FbDoRightMaskByteRRop6Cases(dst,xor)
-#endif
-
 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
     switch (lb) { \
-    FbDoLeftMaskByteRRop6Cases(dst,xor) \
     case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
 	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
 	break; \
@@ -416,7 +276,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 	FbStorePart(dst,0,CARD16,xor); \
 	FbStorePart(dst,2,CARD8,xor); \
 	break; \
-    FbDoRightMaskByteRRop6Cases(dst,xor) \
     default: \
 	WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
     } \
@@ -470,21 +329,7 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 	FbLaneCase2((n)>>2,a,(o)+2)					\
     }
 
-#define FbLaneCase8(n,a,o)						\
-    if ((n) == 0x0ff) {							\
-	*(FbBits *) ((a)+(o)) = fgxor;					\
-    } else {								\
-	FbLaneCase4((n)&15,a,o)						\
-	FbLaneCase4((n)>>4,a,(o)+4)					\
-    }
-
-#if FB_SHIFT == 6
-#define FbLaneCase(n,a)   FbLaneCase8(n,(CARD8 *) (a),0)
-#endif
-
-#if FB_SHIFT == 5
 #define FbLaneCase(n,a)   FbLaneCase4(n,(CARD8 *) (a),0)
-#endif
 
 /* Rotate a filled pixel value to the specified alignement */
 #define FbRot24(p,b)	    (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
@@ -497,19 +342,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 #define FbPrev24Stip(p)	(FbRot24(p,FB_STIP_UNIT%24))
 
 /* step a rotation value to the next/previous rotation value */
-#if FB_UNIT == 64
-#define FbNext24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
-#define FbPrev24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define FbFirst24Rot(x)		(((x) + 8) % 24)
-#else
-#define FbFirst24Rot(x)		((x) % 24)
-#endif
-
-#endif
-
-#if FB_UNIT == 32
 #define FbNext24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
 #define FbPrev24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
 
@@ -518,7 +350,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 #else
 #define FbFirst24Rot(x)		((x) % 24)
 #endif
-#endif
 
 #define FbNext24RotStip(r)        ((r) == 0 ? 16 : (r) - 8)
 #define FbPrev24RotStip(r)        ((r) == 16 ? 0 : (r) + 8)
@@ -621,7 +452,6 @@ typedef struct {
     FbBits bgand, bgxor;        /* for stipples */
     FbBits fg, bg, pm;          /* expanded and filled */
     unsigned int dashLength;    /* total of all dash elements */
-    unsigned char evenStipple;  /* stipple is even */
     unsigned char bpp;          /* current drawable bpp */
 } FbGCPrivRec, *FbGCPrivPtr;
 
@@ -714,11 +544,6 @@ typedef struct {
  * Accelerated tiles are power of 2 width <= FB_UNIT
  */
 #define FbEvenTile(w)	    ((w) <= FB_UNIT && FbPowerOfTwo(w))
-/*
- * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
- * with dstBpp a power of 2 as well
- */
-#define FbEvenStip(w,bpp)   ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
 
 /*
  * fb24_32.c
@@ -925,13 +750,6 @@ fbArc24(FbBits * dst,
         int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
 
 extern _X_EXPORT void
-
-fbGlyph24(FbBits * dstLine,
-          FbStride dstStride,
-          int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
-
-extern _X_EXPORT void
-
 fbPolyline24(DrawablePtr pDrawable,
              GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
 
@@ -1220,9 +1038,6 @@ fbGetSpans(DrawablePtr pDrawable,
  * fbglyph.c
  */
 
-extern _X_EXPORT Bool
- fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height);
-
 extern _X_EXPORT void
 
 fbPolyGlyphBlt(DrawablePtr pDrawable,
@@ -1283,15 +1098,6 @@ fbGetImage(DrawablePtr pDrawable,
  */
 
 extern _X_EXPORT void
-
-fbZeroLine(DrawablePtr pDrawable,
-           GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
-
-extern _X_EXPORT void
- fbZeroSegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs);
-
-extern _X_EXPORT void
-
 fbPolyLine(DrawablePtr pDrawable,
            GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
 
@@ -1339,36 +1145,12 @@ extern _X_EXPORT RegionPtr
 
 extern _X_EXPORT void
 
-fbDots(FbBits * dstOrig,
-       FbStride dstStride,
-       int dstBpp,
-       BoxPtr pBox,
-       xPoint * pts,
-       int npt,
-       int xorg, int yorg, int xoff, int yoff, FbBits andOrig, FbBits xorOrig);
-
-extern _X_EXPORT void
-
 fbPolyPoint(DrawablePtr pDrawable,
             GCPtr pGC, int mode, int npt, xPoint * pptInit);
 
 /*
  * fbpush.c
  */
-extern _X_EXPORT void
-
-fbPushPattern(DrawablePtr pDrawable,
-              GCPtr pGC,
-              FbStip * src,
-              FbStride srcStride,
-              int srcX, int x, int y, int width, int height);
-
-extern _X_EXPORT void
-
-fbPushFill(DrawablePtr pDrawable,
-           GCPtr pGC,
-           FbStip * src,
-           FbStride srcStride, int srcX, int x, int y, int width, int height);
 
 extern _X_EXPORT void
 
@@ -1462,34 +1244,20 @@ typedef void FbBres(DrawablePtr pDrawable,
                     int signdy,
                     int axis, int x, int y, int e, int e1, int e3, int len);
 
-extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
+extern _X_EXPORT void
+fbSegment(DrawablePtr pDrawable,
+          GCPtr pGC,
+          int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
 
 /*
  * fbsetsp.c
  */
 
 extern _X_EXPORT void
-
 fbSetSpans(DrawablePtr pDrawable,
            GCPtr pGC,
            char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
 
-extern _X_EXPORT FbBres *fbSelectBres(DrawablePtr pDrawable, GCPtr pGC);
-
-extern _X_EXPORT void
-
-fbBres(DrawablePtr pDrawable,
-       GCPtr pGC,
-       int dashOffset,
-       int signdx,
-       int signdy, int axis, int x, int y, int e, int e1, int e3, int len);
-
-extern _X_EXPORT void
-
-fbSegment(DrawablePtr pDrawable,
-          GCPtr pGC,
-          int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
-
 /*
  * fbsolid.c
  */
@@ -1507,104 +1275,10 @@ fbSolid24(FbBits * dst,
           int dstX, int width, int height, FbBits and, FbBits xor);
 
 /*
- * fbstipple.c
- */
-
-extern _X_EXPORT void
- fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n);
-
-extern _X_EXPORT void
-
-fbEvenStipple(FbBits * dst,
-              FbStride dstStride,
-              int dstX,
-              int dstBpp,
-              int width,
-              int height,
-              FbStip * stip,
-              FbStride stipStride,
-              int stipHeight,
-              FbBits fgand,
-              FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbOddStipple(FbBits * dst,
-             FbStride dstStride,
-             int dstX,
-             int dstBpp,
-             int width,
-             int height,
-             FbStip * stip,
-             FbStride stipStride,
-             int stipWidth,
-             int stipHeight,
-             FbBits fgand,
-             FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbStipple(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int dstBpp,
-          int width,
-          int height,
-          FbStip * stip,
-          FbStride stipStride,
-          int stipWidth,
-          int stipHeight,
-          Bool even,
-          FbBits fgand,
-          FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-/*
- * fbtile.c
- */
-
-extern _X_EXPORT void
-
-fbEvenTile(FbBits * dst,
-           FbStride dstStride,
-           int dstX,
-           int width,
-           int height,
-           FbBits * tile,
-           FbStride tileStride,
-           int tileHeight, int alu, FbBits pm, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbOddTile(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int width,
-          int height,
-          FbBits * tile,
-          FbStride tileStride,
-          int tileWidth,
-          int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbTile(FbBits * dst,
-       FbStride dstStride,
-       int dstX,
-       int width,
-       int height,
-       FbBits * tile,
-       FbStride tileStride,
-       int tileWidth,
-       int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
-
-/*
  * fbutil.c
  */
 extern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp);
 
-extern _X_EXPORT void
- fbReduceRasterOp(int rop, FbBits fg, FbBits pm, FbBits * andp, FbBits * xorp);
-
 #ifdef FB_ACCESS_WRAPPER
 extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
 extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
diff --git a/xorg-server/fb/fb24_32.c b/xorg-server/fb/fb24_32.c
index ecb3951..b95019e 100644
--- a/xorg-server/fb/fb24_32.c
+++ b/xorg-server/fb/fb24_32.c
@@ -15,7 +15,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/fb/fb24_32.h b/xorg-server/fb/fb24_32.h
index b357edf..77eef23 100644
--- a/xorg-server/fb/fb24_32.h
+++ b/xorg-server/fb/fb24_32.h
@@ -15,7 +15,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/fb/fbbits.c b/xorg-server/fb/fbbits.c
index ac44f3e..d7d089c 100644
--- a/xorg-server/fb/fbbits.c
+++ b/xorg-server/fb/fbbits.c
@@ -70,9 +70,6 @@
 #define POLYSEGMENT fbPolySegment16
 #define BITS	    CARD16
 #define BITS2	    CARD32
-#if FB_SHIFT == 6
-#define BITS4	    FbBits
-#endif
 
 #include "fbbits.h"
 
@@ -85,9 +82,6 @@
 #undef POLYSEGMENT
 #undef BITS
 #undef BITS2
-#if FB_SHIFT == 6
-#undef BITS4
-#endif
 
 #define BRESSOLID   fbBresSolid24
 #define BRESDASH    fbBresDash24
@@ -155,9 +149,6 @@
 #define POLYLINE    fbPolyline32
 #define POLYSEGMENT fbPolySegment32
 #define BITS	    CARD32
-#if FB_SHIFT == 6
-#define BITS2	    FbBits
-#endif
 
 #include "fbbits.h"
 
@@ -169,6 +160,3 @@
 #undef POLYLINE
 #undef POLYSEGMENT
 #undef BITS
-#if FB_SHIFT == 6
-#undef BITS2
-#endif
diff --git a/xorg-server/fb/fbblt.c b/xorg-server/fb/fbblt.c
index c615106..b412365 100644
--- a/xorg-server/fb/fbblt.c
+++ b/xorg-server/fb/fbblt.c
@@ -520,277 +520,12 @@ fbBlt24(FbBits * srcLine,
 #endif
 }
 
-#if FB_SHIFT == FB_STIP_SHIFT + 1
-
-/*
- * Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
- * creating an ring of values stepped through for each line
- */
-
-void
-fbBltOdd(FbBits * srcLine,
-         FbStride srcStrideEven,
-         FbStride srcStrideOdd,
-         int srcXEven,
-         int srcXOdd,
-         FbBits * dstLine,
-         FbStride dstStrideEven,
-         FbStride dstStrideOdd,
-         int dstXEven,
-         int dstXOdd, int width, int height, int alu, FbBits pm, int bpp)
-{
-    FbBits *src;
-    int leftShiftEven, rightShiftEven;
-    FbBits startmaskEven, endmaskEven;
-    int nmiddleEven;
-
-    FbBits *dst;
-    int leftShiftOdd, rightShiftOdd;
-    FbBits startmaskOdd, endmaskOdd;
-    int nmiddleOdd;
-
-    int leftShift, rightShift;
-    FbBits startmask, endmask;
-    int nmiddle;
-
-    int srcX, dstX;
-
-    FbBits bits, bits1;
-    int n;
-
-    Bool destInvarient;
-    Bool even;
-
-    FbDeclareMergeRop();
-
-    FbInitializeMergeRop(alu, pm);
-    destInvarient = FbDestInvarientMergeRop();
-
-    srcLine += srcXEven >> FB_SHIFT;
-    dstLine += dstXEven >> FB_SHIFT;
-    srcXEven &= FB_MASK;
-    dstXEven &= FB_MASK;
-    srcXOdd &= FB_MASK;
-    dstXOdd &= FB_MASK;
-
-    FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
-    FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
-
-    even = TRUE;
-    InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven);
-    InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd);
-    while (height--) {
-        src = srcLine;
-        dst = dstLine;
-        if (even) {
-            srcX = srcXEven;
-            dstX = dstXEven;
-            startmask = startmaskEven;
-            endmask = endmaskEven;
-            nmiddle = nmiddleEven;
-            leftShift = leftShiftEven;
-            rightShift = rightShiftEven;
-            srcLine += srcStrideEven;
-            dstLine += dstStrideEven;
-            even = FALSE;
-        }
-        else {
-            srcX = srcXOdd;
-            dstX = dstXOdd;
-            startmask = startmaskOdd;
-            endmask = endmaskOdd;
-            nmiddle = nmiddleOdd;
-            leftShift = leftShiftOdd;
-            rightShift = rightShiftOdd;
-            srcLine += srcStrideOdd;
-            dstLine += dstStrideOdd;
-            even = TRUE;
-        }
-        if (srcX == dstX) {
-            if (startmask) {
-                bits = READ(src++);
-                WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), startmask));
-                dst++;
-            }
-            n = nmiddle;
-            if (destInvarient) {
-                while (n--) {
-                    bits = READ(src++);
-                    WRITE(dst, FbDoDestInvarientMergeRop(bits));
-                    dst++;
-                }
-            }
-            else {
-                while (n--) {
-                    bits = READ(src++);
-                    WRITE(dst, FbDoMergeRop(bits, READ(dst)));
-                    dst++;
-                }
-            }
-            if (endmask) {
-                bits = READ(src);
-                WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), endmask));
-            }
-        }
-        else {
-            bits = 0;
-            if (srcX > dstX)
-                bits = READ(src++);
-            if (startmask) {
-                bits1 = FbScrLeft(bits, leftShift);
-                bits = READ(src++);
-                bits1 |= FbScrRight(bits, rightShift);
-                WRITE(dst, FbDoMaskMergeRop(bits1, READ(dst), startmask));
-                dst++;
-            }
-            n = nmiddle;
-            if (destInvarient) {
-                while (n--) {
-                    bits1 = FbScrLeft(bits, leftShift);
-                    bits = READ(src++);
-                    bits1 |= FbScrRight(bits, rightShift);
-                    WRITE(dst, FbDoDestInvarientMergeRop(bits1));
-                    dst++;
-                }
-            }
-            else {
-                while (n--) {
-                    bits1 = FbScrLeft(bits, leftShift);
-                    bits = READ(src++);
-                    bits1 |= FbScrRight(bits, rightShift);
-                    WRITE(dst, FbDoMergeRop(bits1, READ(dst)));
-                    dst++;
-                }
-            }
-            if (endmask) {
-                bits1 = FbScrLeft(bits, leftShift);
-                if (FbScrLeft(endmask, rightShift)) {
-                    bits = READ(src);
-                    bits1 |= FbScrRight(bits, rightShift);
-                }
-                WRITE(dst, FbDoMaskMergeRop(bits1, READ(dst), endmask));
-            }
-        }
-    }
-}
-
-void
-fbBltOdd24(FbBits * srcLine,
-           FbStride srcStrideEven,
-           FbStride srcStrideOdd,
-           int srcXEven,
-           int srcXOdd,
-           FbBits * dstLine,
-           FbStride dstStrideEven,
-           FbStride dstStrideOdd,
-           int dstXEven, int dstXOdd, int width, int height, int alu, FbBits pm)
-{
-    Bool even = TRUE;
-
-    while (height--) {
-        if (even) {
-            fbBlt24Line(srcLine, srcXEven, dstLine, dstXEven,
-                        width, alu, pm, FALSE);
-            srcLine += srcStrideEven;
-            dstLine += dstStrideEven;
-            even = FALSE;
-        }
-        else {
-            fbBlt24Line(srcLine, srcXOdd, dstLine, dstXOdd,
-                        width, alu, pm, FALSE);
-            srcLine += srcStrideOdd;
-            dstLine += dstStrideOdd;
-            even = TRUE;
-        }
-    }
-}
-
-#endif
-
-#if FB_STIP_SHIFT != FB_SHIFT
-void
-fbSetBltOdd(FbStip * stip,
-            FbStride stipStride,
-            int srcX,
-            FbBits ** bits,
-            FbStride * strideEven,
-            FbStride * strideOdd, int *srcXEven, int *srcXOdd)
-{
-    int srcAdjust;
-    int strideAdjust;
-
-    /*
-     * bytes needed to align source
-     */
-    srcAdjust = (((int) stip) & (FB_MASK >> 3));
-    /*
-     * FbStip units needed to align stride
-     */
-    strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
-
-    *bits = (FbBits *) ((char *) stip - srcAdjust);
-    if (srcAdjust) {
-        *strideEven = FbStipStrideToBitsStride(stipStride + 1);
-        *strideOdd = FbStipStrideToBitsStride(stipStride);
-
-        *srcXEven = srcX + (srcAdjust << 3);
-        *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
-    }
-    else {
-        *strideEven = FbStipStrideToBitsStride(stipStride);
-        *strideOdd = FbStipStrideToBitsStride(stipStride + 1);
-
-        *srcXEven = srcX;
-        *srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
-    }
-}
-#endif
-
 void
 fbBltStip(FbStip * src, FbStride srcStride,     /* in FbStip units, not FbBits units */
           int srcX, FbStip * dst, FbStride dstStride,   /* in FbStip units, not FbBits units */
           int dstX, int width, int height, int alu, FbBits pm, int bpp)
 {
-#if FB_STIP_SHIFT != FB_SHIFT
-    if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
-        FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst)) {
-        FbStride srcStrideEven, srcStrideOdd;
-        FbStride dstStrideEven, dstStrideOdd;
-        int srcXEven, srcXOdd;
-        int dstXEven, dstXOdd;
-        FbBits *s, *d;
-        int sx, dx;
-
-        src += srcX >> FB_STIP_SHIFT;
-        srcX &= FB_STIP_MASK;
-        dst += dstX >> FB_STIP_SHIFT;
-        dstX &= FB_STIP_MASK;
-
-        fbSetBltOdd(src, srcStride, srcX,
-                    &s, &srcStrideEven, &srcStrideOdd, &srcXEven, &srcXOdd);
-
-        fbSetBltOdd(dst, dstStride, dstX,
-                    &d, &dstStrideEven, &dstStrideOdd, &dstXEven, &dstXOdd);
-
-        if (bpp == 24 && !FbCheck24Pix(pm)) {
-            fbBltOdd24(s, srcStrideEven, srcStrideOdd,
-                       srcXEven, srcXOdd,
-                       d, dstStrideEven, dstStrideOdd,
-                       dstXEven, dstXOdd, width, height, alu, pm);
-        }
-        else {
-            fbBltOdd(s, srcStrideEven, srcStrideOdd,
-                     srcXEven, srcXOdd,
-                     d, dstStrideEven, dstStrideOdd,
-                     dstXEven, dstXOdd, width, height, alu, pm, bpp);
-        }
-    }
-    else
-#endif
-    {
-        fbBlt((FbBits *) src, FbStipStrideToBitsStride(srcStride),
-              srcX,
-              (FbBits *) dst, FbStipStrideToBitsStride(dstStride),
-              dstX, width, height, alu, pm, bpp, FALSE, FALSE);
-    }
+    fbBlt((FbBits *) src, FbStipStrideToBitsStride(srcStride), srcX,
+          (FbBits *) dst, FbStipStrideToBitsStride(dstStride), dstX,
+          width, height, alu, pm, bpp, FALSE, FALSE);
 }
diff --git a/xorg-server/fb/fbbltone.c b/xorg-server/fb/fbbltone.c
index bfcb5a2..d089a43 100644
--- a/xorg-server/fb/fbbltone.c
+++ b/xorg-server/fb/fbbltone.c
@@ -26,6 +26,101 @@
 
 #include "fb.h"
 
+/*
+ * Stipple masks are independent of bit/byte order as long
+ * as bitorder == byteorder.  FB doesn't handle the case
+ * where these differ
+ */
+#define BitsMask(x,w)	((FB_ALLONES << ((x) & FB_MASK)) & \
+			 (FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_MASK)))
+
+#define Mask(x,w)	BitsMask((x)*(w),(w))
+
+#define SelMask(b,n,w)	((((b) >> n) & 1) * Mask(n,w))
+
+#define C1(b,w) \
+    (SelMask(b,0,w))
+
+#define C2(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w))
+
+#define C4(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w) | \
+     SelMask(b,2,w) | \
+     SelMask(b,3,w))
+
+#define C8(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w) | \
+     SelMask(b,2,w) | \
+     SelMask(b,3,w) | \
+     SelMask(b,4,w) | \
+     SelMask(b,5,w) | \
+     SelMask(b,6,w) | \
+     SelMask(b,7,w))
+
+static const FbBits fbStipple8Bits[256] = {
+    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
+    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
+    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
+    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
+    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
+    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
+    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
+    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
+    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
+    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
+    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
+    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
+    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
+    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
+    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
+    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
+    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
+    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
+    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
+    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
+    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
+    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
+    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
+    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
+    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
+    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
+    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
+    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
+    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
+    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
+    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
+    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
+    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
+    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
+    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
+    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
+    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
+    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
+    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
+    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
+    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
+    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
+    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
+};
+
+static const FbBits fbStipple4Bits[16] = {
+    C4(0, 8), C4(1, 8), C4(2, 8), C4(3, 8), C4(4, 8), C4(5, 8),
+    C4(6, 8), C4(7, 8), C4(8, 8), C4(9, 8), C4(10, 8), C4(11, 8),
+    C4(12, 8), C4(13, 8), C4(14, 8), C4(15, 8),
+};
+
+static const FbBits fbStipple2Bits[4] = {
+    C2(0, 16), C2(1, 16), C2(2, 16), C2(3, 16),
+};
+
+static const FbBits fbStipple1Bits[2] = {
+    C1(0, 32), C1(1, 32),
+};
+
 #ifdef __clang__
 /* shift overflow is intentional */
 #pragma clang diagnostic ignored "-Wshift-overflow"
@@ -62,85 +157,6 @@
 	bits = (src < srcEnd ? READ(src++) : 0); \
 }
 
-#define LaneCases1(n,a)	    case n: FbLaneCase(n,a); break
-#define LaneCases2(n,a)	    LaneCases1(n,a); LaneCases1(n+1,a)
-#define LaneCases4(n,a)	    LaneCases2(n,a); LaneCases2(n+2,a)
-#define LaneCases8(n,a)	    LaneCases4(n,a); LaneCases4(n+4,a)
-#define LaneCases16(n,a)    LaneCases8(n,a); LaneCases8(n+8,a)
-#define LaneCases32(n,a)    LaneCases16(n,a); LaneCases16(n+16,a)
-#define LaneCases64(n,a)    LaneCases32(n,a); LaneCases32(n+32,a)
-#define LaneCases128(n,a)   LaneCases64(n,a); LaneCases64(n+64,a)
-#define LaneCases256(n,a)   LaneCases128(n,a); LaneCases128(n+128,a)
-
-#if FB_SHIFT == 6
-#define LaneCases(a)	    LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
-#define LaneCases(a)	    LaneCases16(0,a)
-#endif
-
-#if FB_SHIFT == 6
-CARD8 fb8Lane[256] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
-        21,
-    22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
-    60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
-    79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
-    98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
-        113, 114, 115,
-    116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
-        131, 132, 133,
-    134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
-        149, 150, 151,
-    152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
-        167, 168, 169,
-    170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
-        185, 186, 187,
-    188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
-        203, 204, 205,
-    206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
-        221, 222, 223,
-    224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
-        239, 240, 241,
-    242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-};
-
-CARD8 fb16Lane[256] = {
-    0x00, 0x03, 0x0c, 0x0f,
-    0x30, 0x33, 0x3c, 0x3f,
-    0xc0, 0xc3, 0xcc, 0xcf,
-    0xf0, 0xf3, 0xfc, 0xff,
-};
-
-CARD8 fb32Lane[16] = {
-    0x00, 0x0f, 0xf0, 0xff,
-};
-#endif
-
-#if FB_SHIFT == 5
-CARD8 fb8Lane[16] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-CARD8 fb16Lane[16] = {
-    0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-CARD8 fb32Lane[16] = {
-    0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-#endif
-
-CARD8 *fbLaneTable[33] = {
-    0, 0, 0, 0, 0, 0, 0, 0,
-    fb8Lane, 0, 0, 0, 0, 0, 0, 0,
-    fb16Lane, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0,
-    fb32Lane
-};
-
 void
 fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
          int srcX,              /* bit position of source */
@@ -169,7 +185,6 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     Bool transparent;           /* accelerate 0 nop */
     int srcinc;                 /* source units consumed */
     Bool endNeedsLoad = FALSE;  /* need load for endmask */
-    CARD8 *fbLane;
     int startbyte, endbyte;
 
     if (dstBpp == 24) {
@@ -191,7 +206,7 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     pixelsPerDst = FB_UNIT / dstBpp;
 
     /*
-     * Number of source stipple patterns in FbStip 
+     * Number of source stipple patterns in FbStip
      */
     unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
 
@@ -233,15 +248,26 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
      * Get pointer to stipple mask array for this depth
      */
     fbBits = 0;                 /* unused */
-    if (pixelsPerDst <= 8)
-        fbBits = fbStippleTable[pixelsPerDst];
-    fbLane = 0;
-    if (transparent && fgand == 0 && dstBpp >= 8)
-        fbLane = fbLaneTable[dstBpp];
+    switch (pixelsPerDst) {
+    case 8:
+        fbBits = fbStipple8Bits;
+        break;
+    case 4:
+        fbBits = fbStipple4Bits;
+        break;
+    case 2:
+        fbBits = fbStipple2Bits;
+        break;
+    case 1:
+        fbBits = fbStipple1Bits;
+        break;
+    default:
+        return;
+    }
 
     /*
-     * Compute total number of destination words written, but 
-     * don't count endmask 
+     * Compute total number of destination words written, but
+     * don't count endmask
      */
     nDst = nmiddle;
     if (startmask)
@@ -287,21 +313,11 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
              * Consume stipple bits for startmask
              */
             if (startmask) {
-#if FB_UNIT > 32
-                if (pixelsPerDst == 16)
-                    mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-                else
-#endif
-                    mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-                if (fbLane) {
-                    fbTransparentSpan(dst, mask & startmask, fgxor, 1);
-                }
-                else {
-                    if (mask || !transparent)
-                        FbDoLeftMaskByteStippleRRop(dst, mask,
-                                                    fgand, fgxor, bgand, bgxor,
-                                                    startbyte, startmask);
-                }
+                mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+                if (mask || !transparent)
+                    FbDoLeftMaskByteStippleRRop(dst, mask,
+                                                fgand, fgxor, bgand, bgxor,
+                                                startbyte, startmask);
                 bits = FbStipLeft(bits, pixelsPerDst);
                 dst++;
                 n--;
@@ -314,41 +330,22 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
                 w -= n;
                 if (copy) {
                     while (n--) {
-#if FB_UNIT > 32
-                        if (pixelsPerDst == 16)
-                            mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-                        else
-#endif
-                            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+                        mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
                         WRITE(dst, FbOpaqueStipple(mask, fgxor, bgxor));
                         dst++;
                         bits = FbStipLeft(bits, pixelsPerDst);
                     }
                 }
                 else {
-                    if (fbLane) {
-                        while (bits && n) {
-                            switch (fbLane[FbLeftStipBits(bits, pixelsPerDst)]) {
-                                LaneCases((CARD8 *) dst);
-                            }
-                            bits = FbStipLeft(bits, pixelsPerDst);
-                            dst++;
-                            n--;
-                        }
-                        dst += n;
-                    }
-                    else {
-                        while (n--) {
-                            left = FbLeftStipBits(bits, pixelsPerDst);
-                            if (left || !transparent) {
-                                mask = fbBits[left];
-                                WRITE(dst, FbStippleRRop(READ(dst), mask,
-                                                         fgand, fgxor, bgand,
-                                                         bgxor));
-                            }
-                            dst++;
-                            bits = FbStipLeft(bits, pixelsPerDst);
+                    while (n--) {
+                        left = FbLeftStipBits(bits, pixelsPerDst);
+                        if (left || !transparent) {
+                            mask = fbBits[left];
+                            WRITE(dst, FbStippleRRop(READ(dst), mask, fgand,
+                                                     fgxor, bgand, bgxor));
                         }
+                        dst++;
+                        bits = FbStipLeft(bits, pixelsPerDst);
                     }
                 }
                 if (!w)
@@ -369,21 +366,10 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
             if (endNeedsLoad) {
                 LoadBits;
             }
-#if FB_UNIT > 32
-            if (pixelsPerDst == 16)
-                mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-            else
-#endif
-                mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-            if (fbLane) {
-                fbTransparentSpan(dst, mask & endmask, fgxor, 1);
-            }
-            else {
-                if (mask || !transparent)
-                    FbDoRightMaskByteStippleRRop(dst, mask,
-                                                 fgand, fgxor, bgand, bgxor,
-                                                 endbyte, endmask);
-            }
+            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+            if (mask || !transparent)
+                FbDoRightMaskByteStippleRRop(dst, mask, fgand, fgxor,
+                                             bgand, bgxor, endbyte, endmask);
         }
         dst += dstStride;
         src += srcStride;
@@ -412,47 +398,6 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
 
 #define SelMask24(b,n,r)	((((b) >> n) & 1) * Mask24(n,r))
 
-/*
- * Untested for MSBFirst or FB_UNIT == 32
- */
-
-#if FB_UNIT == 64
-#define C4_24(b,r) \
-    (SelMask24(b,0,r) | \
-     SelMask24(b,1,r) | \
-     SelMask24(b,2,r) | \
-     SelMask24(b,3,r))
-
-#define FbStip24New(rot)    (2 + (rot != 0))
-#define FbStip24Len	    4
-
-const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
-    /* rotate 0 */
-    {
-     C4_24(0, 0), C4_24(1, 0), C4_24(2, 0), C4_24(3, 0),
-     C4_24(4, 0), C4_24(5, 0), C4_24(6, 0), C4_24(7, 0),
-     C4_24(8, 0), C4_24(9, 0), C4_24(10, 0), C4_24(11, 0),
-     C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0),
-     },
-    /* rotate 8 */
-    {
-     C4_24(0, 8), C4_24(1, 8), C4_24(2, 8), C4_24(3, 8),
-     C4_24(4, 8), C4_24(5, 8), C4_24(6, 8), C4_24(7, 8),
-     C4_24(8, 8), C4_24(9, 8), C4_24(10, 8), C4_24(11, 8),
-     C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8),
-     },
-    /* rotate 16 */
-    {
-     C4_24(0, 16), C4_24(1, 16), C4_24(2, 16), C4_24(3, 16),
-     C4_24(4, 16), C4_24(5, 16), C4_24(6, 16), C4_24(7, 16),
-     C4_24(8, 16), C4_24(9, 16), C4_24(10, 16), C4_24(11, 16),
-     C4_24(12, 16), C4_24(13, 16), C4_24(14, 16), C4_24(15, 16),
-     }
-};
-
-#endif
-
-#if FB_UNIT == 32
 #define C2_24(b,r)  \
     (SelMask24(b,0,r) | \
      SelMask24(b,1,r))
@@ -478,7 +423,6 @@ const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
      C2_24(0, 16), C2_24(1, 16), C2_24(2, 16), C2_24(3, 16),
      }
 };
-#endif
 
 #if BITMAP_BIT_ORDER == LSBFirst
 
diff --git a/xorg-server/fb/fbfill.c b/xorg-server/fb/fbfill.c
index de9d6b3..05d81ab 100644
--- a/xorg-server/fb/fbfill.c
+++ b/xorg-server/fb/fbfill.c
@@ -26,6 +26,88 @@
 
 #include "fb.h"
 
+static void
+fbTile(FbBits * dst, FbStride dstStride, int dstX, int width, int height,
+       FbBits * tile, FbStride tileStride, int tileWidth, int tileHeight,
+       int alu, FbBits pm, int bpp, int xRot, int yRot)
+{
+    int tileX, tileY;
+    int widthTmp;
+    int h, w;
+    int x, y;
+
+    modulus(-yRot, tileHeight, tileY);
+    y = 0;
+    while (height) {
+        h = tileHeight - tileY;
+        if (h > height)
+            h = height;
+        height -= h;
+        widthTmp = width;
+        x = dstX;
+        modulus(dstX - xRot, tileWidth, tileX);
+        while (widthTmp) {
+            w = tileWidth - tileX;
+            if (w > widthTmp)
+                w = widthTmp;
+            widthTmp -= w;
+            fbBlt(tile + tileY * tileStride,
+                  tileStride,
+                  tileX,
+                  dst + y * dstStride,
+                  dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
+            x += w;
+            tileX = 0;
+        }
+        y += h;
+        tileY = 0;
+    }
+}
+
+static void
+fbStipple(FbBits * dst, FbStride dstStride,
+          int dstX, int dstBpp,
+          int width, int height,
+          FbStip * stip, FbStride stipStride,
+          int stipWidth, int stipHeight,
+          FbBits fgand, FbBits fgxor,
+          FbBits bgand, FbBits bgxor,
+          int xRot, int yRot)
+{
+    int stipX, stipY, sx;
+    int widthTmp;
+    int h, w;
+    int x, y;
+
+    modulus(-yRot, stipHeight, stipY);
+    modulus(dstX / dstBpp - xRot, stipWidth, stipX);
+    y = 0;
+    while (height) {
+        h = stipHeight - stipY;
+        if (h > height)
+            h = height;
+        height -= h;
+        widthTmp = width;
+        x = dstX;
+        sx = stipX;
+        while (widthTmp) {
+            w = (stipWidth - sx) * dstBpp;
+            if (w > widthTmp)
+                w = widthTmp;
+            widthTmp -= w;
+            fbBltOne(stip + stipY * stipStride,
+                     stipStride,
+                     sx,
+                     dst + y * dstStride,
+                     dstStride, x, dstBpp, w, h, fgand, fgxor, bgand, bgxor);
+            x += w;
+            sx = 0;
+        }
+        y += h;
+        stipY = 0;
+    }
+}
+
 void
 fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height)
 {
@@ -97,7 +179,7 @@ fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height)
             fbStipple(dst + (y + dstYoff) * dstStride, dstStride,
                       (x + dstXoff) * dstBpp, dstBpp, width * dstBpp, height,
                       stip, stipStride, stipWidth, stipHeight,
-                      pPriv->evenStipple, fgand, fgxor, bgand, bgxor,
+                      fgand, fgxor, bgand, bgxor,
                       pGC->patOrg.x + pDrawable->x + dstXoff,
                       pGC->patOrg.y + pDrawable->y - y);
             fbFinishAccess(&pStip->drawable);
diff --git a/xorg-server/fb/fbfillrect.c b/xorg-server/fb/fbfillrect.c
index 64ba2b4..0075b2c 100644
--- a/xorg-server/fb/fbfillrect.c
+++ b/xorg-server/fb/fbfillrect.c
@@ -74,7 +74,7 @@ fbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect)
         }
         else {
             pbox = RegionRects(pClip);
-            /* 
+            /*
              * clip the rectangle to each box in the clip region
              * this is logically equivalent to calling Intersect()
              */
diff --git a/xorg-server/fb/fbgc.c b/xorg-server/fb/fbgc.c
index f4d7f3a..19c6131 100644
--- a/xorg-server/fb/fbgc.c
+++ b/xorg-server/fb/fbgc.c
@@ -110,80 +110,6 @@ fbPadPixmap(PixmapPtr pPixmap)
     fbFinishAccess(&pPixmap->drawable);
 }
 
-/*
- * Verify that 'bits' repeats every 'len' bits
- */
-static Bool
-fbBitsRepeat(FbBits bits, int len, int width)
-{
-    FbBits mask = FbBitsMask(0, len);
-    FbBits orig = bits & mask;
-    int i;
-
-    if (width > FB_UNIT)
-        width = FB_UNIT;
-    for (i = 0; i < width / len; i++) {
-        if ((bits & mask) != orig)
-            return FALSE;
-        bits = FbScrLeft(bits, len);
-    }
-    return TRUE;
-}
-
-/*
- * Check whether an entire bitmap line is a repetition of
- * the first 'len' bits
- */
-static Bool
-fbLineRepeat(FbBits * bits, int len, int width)
-{
-    FbBits first = bits[0];
-
-    if (!fbBitsRepeat(first, len, width))
-        return FALSE;
-    width = (width + FB_UNIT - 1) >> FB_SHIFT;
-    bits++;
-    while (--width)
-        if (READ(bits) != first)
-            return FALSE;
-    return TRUE;
-}
-
-/*
- * The even stipple code wants the first FB_UNIT/bpp bits on
- * each scanline to represent the entire stipple
- */
-static Bool
-fbCanEvenStipple(PixmapPtr pStipple, int bpp)
-{
-    int len = FB_UNIT / bpp;
-    FbBits *bits;
-    int stride;
-    int stip_bpp;
-    _X_UNUSED int stipXoff, stipYoff;
-    int h;
-
-    /* can't even stipple 24bpp drawables */
-    if ((bpp & (bpp - 1)) != 0)
-        return FALSE;
-    /* make sure the stipple width is a multiple of the even stipple width */
-    if (pStipple->drawable.width % len != 0)
-        return FALSE;
-    fbGetDrawable(&pStipple->drawable, bits, stride, stip_bpp, stipXoff,
-                  stipYoff);
-    h = pStipple->drawable.height;
-    /* check to see that the stipple repeats horizontally */
-    while (h--) {
-        if (!fbLineRepeat(bits, len, pStipple->drawable.width)) {
-            fbFinishAccess(&pStipple->drawable);
-            return FALSE;
-        }
-        bits += stride;
-    }
-    fbFinishAccess(&pStipple->drawable);
-    return TRUE;
-}
-
 void
 fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 {
@@ -193,7 +119,7 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
     /*
      * if the client clip is different or moved OR the subwindowMode has
      * changed OR the window's clip has changed since the last validation
-     * we need to recompute the composite clip 
+     * we need to recompute the composite clip
      */
 
     if ((changes &
@@ -239,16 +165,7 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
             fbPadPixmap(pGC->tile.pixmap);
     }
     if (changes & GCStipple) {
-        pPriv->evenStipple = FALSE;
-
         if (pGC->stipple) {
-
-            /* can we do an even stipple ?? */
-            if (FbEvenStip(pGC->stipple->drawable.width,
-                           pDrawable->bitsPerPixel) &&
-                (fbCanEvenStipple(pGC->stipple, pDrawable->bitsPerPixel)))
-                pPriv->evenStipple = TRUE;
-
             if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel <
                 FB_UNIT)
                 fbPadPixmap(pGC->stipple);
diff --git a/xorg-server/fb/fbglyph.c b/xorg-server/fb/fbglyph.c
index 4f2904c..61cb8de 100644
--- a/xorg-server/fb/fbglyph.c
+++ b/xorg-server/fb/fbglyph.c
@@ -29,7 +29,7 @@
 #include	<X11/fonts/fontstruct.h>
 #include	"dixfontstr.h"
 
-Bool
+static Bool
 fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height)
 {
     BoxRec box;
@@ -56,11 +56,7 @@ fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height)
 #define WRITE1(d,n,fg)	WRITE((d) + (n), (CARD8) fg)
 #define WRITE2(d,n,fg)	WRITE((CARD16 *) &(d[n]), (CARD16) fg)
 #define WRITE4(d,n,fg)	WRITE((CARD32 *) &(d[n]), (CARD32) fg)
-#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
-#define WRITE8(d)	WRITE((FbBits *) &(d[0]), fg)
-#else
 #define WRITE8(d)	WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
-#endif
 
 /*
  * This is a bit tricky, but it's brief.  Write 12 bytes worth
@@ -69,7 +65,7 @@ fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height)
  *
  *  a b c d  a b c d  a b c d	bytes
  *  A B C A  B C A B  C A B C	pixels
- * 
+ *
  *    f0        f1       f2
  *  A B C A  B C A B  C A B C	pixels LSB
  *  C A B C  A B C A  B C A B	pixels MSB
@@ -120,7 +116,7 @@ fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height)
 #define CASE(a,b,c,d)	(a | (b << 1) | (c << 2) | (d << 3))
 #endif
 
-void
+static void
 fbGlyph24(FbBits * dstBits,
           FbStride dstStride,
           int dstBpp, FbStip * stipple, FbBits fg, int x, int height)
diff --git a/xorg-server/fb/fbline.c b/xorg-server/fb/fbline.c
index 80dc89d..3e582e6 100644
--- a/xorg-server/fb/fbline.c
+++ b/xorg-server/fb/fbline.c
@@ -26,7 +26,7 @@
 
 #include "fb.h"
 
-void
+static void
 fbZeroLine(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
 {
     int x1, y1, x2, y2;
@@ -54,7 +54,7 @@ fbZeroLine(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
     }
 }
 
-void
+static void
 fbZeroSegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs)
 {
     int dashOffset;
diff --git a/xorg-server/fb/fboverlay.c b/xorg-server/fb/fboverlay.c
index 6a5f0f8..1e5e6b3 100644
--- a/xorg-server/fb/fboverlay.c
+++ b/xorg-server/fb/fboverlay.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/fb/fboverlay.h b/xorg-server/fb/fboverlay.h
index 47727e4..3312145 100644
--- a/xorg-server/fb/fboverlay.h
+++ b/xorg-server/fb/fboverlay.h
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/fb/fbpict.c b/xorg-server/fb/fbpict.c
index f9c9917..c8378ad 100644
--- a/xorg-server/fb/fbpict.c
+++ b/xorg-server/fb/fbpict.c
@@ -82,7 +82,7 @@ fbDestroyGlyphCache(void)
     }
 }
 
-void
+static void
 fbUnrealizeGlyph(ScreenPtr pScreen,
 		 GlyphPtr pGlyph)
 {
@@ -113,7 +113,7 @@ fbGlyphs(CARD8 op,
     int xDst = list->xOff, yDst = list->yOff;
 
     miCompositeSourceValidate(pSrc);
-    
+
     n_glyphs = 0;
     for (i = 0; i < nlist; ++i)
 	n_glyphs += list[i].len;
@@ -122,12 +122,12 @@ fbGlyphs(CARD8 op,
 	glyphCache = pixman_glyph_cache_create();
 
     pixman_glyph_cache_freeze (glyphCache);
-    
+
     if (n_glyphs > N_STACK_GLYPHS) {
 	if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
 	    goto out;
     }
-    
+
     i = 0;
     x = y = 0;
     while (nlist--) {
@@ -309,17 +309,9 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
         return NULL;
 
 #ifdef FB_ACCESS_WRAPPER
-#if FB_SHIFT==5
-
     pixman_image_set_accessors(image,
                                (pixman_read_memory_func_t) wfbReadMemory,
                                (pixman_write_memory_func_t) wfbWriteMemory);
-
-#else
-
-#error The pixman library only works when FbBits is 32 bits wide
-
-#endif
 #endif
 
     /* pCompositeClip is undefined for source pictures, so
diff --git a/xorg-server/fb/fbpict.h b/xorg-server/fb/fbpict.h
index 8b0f59f..5cb8663 100644
--- a/xorg-server/fb/fbpict.h
+++ b/xorg-server/fb/fbpict.h
@@ -72,10 +72,6 @@ fbTriangles(CARD8 op,
             INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
 
 extern _X_EXPORT void
-fbUnrealizeGlyph(ScreenPtr pScreen,
-		 GlyphPtr pGlyph);
-
-extern _X_EXPORT void
 fbGlyphs(CARD8 op,
 	 PicturePtr pSrc,
 	 PicturePtr pDst,
diff --git a/xorg-server/fb/fbpixmap.c b/xorg-server/fb/fbpixmap.c
index 677f28a..951a925 100644
--- a/xorg-server/fb/fbpixmap.c
+++ b/xorg-server/fb/fbpixmap.c
@@ -132,7 +132,7 @@ if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&			\
     r++;							\
 }
 
-/* Convert bitmap clip mask into clipping region. 
+/* Convert bitmap clip mask into clipping region.
  * First, goes through each line and makes boxes by noting the transitions
  * from 0 to 1 and 1 to 0.
  * Then it coalesces the current line with the previous if they have boxes
@@ -246,8 +246,8 @@ fbPixmapToRegion(PixmapPtr pPix)
                     rx1, h, base + (width & FB_MASK), h + 1);
         }
         /* if all rectangles on this line have the same x-coords as
-         * those on the previous line, then add 1 to all the previous  y2s and 
-         * throw away all the rectangles from this line 
+         * those on the previous line, then add 1 to all the previous  y2s and
+         * throw away all the rectangles from this line
          */
         fSame = FALSE;
         if (irectPrevStart != -1) {
diff --git a/xorg-server/fb/fbpoint.c b/xorg-server/fb/fbpoint.c
index d5129d7..be7c801 100644
--- a/xorg-server/fb/fbpoint.c
+++ b/xorg-server/fb/fbpoint.c
@@ -35,7 +35,7 @@ typedef void (*FbDots) (FbBits * dst,
                         int xorg,
                         int yorg, int xoff, int yoff, FbBits and, FbBits xor);
 
-void
+static void
 fbDots(FbBits * dstOrig,
        FbStride dstStride,
        int dstBpp,
diff --git a/xorg-server/fb/fbpush.c b/xorg-server/fb/fbpush.c
index f0a861c..1d1bcfd 100644
--- a/xorg-server/fb/fbpush.c
+++ b/xorg-server/fb/fbpush.c
@@ -26,7 +26,7 @@
 
 #include "fb.h"
 
-void
+static void
 fbPushPattern(DrawablePtr pDrawable,
               GCPtr pGC,
               FbStip * src,
@@ -84,7 +84,7 @@ fbPushPattern(DrawablePtr pDrawable,
     }
 }
 
-void
+static void
 fbPushFill(DrawablePtr pDrawable,
            GCPtr pGC,
            FbStip * src,
diff --git a/xorg-server/fb/fbrop.h b/xorg-server/fb/fbrop.h
index 4362adb..bc12b14 100644
--- a/xorg-server/fb/fbrop.h
+++ b/xorg-server/fb/fbrop.h
@@ -92,19 +92,9 @@ extern _X_EXPORT const FbMergeRopRec FbMergeRopBits[16];
 #define fbAndStip(rop,fg,pm)	fbAndT(rop,fg,pm,FbStip)
 
 /*
- * Stippling operations; 
+ * Stippling operations;
  */
 
-extern _X_EXPORT const FbBits fbStipple16Bits[256];     /* half of table */
-
-#define FbStipple16Bits(b) \
-    (fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
-extern _X_EXPORT const FbBits fbStipple8Bits[256];
-extern _X_EXPORT const FbBits fbStipple4Bits[16];
-extern _X_EXPORT const FbBits fbStipple2Bits[4];
-extern _X_EXPORT const FbBits fbStipple1Bits[2];
-extern _X_EXPORT const FbBits *const fbStippleTable[];
-
 #define FbStippleRRop(dst, b, fa, fx, ba, bx) \
     (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
 
diff --git a/xorg-server/fb/fbseg.c b/xorg-server/fb/fbseg.c
index 1848387..c3c196a 100644
--- a/xorg-server/fb/fbseg.c
+++ b/xorg-server/fb/fbseg.c
@@ -33,7 +33,7 @@
 					((dir < 0) ? FbStipLeft(mask,bpp) : \
 					 FbStipRight(mask,bpp)))
 
-void
+static void
 fbBresSolid(DrawablePtr pDrawable,
             GCPtr pGC,
             int dashOffset,
@@ -65,12 +65,6 @@ fbBresSolid(DrawablePtr pDrawable,
     if (axis == X_AXIS) {
         bits = 0;
         while (len--) {
-            if (e >= 0) {
-                WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
-                bits = 0;
-                dst += dstStride;
-                e += e3;
-            }
             bits |= mask;
             mask = fbBresShiftMask(mask, signdx, dstBpp);
             if (!mask) {
@@ -80,12 +74,23 @@ fbBresSolid(DrawablePtr pDrawable,
                 mask = mask0;
             }
             e += e1;
+            if (e >= 0) {
+                if (bits) {
+                    WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+                    bits = 0;
+                }
+                dst += dstStride;
+                e += e3;
+            }
         }
         if (bits)
             WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, bits));
     }
     else {
         while (len--) {
+            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
+            dst += dstStride;
+            e += e1;
             if (e >= 0) {
                 e += e3;
                 mask = fbBresShiftMask(mask, signdx, dstBpp);
@@ -94,16 +99,13 @@ fbBresSolid(DrawablePtr pDrawable,
                     mask = mask0;
                 }
             }
-            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
-            dst += dstStride;
-            e += e1;
         }
     }
 
     fbFinishAccess(pDrawable);
 }
 
-void
+static void
 fbBresDash(DrawablePtr pDrawable,
            GCPtr pGC,
            int dashOffset,
@@ -176,7 +178,7 @@ fbBresDash(DrawablePtr pDrawable,
     fbFinishAccess(pDrawable);
 }
 
-void
+static void
 fbBresFill(DrawablePtr pDrawable,
            GCPtr pGC,
            int dashOffset,
@@ -216,7 +218,7 @@ fbSetFg(DrawablePtr pDrawable, GCPtr pGC, Pixel fg)
     }
 }
 
-void
+static void
 fbBresFillDash(DrawablePtr pDrawable,
                GCPtr pGC,
                int dashOffset,
@@ -434,7 +436,7 @@ fbBresDash24RRop(DrawablePtr pDrawable,
  * based on the contents of the specified GC.
  */
 
-FbBres *
+static FbBres *
 fbSelectBres(DrawablePtr pDrawable, GCPtr pGC)
 {
     FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
@@ -494,18 +496,6 @@ fbSelectBres(DrawablePtr pDrawable, GCPtr pGC)
 }
 
 void
-fbBres(DrawablePtr pDrawable,
-       GCPtr pGC,
-       int dashOffset,
-       int signdx,
-       int signdy, int axis, int x1, int y1, int e, int e1, int e3, int len)
-{
-    (*fbSelectBres(pDrawable, pGC)) (pDrawable, pGC, dashOffset,
-                                     signdx, signdy, axis, x1, y1,
-                                     e, e1, e3, len);
-}
-
-void
 fbSegment(DrawablePtr pDrawable,
           GCPtr pGC,
           int x1, int y1, int x2, int y2, Bool drawLast, int *dashOffset)
diff --git a/xorg-server/fb/fbstipple.c b/xorg-server/fb/fbstipple.c
deleted file mode 100644
index f6c84a2..0000000
--- a/xorg-server/fb/fbstipple.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * This is a slight abuse of the preprocessor to generate repetitive
- * code, the idea is to generate code for each case of a copy-mode
- * transparent stipple
- */
-#define LaneCases1(c,a)	    case c: \
-				while (n--) { FbLaneCase(c,a); a++; } \
-				break
-#define LaneCases2(c,a)	    LaneCases1(c,a); LaneCases1(c+1,a)
-#define LaneCases4(c,a)	    LaneCases2(c,a); LaneCases2(c+2,a)
-#define LaneCases8(c,a)	    LaneCases4(c,a); LaneCases4(c+4,a)
-#define LaneCases16(c,a)    LaneCases8(c,a); LaneCases8(c+8,a)
-#define LaneCases32(c,a)    LaneCases16(c,a); LaneCases16(c+16,a)
-#define LaneCases64(c,a)    LaneCases32(c,a); LaneCases32(c+32,a)
-#define LaneCases128(c,a)   LaneCases64(c,a); LaneCases64(c+64,a)
-#define LaneCases256(c,a)   LaneCases128(c,a); LaneCases128(c+128,a)
-
-#if FB_SHIFT == 6
-#define LaneCases(a)	    LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
-#define LaneCases(a)	    LaneCases16(0,a)
-#endif
-
-/*
- * Repeat a transparent stipple across a scanline n times
- */
-
-void
-fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n)
-{
-    FbStip s;
-
-    s = ((FbStip) (stip) & 0x01);
-    s |= ((FbStip) (stip >> 8) & 0x02);
-    s |= ((FbStip) (stip >> 16) & 0x04);
-    s |= ((FbStip) (stip >> 24) & 0x08);
-#if FB_SHIFT > 5
-    s |= ((FbStip) (stip >> 32) & 0x10);
-    s |= ((FbStip) (stip >> 40) & 0x20);
-    s |= ((FbStip) (stip >> 48) & 0x40);
-    s |= ((FbStip) (stip >> 56) & 0x80);
-#endif
-    switch (s) {
-        LaneCases(dst);
-    }
-}
-
-void
-fbEvenStipple(FbBits * dst,
-              FbStride dstStride,
-              int dstX,
-              int dstBpp,
-              int width,
-              int height,
-              FbStip * stip,
-              FbStride stipStride,
-              int stipHeight,
-              FbBits fgand,
-              FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    FbBits startmask, endmask;
-    FbBits mask, and, xor;
-    int nmiddle, n;
-    FbStip *s, *stipEnd, bits;
-    int rot, stipX, stipY;
-    int pixelsPerDst;
-    const FbBits *fbBits;
-    Bool transparent;
-    int startbyte, endbyte;
-
-    /*
-     * Check for a transparent stipple (stencil)
-     */
-    transparent = FALSE;
-    if (dstBpp >= 8 && fgand == 0 && bgand == FB_ALLONES && bgxor == 0)
-        transparent = TRUE;
-
-    pixelsPerDst = FB_UNIT / dstBpp;
-    /*
-     * Adjust dest pointers
-     */
-    dst += dstX >> FB_SHIFT;
-    dstX &= FB_MASK;
-    FbMaskBitsBytes(dstX, width, fgand == 0 && bgand == 0,
-                    startmask, startbyte, nmiddle, endmask, endbyte);
-
-    if (startmask)
-        dstStride--;
-    dstStride -= nmiddle;
-
-    xRot *= dstBpp;
-    /*
-     * Compute stip start scanline and rotation parameters
-     */
-    stipEnd = stip + stipStride * stipHeight;
-    modulus(-yRot, stipHeight, stipY);
-    s = stip + stipStride * stipY;
-    modulus(-xRot, FB_UNIT, stipX);
-    rot = stipX;
-
-    /*
-     * Get pointer to stipple mask array for this depth
-     */
-    /* fbStippleTable covers all valid bpp (4,8,16,32) */
-    fbBits = fbStippleTable[pixelsPerDst];
-
-    while (height--) {
-        /*
-         * Extract stipple bits for this scanline;
-         */
-        bits = READ(s);
-        s += stipStride;
-        if (s == stipEnd)
-            s = stip;
-#if FB_UNIT > 32
-        if (pixelsPerDst == 16)
-            mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-        else
-#endif
-            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-        /*
-         * Rotate into position and compute reduced rop values
-         */
-        mask = FbRotLeft(mask, rot);
-        and = (fgand & mask) | (bgand & ~mask);
-        xor = (fgxor & mask) | (bgxor & ~mask);
-
-        if (transparent) {
-            if (startmask) {
-                fbTransparentSpan(dst, mask & startmask, fgxor, 1);
-                dst++;
-            }
-            fbTransparentSpan(dst, mask, fgxor, nmiddle);
-            dst += nmiddle;
-            if (endmask)
-                fbTransparentSpan(dst, mask & endmask, fgxor, 1);
-        }
-        else {
-            /*
-             * Fill scanline
-             */
-            if (startmask) {
-                FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
-                dst++;
-            }
-            n = nmiddle;
-            if (!and)
-                while (n--)
-                    WRITE(dst++, xor);
-            else {
-                while (n--) {
-                    WRITE(dst, FbDoRRop(READ(dst), and, xor));
-                    dst++;
-                }
-            }
-            if (endmask)
-                FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
-        }
-        dst += dstStride;
-    }
-}
-
-void
-fbOddStipple(FbBits * dst,
-             FbStride dstStride,
-             int dstX,
-             int dstBpp,
-             int width,
-             int height,
-             FbStip * stip,
-             FbStride stipStride,
-             int stipWidth,
-             int stipHeight,
-             FbBits fgand,
-             FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    int stipX, stipY, sx;
-    int widthTmp;
-    int h, w;
-    int x, y;
-
-    modulus(-yRot, stipHeight, stipY);
-    modulus(dstX / dstBpp - xRot, stipWidth, stipX);
-    y = 0;
-    while (height) {
-        h = stipHeight - stipY;
-        if (h > height)
-            h = height;
-        height -= h;
-        widthTmp = width;
-        x = dstX;
-        sx = stipX;
-        while (widthTmp) {
-            w = (stipWidth - sx) * dstBpp;
-            if (w > widthTmp)
-                w = widthTmp;
-            widthTmp -= w;
-            fbBltOne(stip + stipY * stipStride,
-                     stipStride,
-                     sx,
-                     dst + y * dstStride,
-                     dstStride, x, dstBpp, w, h, fgand, fgxor, bgand, bgxor);
-            x += w;
-            sx = 0;
-        }
-        y += h;
-        stipY = 0;
-    }
-}
-
-void
-fbStipple(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int dstBpp,
-          int width,
-          int height,
-          FbStip * stip,
-          FbStride stipStride,
-          int stipWidth,
-          int stipHeight,
-          Bool even,
-          FbBits fgand,
-          FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    if (even)
-        fbEvenStipple(dst, dstStride, dstX, dstBpp, width, height,
-                      stip, stipStride, stipHeight,
-                      fgand, fgxor, bgand, bgxor, xRot, yRot);
-    else
-        fbOddStipple(dst, dstStride, dstX, dstBpp, width, height,
-                     stip, stipStride, stipWidth, stipHeight,
-                     fgand, fgxor, bgand, bgxor, xRot, yRot);
-}
diff --git a/xorg-server/fb/fbtile.c b/xorg-server/fb/fbtile.c
deleted file mode 100644
index 785c5f0..0000000
--- a/xorg-server/fb/fbtile.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * Accelerated tile fill -- tile width is a power of two not greater
- * than FB_UNIT
- */
-
-void
-fbEvenTile(FbBits * dst,
-           FbStride dstStride,
-           int dstX,
-           int width,
-           int height,
-           FbBits * tile,
-           FbStride tileStride,
-           int tileHeight, int alu, FbBits pm, int xRot, int yRot)
-{
-    FbBits *t, *tileEnd, bits;
-    FbBits startmask, endmask;
-    FbBits and, xor;
-    int n, nmiddle;
-    int tileX, tileY;
-    int rot;
-    int startbyte, endbyte;
-
-    dst += dstX >> FB_SHIFT;
-    dstX &= FB_MASK;
-    FbMaskBitsBytes(dstX, width, FbDestInvarientRop(alu, pm),
-                    startmask, startbyte, nmiddle, endmask, endbyte);
-    if (startmask)
-        dstStride--;
-    dstStride -= nmiddle;
-
-    /*
-     * Compute tile start scanline and rotation parameters
-     */
-    tileEnd = tile + tileHeight * tileStride;
-    modulus(-yRot, tileHeight, tileY);
-    t = tile + tileY * tileStride;
-    modulus(-xRot, FB_UNIT, tileX);
-    rot = tileX;
-
-    while (height--) {
-
-        /*
-         * Pick up bits for this scanline
-         */
-        bits = READ(t);
-        t += tileStride;
-        if (t >= tileEnd)
-            t = tile;
-        bits = FbRotLeft(bits, rot);
-        and = fbAnd(alu, bits, pm);
-        xor = fbXor(alu, bits, pm);
-
-        if (startmask) {
-            FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
-            dst++;
-        }
-        n = nmiddle;
-        if (!and)
-            while (n--)
-                WRITE(dst++, xor);
-        else
-            while (n--) {
-                WRITE(dst, FbDoRRop(READ(dst), and, xor));
-                dst++;
-            }
-        if (endmask)
-            FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
-        dst += dstStride;
-    }
-}
-
-void
-fbOddTile(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int width,
-          int height,
-          FbBits * tile,
-          FbStride tileStride,
-          int tileWidth,
-          int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
-{
-    int tileX, tileY;
-    int widthTmp;
-    int h, w;
-    int x, y;
-
-    modulus(-yRot, tileHeight, tileY);
-    y = 0;
-    while (height) {
-        h = tileHeight - tileY;
-        if (h > height)
-            h = height;
-        height -= h;
-        widthTmp = width;
-        x = dstX;
-        modulus(dstX - xRot, tileWidth, tileX);
-        while (widthTmp) {
-            w = tileWidth - tileX;
-            if (w > widthTmp)
-                w = widthTmp;
-            widthTmp -= w;
-            fbBlt(tile + tileY * tileStride,
-                  tileStride,
-                  tileX,
-                  dst + y * dstStride,
-                  dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
-            x += w;
-            tileX = 0;
-        }
-        y += h;
-        tileY = 0;
-    }
-}
-
-void
-fbTile(FbBits * dst,
-       FbStride dstStride,
-       int dstX,
-       int width,
-       int height,
-       FbBits * tile,
-       FbStride tileStride,
-       int tileWidth,
-       int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
-{
-    if (FbEvenTile(tileWidth))
-        fbEvenTile(dst, dstStride, dstX, width, height,
-                   tile, tileStride, tileHeight, alu, pm, xRot, yRot);
-    else
-        fbOddTile(dst, dstStride, dstX, width, height,
-                  tile, tileStride, tileWidth, tileHeight,
-                  alu, pm, bpp, xRot, yRot);
-}
diff --git a/xorg-server/fb/fbutil.c b/xorg-server/fb/fbutil.c
index 2ca80d1..c1d5923 100644
--- a/xorg-server/fb/fbutil.c
+++ b/xorg-server/fb/fbutil.c
@@ -39,84 +39,6 @@ fbReplicatePixel(Pixel p, int bpp)
     return b;
 }
 
-void
-fbReduceRasterOp(int rop, FbBits fg, FbBits pm, FbBits * andp, FbBits * xorp)
-{
-    FbBits and, xor;
-
-    switch (rop) {
-    default:
-    case GXclear:              /* 0 0 0 0 */
-        and = 0;
-        xor = 0;
-        break;
-    case GXand:                /* 0 0 0 1 */
-        and = fg;
-        xor = 0;
-        break;
-    case GXandReverse:         /* 0 0 1 0 */
-        and = fg;
-        xor = fg;
-        break;
-    case GXcopy:               /* 0 0 1 1 */
-        and = 0;
-        xor = fg;
-        break;
-    case GXandInverted:        /* 0 1 0 0 */
-        and = ~fg;
-        xor = 0;
-        break;
-    case GXnoop:               /* 0 1 0 1 */
-        and = FB_ALLONES;
-        xor = 0;
-        break;
-    case GXxor:                /* 0 1 1 0 */
-        and = FB_ALLONES;
-        xor = fg;
-        break;
-    case GXor:                 /* 0 1 1 1 */
-        and = ~fg;
-        xor = fg;
-        break;
-    case GXnor:                /* 1 0 0 0 */
-        and = ~fg;
-        xor = ~fg;
-        break;
-    case GXequiv:              /* 1 0 0 1 */
-        and = FB_ALLONES;
-        xor = ~fg;
-        break;
-    case GXinvert:             /* 1 0 1 0 */
-        and = FB_ALLONES;
-        xor = FB_ALLONES;
-        break;
-    case GXorReverse:          /* 1 0 1 1 */
-        and = ~fg;
-        xor = FB_ALLONES;
-        break;
-    case GXcopyInverted:       /* 1 1 0 0 */
-        and = 0;
-        xor = ~fg;
-        break;
-    case GXorInverted:         /* 1 1 0 1 */
-        and = fg;
-        xor = ~fg;
-        break;
-    case GXnand:               /* 1 1 1 0 */
-        and = fg;
-        xor = FB_ALLONES;
-        break;
-    case GXset:                /* 1 1 1 1 */
-        and = 0;
-        xor = FB_ALLONES;
-        break;
-    }
-    and |= ~pm;
-    xor &= pm;
-    *andp = and;
-    *xorp = xor;
-}
-
 #define O 0
 #define I FB_ALLONES
 
@@ -139,233 +61,3 @@ const FbMergeRopRec FbMergeRopBits[16] = {
     {O, O, O, I},               /* set           0xf         1 */
 };
 
-/*
- * Stipple masks are independent of bit/byte order as long
- * as bitorder == byteorder.  FB doesn't handle the case
- * where these differ
- */
-#define BitsMask(x,w)	((FB_ALLONES << ((x) & FB_MASK)) & \
-			 (FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_MASK)))
-
-#define Mask(x,w)	BitsMask((x)*(w),(w))
-
-#define SelMask(b,n,w)	((((b) >> n) & 1) * Mask(n,w))
-
-#define C1(b,w) \
-    (SelMask(b,0,w))
-
-#define C2(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w))
-
-#define C4(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w) | \
-     SelMask(b,2,w) | \
-     SelMask(b,3,w))
-
-#define C8(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w) | \
-     SelMask(b,2,w) | \
-     SelMask(b,3,w) | \
-     SelMask(b,4,w) | \
-     SelMask(b,5,w) | \
-     SelMask(b,6,w) | \
-     SelMask(b,7,w))
-
-#if FB_UNIT == 16
-#define fbStipple16Bits 0
-#define fbStipple8Bits 0
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 4), C4(1, 4), C4(2, 4), C4(3, 4), C4(4, 4), C4(5, 4),
-    C4(6, 4), C4(7, 4), C4(8, 4), C4(9, 4), C4(10, 4), C4(11, 4),
-    C4(12, 4), C4(13, 4), C4(14, 4), C4(15, 4),
-};
-
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 8), C2(1, 8), C2(2, 8), C2(3, 8),
-};
-
-const FbBits fbStipple1Bits[2] = {
-    C1(0, 16), C1(1, 16),
-};
-#endif
-#if FB_UNIT == 32
-#define fbStipple16Bits 0
-const FbBits fbStipple8Bits[256] = {
-    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
-    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
-    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
-    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
-    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
-    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
-    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
-    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
-    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
-    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
-    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
-    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
-    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
-    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
-    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
-    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
-    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
-    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
-    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
-    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
-    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
-    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
-    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
-    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
-    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
-    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
-    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
-    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
-    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
-    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
-    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
-    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
-    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
-    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
-    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
-    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
-    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
-    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
-    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
-    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
-    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
-    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
-    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
-};
-
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 8), C4(1, 8), C4(2, 8), C4(3, 8), C4(4, 8), C4(5, 8),
-    C4(6, 8), C4(7, 8), C4(8, 8), C4(9, 8), C4(10, 8), C4(11, 8),
-    C4(12, 8), C4(13, 8), C4(14, 8), C4(15, 8),
-};
-
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 16), C2(1, 16), C2(2, 16), C2(3, 16),
-};
-
-const FbBits fbStipple1Bits[2] = {
-    C1(0, 32), C1(1, 32),
-};
-#endif
-#if FB_UNIT == 64
-const FbBits fbStipple16Bits[256] = {
-    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
-    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
-    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
-    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
-    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
-    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
-    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
-    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
-    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
-    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
-    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
-    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
-    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
-    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
-    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
-    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
-    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
-    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
-    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
-    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
-    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
-    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
-    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
-    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
-    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
-    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
-    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
-    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
-    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
-    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
-    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
-    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
-    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
-    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
-    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
-    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
-    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
-    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
-    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
-    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
-    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
-    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
-    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
-};
-
-const FbBits fbStipple8Bits[256] = {
-    C8(0, 8), C8(1, 8), C8(2, 8), C8(3, 8), C8(4, 8), C8(5, 8),
-    C8(6, 8), C8(7, 8), C8(8, 8), C8(9, 8), C8(10, 8), C8(11, 8),
-    C8(12, 8), C8(13, 8), C8(14, 8), C8(15, 8), C8(16, 8), C8(17, 8),
-    C8(18, 8), C8(19, 8), C8(20, 8), C8(21, 8), C8(22, 8), C8(23, 8),
-    C8(24, 8), C8(25, 8), C8(26, 8), C8(27, 8), C8(28, 8), C8(29, 8),
-    C8(30, 8), C8(31, 8), C8(32, 8), C8(33, 8), C8(34, 8), C8(35, 8),
-    C8(36, 8), C8(37, 8), C8(38, 8), C8(39, 8), C8(40, 8), C8(41, 8),
-    C8(42, 8), C8(43, 8), C8(44, 8), C8(45, 8), C8(46, 8), C8(47, 8),
-    C8(48, 8), C8(49, 8), C8(50, 8), C8(51, 8), C8(52, 8), C8(53, 8),
-    C8(54, 8), C8(55, 8), C8(56, 8), C8(57, 8), C8(58, 8), C8(59, 8),
-    C8(60, 8), C8(61, 8), C8(62, 8), C8(63, 8), C8(64, 8), C8(65, 8),
-    C8(66, 8), C8(67, 8), C8(68, 8), C8(69, 8), C8(70, 8), C8(71, 8),
-    C8(72, 8), C8(73, 8), C8(74, 8), C8(75, 8), C8(76, 8), C8(77, 8),
-    C8(78, 8), C8(79, 8), C8(80, 8), C8(81, 8), C8(82, 8), C8(83, 8),
-    C8(84, 8), C8(85, 8), C8(86, 8), C8(87, 8), C8(88, 8), C8(89, 8),
-    C8(90, 8), C8(91, 8), C8(92, 8), C8(93, 8), C8(94, 8), C8(95, 8),
-    C8(96, 8), C8(97, 8), C8(98, 8), C8(99, 8), C8(100, 8), C8(101, 8),
-    C8(102, 8), C8(103, 8), C8(104, 8), C8(105, 8), C8(106, 8), C8(107, 8),
-    C8(108, 8), C8(109, 8), C8(110, 8), C8(111, 8), C8(112, 8), C8(113, 8),
-    C8(114, 8), C8(115, 8), C8(116, 8), C8(117, 8), C8(118, 8), C8(119, 8),
-    C8(120, 8), C8(121, 8), C8(122, 8), C8(123, 8), C8(124, 8), C8(125, 8),
-    C8(126, 8), C8(127, 8), C8(128, 8), C8(129, 8), C8(130, 8), C8(131, 8),
-    C8(132, 8), C8(133, 8), C8(134, 8), C8(135, 8), C8(136, 8), C8(137, 8),
-    C8(138, 8), C8(139, 8), C8(140, 8), C8(141, 8), C8(142, 8), C8(143, 8),
-    C8(144, 8), C8(145, 8), C8(146, 8), C8(147, 8), C8(148, 8), C8(149, 8),
-    C8(150, 8), C8(151, 8), C8(152, 8), C8(153, 8), C8(154, 8), C8(155, 8),
-    C8(156, 8), C8(157, 8), C8(158, 8), C8(159, 8), C8(160, 8), C8(161, 8),
-    C8(162, 8), C8(163, 8), C8(164, 8), C8(165, 8), C8(166, 8), C8(167, 8),
-    C8(168, 8), C8(169, 8), C8(170, 8), C8(171, 8), C8(172, 8), C8(173, 8),
-    C8(174, 8), C8(175, 8), C8(176, 8), C8(177, 8), C8(178, 8), C8(179, 8),
-    C8(180, 8), C8(181, 8), C8(182, 8), C8(183, 8), C8(184, 8), C8(185, 8),
-    C8(186, 8), C8(187, 8), C8(188, 8), C8(189, 8), C8(190, 8), C8(191, 8),
-    C8(192, 8), C8(193, 8), C8(194, 8), C8(195, 8), C8(196, 8), C8(197, 8),
-    C8(198, 8), C8(199, 8), C8(200, 8), C8(201, 8), C8(202, 8), C8(203, 8),
-    C8(204, 8), C8(205, 8), C8(206, 8), C8(207, 8), C8(208, 8), C8(209, 8),
-    C8(210, 8), C8(211, 8), C8(212, 8), C8(213, 8), C8(214, 8), C8(215, 8),
-    C8(216, 8), C8(217, 8), C8(218, 8), C8(219, 8), C8(220, 8), C8(221, 8),
-    C8(222, 8), C8(223, 8), C8(224, 8), C8(225, 8), C8(226, 8), C8(227, 8),
-    C8(228, 8), C8(229, 8), C8(230, 8), C8(231, 8), C8(232, 8), C8(233, 8),
-    C8(234, 8), C8(235, 8), C8(236, 8), C8(237, 8), C8(238, 8), C8(239, 8),
-    C8(240, 8), C8(241, 8), C8(242, 8), C8(243, 8), C8(244, 8), C8(245, 8),
-    C8(246, 8), C8(247, 8), C8(248, 8), C8(249, 8), C8(250, 8), C8(251, 8),
-    C8(252, 8), C8(253, 8), C8(254, 8), C8(255, 8),
-};
-
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 16), C4(1, 16), C4(2, 16), C4(3, 16), C4(4, 16), C4(5, 16),
-    C4(6, 16), C4(7, 16), C4(8, 16), C4(9, 16), C4(10, 16), C4(11, 16),
-    C4(12, 16), C4(13, 16), C4(14, 16), C4(15, 16),
-};
-
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 32), C2(1, 32), C2(2, 32), C2(3, 32),
-};
-
-#define fbStipple1Bits 0
-#endif
-const FbBits *const fbStippleTable[] = {
-    0,
-    fbStipple1Bits,
-    fbStipple2Bits,
-    0,
-    fbStipple4Bits,
-    0,
-    0,
-    0,
-    fbStipple8Bits,
-};
diff --git a/xorg-server/fb/wfbrename.h b/xorg-server/fb/wfbrename.h
index 749c6d0..baa80f8 100644
--- a/xorg-server/fb/wfbrename.h
+++ b/xorg-server/fb/wfbrename.h
@@ -1,4 +1,3 @@
-#define fb16Lane wfb16Lane
 #define fb24_32CopyMtoN wfb24_32CopyMtoN
 #define fb24_32CreateScreenResources wfb24_32CreateScreenResources
 #define fb24_32GetImage wfb24_32GetImage
@@ -7,8 +6,6 @@
 #define fb24_32PutZImage wfb24_32PutZImage
 #define fb24_32ReformatTile wfb24_32ReformatTile
 #define fb24_32SetSpans wfb24_32SetSpans
-#define fb32Lane wfb32Lane
-#define fb8Lane wfb8Lane
 #define fbAddTraps wfbAddTraps
 #define fbAddTriangles wfbAddTriangles
 #define fbAllocatePrivates wfbAllocatePrivates
@@ -61,8 +58,6 @@
 #define fbDots24 wfbDots24
 #define fbDots32 wfbDots32
 #define fbDots8 wfbDots8
-#define fbEvenStipple wfbEvenStipple
-#define fbEvenTile wfbEvenTile
 #define fbExpandDirectColors wfbExpandDirectColors
 #define fbFill wfbFill
 #define fbFillRegionSolid wfbFillRegionSolid
@@ -79,18 +74,13 @@
 #define fbGlyph24 wfbGlyph24
 #define fbGlyph32 wfbGlyph32
 #define fbGlyph8 wfbGlyph8
-#define fbGlyphIn wfbGlyphIn
 #define fbHasVisualTypes wfbHasVisualTypes
 #define fbImageGlyphBlt wfbImageGlyphBlt
 #define fbIn wfbIn
 #define fbInitializeColormap wfbInitializeColormap
 #define fbInitVisuals wfbInitVisuals
-#define fbInstallColormap wfbInstallColormap
-#define fbLaneTable wfbLaneTable
 #define fbListInstalledColormaps wfbListInstalledColormaps
 #define FbMergeRopBits wFbMergeRopBits
-#define fbOddStipple wfbOddStipple
-#define fbOddTile wfbOddTile
 #define fbOver wfbOver
 #define fbOver24 wfbOver24
 #define fbOverlayCloseScreen wfbOverlayCloseScreen
@@ -133,8 +123,6 @@
 #define fbQueryBestSize wfbQueryBestSize
 #define fbRasterizeTrapezoid wfbRasterizeTrapezoid
 #define fbRealizeFont wfbRealizeFont
-#define fbRealizeWindow wfbRealizeWindow
-#define fbReduceRasterOp wfbReduceRasterOp
 #define fbReplicatePixel wfbReplicatePixel
 #define fbResolveColor wfbResolveColor
 #define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec
@@ -148,15 +136,6 @@
 #define fbSolid wfbSolid
 #define fbSolid24 wfbSolid24
 #define fbSolidBoxClipped wfbSolidBoxClipped
-#define fbStipple wfbStipple
-#define fbStipple1Bits wfbStipple1Bits
-#define fbStipple24Bits wfbStipple24Bits
-#define fbStipple2Bits wfbStipple2Bits
-#define fbStipple4Bits wfbStipple4Bits
-#define fbStipple8Bits wfbStipple8Bits
-#define fbStippleTable wfbStippleTable
-#define fbTile wfbTile
-#define fbTransparentSpan wfbTransparentSpan
 #define fbTrapezoids wfbTrapezoids
 #define fbTriangles wfbTriangles
 #define fbUninstallColormap wfbUninstallColormap
@@ -164,7 +143,5 @@
 #define fbUnrealizeFont wfbUnrealizeFont
 #define fbValidateGC wfbValidateGC
 #define fbWinPrivateKeyRec wfbWinPrivateKeyRec
-#define fbZeroLine wfbZeroLine
-#define fbZeroSegment wfbZeroSegment
 #define free_pixman_pict wfb_free_pixman_pict
 #define image_from_pict wfb_image_from_pict
diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c
index fc24b1b..d228e35 100644
--- a/xorg-server/glamor/glamor.c
+++ b/xorg-server/glamor/glamor.c
@@ -106,6 +106,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
         ErrorF("XXX fail to create fbo.\n");
         return;
     }
+    fbo->external = TRUE;
 
     glamor_pixmap_attach_fbo(pixmap, fbo);
 }
diff --git a/xorg-server/glamor/glamor_fbo.c b/xorg-server/glamor/glamor_fbo.c
index 090dfd8..4273826 100644
--- a/xorg-server/glamor/glamor_fbo.c
+++ b/xorg-server/glamor/glamor_fbo.c
@@ -153,7 +153,7 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
 #else
     n_format = cache_format(fbo->format);
 
-    if (fbo->fb == 0 || n_format == -1
+    if (fbo->fb == 0 || fbo->external || n_format == -1
         || fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
         fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
         glamor_fbo_expire(fbo->glamor_priv);
@@ -237,6 +237,7 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
     fbo->tex = tex;
     fbo->width = w;
     fbo->height = h;
+    fbo->external = FALSE;
     fbo->format = format;
     fbo->glamor_priv = glamor_priv;
 
diff --git a/xorg-server/glamor/glamor_picture.c b/xorg-server/glamor/glamor_picture.c
index cbbc194..bc658f8 100644
--- a/xorg-server/glamor/glamor_picture.c
+++ b/xorg-server/glamor/glamor_picture.c
@@ -45,7 +45,7 @@ glamor_upload_picture_to_texture(PicturePtr picture)
     return glamor_upload_pixmap_to_texture(pixmap);
 }
 
-/* 
+/*
  * We should already have drawable attached to it, if it has one.
  * Then set the attached pixmap to is_picture format, and set
  * the pict format.
diff --git a/xorg-server/glamor/glamor_pixmap.c b/xorg-server/glamor/glamor_pixmap.c
index 355fe4b..947113e 100644
--- a/xorg-server/glamor/glamor_pixmap.c
+++ b/xorg-server/glamor/glamor_pixmap.c
@@ -774,8 +774,8 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
             return FALSE;
         bits = glamor_color_convert_to_bits(bits, converted_bits, w, h,
                                             stride, no_alpha, revert, swap_rb);
-        free(converted_bits);
         if (bits == NULL) {
+            free(converted_bits);
             ErrorF("Failed to convert pixmap no_alpha %d,"
                    "revert mode %d, swap mode %d\n", no_alpha, revert, swap_rb);
             return FALSE;
@@ -808,45 +808,44 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
                                           format, type,
                                           x + fbo_x_off, y + fbo_y_off, w, h,
                                           bits, pbo);
-        return TRUE;
+    } else {
+        ptexcoords = texcoords_inv;
+
+        pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
+        glamor_set_normalize_vcoords(pixmap_priv, dst_xscale,
+                                     dst_yscale,
+                                     x, y,
+                                     x + w, y + h,
+                                     vertices);
+        /* Slow path, we need to flip y or wire alpha to 1. */
+        glamor_make_current(glamor_priv);
+        glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                              GL_FALSE, 2 * sizeof(float), vertices);
+        glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+        glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+                              GL_FALSE, 2 * sizeof(float), ptexcoords);
+        glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+        glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+        __glamor_upload_pixmap_to_texture(pixmap, &tex,
+                                          format, type, 0, 0, w, h, bits, pbo);
+        glActiveTexture(GL_TEXTURE0);
+        glBindTexture(GL_TEXTURE_2D, tex);
+
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+        glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
+        glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
+
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+        glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+        glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+        glDeleteTextures(1, &tex);
+        glBindFramebuffer(GL_FRAMEBUFFER, 0);
     }
 
-    ptexcoords = texcoords_inv;
-
-    pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
-    glamor_set_normalize_vcoords(pixmap_priv, dst_xscale,
-                                 dst_yscale,
-                                 x, y,
-                                 x + w, y + h,
-                                 vertices);
-    /* Slow path, we need to flip y or wire alpha to 1. */
-    glamor_make_current(glamor_priv);
-    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                          GL_FALSE, 2 * sizeof(float), vertices);
-    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                          GL_FALSE, 2 * sizeof(float), ptexcoords);
-    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-
-    glamor_set_destination_pixmap_priv_nc(pixmap_priv);
-    __glamor_upload_pixmap_to_texture(pixmap, &tex,
-                                      format, type, 0, 0, w, h, bits, pbo);
-    glActiveTexture(GL_TEXTURE0);
-    glBindTexture(GL_TEXTURE_2D, tex);
-
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
-    glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
-    glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
-
-    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    glDeleteTextures(1, &tex);
-    glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
     if (need_free_bits)
         free(bits);
     return TRUE;
diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h
index c089db8..885f12a 100644
--- a/xorg-server/glamor/glamor_priv.h
+++ b/xorg-server/glamor/glamor_priv.h
@@ -352,6 +352,7 @@ enum glamor_fbo_state {
  * @pbo:     attached pbo.
  * @width:   width of this fbo.
  * @height:  height of this fbo.
+ * @external set when the texture was not created by glamor
  * @format:  internal format of this fbo's texture.
  * @type:    internal type of this fbo's texture.
  * @glamor_priv: point to glamor private data.
@@ -365,6 +366,7 @@ typedef struct glamor_pixmap_fbo {
     GLuint pbo;
     int width;
     int height;
+    Bool external;
     GLenum format;
     GLenum type;
     glamor_screen_private *glamor_priv;
diff --git a/xorg-server/glx/glxbyteorder.h b/xorg-server/glx/glxbyteorder.h
index 73f0f7d..aa88b44 100644
--- a/xorg-server/glx/glxbyteorder.h
+++ b/xorg-server/glx/glxbyteorder.h
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2006, 2007
  * 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
@@ -25,7 +25,7 @@
 /**
  * \file glxbyteorder.h
  * Platform glue for handling byte-ordering issues in GLX protocol.
- * 
+ *
  * \author Ian Romanick <idr at us.ibm.com>
  */
 #if !defined(__GLXBYTEORDER_H__)
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c
index d11c667..8d3fa9f 100644
--- a/xorg-server/glx/glxcmds.c
+++ b/xorg-server/glx/glxcmds.c
@@ -233,13 +233,13 @@ DoCreateContext(__GLXclientState * cl, GLXContextID gcId,
     LEGAL_NEW_RESOURCE(gcId, client);
 
     /*
-     ** Find the display list space that we want to share.  
+     ** Find the display list space that we want to share.
      **
      ** NOTE: In a multithreaded X server, we would need to keep a reference
-     ** count for each display list so that if one client detroyed a list that 
-     ** another client was using, the list would not really be freed until it 
-     ** was no longer in use.  Since this sample implementation has no support 
-     ** for multithreaded servers, we don't do this.  
+     ** count for each display list so that if one client detroyed a list that
+     ** another client was using, the list would not really be freed until it
+     ** was no longer in use.  Since this sample implementation has no support
+     ** for multithreaded servers, we don't do this.
      */
     if (shareList == None) {
         shareglxc = 0;
@@ -992,7 +992,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
         buf[p++] = modes->level;
 
         assert(p == GLX_VIS_CONFIG_UNPAIRED);
-        /* 
+        /*
          ** Add token/value pairs for extensions.
          */
         buf[p++] = GLX_VISUAL_CAVEAT_EXT;
@@ -1041,7 +1041,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
  * and interface into the driver on the server-side to get GLXFBConfigs,
  * so we "invent" some based on the \c __GLXvisualConfig structures that
  * the driver does supply.
- * 
+ *
  * The reply format for both \c glXGetFBConfigs and \c glXGetFBConfigsSGIX
  * is the same, so this routine pulls double duty.
  */
@@ -2253,9 +2253,9 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
             /* NOTE: the two pad macros have been added below; they are needed
              ** because the client library pads the total byte count, but not
              ** the per-request byte counts.  The Protocol Encoding says the
-             ** total byte count should not be padded, so a proposal will be 
-             ** made to the ARB to relax the padding constraint on the total 
-             ** byte count, thus preserving backward compatibility.  Meanwhile, 
+             ** total byte count should not be padded, so a proposal will be
+             ** made to the ARB to relax the padding constraint on the total
+             ** byte count, thus preserving backward compatibility.  Meanwhile,
              ** the padding done below fixes a bug that did not allow
              ** large commands of odd sizes to be accepted by the server.
              */
@@ -2528,7 +2528,7 @@ __glXpresentCompleteNotify(WindowPtr window, CARD8 present_kind, CARD8 present_m
         glx_type = GLX_FLIP_COMPLETE_INTEL;
     else
         glx_type = GLX_BLIT_COMPLETE_INTEL;
-        
+
     __glXsendSwapEvent(drawable, glx_type, ust, msc, serial);
 }
 
diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c
index 5a8966f..bcd57a4 100644
--- a/xorg-server/glx/glxdri2.c
+++ b/xorg-server/glx/glxdri2.c
@@ -187,7 +187,7 @@ __glXdriSwapEvent(ClientPtr client, void *data, int type, CARD64 ust,
         glx_type = GLX_FLIP_COMPLETE_INTEL;
         break;
     }
-    
+
     __glXsendSwapEvent(drawable, glx_type, ust, msc, sbc);
 }
 
diff --git a/xorg-server/glx/glxscreens.c b/xorg-server/glx/glxscreens.c
index 78769f4..b0ad3b7 100644
--- a/xorg-server/glx/glxscreens.c
+++ b/xorg-server/glx/glxscreens.c
@@ -155,7 +155,7 @@ static const char GLServerExtensions[] =
     "GL_SUN_slice_accum ";
 
 /*
-** We have made the simplifying assuption that the same extensions are 
+** We have made the simplifying assuption that the same extensions are
 ** supported across all screens in a multi-screen system.
 */
 unsigned glxMajorVersion = SERVER_GLX_MAJOR_VERSION;
diff --git a/xorg-server/glx/glxscreens.h b/xorg-server/glx/glxscreens.h
index c8119fd..a905877 100644
--- a/xorg-server/glx/glxscreens.h
+++ b/xorg-server/glx/glxscreens.h
@@ -56,7 +56,7 @@ struct __GLXconfig {
 
     /* GLX */
     GLint visualID;
-    GLint visualType;     /**< One of the GLX X visual types. (i.e., 
+    GLint visualType;     /**< One of the GLX X visual types. (i.e.,
 			   * \c GLX_TRUE_COLOR, etc.)
 			   */
 
diff --git a/xorg-server/glx/indirect_dispatch.c b/xorg-server/glx/indirect_dispatch.c
index f6cabef..24784e6 100644
--- a/xorg-server/glx/indirect_dispatch.c
+++ b/xorg-server/glx/indirect_dispatch.c
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/indirect_dispatch.h b/xorg-server/glx/indirect_dispatch.h
index e6e3fda..536be60 100644
--- a/xorg-server/glx/indirect_dispatch.h
+++ b/xorg-server/glx/indirect_dispatch.h
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/indirect_dispatch_swap.c b/xorg-server/glx/indirect_dispatch_swap.c
index c0bb64d..7ebcc63 100644
--- a/xorg-server/glx/indirect_dispatch_swap.c
+++ b/xorg-server/glx/indirect_dispatch_swap.c
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/indirect_program.c b/xorg-server/glx/indirect_program.c
index d503262..cda139e 100644
--- a/xorg-server/glx/indirect_program.c
+++ b/xorg-server/glx/indirect_program.c
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2005, 2006
  * 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
diff --git a/xorg-server/glx/indirect_reqsize.c b/xorg-server/glx/indirect_reqsize.c
index 026afb6..abd0766 100644
--- a/xorg-server/glx/indirect_reqsize.c
+++ b/xorg-server/glx/indirect_reqsize.c
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/indirect_reqsize.h b/xorg-server/glx/indirect_reqsize.h
index 43e1e69..49d400c 100644
--- a/xorg-server/glx/indirect_reqsize.h
+++ b/xorg-server/glx/indirect_reqsize.h
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/indirect_size.h b/xorg-server/glx/indirect_size.h
index fec7ed3..6a3d14c 100644
--- a/xorg-server/glx/indirect_size.h
+++ b/xorg-server/glx/indirect_size.h
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2004
  * 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
diff --git a/xorg-server/glx/indirect_size_get.c b/xorg-server/glx/indirect_size_get.c
index f879311..7e81e62 100644
--- a/xorg-server/glx/indirect_size_get.c
+++ b/xorg-server/glx/indirect_size_get.c
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2004
  * 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
diff --git a/xorg-server/glx/indirect_size_get.h b/xorg-server/glx/indirect_size_get.h
index 9b62036..5af11d3 100644
--- a/xorg-server/glx/indirect_size_get.h
+++ b/xorg-server/glx/indirect_size_get.h
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2004
  * 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
diff --git a/xorg-server/glx/indirect_table.c b/xorg-server/glx/indirect_table.c
index 33e3d6a..f0f0b83 100644
--- a/xorg-server/glx/indirect_table.c
+++ b/xorg-server/glx/indirect_table.c
@@ -3,18 +3,18 @@
 /*
  * (C) Copyright IBM Corporation 2005, 2006
  * 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
diff --git a/xorg-server/glx/indirect_table.h b/xorg-server/glx/indirect_table.h
index a39dc4e..c0d6ee9 100644
--- a/xorg-server/glx/indirect_table.h
+++ b/xorg-server/glx/indirect_table.h
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2005, 2006
  * 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
diff --git a/xorg-server/glx/indirect_texture_compression.c b/xorg-server/glx/indirect_texture_compression.c
index 2018de6..cda7656 100644
--- a/xorg-server/glx/indirect_texture_compression.c
+++ b/xorg-server/glx/indirect_texture_compression.c
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2005, 2006
  * 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
diff --git a/xorg-server/glx/indirect_util.c b/xorg-server/glx/indirect_util.c
index f9d1243..926e57c 100644
--- a/xorg-server/glx/indirect_util.c
+++ b/xorg-server/glx/indirect_util.c
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
@@ -205,7 +205,7 @@ get_decode_index(const struct __glXDispatchInfo *dispatch_info, unsigned opcode)
         unsigned child_index;
 
         /* Calculate the slice of bits used by this node.
-         * 
+         *
          * If remaining_bits = 8 and tree[index] = 3, the mask of just the
          * remaining bits is 0x00ff and the mask for the remaining bits after
          * this node is 0x001f.  By taking 0x00ff & ~0x001f, we get 0x00e0.
diff --git a/xorg-server/glx/indirect_util.h b/xorg-server/glx/indirect_util.h
index 0e65075..f5db262 100644
--- a/xorg-server/glx/indirect_util.h
+++ b/xorg-server/glx/indirect_util.h
@@ -1,18 +1,18 @@
 /*
  * (C) Copyright IBM Corporation 2005
  * 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
diff --git a/xorg-server/glx/rensize.c b/xorg-server/glx/rensize.c
index bcc3a53..ba22d10 100644
--- a/xorg-server/glx/rensize.c
+++ b/xorg-server/glx/rensize.c
@@ -129,12 +129,12 @@ __glXMap2fReqSize(const GLbyte * pc, Bool swap)
 
 /**
  * Calculate the size of an image.
- * 
+ *
  * The size of an image sent to the server from the client or sent from the
  * server to the client is calculated.  The size is based on the dimensions
  * of the image, the type of pixel data, padding in the image, and the
  * alignment requirements of the image.
- * 
+ *
  * \param format       Format of the pixels.  Same as the \c format parameter
  *                     to \c glTexImage1D
  * \param type         Type of the pixel data.  Same as the \c type parameter
diff --git a/xorg-server/hw/dmx/config/Canvas.c b/xorg-server/hw/dmx/config/Canvas.c
index 1031033..3662fe8 100644
--- a/xorg-server/hw/dmx/config/Canvas.c
+++ b/xorg-server/hw/dmx/config/Canvas.c
@@ -9,7 +9,7 @@
  *
  * The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
diff --git a/xorg-server/hw/dmx/config/dmxprint.c b/xorg-server/hw/dmx/config/dmxprint.c
index 3145fb5..9dec52b 100644
--- a/xorg-server/hw/dmx/config/dmxprint.c
+++ b/xorg-server/hw/dmx/config/dmxprint.c
@@ -35,7 +35,7 @@
  *
  * This file provides support routines and helper functions to be used
  * to pretty-print DMX configurations.
- * 
+ *
  * Because the DMX configuration file parsing should be capable of being
  * used in a stand-alone fashion (i.e., independent from the DMX server
  * source tree), no dependencies on other DMX routines are made. */
diff --git a/xorg-server/hw/dmx/dmxgc.c b/xorg-server/hw/dmx/dmxgc.c
index 2d61ea2..2343167 100644
--- a/xorg-server/hw/dmx/dmxgc.c
+++ b/xorg-server/hw/dmx/dmxgc.c
@@ -391,13 +391,10 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
     pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
 
     /* Set the client clip on the back-end server */
-    switch (pGC->clientClipType) {
-    case CT_NONE:
+    if (!pGC->clientClip) {
         if (dmxScreen->beDisplay)
             XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
-        break;
-
-    case CT_REGION:
+    } else {
         if (dmxScreen->beDisplay) {
             nRects = RegionNumRects((RegionPtr) pGC->clientClip);
             pRects = malloc(nRects * sizeof(*pRects));
@@ -416,11 +413,6 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
 
             free(pRects);
         }
-        break;
-
-    case CT_PIXMAP:
-        /* Condensed down to REGION in the mi code */
-        break;
     }
 
     DMX_GC_FUNC_EPILOGUE(pGC);
diff --git a/xorg-server/hw/dmx/dmxpict.h b/xorg-server/hw/dmx/dmxpict.h
index 080da3b..f36eca3 100644
--- a/xorg-server/hw/dmx/dmxpict.h
+++ b/xorg-server/hw/dmx/dmxpict.h
@@ -34,7 +34,7 @@
 /** \file
  *  This file provides access to the externally visible RENDER support
  *  functions, global variables and macros for DMX.
- *  
+ *
  *  FIXME: Move function definitions for non-externally visible function
  *  to .c file. */
 
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c
index 23c3366..fb4d5ac 100644
--- a/xorg-server/hw/dmx/glxProxy/glxcmds.c
+++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c
@@ -188,7 +188,7 @@ CreateContext(__GLXclientState * cl,
 #endif
 
     /*
-     ** Find the display list space that we want to share.  
+     ** Find the display list space that we want to share.
      **
      */
     if (shareList == None) {
@@ -1751,7 +1751,7 @@ __glXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
         buf[p++] = pGlxVisual->stencilSize;
         buf[p++] = pGlxVisual->auxBuffers;
         buf[p++] = pGlxVisual->level;
-        /* 
+        /*
          ** Add token/value pairs for extensions.
          */
         buf[p++] = GLX_VISUAL_CAVEAT_EXT;
@@ -3087,7 +3087,7 @@ __glXCreateWindow(__GLXclientState * cl, GLbyte * pc)
     void *val;
 
     /*
-     ** Check if windowId is valid 
+     ** Check if windowId is valid
      */
     rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW,
                            DixAddAccess);
@@ -3112,7 +3112,7 @@ __glXCreateWindow(__GLXclientState * cl, GLbyte * pc)
     visId = pGlxFBConfig->associatedVisualId;
 
     /*
-     ** Check if the fbconfig supports rendering to windows 
+     ** Check if the fbconfig supports rendering to windows
      */
     if (!(pGlxFBConfig->drawableType & GLX_WINDOW_BIT)) {
         return BadMatch;
@@ -3134,7 +3134,7 @@ __glXCreateWindow(__GLXclientState * cl, GLbyte * pc)
         }
 
         /*
-         ** Check if color buffer depth of fbconfig matches depth 
+         ** Check if color buffer depth of fbconfig matches depth
          ** of window.
          */
         if (pVisual->nplanes != pDraw->depth) {
@@ -3144,7 +3144,7 @@ __glXCreateWindow(__GLXclientState * cl, GLbyte * pc)
     else
         /*
          ** The window was created with no visual that corresponds
-         ** to fbconfig 
+         ** to fbconfig
          */
         return BadMatch;
 
@@ -3561,7 +3561,7 @@ __glXGetDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
         return __glXBadDrawable;
     }
 
-    /* if the drawable is a window or GLXWindow - 
+    /* if the drawable is a window or GLXWindow -
      * we need to find the base id on the back-end server
      */
     if (!be_drawable) {
@@ -3723,7 +3723,7 @@ __glXChangeDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
         return __glXBadDrawable;
     }
 
-    /* if the drawable is a window or GLXWindow - 
+    /* if the drawable is a window or GLXWindow -
      * we need to find the base id on the back-end server
      */
     if (!be_drawable) {
diff --git a/xorg-server/hw/dmx/glxProxy/glxsingle.c b/xorg-server/hw/dmx/glxProxy/glxsingle.c
index 679a302..0344973 100644
--- a/xorg-server/hw/dmx/glxProxy/glxsingle.c
+++ b/xorg-server/hw/dmx/glxProxy/glxsingle.c
@@ -233,7 +233,7 @@ __glXForwardPipe0WithReply(__GLXclientState * cl, GLbyte * pc)
     dmxScreen = &dmxScreens[glxc->pScreen->myNum];
     dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
 
-    /* 
+    /*
      * send the request to the first back-end server
      */
     LockDisplay(dpy);
@@ -329,7 +329,7 @@ __glXForwardAllWithReply(__GLXclientState * cl, GLbyte * pc)
     pc += sz_xGLXSingleReq;
     buf_size = (req->length << 2) - sz_xGLXSingleReq;
 
-    /* 
+    /*
      * send the request to the first back-end server(s)
      */
     for (s = to_screen; s >= from_screen; s--) {
diff --git a/xorg-server/hw/dmx/glxProxy/glxvendor.c b/xorg-server/hw/dmx/glxProxy/glxvendor.c
index b475daf..fc8aff0 100644
--- a/xorg-server/hw/dmx/glxProxy/glxvendor.c
+++ b/xorg-server/hw/dmx/glxProxy/glxvendor.c
@@ -220,7 +220,7 @@ __glXVForwardPipe0WithReply(__GLXclientState * cl, GLbyte * pc)
     dmxScreen = &dmxScreens[glxc->pScreen->myNum];
     dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
 
-    /* 
+    /*
      * send the request to the first back-end server
      */
     LockDisplay(dpy);
@@ -311,7 +311,7 @@ __glXVForwardAllWithReply(__GLXclientState * cl, GLbyte * pc)
     pc += sz_xGLXVendorPrivateReq;
     buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
 
-    /* 
+    /*
      * send the request to the first back-end server(s)
      */
     for (s = to_screen; s >= from_screen; s--) {
diff --git a/xorg-server/hw/dmx/input/ChkNotMaskEv.c b/xorg-server/hw/dmx/input/ChkNotMaskEv.c
index bde04ae..8411af8 100644
--- a/xorg-server/hw/dmx/input/ChkNotMaskEv.c
+++ b/xorg-server/hw/dmx/input/ChkNotMaskEv.c
@@ -16,7 +16,7 @@
  * OPEN GROUP 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.
- * 
+ *
  * Except as contained in this notice, the name of The Open Group shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from The Open Group.
diff --git a/xorg-server/hw/dmx/input/lnx-keyboard.c b/xorg-server/hw/dmx/input/lnx-keyboard.c
index 1a4d01f..0aa62f4 100644
--- a/xorg-server/hw/dmx/input/lnx-keyboard.c
+++ b/xorg-server/hw/dmx/input/lnx-keyboard.c
@@ -65,19 +65,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Orest Zborowski and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Orest Zborowski and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Orest Zborowski
- * and David Dawes make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * and David Dawes make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD 
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE 
- * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+ * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
diff --git a/xorg-server/hw/dmx/input/lnx-ms.c b/xorg-server/hw/dmx/input/lnx-ms.c
index 210f6de..621f0fe 100644
--- a/xorg-server/hw/dmx/input/lnx-ms.c
+++ b/xorg-server/hw/dmx/input/lnx-ms.c
@@ -17,7 +17,7 @@
  *
  * The above copyright notice and this permission notice 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
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 5761710..93a48a9 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -313,8 +313,8 @@ ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
     EPHYR_LOG("slow paint");
 
     /* FIXME: Slow Rotated/Reflected updates could be much
-     * much faster efficiently updating via tranforming 
-     * pBuf->pDamage  regions     
+     * much faster efficiently updating via tranforming
+     * pBuf->pDamage  regions
      */
     shadowUpdateRotatePacked(pScreen, pBuf);
     hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height);
@@ -535,7 +535,7 @@ ephyrRandRSetConfig(ScreenPtr pScreen,
             goto bail4;
     }
     else {
-        /* Without shadow fb ( non rotated ) we need 
+        /* Without shadow fb ( non rotated ) we need
          * to use damage to efficiently update display
          * via signal regions what to copy from 'fb'.
          */
@@ -687,7 +687,7 @@ ephyrInitScreen(ScreenPtr pScreen)
 Bool
 ephyrFinishInitScreen(ScreenPtr pScreen)
 {
-    /* FIXME: Calling this even if not using shadow.  
+    /* FIXME: Calling this even if not using shadow.
      * Seems harmless enough. But may be safer elsewhere.
      */
     if (!shadowSetup(pScreen))
@@ -773,7 +773,7 @@ ephyrCloseScreen(ScreenPtr pScreen)
     ephyrUnsetInternalDamage(pScreen);
 }
 
-/*  
+/*
  * Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
  * See https://bugs.freedesktop.org/show_bug.cgi?id=3030
  */
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
index f3a3c8e..2395a7f 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at o-hand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.c b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
index 16678fc..1e34301 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdri.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.h b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
index 8f2d302..b312e62 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdri.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
index 8368d12..3d5cf77 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.h b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
index 5808576..9755715 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
index 632a9c4..248689e 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.h b/xorg-server/hw/kdrive/ephyr/ephyrglxext.h
index 053f8d3..8b4b3a2 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrglxext.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
index 007524d..0b98cce 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
index 309d0f2..f1eec5f 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index bcfb750..897aa19 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at o-hand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrlog.h b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
index 0da0a25..43679e1 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrlog.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
index ab18c7a..56a5ff1 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at openedhand.com>
- * 
- * Copyright © 2007 OpenedHand Ltd 
+ *
+ * Copyright © 2007 OpenedHand Ltd
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c
index 0562625..8d6d5e8 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.c
+++ b/xorg-server/hw/kdrive/ephyr/hostx.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at o-hand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -974,15 +974,15 @@ hostx_paint_rect(KdScreenInfo *screen,
         hostx_paint_debug_rect(screen, dx, dy, width, height);
     }
 
-    /* 
+    /*
      * If the depth of the ephyr server is less than that of the host,
      * the kdrive fb does not point to the ximage data but to a buffer
      * ( fb_data ), we shift the various bits from this onto the XImage
      * so they match the host.
      *
-     * Note, This code is pretty new ( and simple ) so may break on 
-     *       endian issues, 32 bpp host etc. 
-     *       Not sure if 8bpp case is right either. 
+     * Note, This code is pretty new ( and simple ) so may break on
+     *       endian issues, 32 bpp host etc.
+     *       Not sure if 8bpp case is right either.
      *       ... and it will be slower than the matching depth case.
      */
 
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.h b/xorg-server/hw/kdrive/ephyr/hostx.h
index 229961e..87acd5a 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.h
+++ b/xorg-server/hw/kdrive/ephyr/hostx.h
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at o-hand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/ephyr/os.c b/xorg-server/hw/kdrive/ephyr/os.c
index 56b52d1..0dbcbb8 100644
--- a/xorg-server/hw/kdrive/ephyr/os.c
+++ b/xorg-server/hw/kdrive/ephyr/os.c
@@ -1,8 +1,8 @@
 /*
  * Xephyr - A kdrive X server thats runs in a host X window.
  *          Authored by Matthew Allum <mallum at o-hand.com>
- * 
- * Copyright © 2004 Nokia 
+ *
+ * Copyright © 2004 Nokia
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index 163d5c1..369db33 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -492,7 +492,7 @@ static void
 KdXVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
 {
     /* copy the new clip if it exists */
-    if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+    if (pGC->clientClip) {
         if (!portPriv->clientClip)
             portPriv->clientClip = RegionCreate(NullBox, 1);
         /* Note: this is in window coordinates */
diff --git a/xorg-server/hw/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am
index 30f7c8f..d46bf0a 100644
--- a/xorg-server/hw/xfree86/Makefile.am
+++ b/xorg-server/hw/xfree86/Makefile.am
@@ -43,7 +43,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
 DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
                parser ramdac shadowfb vbe vgahw \
                loader dixmods dri dri2 exa modes \
-	       utils doc man glamor_egl
+	       utils doc man glamor_egl drivers
 
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am
index 7a2b4bc..54e7f4d 100644
--- a/xorg-server/hw/xfree86/common/Makefile.am
+++ b/xorg-server/hw/xfree86/common/Makefile.am
@@ -103,4 +103,8 @@ if LNXACPI
 XORG_CFLAGS += -DHAVE_ACPI
 endif
 
+if NEED_DBUS
+XORG_CFLAGS += $(DBUS_CFLAGS)
+endif
+
 AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h
index 5325129..1653574 100644
--- a/xorg-server/hw/xfree86/common/compiler.h
+++ b/xorg-server/hw/xfree86/common/compiler.h
@@ -1077,9 +1077,9 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
     (*xf86WriteMmio16)((CARD16)(val), base, offset)
 
 #elif defined(__powerpc__) || defined(__sparc__)
- /* 
+ /*
   * we provide byteswapping and no byteswapping functions here
-  * with byteswapping as default, 
+  * with byteswapping as default,
   * drivers that don't need byteswapping should define MMIO_IS_BE
   */
 #define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index 2b53b90..03dad15 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -9,10 +9,10 @@
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -20,12 +20,12 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the copyright holder(s)
  * and author(s) shall not be used in advertising or otherwise to promote
  * the sale, use or other dealings in this Software without prior written
  * authorization from the copyright holder(s) and author(s).
- * 
+ *
  * Author: David Dawes <dawes at XFree86.Org>.
  */
 
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index bd3e4e3..889294f 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -519,7 +519,7 @@ xf86GetDevFromEntity(int entityIndex, int instance)
 }
 
 /*
- * xf86AccessEnter() -- gets called to save the text mode VGA IO 
+ * xf86AccessEnter() -- gets called to save the text mode VGA IO
  * resources when reentering the server after a VT switch.
  */
 void
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 5b254ba..d42572f 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -274,7 +274,7 @@ xf86ModulelistFromConfig(void ***optlist)
 
     if (xf86configptr->conf_modules) {
         /* Walk the disable list and let people know what we've parsed to
-         * not be loaded 
+         * not be loaded
          */
         modp = xf86configptr->conf_modules->mod_disable_lst;
         while (modp) {
@@ -1941,7 +1941,7 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
         /* now add the modes found in the modes
            section to the list of modes for this
            monitor unless it has been added before
-           because we are reusing the same section 
+           because we are reusing the same section
            for another screen */
         if (xf86itemNotSublist((GenericListPtr) conf_monitor->mon_modeline_lst,
                                (GenericListPtr) modes->mon_modeline_lst)) {
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index 8dbca3a..cc7ff1b 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -679,8 +679,8 @@ DoConfigure(void)
                 if (primary)
                     continue;
                 /* not primary: assign it to next device of same driver */
-                /* 
-                 * NOTE: we assume that devices in DevToConfig 
+                /*
+                 * NOTE: we assume that devices in DevToConfig
                  * and xf86Screens[] have the same order except
                  * for the primary device which always comes first.
                  */
diff --git a/xorg-server/hw/xfree86/common/xf86Mode.c b/xorg-server/hw/xfree86/common/xf86Mode.c
index 44bc559..9a5550f 100644
--- a/xorg-server/hw/xfree86/common/xf86Mode.c
+++ b/xorg-server/hw/xfree86/common/xf86Mode.c
@@ -1878,8 +1878,8 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
             const int ntypes = sizeof(types) / sizeof(int);
             int n;
 
-            /* 
-             * We did not find the estimated virtual size. So now we want to 
+            /*
+             * We did not find the estimated virtual size. So now we want to
              * find the largest mode available, but we want to search in the
              * modes in the order of "types" listed above.
              */
@@ -2033,8 +2033,8 @@ xf86PruneDriverModes(ScrnInfoPtr scrp)
         /*
          * A modePool mode's prev field is used to hold a pointer to the
          * member of the scrp->modes list for which a match was considered.
-         * Clear that pointer first, otherwise xf86DeleteMode might get 
-         * confused 
+         * Clear that pointer first, otherwise xf86DeleteMode might get
+         * confused
          */
         scrp->modePool->prev = NULL;
         xf86DeleteMode(&scrp->modePool, scrp->modePool);
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index b848f53..e68fe9c 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -80,9 +80,9 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(18, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(19, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(21, 0)
-#define ABI_EXTENSION_VERSION	SET_ABI_VERSION(8, 0)
+#define ABI_EXTENSION_VERSION	SET_ABI_VERSION(9, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
 #define MODINFOSTRING1	0xef23fdc5
diff --git a/xorg-server/hw/xfree86/common/xf86PciInfo.h b/xorg-server/hw/xfree86/common/xf86PciInfo.h
index d6450e2..0f54308 100644
--- a/xorg-server/hw/xfree86/common/xf86PciInfo.h
+++ b/xorg-server/hw/xfree86/common/xf86PciInfo.h
@@ -40,7 +40,7 @@
  * or for non-video devices unless they're needed by a driver or elsewhere.
  * A comprehensive set of PCI vendor, device and subsystem data is
  * auto-generated from the ../etc/pci.ids file using the pciids2c.pl script,
- * and is used in scanpci utility.  Don't modify the pci.ids file.  If 
+ * and is used in scanpci utility.  Don't modify the pci.ids file.  If
  * new/corrected entries are required, add them to ../etc/extrapci.ids.
  */
 
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 4e8060b..1fb5b16 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-1999 by Frederic Lepied, France. <Lepied at XFree86.org>
- *                                                                            
+ *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is  hereby granted without fee, provided that
  * the  above copyright   notice appear  in   all  copies and  that both  that
@@ -9,8 +9,8 @@
  * advertising or publicity pertaining to distribution of the software without
  * specific,  written      prior  permission.     Frederic  Lepied   makes  no
  * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.                   
- *                                                                            
+ * is provided "as is" without express or implied warranty.
+ *
  * FREDERIC  LEPIED DISCLAIMS ALL   WARRANTIES WITH REGARD  TO  THIS SOFTWARE,
  * INCLUDING ALL IMPLIED   WARRANTIES OF MERCHANTABILITY  AND   FITNESS, IN NO
  * EVENT  SHALL FREDERIC  LEPIED BE   LIABLE   FOR ANY  SPECIAL, INDIRECT   OR
@@ -315,7 +315,7 @@ ApplyTransformationMatrix(DeviceIntPtr dev)
 /***********************************************************************
  *
  * xf86ProcessCommonOptions --
- * 
+ *
  *	Process global options.
  *
  ***********************************************************************
@@ -1077,7 +1077,7 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
     OsReleaseSignals();
 }
 
-/* 
+/*
  * convenient functions to post events
  */
 
@@ -1401,7 +1401,7 @@ xf86FirstLocalDevice(void)
     return xf86InputDevs;
 }
 
-/* 
+/*
  * Cx     - raw data from touch screen
  * to_max - scaled highest dimension
  *          (remember, this is of rows - 1 because of 0 origin)
@@ -1475,7 +1475,7 @@ xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
  * Device will be moved to the off_devices list, but it will still be there
  * until you really clean up after it.
  * Notifies the client about an inactive device.
- * 
+ *
  * @param panic True if device is unrecoverable and needs to be removed.
  */
 void
@@ -1493,7 +1493,7 @@ xf86DisableDevice(DeviceIntPtr dev, Bool panic)
 /**
  * Reactivate a device. Call this function from the driver if you just found
  * out that the read error wasn't quite that bad after all.
- * Device will be re-activated, and an event sent to the client. 
+ * Device will be re-activated, and an event sent to the client.
  */
 void
 xf86EnableDevice(DeviceIntPtr dev)
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.h b/xorg-server/hw/xfree86/common/xf86Xinput.h
index 66a64fb..42d66d2 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.h
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-1999 by Frederic Lepied, France. <Lepied at XFree86.org>
- *                                                                            
+ *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is  hereby granted without fee, provided that
  * the  above copyright   notice appear  in   all  copies and  that both  that
@@ -9,8 +9,8 @@
  * advertising or publicity pertaining to distribution of the software without
  * specific,  written      prior  permission.     Frederic  Lepied   makes  no
  * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.                   
- *                                                                            
+ * is provided "as is" without express or implied warranty.
+ *
  * FREDERIC  LEPIED DISCLAIMS ALL   WARRANTIES WITH REGARD  TO  THIS SOFTWARE,
  * INCLUDING ALL IMPLIED   WARRANTIES OF MERCHANTABILITY  AND   FITNESS, IN NO
  * EVENT  SHALL FREDERIC  LEPIED BE   LIABLE   FOR ANY  SPECIAL, INDIRECT   OR
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index c4bae56..ab51f96 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -443,7 +443,7 @@ CMapInstallColormap(ColormapPtr pmap)
     (*pScreen->InstallColormap) (pmap);
     pScreen->InstallColormap = CMapInstallColormap;
 
-    /* Important. We let the lower layers, namely DGA, 
+    /* Important. We let the lower layers, namely DGA,
        overwrite the choice of Colormap to install */
     if (GetInstalledmiColormap(pmap->pScreen))
         pmap = GetInstalledmiColormap(pmap->pScreen);
@@ -958,7 +958,7 @@ CMapChangeGamma(ScrnInfoPtr pScrn, Gamma gamma)
             }
 
             if (pLink) {
-                /* need to trick CMapRefreshColors() into thinking 
+                /* need to trick CMapRefreshColors() into thinking
                    this is the currently installed map */
                 SetInstalledmiColormap(pScreen, pLink->cmap);
                 CMapReinstallMap(pLink->cmap);
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c
index db715bd..1b2cb57 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.c
+++ b/xorg-server/hw/xfree86/common/xf86fbman.c
@@ -38,7 +38,7 @@
 #include "regionstr.h"
 #include "xf86fbman.h"
 
-/* 
+/*
 #define DEBUG
 */
 
@@ -259,7 +259,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
     return (*funcs->PurgeOffscreenAreas) (pScreen);
 }
 
-/************************************************************\ 
+/************************************************************\
 
    Below is a specific implementation of an offscreen manager.
 
@@ -1381,7 +1381,7 @@ xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size)
     return TRUE;
 }
 
-/* This is an implementation specific function and should 
+/* This is an implementation specific function and should
    disappear after the next release.  People should use the
    real linear functions instead */
 
diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c
index 5ad9b70..15988b8 100644
--- a/xorg-server/hw/xfree86/common/xf86platformBus.c
+++ b/xorg-server/hw/xfree86/common/xf86platformBus.c
@@ -497,7 +497,7 @@ xf86platformAddDevice(int index)
 
     if (xf86GPUScreens[i]->PreInit &&
         xf86GPUScreens[i]->PreInit(xf86GPUScreens[i], 0))
-        xf86GPUScreens[i]->configured = TRUE; 
+        xf86GPUScreens[i]->configured = TRUE;
 
     if (!xf86GPUScreens[i]->configured) {
         ErrorF("hotplugged device %d didn't configure\n", i);
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index 9ad1b90..643a65d 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -568,7 +568,7 @@ typedef struct _PciChipsets {
      * In drivers that don't have a specific vendor (e.g., vga) contains the
      * device ID for either the generic VGA or generic 8514 devices.  This
      * turns out to be the same as the subclass and programming interface
-     * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or 
+     * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or
      * 0x000101) and for 8514 is 0x030001).
      */
     int PCIid;
diff --git a/xorg-server/hw/xfree86/common/xf86vmode.c b/xorg-server/hw/xfree86/common/xf86vmode.c
index 2b07833..0ce58e3 100644
--- a/xorg-server/hw/xfree86/common/xf86vmode.c
+++ b/xorg-server/hw/xfree86/common/xf86vmode.c
@@ -17,13 +17,13 @@ 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 NONINFRINGEMENT.
-IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES 
+IN NO EVENT SHALL Kaleb S. KEITHLEY 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.
 
-Except as contained in this notice, the name of Kaleb S. KEITHLEY 
-shall not be used in advertising or otherwise to promote the sale, use 
+Except as contained in this notice, the name of Kaleb S. KEITHLEY
+shall not be used in advertising or otherwise to promote the sale, use
 or other dealings in this Software without prior written authorization
 from Kaleb S. KEITHLEY
 
@@ -361,7 +361,7 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
     }
 
     /*
-     * Older servers sometimes had server privates that the VidMode 
+     * Older servers sometimes had server privates that the VidMode
      * extention made available. So to be compatiable pretend that
      * there are no server privates to pass to the client
      */
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index 5ef5de1..b974cd2 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -599,7 +599,7 @@ static void
 xf86XVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
 {
     /* copy the new clip if it exists */
-    if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+    if (pGC->clientClip) {
         if (!portPriv->clientClip)
             portPriv->clientClip = RegionCreate(NullBox, 1);
         /* Note: this is in window coordinates */
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.h b/xorg-server/hw/xfree86/common/xf86xvmc.h
index aaa4e65..023aff5 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.h
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.h
@@ -51,7 +51,7 @@ typedef struct {
 } XF86MCSurfaceInfoRec, *XF86MCSurfaceInfoPtr;
 
 /*
-   xf86XvMCCreateContextProc 
+   xf86XvMCCreateContextProc
 
    DIX will fill everything out in the context except the driver_priv.
    The port_priv holds the private data specified for the port when
@@ -71,7 +71,7 @@ typedef void (*xf86XvMCDestroyContextProcPtr) (ScrnInfoPtr pScrn,
                                                XvMCContextPtr context);
 
 /*
-   xf86XvMCCreateSurfaceProc 
+   xf86XvMCCreateSurfaceProc
 
    DIX will fill everything out in the surface except the driver_priv.
    The driver may store whatever it wants in driver_priv.  The driver
@@ -87,7 +87,7 @@ typedef void (*xf86XvMCDestroySurfaceProcPtr) (ScrnInfoPtr pScrn,
                                                XvMCSurfacePtr surface);
 
 /*
-   xf86XvMCCreateSubpictureProc 
+   xf86XvMCCreateSubpictureProc
 
    DIX will fill everything out in the subpicture except the driver_priv,
    num_palette_entries, entry_bytes and component_order.  The driver may
@@ -122,8 +122,8 @@ typedef struct {
     xf86XvMCDestroySubpictureProcPtr DestroySubpicture;
 } XF86MCAdaptorRec, *XF86MCAdaptorPtr;
 
-/* 
-   xf86XvMCScreenInit 
+/*
+   xf86XvMCScreenInit
 
    Unlike Xv, the adaptor data is not copied from this structure.
    This structure's data is used so it must stick around for the
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 15e4beb..29185ad 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -1,5 +1,5 @@
-/* xf86DDC.c 
- * 
+/* xf86DDC.c
+ *
  * Copyright 1998,1999 by Egbert Eich <Egbert.Eich at Physik.TU-Darmstadt.DE>
  */
 
@@ -212,10 +212,10 @@ TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC) (ScrnInfoPtr))
     return count;
 }
 
-/* 
+/*
  * read EDID record , pass it to callback function to interpret.
  * callback function will store it for further use by calling
- * function; it will also decide if we need to reread it 
+ * function; it will also decide if we need to reread it
  */
 static unsigned char *
 EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
@@ -328,7 +328,7 @@ DDC2Init(I2CBusPtr pBus)
     I2CDevPtr dev = NULL;
 
     /*
-     * Slow down the bus so that older monitors don't 
+     * Slow down the bus so that older monitors don't
      * miss things.
      */
     pBus->RiseFallTime = 20;
diff --git a/xorg-server/hw/xfree86/ddc/edid.h b/xorg-server/hw/xfree86/ddc/edid.h
index 91565a2..4c2da51 100644
--- a/xorg-server/hw/xfree86/ddc/edid.h
+++ b/xorg-server/hw/xfree86/ddc/edid.h
@@ -1,9 +1,9 @@
 /*
- * edid.h: defines to parse an EDID block 
+ * edid.h: defines to parse an EDID block
  *
- * This file contains all information to interpret a standard EDIC block 
- * transmitted by a display device via DDC (Display Data Channel). So far 
- * there is no information to deal with optional EDID blocks.  
+ * This file contains all information to interpret a standard EDIC block
+ * transmitted by a display device via DDC (Display Data Channel). So far
+ * there is no information to deal with optional EDID blocks.
  * DDC is a Trademark of VESA (Video Electronics Standard Association).
  *
  * Copyright 1998 by Egbert Eich <Egbert.Eich at Physik.TU-Darmstadt.DE>
diff --git a/xorg-server/hw/xfree86/ddc/print_edid.c b/xorg-server/hw/xfree86/ddc/print_edid.c
index 4f983f9..e16b124 100644
--- a/xorg-server/hw/xfree86/ddc/print_edid.c
+++ b/xorg-server/hw/xfree86/ddc/print_edid.c
@@ -21,7 +21,7 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  *
- * print_edid.c: print out all information retrieved from display device  
+ * print_edid.c: print out all information retrieved from display device
  */
 
 #ifdef HAVE_XORG_CONFIG_H
diff --git a/xorg-server/hw/xfree86/ddc/xf86DDC.h b/xorg-server/hw/xfree86/ddc/xf86DDC.h
index 727813f..7d81ab9 100644
--- a/xorg-server/hw/xfree86/ddc/xf86DDC.h
+++ b/xorg-server/hw/xfree86/ddc/xf86DDC.h
@@ -1,9 +1,9 @@
 
 /* xf86DDC.h
  *
- * This file contains all information to interpret a standard EDIC block 
- * transmitted by a display device via DDC (Display Data Channel). So far 
- * there is no information to deal with optional EDID blocks.  
+ * This file contains all information to interpret a standard EDIC block
+ * transmitted by a display device via DDC (Display Data Channel). So far
+ * there is no information to deal with optional EDID blocks.
  * DDC is a Trademark of VESA (Video Electronics Standard Association).
  *
  * Copyright 1998 by Egbert Eich <Egbert.Eich at Physik.TU-Darmstadt.DE>
diff --git a/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c b/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c
index 6dd21dd..79cf081 100644
--- a/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c
+++ b/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/hw/xfree86/dixmods/xkbVT.c b/xorg-server/hw/xfree86/dixmods/xkbVT.c
index 4ca4451..9840961 100644
--- a/xorg-server/hw/xfree86/dixmods/xkbVT.c
+++ b/xorg-server/hw/xfree86/dixmods/xkbVT.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index 5077c7c..ae92fc2 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -2292,11 +2292,11 @@ DRIAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
     _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
 }
 
-/* 
+/*
  * DRIMoveBuffersHelper swaps the regions rects in place leaving you
  * a region with the rects in the order that you need to blit them,
  * but it is possibly (likely) an invalid region afterwards.  If you
- * need to use the region again for anything you have to call 
+ * need to use the region again for anything you have to call
  * REGION_VALIDATE on it, or better yet, save a copy first.
  */
 
diff --git a/xorg-server/hw/xfree86/dri/sarea.h b/xorg-server/hw/xfree86/dri/sarea.h
index 7a55b49..1bef242 100644
--- a/xorg-server/hw/xfree86/dri/sarea.h
+++ b/xorg-server/hw/xfree86/dri/sarea.h
@@ -1,7 +1,7 @@
 /**
- * \file sarea.h 
+ * \file sarea.h
  * SAREA definitions.
- * 
+ *
  * \author Kevin E. Martin <kevin at precisioninsight.com>
  * \author Jens Owen <jens at tungstengraphics.com>
  * \author Rickard E. (Rik) Faith <faith at valinux.com>
@@ -11,7 +11,7 @@
  * 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
@@ -19,11 +19,11 @@
  * 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.
diff --git a/xorg-server/hw/xfree86/dri2/Makefile.am b/xorg-server/hw/xfree86/dri2/Makefile.am
index 502a2ee..78e507b 100644
--- a/xorg-server/hw/xfree86/dri2/Makefile.am
+++ b/xorg-server/hw/xfree86/dri2/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS=pci_ids
+
 noinst_LTLIBRARIES = libdri2.la
 AM_CFLAGS = \
 	-DHAVE_XORG_CONFIG_H \
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 6459f11..c8fcd62 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -1410,6 +1410,59 @@ get_prime_id(void)
     return -1;
 }
 
+#include "pci_ids/pci_id_driver_map.h"
+
+static char *
+dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+    EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+    struct pci_device *pdev = NULL;
+    int i, j;
+
+    if (pEnt)
+        pdev = xf86GetPciInfoForEntity(pEnt->index);
+
+    /* For non-PCI devices, just assume that the 3D driver is named
+     * the same as the kernel driver.  This is currently true for vc4
+     * and msm (freedreno).
+     */
+    if (!pdev) {
+        drmVersionPtr version = drmGetVersion(info->fd);
+        char *kernel_driver;
+
+        if (!version) {
+            xf86DrvMsg(pScreen->myNum, X_ERROR,
+                       "[DRI2] Couldn't drmGetVersion() on non-PCI device, "
+                       "no driver name found.\n");
+            return NULL;
+        }
+
+        kernel_driver = strndup(version->name, version->name_len);
+        drmFreeVersion(version);
+        return kernel_driver;
+    }
+
+    for (i = 0; driver_map[i].driver; i++) {
+        if (pdev->vendor_id != driver_map[i].vendor_id)
+            continue;
+
+        if (driver_map[i].num_chips_ids == -1)
+            return strdup(driver_map[i].driver);
+
+        for (j = 0; j < driver_map[i].num_chips_ids; j++) {
+            if (driver_map[i].chip_ids[j] == pdev->device_id)
+                return strdup(driver_map[i].driver);
+        }
+    }
+
+    xf86DrvMsg(pScreen->myNum, X_ERROR,
+               "[DRI2] No driver mapping found for PCI device "
+               "0x%04x / 0x%04x\n",
+               pdev->vendor_id, pdev->device_id);
+    return NULL;
+}
+
 Bool
 DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 {
@@ -1524,7 +1577,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->driverNames = malloc(sizeof(*ds->driverNames));
         if (!ds->driverNames)
             goto err_out;
-        ds->driverNames[0] = info->driverName;
+
+        if (info->driverName) {
+            ds->driverNames[0] = info->driverName;
+        } else {
+            ds->driverNames[0] = dri2_probe_driver_name(pScreen, info);
+            if (!ds->driverNames[0])
+                return FALSE;
+        }
     }
     else {
         ds->numDrivers = info->numDrivers;
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/Makefile.am b/xorg-server/hw/xfree86/dri2/pci_ids/Makefile.am
new file mode 100644
index 0000000..c511108
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/Makefile.am
@@ -0,0 +1,11 @@
+EXTRA_DIST = \
+	pci_id_driver_map.h \
+	i810_pci_ids.h \
+	i915_pci_ids.h \
+	i965_pci_ids.h \
+	r200_pci_ids.h \
+	r300_pci_ids.h \
+	r600_pci_ids.h \
+	radeon_pci_ids.h \
+	radeonsi_pci_ids.h \
+	vmwgfx_pci_ids.h
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/i810_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/i810_pci_ids.h
new file mode 100644
index 0000000..7f68192
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/i810_pci_ids.h
@@ -0,0 +1,4 @@
+CHIPSET(0x7121, I810, i8xx)
+CHIPSET(0x7123, I810_DC100, i8xx)
+CHIPSET(0x7125, I810_E, i8xx)
+CHIPSET(0x1132, I815, i8xx)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/i915_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/i915_pci_ids.h
new file mode 100644
index 0000000..7d51975
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/i915_pci_ids.h
@@ -0,0 +1,15 @@
+CHIPSET(0x3577, I830_M,   "Intel(R) 830M")
+CHIPSET(0x2562, 845_G,    "Intel(R) 845G")
+CHIPSET(0x3582, I855_GM,  "Intel(R) 852GM/855GM")
+CHIPSET(0x2572, I865_G,   "Intel(R) 865G")
+CHIPSET(0x2582, I915_G,   "Intel(R) 915G")
+CHIPSET(0x258A, E7221_G,  "Intel(R) E7221G (i915)")
+CHIPSET(0x2592, I915_GM,  "Intel(R) 915GM")
+CHIPSET(0x2772, I945_G,   "Intel(R) 945G")
+CHIPSET(0x27A2, I945_GM,  "Intel(R) 945GM")
+CHIPSET(0x27AE, I945_GME, "Intel(R) 945GME")
+CHIPSET(0x29B2, Q35_G,    "Intel(R) Q35")
+CHIPSET(0x29C2, G33_G,    "Intel(R) G33")
+CHIPSET(0x29D2, Q33_G,    "Intel(R) Q33")
+CHIPSET(0xA011, IGD_GM,   "Intel(R) IGD")
+CHIPSET(0xA001, IGD_G,    "Intel(R) IGD")
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/i965_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/i965_pci_ids.h
new file mode 100644
index 0000000..2e04301
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/i965_pci_ids.h
@@ -0,0 +1,115 @@
+CHIPSET(0x29A2, i965,    "Intel(R) 965G")
+CHIPSET(0x2992, i965,    "Intel(R) 965Q")
+CHIPSET(0x2982, i965,    "Intel(R) 965G")
+CHIPSET(0x2972, i965,    "Intel(R) 946GZ")
+CHIPSET(0x2A02, i965,    "Intel(R) 965GM")
+CHIPSET(0x2A12, i965,    "Intel(R) 965GME/GLE")
+CHIPSET(0x2A42, g4x,     "Mobile Intel® GM45 Express Chipset")
+CHIPSET(0x2E02, g4x,     "Intel(R) Integrated Graphics Device")
+CHIPSET(0x2E12, g4x,     "Intel(R) Q45/Q43")
+CHIPSET(0x2E22, g4x,     "Intel(R) G45/G43")
+CHIPSET(0x2E32, g4x,     "Intel(R) G41")
+CHIPSET(0x2E42, g4x,     "Intel(R) B43")
+CHIPSET(0x2E92, g4x,     "Intel(R) B43")
+CHIPSET(0x0042, ilk,     "Intel(R) Ironlake Desktop")
+CHIPSET(0x0046, ilk,     "Intel(R) Ironlake Mobile")
+CHIPSET(0x0102, snb_gt1, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0112, snb_gt2, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0122, snb_gt2, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0106, snb_gt1, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x0116, snb_gt2, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x0126, snb_gt2, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x010A, snb_gt1, "Intel(R) Sandybridge Server")
+CHIPSET(0x0152, ivb_gt1, "Intel(R) Ivybridge Desktop")
+CHIPSET(0x0162, ivb_gt2, "Intel(R) Ivybridge Desktop")
+CHIPSET(0x0156, ivb_gt1, "Intel(R) Ivybridge Mobile")
+CHIPSET(0x0166, ivb_gt2, "Intel(R) Ivybridge Mobile")
+CHIPSET(0x015a, ivb_gt1, "Intel(R) Ivybridge Server")
+CHIPSET(0x016a, ivb_gt2, "Intel(R) Ivybridge Server")
+CHIPSET(0x0402, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0412, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0422, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0406, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0416, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0426, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x040A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x041A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x042A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x040B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x041B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x042B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x040E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x041E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x042E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0C02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0C1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0C2A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x0C0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0C1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0C2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0C0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0C1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0C2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0A02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0A1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0A2A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x0A0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0A1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0A2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0A0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0A1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0A2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0D1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0D2A, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0D1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0D2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0D1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0D2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0F31, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0F32, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0F33, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0157, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0155, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x1602, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x1606, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160A, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160B, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160D, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160E, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x1612, bdw_gt2, "Intel(R) HD Graphics 5600 (Broadwell GT2)")
+CHIPSET(0x1616, bdw_gt2, "Intel(R) HD Graphics 5500 (Broadwell GT2)")
+CHIPSET(0x161A, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161B, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161D, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161E, bdw_gt2, "Intel(R) HD Graphics 5300 (Broadwell GT2)")
+CHIPSET(0x1622, bdw_gt3, "Intel(R) Iris Pro 6200 (Broadwell GT3e)")
+CHIPSET(0x1626, bdw_gt3, "Intel(R) HD Graphics 6000 (Broadwell GT3)")
+CHIPSET(0x162A, bdw_gt3, "Intel(R) Iris Pro P6300 (Broadwell GT3e)")
+CHIPSET(0x162B, bdw_gt3, "Intel(R) Iris 6100 (Broadwell GT3)")
+CHIPSET(0x162D, bdw_gt3, "Intel(R) Broadwell GT3")
+CHIPSET(0x162E, bdw_gt3, "Intel(R) Broadwell GT3")
+CHIPSET(0x22B0, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B1, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B2, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B3, chv,     "Intel(R) Cherryview")
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h b/xorg-server/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
new file mode 100644
index 0000000..8a97c6f
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
@@ -0,0 +1,80 @@
+#ifndef _PCI_ID_DRIVER_MAP_H_
+#define _PCI_ID_DRIVER_MAP_H_
+
+#include <stddef.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+static const int i915_chip_ids[] = {
+#define CHIPSET(chip, desc, name) chip,
+#include "pci_ids/i915_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int i965_chip_ids[] = {
+#define CHIPSET(chip, family, name) chip,
+#include "pci_ids/i965_pci_ids.h"
+#undef CHIPSET
+};
+
+#ifndef DRIVER_MAP_GALLIUM_ONLY
+static const int r100_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/radeon_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int r200_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r200_pci_ids.h"
+#undef CHIPSET
+};
+#endif
+
+static const int r300_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r300_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int r600_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r600_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int radeonsi_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/radeonsi_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int vmwgfx_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/vmwgfx_pci_ids.h"
+#undef CHIPSET
+};
+
+static const struct {
+   int vendor_id;
+   const char *driver;
+   const int *chip_ids;
+   int num_chips_ids;
+} driver_map[] = {
+   { 0x8086, "i915", i915_chip_ids, ARRAY_SIZE(i915_chip_ids) },
+   { 0x8086, "i965", i965_chip_ids, ARRAY_SIZE(i965_chip_ids) },
+#ifndef DRIVER_MAP_GALLIUM_ONLY
+   { 0x1002, "radeon", r100_chip_ids, ARRAY_SIZE(r100_chip_ids) },
+   { 0x1002, "r200", r200_chip_ids, ARRAY_SIZE(r200_chip_ids) },
+#endif
+   { 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
+   { 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
+   { 0x1002, "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids) },
+   { 0x10de, "nouveau", NULL, -1 },
+   { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
+   { 0x0000, NULL, NULL, 0 },
+};
+
+#endif /* _PCI_ID_DRIVER_MAP_H_ */
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/r200_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/r200_pci_ids.h
new file mode 100644
index 0000000..f857ca7
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/r200_pci_ids.h
@@ -0,0 +1,24 @@
+CHIPSET(0x5148, R200_QH, R200)
+CHIPSET(0x514C, R200_QL, R200)
+CHIPSET(0x514D, R200_QM, R200)
+CHIPSET(0x4242, R200_BB, R200)
+
+CHIPSET(0x4966, RV250_If, RV250)
+CHIPSET(0x4967, RV250_Ig, RV250)
+CHIPSET(0x4C64, RV250_Ld, RV250)
+CHIPSET(0x4C66, RV250_Lf, RV250)
+CHIPSET(0x4C67, RV250_Lg, RV250)
+
+CHIPSET(0x4C6E, RV280_4C6E, RV280)
+CHIPSET(0x5960, RV280_5960, RV280)
+CHIPSET(0x5961, RV280_5961, RV280)
+CHIPSET(0x5962, RV280_5962, RV280)
+CHIPSET(0x5964, RV280_5964, RV280)
+CHIPSET(0x5965, RV280_5965, RV280)
+CHIPSET(0x5C61, RV280_5C61, RV280)
+CHIPSET(0x5C63, RV280_5C63, RV280)
+
+CHIPSET(0x5834, RS300_5834, RS300)
+CHIPSET(0x5835, RS300_5835, RS300)
+CHIPSET(0x7834, RS350_7834, RS300)
+CHIPSET(0x7835, RS350_7835, RS300)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/r300_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/r300_pci_ids.h
new file mode 100644
index 0000000..791026a
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/r300_pci_ids.h
@@ -0,0 +1,227 @@
+CHIPSET(0x4144, R300_AD, R300)
+CHIPSET(0x4145, R300_AE, R300)
+CHIPSET(0x4146, R300_AF, R300)
+CHIPSET(0x4147, R300_AG, R300)
+CHIPSET(0x4E44, R300_ND, R300)
+CHIPSET(0x4E45, R300_NE, R300)
+CHIPSET(0x4E46, R300_NF, R300)
+CHIPSET(0x4E47, R300_NG, R300)
+
+CHIPSET(0x4E48, R350_NH, R350)
+CHIPSET(0x4E49, R350_NI, R350)
+CHIPSET(0x4E4B, R350_NK, R350)
+CHIPSET(0x4148, R350_AH, R350)
+CHIPSET(0x4149, R350_AI, R350)
+CHIPSET(0x414A, R350_AJ, R350)
+CHIPSET(0x414B, R350_AK, R350)
+CHIPSET(0x4E4A, R360_NJ, R350)
+
+CHIPSET(0x4150, RV350_AP, RV350)
+CHIPSET(0x4151, RV350_AQ, RV350)
+CHIPSET(0x4152, RV350_AR, RV350)
+CHIPSET(0x4153, RV350_AS, RV350)
+CHIPSET(0x4154, RV350_AT, RV350)
+CHIPSET(0x4155, RV350_AU, RV350)
+CHIPSET(0x4156, RV350_AV, RV350)
+CHIPSET(0x4E50, RV350_NP, RV350)
+CHIPSET(0x4E51, RV350_NQ, RV350)
+CHIPSET(0x4E52, RV350_NR, RV350)
+CHIPSET(0x4E53, RV350_NS, RV350)
+CHIPSET(0x4E54, RV350_NT, RV350)
+CHIPSET(0x4E56, RV350_NV, RV350)
+
+CHIPSET(0x5460, RV370_5460, RV370)
+CHIPSET(0x5462, RV370_5462, RV370)
+CHIPSET(0x5464, RV370_5464, RV370)
+CHIPSET(0x5B60, RV370_5B60, RV370)
+CHIPSET(0x5B62, RV370_5B62, RV370)
+CHIPSET(0x5B63, RV370_5B63, RV370)
+CHIPSET(0x5B64, RV370_5B64, RV370)
+CHIPSET(0x5B65, RV370_5B65, RV370)
+
+CHIPSET(0x3150, RV380_3150, RV380)
+CHIPSET(0x3151, RV380_3151, RV380)
+CHIPSET(0x3152, RV380_3152, RV380)
+CHIPSET(0x3154, RV380_3154, RV380)
+CHIPSET(0x3155, RV380_3155, RV380)
+CHIPSET(0x3E50, RV380_3E50, RV380)
+CHIPSET(0x3E54, RV380_3E54, RV380)
+
+CHIPSET(0x4A48, R420_JH, R420)
+CHIPSET(0x4A49, R420_JI, R420)
+CHIPSET(0x4A4A, R420_JJ, R420)
+CHIPSET(0x4A4B, R420_JK, R420)
+CHIPSET(0x4A4C, R420_JL, R420)
+CHIPSET(0x4A4D, R420_JM, R420)
+CHIPSET(0x4A4E, R420_JN, R420)
+CHIPSET(0x4A4F, R420_JO, R420)
+CHIPSET(0x4A50, R420_JP, R420)
+CHIPSET(0x4A54, R420_JT, R420)
+
+CHIPSET(0x5548, R423_UH, R423)
+CHIPSET(0x5549, R423_UI, R423)
+CHIPSET(0x554A, R423_UJ, R423)
+CHIPSET(0x554B, R423_UK, R423)
+CHIPSET(0x5550, R423_5550, R423)
+CHIPSET(0x5551, R423_UQ, R423)
+CHIPSET(0x5552, R423_UR, R423)
+CHIPSET(0x5554, R423_UT, R423)
+CHIPSET(0x5D57, R423_5D57, R423)
+
+CHIPSET(0x554C, R430_554C, R430)
+CHIPSET(0x554D, R430_554D, R430)
+CHIPSET(0x554E, R430_554E, R430)
+CHIPSET(0x554F, R430_554F, R430)
+CHIPSET(0x5D48, R430_5D48, R430)
+CHIPSET(0x5D49, R430_5D49, R430)
+CHIPSET(0x5D4A, R430_5D4A, R430)
+
+CHIPSET(0x5D4C, R480_5D4C, R480)
+CHIPSET(0x5D4D, R480_5D4D, R480)
+CHIPSET(0x5D4E, R480_5D4E, R480)
+CHIPSET(0x5D4F, R480_5D4F, R480)
+CHIPSET(0x5D50, R480_5D50, R480)
+CHIPSET(0x5D52, R480_5D52, R480)
+
+CHIPSET(0x4B48, R481_4B48, R481)
+CHIPSET(0x4B49, R481_4B49, R481)
+CHIPSET(0x4B4A, R481_4B4A, R481)
+CHIPSET(0x4B4B, R481_4B4B, R481)
+CHIPSET(0x4B4C, R481_4B4C, R481)
+
+CHIPSET(0x564A, RV410_564A, RV410)
+CHIPSET(0x564B, RV410_564B, RV410)
+CHIPSET(0x564F, RV410_564F, RV410)
+CHIPSET(0x5652, RV410_5652, RV410)
+CHIPSET(0x5653, RV410_5653, RV410)
+CHIPSET(0x5657, RV410_5657, RV410)
+CHIPSET(0x5E48, RV410_5E48, RV410)
+CHIPSET(0x5E4A, RV410_5E4A, RV410)
+CHIPSET(0x5E4B, RV410_5E4B, RV410)
+CHIPSET(0x5E4C, RV410_5E4C, RV410)
+CHIPSET(0x5E4D, RV410_5E4D, RV410)
+CHIPSET(0x5E4F, RV410_5E4F, RV410)
+
+CHIPSET(0x5A41, RS400_5A41, RS400)
+CHIPSET(0x5A42, RS400_5A42, RS400)
+
+CHIPSET(0x5A61, RC410_5A61, RC410)
+CHIPSET(0x5A62, RC410_5A62, RC410)
+
+CHIPSET(0x5954, RS480_5954, RS480)
+CHIPSET(0x5955, RS480_5955, RS480)
+CHIPSET(0x5974, RS482_5974, RS480)
+CHIPSET(0x5975, RS482_5975, RS480)
+
+CHIPSET(0x7100, R520_7100, R520)
+CHIPSET(0x7101, R520_7101, R520)
+CHIPSET(0x7102, R520_7102, R520)
+CHIPSET(0x7103, R520_7103, R520)
+CHIPSET(0x7104, R520_7104, R520)
+CHIPSET(0x7105, R520_7105, R520)
+CHIPSET(0x7106, R520_7106, R520)
+CHIPSET(0x7108, R520_7108, R520)
+CHIPSET(0x7109, R520_7109, R520)
+CHIPSET(0x710A, R520_710A, R520)
+CHIPSET(0x710B, R520_710B, R520)
+CHIPSET(0x710C, R520_710C, R520)
+CHIPSET(0x710E, R520_710E, R520)
+CHIPSET(0x710F, R520_710F, R520)
+
+CHIPSET(0x7140, RV515_7140, RV515)
+CHIPSET(0x7141, RV515_7141, RV515)
+CHIPSET(0x7142, RV515_7142, RV515)
+CHIPSET(0x7143, RV515_7143, RV515)
+CHIPSET(0x7144, RV515_7144, RV515)
+CHIPSET(0x7145, RV515_7145, RV515)
+CHIPSET(0x7146, RV515_7146, RV515)
+CHIPSET(0x7147, RV515_7147, RV515)
+CHIPSET(0x7149, RV515_7149, RV515)
+CHIPSET(0x714A, RV515_714A, RV515)
+CHIPSET(0x714B, RV515_714B, RV515)
+CHIPSET(0x714C, RV515_714C, RV515)
+CHIPSET(0x714D, RV515_714D, RV515)
+CHIPSET(0x714E, RV515_714E, RV515)
+CHIPSET(0x714F, RV515_714F, RV515)
+CHIPSET(0x7151, RV515_7151, RV515)
+CHIPSET(0x7152, RV515_7152, RV515)
+CHIPSET(0x7153, RV515_7153, RV515)
+CHIPSET(0x715E, RV515_715E, RV515)
+CHIPSET(0x715F, RV515_715F, RV515)
+CHIPSET(0x7180, RV515_7180, RV515)
+CHIPSET(0x7181, RV515_7181, RV515)
+CHIPSET(0x7183, RV515_7183, RV515)
+CHIPSET(0x7186, RV515_7186, RV515)
+CHIPSET(0x7187, RV515_7187, RV515)
+CHIPSET(0x7188, RV515_7188, RV515)
+CHIPSET(0x718A, RV515_718A, RV515)
+CHIPSET(0x718B, RV515_718B, RV515)
+CHIPSET(0x718C, RV515_718C, RV515)
+CHIPSET(0x718D, RV515_718D, RV515)
+CHIPSET(0x718F, RV515_718F, RV515)
+CHIPSET(0x7193, RV515_7193, RV515)
+CHIPSET(0x7196, RV515_7196, RV515)
+CHIPSET(0x719B, RV515_719B, RV515)
+CHIPSET(0x719F, RV515_719F, RV515)
+CHIPSET(0x7200, RV515_7200, RV515)
+CHIPSET(0x7210, RV515_7210, RV515)
+CHIPSET(0x7211, RV515_7211, RV515)
+
+CHIPSET(0x71C0, RV530_71C0, RV530)
+CHIPSET(0x71C1, RV530_71C1, RV530)
+CHIPSET(0x71C2, RV530_71C2, RV530)
+CHIPSET(0x71C3, RV530_71C3, RV530)
+CHIPSET(0x71C4, RV530_71C4, RV530)
+CHIPSET(0x71C5, RV530_71C5, RV530)
+CHIPSET(0x71C6, RV530_71C6, RV530)
+CHIPSET(0x71C7, RV530_71C7, RV530)
+CHIPSET(0x71CD, RV530_71CD, RV530)
+CHIPSET(0x71CE, RV530_71CE, RV530)
+CHIPSET(0x71D2, RV530_71D2, RV530)
+CHIPSET(0x71D4, RV530_71D4, RV530)
+CHIPSET(0x71D5, RV530_71D5, RV530)
+CHIPSET(0x71D6, RV530_71D6, RV530)
+CHIPSET(0x71DA, RV530_71DA, RV530)
+CHIPSET(0x71DE, RV530_71DE, RV530)
+
+CHIPSET(0x7281, RV560_7281, RV560)
+CHIPSET(0x7283, RV560_7283, RV560)
+CHIPSET(0x7287, RV560_7287, RV560)
+CHIPSET(0x7290, RV560_7290, RV560)
+CHIPSET(0x7291, RV560_7291, RV560)
+CHIPSET(0x7293, RV560_7293, RV560)
+CHIPSET(0x7297, RV560_7297, RV560)
+
+CHIPSET(0x7280, RV570_7280, RV570)
+CHIPSET(0x7288, RV570_7288, RV570)
+CHIPSET(0x7289, RV570_7289, RV570)
+CHIPSET(0x728B, RV570_728B, RV570)
+CHIPSET(0x728C, RV570_728C, RV570)
+
+CHIPSET(0x7240, R580_7240, R580)
+CHIPSET(0x7243, R580_7243, R580)
+CHIPSET(0x7244, R580_7244, R580)
+CHIPSET(0x7245, R580_7245, R580)
+CHIPSET(0x7246, R580_7246, R580)
+CHIPSET(0x7247, R580_7247, R580)
+CHIPSET(0x7248, R580_7248, R580)
+CHIPSET(0x7249, R580_7249, R580)
+CHIPSET(0x724A, R580_724A, R580)
+CHIPSET(0x724B, R580_724B, R580)
+CHIPSET(0x724C, R580_724C, R580)
+CHIPSET(0x724D, R580_724D, R580)
+CHIPSET(0x724E, R580_724E, R580)
+CHIPSET(0x724F, R580_724F, R580)
+CHIPSET(0x7284, R580_7284, R580)
+
+CHIPSET(0x793F, RS600_793F, RS600)
+CHIPSET(0x7941, RS600_7941, RS600)
+CHIPSET(0x7942, RS600_7942, RS600)
+
+CHIPSET(0x791E, RS690_791E, RS690)
+CHIPSET(0x791F, RS690_791F, RS690)
+
+CHIPSET(0x796C, RS740_796C, RS740)
+CHIPSET(0x796D, RS740_796D, RS740)
+CHIPSET(0x796E, RS740_796E, RS740)
+CHIPSET(0x796F, RS740_796F, RS740)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/r600_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/r600_pci_ids.h
new file mode 100644
index 0000000..533c9f3
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/r600_pci_ids.h
@@ -0,0 +1,327 @@
+CHIPSET(0x9400, R600_9400, R600)
+CHIPSET(0x9401, R600_9401, R600)
+CHIPSET(0x9402, R600_9402, R600)
+CHIPSET(0x9403, R600_9403, R600)
+CHIPSET(0x9405, R600_9405, R600)
+CHIPSET(0x940A, R600_940A, R600)
+CHIPSET(0x940B, R600_940B, R600)
+CHIPSET(0x940F, R600_940F, R600)
+
+CHIPSET(0x94C0, RV610_94C0, RV610)
+CHIPSET(0x94C1, RV610_94C1, RV610)
+CHIPSET(0x94C3, RV610_94C3, RV610)
+CHIPSET(0x94C4, RV610_94C4, RV610)
+CHIPSET(0x94C5, RV610_94C5, RV610)
+CHIPSET(0x94C6, RV610_94C6, RV610)
+CHIPSET(0x94C7, RV610_94C7, RV610)
+CHIPSET(0x94C8, RV610_94C8, RV610)
+CHIPSET(0x94C9, RV610_94C9, RV610)
+CHIPSET(0x94CB, RV610_94CB, RV610)
+CHIPSET(0x94CC, RV610_94CC, RV610)
+CHIPSET(0x94CD, RV610_94CD, RV610)
+
+CHIPSET(0x9580, RV630_9580, RV630)
+CHIPSET(0x9581, RV630_9581, RV630)
+CHIPSET(0x9583, RV630_9583, RV630)
+CHIPSET(0x9586, RV630_9586, RV630)
+CHIPSET(0x9587, RV630_9587, RV630)
+CHIPSET(0x9588, RV630_9588, RV630)
+CHIPSET(0x9589, RV630_9589, RV630)
+CHIPSET(0x958A, RV630_958A, RV630)
+CHIPSET(0x958B, RV630_958B, RV630)
+CHIPSET(0x958C, RV630_958C, RV630)
+CHIPSET(0x958D, RV630_958D, RV630)
+CHIPSET(0x958E, RV630_958E, RV630)
+CHIPSET(0x958F, RV630_958F, RV630)
+
+CHIPSET(0x9500, RV670_9500, RV670)
+CHIPSET(0x9501, RV670_9501, RV670)
+CHIPSET(0x9504, RV670_9504, RV670)
+CHIPSET(0x9505, RV670_9505, RV670)
+CHIPSET(0x9506, RV670_9506, RV670)
+CHIPSET(0x9507, RV670_9507, RV670)
+CHIPSET(0x9508, RV670_9508, RV670)
+CHIPSET(0x9509, RV670_9509, RV670)
+CHIPSET(0x950F, RV670_950F, RV670)
+CHIPSET(0x9511, RV670_9511, RV670)
+CHIPSET(0x9515, RV670_9515, RV670)
+CHIPSET(0x9517, RV670_9517, RV670)
+CHIPSET(0x9519, RV670_9519, RV670)
+
+CHIPSET(0x95C0, RV620_95C0, RV620)
+CHIPSET(0x95C2, RV620_95C2, RV620)
+CHIPSET(0x95C4, RV620_95C4, RV620)
+CHIPSET(0x95C5, RV620_95C5, RV620)
+CHIPSET(0x95C6, RV620_95C6, RV620)
+CHIPSET(0x95C7, RV620_95C7, RV620)
+CHIPSET(0x95C9, RV620_95C9, RV620)
+CHIPSET(0x95CC, RV620_95CC, RV620)
+CHIPSET(0x95CD, RV620_95CD, RV620)
+CHIPSET(0x95CE, RV620_95CE, RV620)
+CHIPSET(0x95CF, RV620_95CF, RV620)
+
+CHIPSET(0x9590, RV635_9590, RV635)
+CHIPSET(0x9591, RV635_9591, RV635)
+CHIPSET(0x9593, RV635_9593, RV635)
+CHIPSET(0x9595, RV635_9595, RV635)
+CHIPSET(0x9596, RV635_9596, RV635)
+CHIPSET(0x9597, RV635_9597, RV635)
+CHIPSET(0x9598, RV635_9598, RV635)
+CHIPSET(0x9599, RV635_9599, RV635)
+CHIPSET(0x959B, RV635_959B, RV635)
+
+CHIPSET(0x9610, RS780_9610, RS780)
+CHIPSET(0x9611, RS780_9611, RS780)
+CHIPSET(0x9612, RS780_9612, RS780)
+CHIPSET(0x9613, RS780_9613, RS780)
+CHIPSET(0x9614, RS780_9614, RS780)
+CHIPSET(0x9615, RS780_9615, RS780)
+CHIPSET(0x9616, RS780_9616, RS780)
+
+CHIPSET(0x9710, RS880_9710, RS880)
+CHIPSET(0x9711, RS880_9711, RS880)
+CHIPSET(0x9712, RS880_9712, RS880)
+CHIPSET(0x9713, RS880_9713, RS880)
+CHIPSET(0x9714, RS880_9714, RS880)
+CHIPSET(0x9715, RS880_9715, RS880)
+
+CHIPSET(0x9440, RV770_9440, RV770)
+CHIPSET(0x9441, RV770_9441, RV770)
+CHIPSET(0x9442, RV770_9442, RV770)
+CHIPSET(0x9443, RV770_9443, RV770)
+CHIPSET(0x9444, RV770_9444, RV770)
+CHIPSET(0x9446, RV770_9446, RV770)
+CHIPSET(0x944A, RV770_944A, RV770)
+CHIPSET(0x944B, RV770_944B, RV770)
+CHIPSET(0x944C, RV770_944C, RV770)
+CHIPSET(0x944E, RV770_944E, RV770)
+CHIPSET(0x9450, RV770_9450, RV770)
+CHIPSET(0x9452, RV770_9452, RV770)
+CHIPSET(0x9456, RV770_9456, RV770)
+CHIPSET(0x945A, RV770_945A, RV770)
+CHIPSET(0x945B, RV770_945B, RV770)
+CHIPSET(0x945E, RV770_945E, RV770)
+CHIPSET(0x9460, RV790_9460, RV770)
+CHIPSET(0x9462, RV790_9462, RV770)
+CHIPSET(0x946A, RV770_946A, RV770)
+CHIPSET(0x946B, RV770_946B, RV770)
+CHIPSET(0x947A, RV770_947A, RV770)
+CHIPSET(0x947B, RV770_947B, RV770)
+
+CHIPSET(0x9480, RV730_9480, RV730)
+CHIPSET(0x9487, RV730_9487, RV730)
+CHIPSET(0x9488, RV730_9488, RV730)
+CHIPSET(0x9489, RV730_9489, RV730)
+CHIPSET(0x948A, RV730_948A, RV730)
+CHIPSET(0x948F, RV730_948F, RV730)
+CHIPSET(0x9490, RV730_9490, RV730)
+CHIPSET(0x9491, RV730_9491, RV730)
+CHIPSET(0x9495, RV730_9495, RV730)
+CHIPSET(0x9498, RV730_9498, RV730)
+CHIPSET(0x949C, RV730_949C, RV730)
+CHIPSET(0x949E, RV730_949E, RV730)
+CHIPSET(0x949F, RV730_949F, RV730)
+
+CHIPSET(0x9540, RV710_9540, RV710)
+CHIPSET(0x9541, RV710_9541, RV710)
+CHIPSET(0x9542, RV710_9542, RV710)
+CHIPSET(0x954E, RV710_954E, RV710)
+CHIPSET(0x954F, RV710_954F, RV710)
+CHIPSET(0x9552, RV710_9552, RV710)
+CHIPSET(0x9553, RV710_9553, RV710)
+CHIPSET(0x9555, RV710_9555, RV710)
+CHIPSET(0x9557, RV710_9557, RV710)
+CHIPSET(0x955F, RV710_955F, RV710)
+
+CHIPSET(0x94A0, RV740_94A0, RV740)
+CHIPSET(0x94A1, RV740_94A1, RV740)
+CHIPSET(0x94A3, RV740_94A3, RV740)
+CHIPSET(0x94B1, RV740_94B1, RV740)
+CHIPSET(0x94B3, RV740_94B3, RV740)
+CHIPSET(0x94B4, RV740_94B4, RV740)
+CHIPSET(0x94B5, RV740_94B5, RV740)
+CHIPSET(0x94B9, RV740_94B9, RV740)
+
+CHIPSET(0x68E0, CEDAR_68E0, CEDAR)
+CHIPSET(0x68E1, CEDAR_68E1, CEDAR)
+CHIPSET(0x68E4, CEDAR_68E4, CEDAR)
+CHIPSET(0x68E5, CEDAR_68E5, CEDAR)
+CHIPSET(0x68E8, CEDAR_68E8, CEDAR)
+CHIPSET(0x68E9, CEDAR_68E9, CEDAR)
+CHIPSET(0x68F1, CEDAR_68F1, CEDAR)
+CHIPSET(0x68F2, CEDAR_68F2, CEDAR)
+CHIPSET(0x68F8, CEDAR_68F8, CEDAR)
+CHIPSET(0x68F9, CEDAR_68F9, CEDAR)
+CHIPSET(0x68FA, CEDAR_68FA, CEDAR)
+CHIPSET(0x68FE, CEDAR_68FE, CEDAR)
+
+CHIPSET(0x68C0, REDWOOD_68C0, REDWOOD)
+CHIPSET(0x68C1, REDWOOD_68C1, REDWOOD)
+CHIPSET(0x68C7, REDWOOD_68C7, REDWOOD)
+CHIPSET(0x68C8, REDWOOD_68C8, REDWOOD)
+CHIPSET(0x68C9, REDWOOD_68C9, REDWOOD)
+CHIPSET(0x68D8, REDWOOD_68D8, REDWOOD)
+CHIPSET(0x68D9, REDWOOD_68D9, REDWOOD)
+CHIPSET(0x68DA, REDWOOD_68DA, REDWOOD)
+CHIPSET(0x68DE, REDWOOD_68DE, REDWOOD)
+
+CHIPSET(0x68A0, JUNIPER_68A0, JUNIPER)
+CHIPSET(0x68A1, JUNIPER_68A1, JUNIPER)
+CHIPSET(0x68A8, JUNIPER_68A8, JUNIPER)
+CHIPSET(0x68A9, JUNIPER_68A9, JUNIPER)
+CHIPSET(0x68B0, JUNIPER_68B0, JUNIPER)
+CHIPSET(0x68B8, JUNIPER_68B8, JUNIPER)
+CHIPSET(0x68B9, JUNIPER_68B9, JUNIPER)
+CHIPSET(0x68BA, JUNIPER_68BA, JUNIPER)
+CHIPSET(0x68BE, JUNIPER_68BE, JUNIPER)
+CHIPSET(0x68BF, JUNIPER_68BF, JUNIPER)
+
+CHIPSET(0x6880, CYPRESS_6880, CYPRESS)
+CHIPSET(0x6888, CYPRESS_6888, CYPRESS)
+CHIPSET(0x6889, CYPRESS_6889, CYPRESS)
+CHIPSET(0x688A, CYPRESS_688A, CYPRESS)
+CHIPSET(0x688C, CYPRESS_688C, CYPRESS)
+CHIPSET(0x688D, CYPRESS_688D, CYPRESS)
+CHIPSET(0x6898, CYPRESS_6898, CYPRESS)
+CHIPSET(0x6899, CYPRESS_6899, CYPRESS)
+CHIPSET(0x689B, CYPRESS_689B, CYPRESS)
+CHIPSET(0x689E, CYPRESS_689E, CYPRESS)
+
+CHIPSET(0x689C, HEMLOCK_689C, HEMLOCK)
+CHIPSET(0x689D, HEMLOCK_689D, HEMLOCK)
+
+CHIPSET(0x9802, PALM_9802, PALM)
+CHIPSET(0x9803, PALM_9803, PALM)
+CHIPSET(0x9804, PALM_9804, PALM)
+CHIPSET(0x9805, PALM_9805, PALM)
+CHIPSET(0x9806, PALM_9806, PALM)
+CHIPSET(0x9807, PALM_9807, PALM)
+CHIPSET(0x9808, PALM_9808, PALM)
+CHIPSET(0x9809, PALM_9809, PALM)
+CHIPSET(0x980A, PALM_980A, PALM)
+
+CHIPSET(0x9640, SUMO_9640,  SUMO)
+CHIPSET(0x9641, SUMO_9641,  SUMO)
+CHIPSET(0x9642, SUMO2_9642, SUMO2)
+CHIPSET(0x9643, SUMO2_9643, SUMO2)
+CHIPSET(0x9644, SUMO2_9644, SUMO2)
+CHIPSET(0x9645, SUMO2_9645, SUMO2)
+CHIPSET(0x9647, SUMO_9647,  SUMO)
+CHIPSET(0x9648, SUMO_9648,  SUMO)
+CHIPSET(0x9649, SUMO2_9649, SUMO2)
+CHIPSET(0x964a, SUMO_964A,  SUMO)
+CHIPSET(0x964b, SUMO_964B,  SUMO)
+CHIPSET(0x964c, SUMO_964C,  SUMO)
+CHIPSET(0x964e, SUMO_964E,  SUMO)
+CHIPSET(0x964f, SUMO_964F,  SUMO)
+
+CHIPSET(0x6700, CAYMAN_6700, CAYMAN)
+CHIPSET(0x6701, CAYMAN_6701, CAYMAN)
+CHIPSET(0x6702, CAYMAN_6702, CAYMAN)
+CHIPSET(0x6703, CAYMAN_6703, CAYMAN)
+CHIPSET(0x6704, CAYMAN_6704, CAYMAN)
+CHIPSET(0x6705, CAYMAN_6705, CAYMAN)
+CHIPSET(0x6706, CAYMAN_6706, CAYMAN)
+CHIPSET(0x6707, CAYMAN_6707, CAYMAN)
+CHIPSET(0x6708, CAYMAN_6708, CAYMAN)
+CHIPSET(0x6709, CAYMAN_6709, CAYMAN)
+CHIPSET(0x6718, CAYMAN_6718, CAYMAN)
+CHIPSET(0x6719, CAYMAN_6719, CAYMAN)
+CHIPSET(0x671C, CAYMAN_671C, CAYMAN)
+CHIPSET(0x671D, CAYMAN_671D, CAYMAN)
+CHIPSET(0x671F, CAYMAN_671F, CAYMAN)
+
+CHIPSET(0x6720, BARTS_6720, BARTS)
+CHIPSET(0x6721, BARTS_6721, BARTS)
+CHIPSET(0x6722, BARTS_6722, BARTS)
+CHIPSET(0x6723, BARTS_6723, BARTS)
+CHIPSET(0x6724, BARTS_6724, BARTS)
+CHIPSET(0x6725, BARTS_6725, BARTS)
+CHIPSET(0x6726, BARTS_6726, BARTS)
+CHIPSET(0x6727, BARTS_6727, BARTS)
+CHIPSET(0x6728, BARTS_6728, BARTS)
+CHIPSET(0x6729, BARTS_6729, BARTS)
+CHIPSET(0x6738, BARTS_6738, BARTS)
+CHIPSET(0x6739, BARTS_6739, BARTS)
+CHIPSET(0x673E, BARTS_673E, BARTS)
+
+CHIPSET(0x6740, TURKS_6740, TURKS)
+CHIPSET(0x6741, TURKS_6741, TURKS)
+CHIPSET(0x6742, TURKS_6742, TURKS)
+CHIPSET(0x6743, TURKS_6743, TURKS)
+CHIPSET(0x6744, TURKS_6744, TURKS)
+CHIPSET(0x6745, TURKS_6745, TURKS)
+CHIPSET(0x6746, TURKS_6746, TURKS)
+CHIPSET(0x6747, TURKS_6747, TURKS)
+CHIPSET(0x6748, TURKS_6748, TURKS)
+CHIPSET(0x6749, TURKS_6749, TURKS)
+CHIPSET(0x674A, TURKS_674A, TURKS)
+CHIPSET(0x6750, TURKS_6750, TURKS)
+CHIPSET(0x6751, TURKS_6751, TURKS)
+CHIPSET(0x6758, TURKS_6758, TURKS)
+CHIPSET(0x6759, TURKS_6759, TURKS)
+CHIPSET(0x675B, TURKS_675B, TURKS)
+CHIPSET(0x675D, TURKS_675D, TURKS)
+CHIPSET(0x675F, TURKS_675F, TURKS)
+CHIPSET(0x6840, TURKS_6840, TURKS)
+CHIPSET(0x6841, TURKS_6841, TURKS)
+CHIPSET(0x6842, TURKS_6842, TURKS)
+CHIPSET(0x6843, TURKS_6843, TURKS)
+CHIPSET(0x6849, TURKS_6849, TURKS)
+CHIPSET(0x6850, TURKS_6850, TURKS)
+CHIPSET(0x6858, TURKS_6858, TURKS)
+CHIPSET(0x6859, TURKS_6859, TURKS)
+
+CHIPSET(0x6760, CAICOS_6760, CAICOS)
+CHIPSET(0x6761, CAICOS_6761, CAICOS)
+CHIPSET(0x6762, CAICOS_6762, CAICOS)
+CHIPSET(0x6763, CAICOS_6763, CAICOS)
+CHIPSET(0x6764, CAICOS_6764, CAICOS)
+CHIPSET(0x6765, CAICOS_6765, CAICOS)
+CHIPSET(0x6766, CAICOS_6766, CAICOS)
+CHIPSET(0x6767, CAICOS_6767, CAICOS)
+CHIPSET(0x6768, CAICOS_6768, CAICOS)
+CHIPSET(0x6770, CAICOS_6770, CAICOS)
+CHIPSET(0x6771, CAICOS_6771, CAICOS)
+CHIPSET(0x6772, CAICOS_6772, CAICOS)
+CHIPSET(0x6778, CAICOS_6778, CAICOS)
+CHIPSET(0x6779, CAICOS_6779, CAICOS)
+CHIPSET(0x677B, CAICOS_677B, CAICOS)
+
+CHIPSET(0x9900, ARUBA_9900, ARUBA)
+CHIPSET(0x9901, ARUBA_9901, ARUBA)
+CHIPSET(0x9903, ARUBA_9903, ARUBA)
+CHIPSET(0x9904, ARUBA_9904, ARUBA)
+CHIPSET(0x9905, ARUBA_9905, ARUBA)
+CHIPSET(0x9906, ARUBA_9906, ARUBA)
+CHIPSET(0x9907, ARUBA_9907, ARUBA)
+CHIPSET(0x9908, ARUBA_9908, ARUBA)
+CHIPSET(0x9909, ARUBA_9909, ARUBA)
+CHIPSET(0x990A, ARUBA_990A, ARUBA)
+CHIPSET(0x990B, ARUBA_990B, ARUBA)
+CHIPSET(0x990C, ARUBA_990C, ARUBA)
+CHIPSET(0x990D, ARUBA_990D, ARUBA)
+CHIPSET(0x990E, ARUBA_990E, ARUBA)
+CHIPSET(0x990F, ARUBA_990F, ARUBA)
+CHIPSET(0x9910, ARUBA_9910, ARUBA)
+CHIPSET(0x9913, ARUBA_9913, ARUBA)
+CHIPSET(0x9917, ARUBA_9917, ARUBA)
+CHIPSET(0x9918, ARUBA_9918, ARUBA)
+CHIPSET(0x9919, ARUBA_9919, ARUBA)
+CHIPSET(0x9990, ARUBA_9990, ARUBA)
+CHIPSET(0x9991, ARUBA_9991, ARUBA)
+CHIPSET(0x9992, ARUBA_9992, ARUBA)
+CHIPSET(0x9993, ARUBA_9993, ARUBA)
+CHIPSET(0x9994, ARUBA_9994, ARUBA)
+CHIPSET(0x9995, ARUBA_9995, ARUBA)
+CHIPSET(0x9996, ARUBA_9996, ARUBA)
+CHIPSET(0x9997, ARUBA_9997, ARUBA)
+CHIPSET(0x9998, ARUBA_9998, ARUBA)
+CHIPSET(0x9999, ARUBA_9999, ARUBA)
+CHIPSET(0x999A, ARUBA_999A, ARUBA)
+CHIPSET(0x999B, ARUBA_999B, ARUBA)
+CHIPSET(0x999C, ARUBA_999C, ARUBA)
+CHIPSET(0x999D, ARUBA_999D, ARUBA)
+CHIPSET(0x99A0, ARUBA_99A0, ARUBA)
+CHIPSET(0x99A2, ARUBA_99A2, ARUBA)
+CHIPSET(0x99A4, ARUBA_99A4, ARUBA)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h
new file mode 100644
index 0000000..a9efc76
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h
@@ -0,0 +1,23 @@
+CHIPSET(0x4C57, RADEON_LW, RV200)
+CHIPSET(0x4C58, RADEON_LX, RV200)
+CHIPSET(0x4C59, RADEON_LY, RV100)
+CHIPSET(0x4C5A, RADEON_LZ, RV100)
+CHIPSET(0x5144, RADEON_QD, R100)
+CHIPSET(0x5145, RADEON_QE, R100)
+CHIPSET(0x5146, RADEON_QF, R100)
+CHIPSET(0x5147, RADEON_QG, R100)
+CHIPSET(0x5159, RADEON_QY, RV100)
+CHIPSET(0x515A, RADEON_QZ, RV100)
+
+CHIPSET(0x5157, RV200_QW, RV200)
+CHIPSET(0x5158, RV200_QX, RV200)
+
+CHIPSET(0x515E, RN50_515E, UNKNOWN)
+CHIPSET(0x5969, RN50_5969, UNKNOWN)
+
+CHIPSET(0x4136, RS100_4136, RS100)
+CHIPSET(0x4336, RS100_4336, RS100)
+CHIPSET(0x4137, RS200_4137, RS200)
+CHIPSET(0x4337, RS200_4337, RS200)
+CHIPSET(0x4237, RS250_4237, RS200)
+CHIPSET(0x4437, RS250_4437, RS200)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h
new file mode 100644
index 0000000..571e863
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h
@@ -0,0 +1,157 @@
+CHIPSET(0x6780, TAHITI_6780, TAHITI)
+CHIPSET(0x6784, TAHITI_6784, TAHITI)
+CHIPSET(0x6788, TAHITI_6788, TAHITI)
+CHIPSET(0x678A, TAHITI_678A, TAHITI)
+CHIPSET(0x6790, TAHITI_6790, TAHITI)
+CHIPSET(0x6791, TAHITI_6791, TAHITI)
+CHIPSET(0x6792, TAHITI_6792, TAHITI)
+CHIPSET(0x6798, TAHITI_6798, TAHITI)
+CHIPSET(0x6799, TAHITI_6799, TAHITI)
+CHIPSET(0x679A, TAHITI_679A, TAHITI)
+CHIPSET(0x679B, TAHITI_679B, TAHITI)
+CHIPSET(0x679E, TAHITI_679E, TAHITI)
+CHIPSET(0x679F, TAHITI_679F, TAHITI)
+
+CHIPSET(0x6800, PITCAIRN_6800, PITCAIRN)
+CHIPSET(0x6801, PITCAIRN_6801, PITCAIRN)
+CHIPSET(0x6802, PITCAIRN_6802, PITCAIRN)
+CHIPSET(0x6806, PITCAIRN_6806, PITCAIRN)
+CHIPSET(0x6808, PITCAIRN_6808, PITCAIRN)
+CHIPSET(0x6809, PITCAIRN_6809, PITCAIRN)
+CHIPSET(0x6810, PITCAIRN_6810, PITCAIRN)
+CHIPSET(0x6811, PITCAIRN_6811, PITCAIRN)
+CHIPSET(0x6816, PITCAIRN_6816, PITCAIRN)
+CHIPSET(0x6817, PITCAIRN_6817, PITCAIRN)
+CHIPSET(0x6818, PITCAIRN_6818, PITCAIRN)
+CHIPSET(0x6819, PITCAIRN_6819, PITCAIRN)
+CHIPSET(0x684C, PITCAIRN_684C, PITCAIRN)
+
+CHIPSET(0x6820, VERDE_6820, VERDE)
+CHIPSET(0x6821, VERDE_6821, VERDE)
+CHIPSET(0x6822, VERDE_6822, VERDE)
+CHIPSET(0x6823, VERDE_6823, VERDE)
+CHIPSET(0x6824, VERDE_6824, VERDE)
+CHIPSET(0x6825, VERDE_6825, VERDE)
+CHIPSET(0x6826, VERDE_6826, VERDE)
+CHIPSET(0x6827, VERDE_6827, VERDE)
+CHIPSET(0x6828, VERDE_6828, VERDE)
+CHIPSET(0x6829, VERDE_6829, VERDE)
+CHIPSET(0x682A, VERDE_682A, VERDE)
+CHIPSET(0x682B, VERDE_682B, VERDE)
+CHIPSET(0x682C, VERDE_682C, VERDE)
+CHIPSET(0x682D, VERDE_682D, VERDE)
+CHIPSET(0x682F, VERDE_682F, VERDE)
+CHIPSET(0x6830, VERDE_6830, VERDE)
+CHIPSET(0x6831, VERDE_6831, VERDE)
+CHIPSET(0x6835, VERDE_6835, VERDE)
+CHIPSET(0x6837, VERDE_6837, VERDE)
+CHIPSET(0x6838, VERDE_6838, VERDE)
+CHIPSET(0x6839, VERDE_6839, VERDE)
+CHIPSET(0x683B, VERDE_683B, VERDE)
+CHIPSET(0x683D, VERDE_683D, VERDE)
+CHIPSET(0x683F, VERDE_683F, VERDE)
+
+CHIPSET(0x6600, OLAND_6600, OLAND)
+CHIPSET(0x6601, OLAND_6601, OLAND)
+CHIPSET(0x6602, OLAND_6602, OLAND)
+CHIPSET(0x6603, OLAND_6603, OLAND)
+CHIPSET(0x6604, OLAND_6604, OLAND)
+CHIPSET(0x6605, OLAND_6605, OLAND)
+CHIPSET(0x6606, OLAND_6606, OLAND)
+CHIPSET(0x6607, OLAND_6607, OLAND)
+CHIPSET(0x6608, OLAND_6608, OLAND)
+CHIPSET(0x6610, OLAND_6610, OLAND)
+CHIPSET(0x6611, OLAND_6611, OLAND)
+CHIPSET(0x6613, OLAND_6613, OLAND)
+CHIPSET(0x6620, OLAND_6620, OLAND)
+CHIPSET(0x6621, OLAND_6621, OLAND)
+CHIPSET(0x6623, OLAND_6623, OLAND)
+CHIPSET(0x6631, OLAND_6631, OLAND)
+
+CHIPSET(0x6660, HAINAN_6660, HAINAN)
+CHIPSET(0x6663, HAINAN_6663, HAINAN)
+CHIPSET(0x6664, HAINAN_6664, HAINAN)
+CHIPSET(0x6665, HAINAN_6665, HAINAN)
+CHIPSET(0x6667, HAINAN_6667, HAINAN)
+CHIPSET(0x666F, HAINAN_666F, HAINAN)
+
+CHIPSET(0x6640, BONAIRE_6640, BONAIRE)
+CHIPSET(0x6641, BONAIRE_6641, BONAIRE)
+CHIPSET(0x6646, BONAIRE_6646, BONAIRE)
+CHIPSET(0x6647, BONAIRE_6647, BONAIRE)
+CHIPSET(0x6649, BONAIRE_6649, BONAIRE)
+CHIPSET(0x6650, BONAIRE_6650, BONAIRE)
+CHIPSET(0x6651, BONAIRE_6651, BONAIRE)
+CHIPSET(0x6658, BONAIRE_6658, BONAIRE)
+CHIPSET(0x665C, BONAIRE_665C, BONAIRE)
+CHIPSET(0x665D, BONAIRE_665D, BONAIRE)
+
+CHIPSET(0x9830, KABINI_9830, KABINI)
+CHIPSET(0x9831, KABINI_9831, KABINI)
+CHIPSET(0x9832, KABINI_9832, KABINI)
+CHIPSET(0x9833, KABINI_9833, KABINI)
+CHIPSET(0x9834, KABINI_9834, KABINI)
+CHIPSET(0x9835, KABINI_9835, KABINI)
+CHIPSET(0x9836, KABINI_9836, KABINI)
+CHIPSET(0x9837, KABINI_9837, KABINI)
+CHIPSET(0x9838, KABINI_9838, KABINI)
+CHIPSET(0x9839, KABINI_9839, KABINI)
+CHIPSET(0x983A, KABINI_983A, KABINI)
+CHIPSET(0x983B, KABINI_983B, KABINI)
+CHIPSET(0x983C, KABINI_983C, KABINI)
+CHIPSET(0x983D, KABINI_983D, KABINI)
+CHIPSET(0x983E, KABINI_983E, KABINI)
+CHIPSET(0x983F, KABINI_983F, KABINI)
+
+CHIPSET(0x9850, MULLINS_9850, MULLINS)
+CHIPSET(0x9851, MULLINS_9851, MULLINS)
+CHIPSET(0x9852, MULLINS_9852, MULLINS)
+CHIPSET(0x9853, MULLINS_9853, MULLINS)
+CHIPSET(0x9854, MULLINS_9854, MULLINS)
+CHIPSET(0x9855, MULLINS_9855, MULLINS)
+CHIPSET(0x9856, MULLINS_9856, MULLINS)
+CHIPSET(0x9857, MULLINS_9857, MULLINS)
+CHIPSET(0x9858, MULLINS_9858, MULLINS)
+CHIPSET(0x9859, MULLINS_9859, MULLINS)
+CHIPSET(0x985A, MULLINS_985A, MULLINS)
+CHIPSET(0x985B, MULLINS_985B, MULLINS)
+CHIPSET(0x985C, MULLINS_985C, MULLINS)
+CHIPSET(0x985D, MULLINS_985D, MULLINS)
+CHIPSET(0x985E, MULLINS_985E, MULLINS)
+CHIPSET(0x985F, MULLINS_985F, MULLINS)
+
+CHIPSET(0x1304, KAVERI_1304, KAVERI)
+CHIPSET(0x1305, KAVERI_1305, KAVERI)
+CHIPSET(0x1306, KAVERI_1306, KAVERI)
+CHIPSET(0x1307, KAVERI_1307, KAVERI)
+CHIPSET(0x1309, KAVERI_1309, KAVERI)
+CHIPSET(0x130A, KAVERI_130A, KAVERI)
+CHIPSET(0x130B, KAVERI_130B, KAVERI)
+CHIPSET(0x130C, KAVERI_130C, KAVERI)
+CHIPSET(0x130D, KAVERI_130D, KAVERI)
+CHIPSET(0x130E, KAVERI_130E, KAVERI)
+CHIPSET(0x130F, KAVERI_130F, KAVERI)
+CHIPSET(0x1310, KAVERI_1310, KAVERI)
+CHIPSET(0x1311, KAVERI_1311, KAVERI)
+CHIPSET(0x1312, KAVERI_1312, KAVERI)
+CHIPSET(0x1313, KAVERI_1313, KAVERI)
+CHIPSET(0x1315, KAVERI_1315, KAVERI)
+CHIPSET(0x1316, KAVERI_1316, KAVERI)
+CHIPSET(0x1317, KAVERI_1317, KAVERI)
+CHIPSET(0x1318, KAVERI_1318, KAVERI)
+CHIPSET(0x131B, KAVERI_131B, KAVERI)
+CHIPSET(0x131C, KAVERI_131C, KAVERI)
+CHIPSET(0x131D, KAVERI_131D, KAVERI)
+
+CHIPSET(0x67A0, HAWAII_67A0, HAWAII)
+CHIPSET(0x67A1, HAWAII_67A1, HAWAII)
+CHIPSET(0x67A2, HAWAII_67A2, HAWAII)
+CHIPSET(0x67A8, HAWAII_67A8, HAWAII)
+CHIPSET(0x67A9, HAWAII_67A9, HAWAII)
+CHIPSET(0x67AA, HAWAII_67AA, HAWAII)
+CHIPSET(0x67B0, HAWAII_67B0, HAWAII)
+CHIPSET(0x67B1, HAWAII_67B1, HAWAII)
+CHIPSET(0x67B8, HAWAII_67B8, HAWAII)
+CHIPSET(0x67B9, HAWAII_67B9, HAWAII)
+CHIPSET(0x67BA, HAWAII_67BA, HAWAII)
+CHIPSET(0x67BE, HAWAII_67BE, HAWAII)
diff --git a/xorg-server/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h b/xorg-server/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h
new file mode 100644
index 0000000..124d75b
--- /dev/null
+++ b/xorg-server/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h
@@ -0,0 +1 @@
+CHIPSET(0x0405, SVGAII, SVGAII)
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am b/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am
index e6834e2..5b08600 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/xorg-server/hw/xfree86/drivers/modesetting/Makefile.am
@@ -30,6 +30,7 @@ AM_CPPFLAGS = \
 	$(XORG_INCS) \
 	-I$(top_srcdir)/glamor \
 	-I$(srcdir)/../../ddc \
+	-I$(srcdir)/../../dri2 \
 	-I$(srcdir)/../../i2c \
 	-I$(srcdir)/../../modes \
 	-I$(srcdir)/../../parser \
@@ -42,10 +43,13 @@ modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS)
 modesetting_drv_ladir = @moduledir@/drivers
 
 modesetting_drv_la_SOURCES = \
+	 dri2.c \
 	 driver.c \
 	 driver.h \
 	 drmmode_display.c \
-	 drmmode_display.h
+	 drmmode_display.h \
+	 vblank.c \
+	 $(NULL)
 
 drivermandir = $(DRIVER_MAN_DIR)
 driverman_PRE = modesetting.man
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/dri2.c b/xorg-server/hw/xfree86/drivers/modesetting/dri2.c
new file mode 100644
index 0000000..6c88060
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/dri2.c
@@ -0,0 +1,863 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Broadcom
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * @file dri2.c
+ *
+ * Implements generic support for DRI2 on KMS, using glamor pixmaps
+ * for color buffer management (no support for other aux buffers), and
+ * the DRM vblank ioctls.
+ *
+ * This doesn't implement pageflipping yet.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <time.h>
+#include "list.h"
+#include "xf86.h"
+#include "driver.h"
+#include "dri2.h"
+
+#ifdef GLAMOR
+#define GLAMOR_FOR_XORG 1
+#include "glamor.h"
+
+enum ms_dri2_frame_event_type {
+    MS_DRI2_QUEUE_SWAP,
+    MS_DRI2_WAIT_MSC,
+};
+
+typedef struct ms_dri2_frame_event {
+    ScreenPtr screen;
+
+    DrawablePtr drawable;
+    ClientPtr client;
+    enum ms_dri2_frame_event_type type;
+    int frame;
+    xf86CrtcPtr crtc;
+
+    struct xorg_list drawable_resource, client_resource;
+
+    /* for swaps & flips only */
+    DRI2SwapEventPtr event_complete;
+    void *event_data;
+    DRI2BufferPtr front;
+    DRI2BufferPtr back;
+} ms_dri2_frame_event_rec, *ms_dri2_frame_event_ptr;
+
+typedef struct {
+    int refcnt;
+    PixmapPtr pixmap;
+} ms_dri2_buffer_private_rec, *ms_dri2_buffer_private_ptr;
+
+static DevPrivateKeyRec ms_dri2_client_key;
+static RESTYPE frame_event_client_type, frame_event_drawable_type;
+static int ms_dri2_server_generation;
+
+struct ms_dri2_resource {
+    XID id;
+    RESTYPE type;
+    struct xorg_list list;
+};
+
+static struct ms_dri2_resource *
+ms_get_resource(XID id, RESTYPE type)
+{
+    struct ms_dri2_resource *resource;
+    void *ptr;
+
+    ptr = NULL;
+    dixLookupResourceByType(&ptr, id, type, NULL, DixWriteAccess);
+    if (ptr)
+        return ptr;
+
+    resource = malloc(sizeof(*resource));
+    if (resource == NULL)
+        return NULL;
+
+    if (!AddResource(id, type, resource)) {
+        free(resource);
+        return NULL;
+    }
+
+    resource->id = id;
+    resource->type = type;
+    xorg_list_init(&resource->list);
+    return resource;
+}
+
+static inline PixmapPtr
+get_drawable_pixmap(DrawablePtr drawable)
+{
+    ScreenPtr screen = drawable->pScreen;
+
+    if (drawable->type == DRAWABLE_PIXMAP)
+        return (PixmapPtr) drawable;
+    else
+        return screen->GetWindowPixmap((WindowPtr) drawable);
+}
+
+static PixmapPtr
+get_front_buffer(DrawablePtr drawable)
+{
+    PixmapPtr pixmap;
+
+    pixmap = get_drawable_pixmap(drawable);
+    pixmap->refcnt++;
+
+    return pixmap;
+}
+
+static DRI2Buffer2Ptr
+ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment,
+                      unsigned int format)
+{
+    ScreenPtr screen = drawable->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    DRI2Buffer2Ptr buffer;
+    PixmapPtr pixmap;
+    uint32_t size;
+    uint16_t pitch;
+    ms_dri2_buffer_private_ptr private;
+
+    buffer = calloc(1, sizeof *buffer);
+    if (buffer == NULL)
+        return NULL;
+
+    private = calloc(1, sizeof(*private));
+    if (private == NULL) {
+        free(buffer);
+        return NULL;
+    }
+
+    pixmap = NULL;
+    if (attachment == DRI2BufferFrontLeft)
+        pixmap = get_front_buffer(drawable);
+
+    if (pixmap == NULL) {
+        int pixmap_width = drawable->width;
+        int pixmap_height = drawable->height;
+        int pixmap_cpp = (format != 0) ? format : drawable->depth;
+
+        /* Assume that non-color-buffers require special
+         * device-specific handling.  Mesa currently makes no requests
+         * for non-color aux buffers.
+         */
+        switch (attachment) {
+        case DRI2BufferAccum:
+        case DRI2BufferBackLeft:
+        case DRI2BufferBackRight:
+        case DRI2BufferFakeFrontLeft:
+        case DRI2BufferFakeFrontRight:
+        case DRI2BufferFrontLeft:
+        case DRI2BufferFrontRight:
+            break;
+
+        case DRI2BufferStencil:
+        case DRI2BufferDepth:
+        case DRI2BufferDepthStencil:
+        case DRI2BufferHiz:
+        default:
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "Request for DRI2 buffer attachment %d unsupported\n",
+                       attachment);
+            free(private);
+            free(buffer);
+            return NULL;
+        }
+
+        pixmap = screen->CreatePixmap(screen,
+                                      pixmap_width,
+                                      pixmap_height,
+                                      pixmap_cpp,
+                                      0);
+        if (pixmap == NULL) {
+            if (pixmap)
+                screen->DestroyPixmap(pixmap);
+            free(private);
+            free(buffer);
+            return NULL;
+        }
+    }
+
+    buffer->attachment = attachment;
+    buffer->cpp = pixmap->drawable.bitsPerPixel / 8;
+    buffer->format = format;
+    /* The buffer's flags field is unused by the client drivers in
+     * Mesa currently.
+     */
+    buffer->flags = 0;
+
+    buffer->name = glamor_name_from_pixmap(pixmap, &pitch, &size);
+    buffer->pitch = pitch;
+    if (buffer->name == -1) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "Failed to get DRI2 name for pixmap\n");
+        screen->DestroyPixmap(pixmap);
+        free(private);
+        free(buffer);
+        return NULL;
+    }
+
+    buffer->driverPrivate = private;
+    private->refcnt = 1;
+    private->pixmap = pixmap;
+
+    return buffer;
+}
+
+static void
+ms_dri2_reference_buffer(DRI2Buffer2Ptr buffer)
+{
+    if (buffer) {
+        ms_dri2_buffer_private_ptr private = buffer->driverPrivate;
+        private->refcnt++;
+    }
+}
+
+static void ms_dri2_destroy_buffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer)
+{
+    if (!buffer)
+        return;
+
+    if (buffer->driverPrivate) {
+        ms_dri2_buffer_private_ptr private = buffer->driverPrivate;
+        if (--private->refcnt == 0) {
+            ScreenPtr screen = private->pixmap->drawable.pScreen;
+            screen->DestroyPixmap(private->pixmap);
+            free(private);
+            free(buffer);
+        }
+    } else {
+        free(buffer);
+    }
+}
+
+static void
+ms_dri2_copy_region(DrawablePtr drawable, RegionPtr pRegion,
+                    DRI2BufferPtr destBuffer, DRI2BufferPtr sourceBuffer)
+{
+    ms_dri2_buffer_private_ptr src_priv = sourceBuffer->driverPrivate;
+    ms_dri2_buffer_private_ptr dst_priv = destBuffer->driverPrivate;
+    PixmapPtr src_pixmap = src_priv->pixmap;
+    PixmapPtr dst_pixmap = dst_priv->pixmap;
+    ScreenPtr screen = drawable->pScreen;
+    DrawablePtr src = (sourceBuffer->attachment == DRI2BufferFrontLeft)
+        ? drawable : &src_pixmap->drawable;
+    DrawablePtr dst = (destBuffer->attachment == DRI2BufferFrontLeft)
+        ? drawable : &dst_pixmap->drawable;
+    RegionPtr pCopyClip;
+    GCPtr gc;
+
+    gc = GetScratchGC(dst->depth, screen);
+    if (!gc)
+        return;
+
+    pCopyClip = REGION_CREATE(screen, NULL, 0);
+    REGION_COPY(screen, pCopyClip, pRegion);
+    (*gc->funcs->ChangeClip) (gc, CT_REGION, pCopyClip, 0);
+    ValidateGC(dst, gc);
+
+    /* It's important that this copy gets submitted before the direct
+     * rendering client submits rendering for the next frame, but we
+     * don't actually need to submit right now.  The client will wait
+     * for the DRI2CopyRegion reply or the swap buffer event before
+     * rendering, and we'll hit the flush callback chain before those
+     * messages are sent.  We submit our batch buffers from the flush
+     * callback chain so we know that will happen before the client
+     * tries to render again.
+     */
+    gc->ops->CopyArea(src, dst, gc,
+                      0, 0,
+                      drawable->width, drawable->height,
+                      0, 0);
+
+    FreeScratchGC(gc);
+}
+
+static uint64_t
+gettime_us(void)
+{
+    struct timespec tv;
+
+    if (clock_gettime(CLOCK_MONOTONIC, &tv))
+        return 0;
+
+    return (uint64_t)tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
+}
+
+/**
+ * Get current frame count and frame count timestamp, based on drawable's
+ * crtc.
+ */
+static int
+ms_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
+{
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+
+    /* Drawable not displayed, make up a *monotonic* value */
+    if (crtc == NULL) {
+        *ust = gettime_us();
+        *msc = 0;
+        return TRUE;
+    }
+
+    ret = ms_get_crtc_ust_msc(crtc, ust, msc);
+
+    if (ret)
+        return FALSE;
+
+    return TRUE;
+}
+
+static XID
+get_client_id(ClientPtr client)
+{
+    XID *ptr = dixGetPrivateAddr(&client->devPrivates, &ms_dri2_client_key);
+    if (*ptr == 0)
+        *ptr = FakeClientID(client->index);
+    return *ptr;
+}
+
+/*
+ * Hook this frame event into the server resource
+ * database so we can clean it up if the drawable or
+ * client exits while the swap is pending
+ */
+static Bool
+ms_dri2_add_frame_event(ms_dri2_frame_event_ptr info)
+{
+    struct ms_dri2_resource *resource;
+
+    resource = ms_get_resource(get_client_id(info->client),
+                               frame_event_client_type);
+    if (resource == NULL)
+        return FALSE;
+
+    xorg_list_add(&info->client_resource, &resource->list);
+
+    resource = ms_get_resource(info->drawable->id, frame_event_drawable_type);
+    if (resource == NULL) {
+        xorg_list_del(&info->client_resource);
+        return FALSE;
+    }
+
+    xorg_list_add(&info->drawable_resource, &resource->list);
+
+    return TRUE;
+}
+
+static void
+ms_dri2_del_frame_event(ms_dri2_frame_event_rec *info)
+{
+    xorg_list_del(&info->client_resource);
+    xorg_list_del(&info->drawable_resource);
+
+    if (info->front)
+        ms_dri2_destroy_buffer(NULL, info->front);
+    if (info->back)
+        ms_dri2_destroy_buffer(NULL, info->back);
+
+    free(info);
+}
+
+static void
+ms_dri2_blit_swap(DrawablePtr drawable,
+                  DRI2BufferPtr dst,
+                  DRI2BufferPtr src)
+{
+    BoxRec box;
+    RegionRec region;
+
+    box.x1 = 0;
+    box.y1 = 0;
+    box.x2 = drawable->width;
+    box.y2 = drawable->height;
+    REGION_INIT(pScreen, &region, &box, 0);
+
+    ms_dri2_copy_region(drawable, &region, dst, src);
+}
+
+static void
+ms_dri2_frame_event_handler(uint64_t msc,
+                            uint64_t usec,
+                            void *data)
+{
+    ms_dri2_frame_event_ptr frame_info = data;
+    DrawablePtr drawable = frame_info->drawable;
+    ScreenPtr screen = frame_info->screen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    uint32_t tv_sec = usec / 1000000;
+    uint32_t tv_usec = usec % 1000000;
+
+    if (!drawable) {
+        ms_dri2_del_frame_event(frame_info);
+        return;
+    }
+
+    switch (frame_info->type) {
+    case MS_DRI2_QUEUE_SWAP:
+        ms_dri2_blit_swap(drawable, frame_info->front, frame_info->back);
+        DRI2SwapComplete(frame_info->client, drawable, msc, tv_sec, tv_usec,
+                         DRI2_BLIT_COMPLETE,
+                         frame_info->client ? frame_info->event_complete : NULL,
+                         frame_info->event_data);
+        break;
+
+    case MS_DRI2_WAIT_MSC:
+        if (frame_info->client)
+            DRI2WaitMSCComplete(frame_info->client, drawable,
+                                msc, tv_sec, tv_usec);
+        break;
+
+    default:
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "%s: unknown vblank event (type %d) received\n", __func__,
+                   frame_info->type);
+        break;
+    }
+
+    ms_dri2_del_frame_event(frame_info);
+}
+
+static void
+ms_dri2_frame_event_abort(void *data)
+{
+    ms_dri2_frame_event_ptr frame_info = data;
+
+    ms_dri2_del_frame_event(frame_info);
+}
+
+/**
+ * Request a DRM event when the requested conditions will be satisfied.
+ *
+ * We need to handle the event and ask the server to wake up the client when
+ * we receive it.
+ */
+static int
+ms_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
+                          CARD64 divisor, CARD64 remainder)
+{
+    ScreenPtr screen = draw->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    ms_dri2_frame_event_ptr wait_info;
+    drmVBlank vbl;
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+    drmmode_crtc_private_ptr drmmode_crtc;
+    CARD64 current_msc, current_ust, request_msc;
+    uint32_t seq;
+
+    /* Drawable not visible, return immediately */
+    if (!crtc)
+        goto out_complete;
+    drmmode_crtc = crtc->driver_private;
+
+    wait_info = calloc(1, sizeof(*wait_info));
+    if (!wait_info)
+        goto out_complete;
+
+    wait_info->screen = screen;
+    wait_info->drawable = draw;
+    wait_info->client = client;
+    wait_info->type = MS_DRI2_WAIT_MSC;
+
+    if (!ms_dri2_add_frame_event(wait_info)) {
+        free(wait_info);
+        wait_info = NULL;
+        goto out_complete;
+    }
+
+    /* Get current count */
+    ret = ms_get_crtc_ust_msc(crtc, &current_ust, &current_msc);
+
+    /*
+     * If divisor is zero, or current_msc is smaller than target_msc,
+     * we just need to make sure target_msc passes  before waking up the
+     * client.
+     */
+    if (divisor == 0 || current_msc < target_msc) {
+        /* If target_msc already reached or passed, set it to
+         * current_msc to ensure we return a reasonable value back
+         * to the caller. This keeps the client from continually
+         * sending us MSC targets from the past by forcibly updating
+         * their count on this call.
+         */
+        seq = ms_drm_queue_alloc(crtc, wait_info,
+                                 ms_dri2_frame_event_handler,
+                                 ms_dri2_frame_event_abort);
+        if (!seq)
+            goto out_free;
+
+        if (current_msc >= target_msc)
+            target_msc = current_msc;
+        vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                            DRM_VBLANK_EVENT |
+                            drmmode_crtc->vblank_pipe);
+        vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, target_msc);
+        vbl.request.signal = (unsigned long)seq;
+
+        ret = drmWaitVBlank(ms->fd, &vbl);
+        if (ret) {
+            static int limit = 5;
+            if (limit) {
+                xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                           "%s:%d get vblank counter failed: %s\n",
+                           __FUNCTION__, __LINE__,
+                           strerror(errno));
+                limit--;
+            }
+            goto out_free;
+        }
+
+        wait_info->frame = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+        DRI2BlockClient(client, draw);
+        return TRUE;
+    }
+
+    /*
+     * If we get here, target_msc has already passed or we don't have one,
+     * so we queue an event that will satisfy the divisor/remainder equation.
+     */
+    vbl.request.type =
+        DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT | drmmode_crtc->vblank_pipe;
+
+    request_msc = current_msc - (current_msc % divisor) +
+        remainder;
+    /*
+     * If calculated remainder is larger than requested remainder,
+     * it means we've passed the last point where
+     * seq % divisor == remainder, so we need to wait for the next time
+     * that will happen.
+     */
+    if ((current_msc % divisor) >= remainder)
+        request_msc += divisor;
+
+    seq = ms_drm_queue_alloc(crtc, wait_info,
+                             ms_dri2_frame_event_handler,
+                             ms_dri2_frame_event_abort);
+    if (!seq)
+        goto out_free;
+
+    vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, request_msc);
+    vbl.request.signal = (unsigned long)seq;
+
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        static int limit = 5;
+        if (limit) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "%s:%d get vblank counter failed: %s\n",
+                       __FUNCTION__, __LINE__,
+                       strerror(errno));
+            limit--;
+        }
+        goto out_free;
+    }
+
+    wait_info->frame = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+    DRI2BlockClient(client, draw);
+
+    return TRUE;
+
+ out_free:
+    ms_dri2_del_frame_event(wait_info);
+ out_complete:
+    DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
+    return TRUE;
+}
+
+/**
+ * ScheduleSwap is responsible for requesting a DRM vblank event for
+ * the appropriate frame, or executing the swap immediately if it
+ * doesn't need to wait.
+ *
+ * When the swap is complete, the driver should call into the server so it
+ * can send any swap complete events that have been requested.
+ */
+static int
+ms_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
+                      DRI2BufferPtr front, DRI2BufferPtr back,
+                      CARD64 *target_msc, CARD64 divisor,
+                      CARD64 remainder, DRI2SwapEventPtr func, void *data)
+{
+    ScreenPtr screen = draw->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    drmVBlank vbl;
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+    drmmode_crtc_private_ptr drmmode_crtc;
+    ms_dri2_frame_event_ptr frame_info = NULL;
+    uint64_t current_msc, current_ust;
+    uint64_t request_msc;
+    uint32_t seq;
+
+    /* Drawable not displayed... just complete the swap */
+    if (!crtc)
+        goto blit_fallback;
+    drmmode_crtc = crtc->driver_private;
+
+    frame_info = calloc(1, sizeof(*frame_info));
+    if (!frame_info)
+        goto blit_fallback;
+
+    frame_info->screen = screen;
+    frame_info->drawable = draw;
+    frame_info->client = client;
+    frame_info->event_complete = func;
+    frame_info->event_data = data;
+    frame_info->front = front;
+    frame_info->back = back;
+    frame_info->crtc = crtc;
+    frame_info->type = MS_DRI2_QUEUE_SWAP;
+
+    if (!ms_dri2_add_frame_event(frame_info)) {
+        free(frame_info);
+        frame_info = NULL;
+        goto blit_fallback;
+    }
+
+    ms_dri2_reference_buffer(front);
+    ms_dri2_reference_buffer(back);
+
+    ret = ms_get_crtc_ust_msc(crtc, &current_ust, &current_msc);
+
+    /*
+     * If divisor is zero, or current_msc is smaller than target_msc
+     * we just need to make sure target_msc passes before initiating
+     * the swap.
+     */
+    if (divisor == 0 || current_msc < *target_msc) {
+        /* We need to use DRM_VBLANK_NEXTONMISS to avoid unreliable
+         * timestamping later on.
+         */
+        vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                            DRM_VBLANK_NEXTONMISS |
+                            DRM_VBLANK_EVENT |
+                            drmmode_crtc->vblank_pipe);
+
+        /* If target_msc already reached or passed, set it to
+         * current_msc to ensure we return a reasonable value back
+         * to the caller. This makes swap_interval logic more robust.
+         */
+        if (current_msc >= *target_msc)
+            *target_msc = current_msc;
+
+        seq = ms_drm_queue_alloc(crtc, frame_info,
+                                 ms_dri2_frame_event_handler,
+                                 ms_dri2_frame_event_abort);
+        if (!seq)
+            goto blit_fallback;
+
+        vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, *target_msc);
+        vbl.request.signal = (unsigned long)seq;
+
+        ret = drmWaitVBlank(ms->fd, &vbl);
+        if (ret) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "divisor 0 get vblank counter failed: %s\n",
+                       strerror(errno));
+            goto blit_fallback;
+        }
+
+        *target_msc = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+        frame_info->frame = *target_msc;
+
+        return TRUE;
+    }
+
+    /*
+     * If we get here, target_msc has already passed or we don't have one,
+     * and we need to queue an event that will satisfy the divisor/remainder
+     * equation.
+     */
+    vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                        DRM_VBLANK_NEXTONMISS |
+                        DRM_VBLANK_EVENT |
+                        drmmode_crtc->vblank_pipe);
+
+    request_msc = current_msc - (current_msc % divisor) +
+        remainder;
+
+    /*
+     * If the calculated deadline vbl.request.sequence is smaller than
+     * or equal to current_msc, it means we've passed the last point
+     * when effective onset frame seq could satisfy
+     * seq % divisor == remainder, so we need to wait for the next time
+     * this will happen.
+
+     * This comparison takes the DRM_VBLANK_NEXTONMISS delay into account.
+     */
+    if (request_msc <= current_msc)
+        request_msc += divisor;
+
+
+    seq = ms_drm_queue_alloc(crtc, frame_info,
+                             ms_dri2_frame_event_handler,
+                             ms_dri2_frame_event_abort);
+    if (!seq)
+        goto blit_fallback;
+
+    vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, request_msc);
+    vbl.request.signal = (unsigned long)seq;
+
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "final get vblank counter failed: %s\n",
+                   strerror(errno));
+        goto blit_fallback;
+    }
+
+    *target_msc = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+    frame_info->frame = *target_msc;
+
+    return TRUE;
+
+ blit_fallback:
+    ms_dri2_blit_swap(draw, front, back);
+    DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data);
+    if (frame_info)
+        ms_dri2_del_frame_event(frame_info);
+    *target_msc = 0; /* offscreen, so zero out target vblank count */
+    return TRUE;
+}
+
+static int
+ms_dri2_frame_event_client_gone(void *data, XID id)
+{
+    struct ms_dri2_resource *resource = data;
+
+    while (!xorg_list_is_empty(&resource->list)) {
+        ms_dri2_frame_event_ptr info =
+            xorg_list_first_entry(&resource->list,
+                                  ms_dri2_frame_event_rec,
+                                  client_resource);
+
+        xorg_list_del(&info->client_resource);
+        info->client = NULL;
+    }
+    free(resource);
+
+    return Success;
+}
+
+static int
+ms_dri2_frame_event_drawable_gone(void *data, XID id)
+{
+    struct ms_dri2_resource *resource = data;
+
+    while (!xorg_list_is_empty(&resource->list)) {
+        ms_dri2_frame_event_ptr info =
+            xorg_list_first_entry(&resource->list,
+                                  ms_dri2_frame_event_rec,
+                                  drawable_resource);
+
+        xorg_list_del(&info->drawable_resource);
+        info->drawable = NULL;
+    }
+    free(resource);
+
+    return Success;
+}
+
+static Bool
+ms_dri2_register_frame_event_resource_types(void)
+{
+    frame_event_client_type =
+        CreateNewResourceType(ms_dri2_frame_event_client_gone,
+                              "Frame Event Client");
+    if (!frame_event_client_type)
+        return FALSE;
+
+    frame_event_drawable_type =
+        CreateNewResourceType(ms_dri2_frame_event_drawable_gone,
+                              "Frame Event Drawable");
+    if (!frame_event_drawable_type)
+        return FALSE;
+
+    return TRUE;
+}
+
+Bool
+ms_dri2_screen_init(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    DRI2InfoRec info;
+
+    if (!glamor_supports_pixmap_import_export(screen)) {
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "DRI2: glamor lacks support for pixmap import/export\n");
+    }
+
+    if (!xf86LoaderCheckSymbol("DRI2Version"))
+        return FALSE;
+
+    if (!dixRegisterPrivateKey(&ms_dri2_client_key,
+                               PRIVATE_CLIENT, sizeof(XID)))
+        return FALSE;
+
+    if (serverGeneration != ms_dri2_server_generation) {
+        ms_dri2_server_generation = serverGeneration;
+        if (!ms_dri2_register_frame_event_resource_types()) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "Cannot register DRI2 frame event resources\n");
+            return FALSE;
+        }
+    }
+
+    memset(&info, '\0', sizeof(info));
+    info.fd = ms->fd;
+    info.driverName = NULL; /* Compat field, unused. */
+    info.deviceName = drmGetDeviceNameFromFd(ms->fd);
+
+    info.version = 4;
+    info.CreateBuffer = ms_dri2_create_buffer;
+    info.DestroyBuffer = ms_dri2_destroy_buffer;
+    info.CopyRegion = ms_dri2_copy_region;
+    info.ScheduleSwap = ms_dri2_schedule_swap;
+    info.GetMSC = ms_dri2_get_msc;
+    info.ScheduleWaitMSC = ms_dri2_schedule_wait_msc;
+
+    /* These two will be filled in by dri2.c */
+    info.numDrivers = 0;
+    info.driverNames = NULL;
+
+    return DRI2ScreenInit(screen, &info);
+}
+
+void
+ms_dri2_close_screen(ScreenPtr screen)
+{
+    DRI2CloseScreen(screen);
+}
+
+#endif /* GLAMOR */
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
index c62147a..592f246 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/driver.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
@@ -25,7 +25,7 @@
  *
  *
  * Original Author: Alan Hourihane <alanh at tungstengraphics.com>
- * Rewrite: Dave Airlie <airlied at redhat.com> 
+ * Rewrite: Dave Airlie <airlied at redhat.com>
  *
  */
 
@@ -788,7 +788,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
     try_enable_glamor(pScrn);
 
-    if (!ms->glamor) {
+    if (ms->glamor) {
+        xf86LoadSubModule(pScrn, "dri2");
+    } else {
         Bool prefer_shadow = TRUE;
 
         ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
@@ -1107,6 +1109,21 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     if (serverGeneration == 1)
         xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
+    if (!ms_vblank_screen_init(pScreen)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Failed to initialize vblank support.\n");
+        return FALSE;
+    }
+
+#ifdef GLAMOR
+    if (ms->glamor) {
+        if (!ms_dri2_screen_init(pScreen)) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Failed to initialize the DRI2 extension.\n");
+        }
+    }
+#endif
+
     return EnterVT(pScrn);
 }
 
@@ -1172,6 +1189,14 @@ CloseScreen(ScreenPtr pScreen)
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
 
+#ifdef GLAMOR
+    if (ms->glamor) {
+        ms_dri2_close_screen(pScreen);
+    }
+#endif
+
+    ms_vblank_close_screen(pScreen);
+
     if (ms->damage) {
         DamageUnregister(ms->damage);
         DamageDestroy(ms->damage);
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.h b/xorg-server/hw/xfree86/drivers/modesetting/driver.h
index 35f2419..9eda1c4 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/driver.h
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.h
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <drm.h>
 #include <xf86drm.h>
+#include <xf86Crtc.h>
 #include <damage.h>
 
 #include "drmmode_display.h"
@@ -42,6 +43,26 @@ typedef struct {
     ScrnInfoPtr pScrn_2;
 } EntRec, *EntPtr;
 
+typedef void (*ms_drm_handler_proc)(uint64_t frame,
+                                    uint64_t usec,
+                                    void *data);
+
+typedef void (*ms_drm_abort_proc)(void *data);
+
+/**
+ * A tracked handler for an event that will hopefully be generated by
+ * the kernel, and what to do when it is encountered.
+ */
+struct ms_drm_queue {
+    struct xorg_list list;
+    xf86CrtcPtr crtc;
+    uint32_t seq;
+    void *data;
+    ScrnInfoPtr scrn;
+    ms_drm_handler_proc handler;
+    ms_drm_abort_proc abort;
+};
+
 typedef struct _modesettingRec {
     int fd;
 
@@ -70,6 +91,8 @@ typedef struct _modesettingRec {
 
     drmmode_rec drmmode;
 
+    drmEventContext event_context;
+
     DamagePtr damage;
     Bool dirty_enabled;
 
@@ -78,3 +101,24 @@ typedef struct _modesettingRec {
 } modesettingRec, *modesettingPtr;
 
 #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
+
+uint32_t ms_drm_queue_alloc(xf86CrtcPtr crtc,
+                            void *data,
+                            ms_drm_handler_proc handler,
+                            ms_drm_abort_proc abort);
+
+xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
+xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
+                             xf86CrtcPtr desired, BoxPtr crtc_box_ret);
+
+int ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
+
+uint32_t ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect);
+uint64_t ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence);
+
+
+Bool ms_dri2_screen_init(ScreenPtr screen);
+void ms_dri2_close_screen(ScreenPtr screen);
+
+Bool ms_vblank_screen_init(ScreenPtr screen);
+void ms_vblank_close_screen(ScreenPtr screen);
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
index d959837..ef9009e 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -116,7 +116,7 @@ dumb_bo_unmap(int fd, struct dumb_bo *bo)
 }
 #endif
 
-static int
+int
 dumb_bo_destroy(int fd, struct dumb_bo *bo)
 {
     struct drm_mode_destroy_dumb arg;
@@ -137,8 +137,8 @@ dumb_bo_destroy(int fd, struct dumb_bo *bo)
     return 0;
 }
 
-static struct dumb_bo *
-dumb_get_bo_from_handle(int fd, int handle, int pitch, int size)
+struct dumb_bo *
+dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
 {
     struct dumb_bo *bo;
     int ret;
@@ -164,7 +164,7 @@ drmmode_SetSlaveBO(PixmapPtr ppix,
     msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
 
     ppriv->backing_bo =
-        dumb_get_bo_from_handle(drmmode->fd, fd_handle, pitch, size);
+        dumb_get_bo_from_fd(drmmode->fd, fd_handle, pitch, size);
     if (!ppriv->backing_bo)
         return FALSE;
 
@@ -582,6 +582,17 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .shadow_create = drmmode_shadow_create,
 };
 
+static uint32_t
+drmmode_crtc_vblank_pipe(int crtc_id)
+{
+    if (crtc_id > 1)
+        return crtc_id << DRM_VBLANK_HIGH_CRTC_SHIFT;
+    else if (crtc_id > 0)
+        return DRM_VBLANK_SECONDARY;
+    else
+        return 0;
+}
+
 static void
 drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 {
@@ -596,6 +607,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
     drmmode_crtc->mode_crtc =
         drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
     drmmode_crtc->drmmode = drmmode;
+    drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num);
     crtc->driver_private = drmmode_crtc;
 }
 
@@ -1183,6 +1195,11 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     xf86DrvMsg(scrn->scrnIndex, X_INFO,
                "Allocate new frame buffer %dx%d stride\n", width, height);
 
+    if (drmmode->triple_buffer_pixmap) {
+        screen->DestroyPixmap(drmmode->triple_buffer_pixmap);
+        drmmode->triple_buffer_pixmap = NULL;
+    }
+
     old_width = scrn->virtualX;
     old_height = scrn->virtualY;
     old_pitch = drmmode->front_bo->pitch;
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
index 438743b..987608c 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -43,6 +43,7 @@ struct dumb_bo {
 typedef struct {
     int fd;
     unsigned fb_id;
+    unsigned old_fb_id;
     drmModeResPtr mode_res;
     drmModeFBPtr mode_fb;
     int cpp;
@@ -58,17 +59,42 @@ typedef struct {
     Bool shadow_enable;
     void *shadow_fb;
 
+    /**
+     * A screen-sized pixmap when we're doing triple-buffered DRI2
+     * pageflipping.
+     *
+     * One is shared between all drawables that flip to the front
+     * buffer, and it only gets reallocated when root pixmap size
+     * changes.
+     */
+    PixmapPtr triple_buffer_pixmap;
+
+    /** The GEM name for triple_buffer_pixmap */
+    uint32_t triple_buffer_name;
+
     DevPrivateKeyRec pixmapPrivateKeyRec;
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
     drmmode_ptr drmmode;
     drmModeCrtcPtr mode_crtc;
-    int hw_id;
+    uint32_t vblank_pipe;
     struct dumb_bo *cursor_bo;
     unsigned rotate_fb_id;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
     DamagePtr slave_damage;
+
+    /**
+     * @{ MSC (vblank count) handling for the PRESENT extension.
+     *
+     * The kernel's vblank counters are 32 bits and apparently full of
+     * lies, and we need to give a reliable 64-bit msc for GL, so we
+     * have to track and convert to a userland-tracked 64-bit msc.
+     */
+    int32_t vblank_offset;
+    uint32_t msc_prev;
+    uint64_t msc_high;
+    /** @} */
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 
 typedef struct {
@@ -121,6 +147,9 @@ Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
                              int *depth, int *bpp);
+struct dumb_bo *dumb_get_bo_from_fd(int drm_fd, int fd, int pitch, int size);
+int dumb_bo_destroy(int fd, struct dumb_bo *bo);
+
 
 #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
 #define DRM_CAP_DUMB_PREFERRED_DEPTH 3
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/vblank.c b/xorg-server/hw/xfree86/drivers/modesetting/vblank.c
new file mode 100644
index 0000000..5031ef8
--- /dev/null
+++ b/xorg-server/hw/xfree86/drivers/modesetting/vblank.c
@@ -0,0 +1,383 @@
+/*
+ * Copyright © 2013 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/** @file vblank.c
+ *
+ * Support for tracking the DRM's vblank events.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <unistd.h>
+#include <xf86.h>
+#include <xf86Crtc.h>
+#include <poll.h>
+#include "driver.h"
+#include "drmmode_display.h"
+
+/**
+ * Tracking for outstanding events queued to the kernel.
+ *
+ * Each list entry is a struct ms_drm_queue, which has a uint32_t
+ * value generated from drm_seq that identifies the event and a
+ * reference back to the crtc/screen associated with the event.  It's
+ * done this way rather than in the screen because we want to be able
+ * to drain the list of event handlers that should be called at server
+ * regen time, even though we don't close the drm fd and have no way
+ * to actually drain the kernel events.
+ */
+static struct xorg_list ms_drm_queue;
+static uint32_t ms_drm_seq;
+
+struct ms_pageflip {
+    ScreenPtr screen;
+    Bool crtc_for_msc_ust;
+};
+
+static void ms_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
+{
+    dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
+    dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+    if (dest->x1 >= dest->x2) {
+        dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+        return;
+    }
+
+    dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
+    dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
+    if (dest->y1 >= dest->y2)
+        dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+}
+
+static void ms_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
+{
+    if (crtc->enabled) {
+        crtc_box->x1 = crtc->x;
+        crtc_box->x2 =
+            crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+        crtc_box->y1 = crtc->y;
+        crtc_box->y2 =
+            crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+    } else
+        crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
+}
+
+static int ms_box_area(BoxPtr box)
+{
+    return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
+}
+
+/*
+ * Return the crtc covering 'box'. If two crtcs cover a portion of
+ * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
+ * with greater coverage
+ */
+
+xf86CrtcPtr
+ms_covering_crtc(ScrnInfoPtr scrn,
+                 BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
+{
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CrtcPtr crtc, best_crtc;
+    int coverage, best_coverage;
+    int c;
+    BoxRec crtc_box, cover_box;
+
+    best_crtc = NULL;
+    best_coverage = 0;
+    crtc_box_ret->x1 = 0;
+    crtc_box_ret->x2 = 0;
+    crtc_box_ret->y1 = 0;
+    crtc_box_ret->y2 = 0;
+    for (c = 0; c < xf86_config->num_crtc; c++) {
+        crtc = xf86_config->crtc[c];
+
+        /* If the CRTC is off, treat it as not covering */
+        if (!crtc->enabled)
+            continue;
+
+        ms_crtc_box(crtc, &crtc_box);
+        ms_box_intersect(&cover_box, &crtc_box, box);
+        coverage = ms_box_area(&cover_box);
+        if (coverage && crtc == desired) {
+            *crtc_box_ret = crtc_box;
+            return crtc;
+        }
+        if (coverage > best_coverage) {
+            *crtc_box_ret = crtc_box;
+            best_crtc = crtc;
+            best_coverage = coverage;
+        }
+    }
+    return best_crtc;
+}
+
+xf86CrtcPtr
+ms_dri2_crtc_covering_drawable(DrawablePtr pDraw)
+{
+    ScreenPtr pScreen = pDraw->pScreen;
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+    BoxRec box, crtcbox;
+    xf86CrtcPtr crtc;
+
+    box.x1 = pDraw->x;
+    box.y1 = pDraw->y;
+    box.x2 = box.x1 + pDraw->width;
+    box.y2 = box.y1 + pDraw->height;
+
+    crtc = ms_covering_crtc(pScrn, &box, NULL, &crtcbox);
+
+    /* Make sure the CRTC is valid and this is the real front buffer */
+    if (crtc != NULL && !crtc->rotatedData)
+        return crtc;
+
+    return NULL;
+}
+
+static Bool
+ms_get_kernel_ust_msc(xf86CrtcPtr crtc,
+                      uint32_t *msc, uint64_t *ust)
+{
+    ScreenPtr screen = crtc->randr_crtc->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmVBlank vbl;
+    int ret;
+
+    /* Get current count */
+    vbl.request.type = DRM_VBLANK_RELATIVE | drmmode_crtc->vblank_pipe;
+    vbl.request.sequence = 0;
+    vbl.request.signal = 0;
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        *msc = 0;
+        *ust = 0;
+        return FALSE;
+    } else {
+        *msc = vbl.reply.sequence;
+        *ust = (CARD64) vbl.reply.tval_sec * 1000000 + vbl.reply.tval_usec;
+        return TRUE;
+    }
+}
+
+/**
+ * Convert a 32-bit kernel MSC sequence number to a 64-bit local sequence
+ * number, adding in the vblank_offset and high 32 bits, and dealing
+ * with 64-bit wrapping
+ */
+uint64_t
+ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence)
+{
+    drmmode_crtc_private_rec *drmmode_crtc = crtc->driver_private;
+    sequence += drmmode_crtc->vblank_offset;
+
+    if ((int32_t) (sequence - drmmode_crtc->msc_prev) < -0x40000000)
+        drmmode_crtc->msc_high += 0x100000000L;
+    drmmode_crtc->msc_prev = sequence;
+    return drmmode_crtc->msc_high + sequence;
+}
+
+int
+ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc)
+{
+    uint32_t kernel_msc;
+
+    if (!ms_get_kernel_ust_msc(crtc, &kernel_msc, ust))
+        return BadMatch;
+    *msc = ms_kernel_msc_to_crtc_msc(crtc, kernel_msc);
+
+    return Success;
+}
+
+#define MAX_VBLANK_OFFSET       1000
+
+/**
+ * Convert a 64-bit adjusted MSC value into a 32-bit kernel sequence number,
+ * removing the high 32 bits and subtracting out the vblank_offset term.
+ *
+ * This also updates the vblank_offset when it notices that the value should
+ * change.
+ */
+uint32_t
+ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect)
+{
+    drmmode_crtc_private_rec *drmmode_crtc = crtc->driver_private;
+    uint64_t msc;
+    uint64_t ust;
+    int64_t diff;
+
+    if (ms_get_crtc_ust_msc(crtc, &ust, &msc) == Success) {
+        diff = expect - msc;
+
+        /* We're way off here, assume that the kernel has lost its mind
+         * and smack the vblank back to something sensible
+         */
+        if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) {
+            drmmode_crtc->vblank_offset += (int32_t) diff;
+            if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET &&
+                drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET)
+                drmmode_crtc->vblank_offset = 0;
+        }
+    }
+    return (uint32_t) (expect - drmmode_crtc->vblank_offset);
+}
+
+/**
+ * Check for pending DRM events and process them.
+ */
+static void
+ms_drm_wakeup_handler(void *data, int err, void *mask)
+{
+    ScreenPtr screen = data;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    fd_set *read_mask = mask;
+
+    if (data == NULL || err < 0)
+        return;
+
+    if (FD_ISSET(ms->fd, read_mask))
+        drmHandleEvent(ms->fd, &ms->event_context);
+}
+
+/*
+ * Enqueue a potential drm response; when the associated response
+ * appears, we've got data to pass to the handler from here
+ */
+uint32_t
+ms_drm_queue_alloc(xf86CrtcPtr crtc,
+                   void *data,
+                   ms_drm_handler_proc handler,
+                   ms_drm_abort_proc abort)
+{
+    ScreenPtr screen = crtc->randr_crtc->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    struct ms_drm_queue *q;
+
+    q = calloc(1, sizeof(struct ms_drm_queue));
+
+    if (!q)
+        return 0;
+    if (!ms_drm_seq)
+        ++ms_drm_seq;
+    q->seq = ms_drm_seq++;
+    q->scrn = scrn;
+    q->crtc = crtc;
+    q->data = data;
+    q->handler = handler;
+    q->abort = abort;
+
+    xorg_list_add(&q->list, &ms_drm_queue);
+
+    return q->seq;
+}
+
+/**
+ * Abort one queued DRM entry, removing it
+ * from the list, calling the abort function and
+ * freeing the memory
+ */
+static void
+ms_drm_abort_one(struct ms_drm_queue *q)
+{
+        xorg_list_del(&q->list);
+        q->abort(q->data);
+        free(q);
+}
+
+/**
+ * Abort all queued entries on a specific scrn, used
+ * when resetting the X server
+ */
+static void
+ms_drm_abort_scrn(ScrnInfoPtr scrn)
+{
+    struct ms_drm_queue *q, *tmp;
+
+    xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+        if (q->scrn == scrn)
+            ms_drm_abort_one(q);
+    }
+}
+
+/*
+ * General DRM kernel handler. Looks for the matching sequence number in the
+ * drm event queue and calls the handler for it.
+ */
+static void
+ms_drm_handler(int fd, uint32_t frame, uint32_t sec, uint32_t usec,
+               void *user_ptr)
+{
+    struct ms_drm_queue *q, *tmp;
+    uint32_t user_data = (uint32_t) (intptr_t) user_ptr;
+
+    xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+        if (q->seq == user_data) {
+            uint64_t msc;
+
+            msc = ms_kernel_msc_to_crtc_msc(q->crtc, frame);
+            xorg_list_del(&q->list);
+            q->handler(msc, (uint64_t) sec * 1000000 + usec, q->data);
+            free(q);
+            break;
+        }
+    }
+}
+
+Bool
+ms_vblank_screen_init(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+
+    xorg_list_init(&ms_drm_queue);
+
+    ms->event_context.version = DRM_EVENT_CONTEXT_VERSION;
+    ms->event_context.vblank_handler = ms_drm_handler;
+    ms->event_context.page_flip_handler = ms_drm_handler;
+
+    /* We need to re-register the DRM fd for the synchronisation
+     * feedback on every server generation, so perform the
+     * registration within ScreenInit and not PreInit.
+     */
+    AddGeneralSocket(ms->fd);
+    RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+                                   ms_drm_wakeup_handler, screen);
+
+    return TRUE;
+}
+
+void
+ms_vblank_close_screen(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+
+    ms_drm_abort_scrn(scrn);
+
+    RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+                                 ms_drm_wakeup_handler, screen);
+    RemoveGeneralSocket(ms->fd);
+}
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
index 0450822..8cd2079 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
@@ -251,7 +251,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
 /* open correct framebuffer device                                      */
 
 /**
- * Try to find the framebuffer device for a given PCI device 
+ * Try to find the framebuffer device for a given PCI device
  */
 static int
 fbdev_open_pci(struct pci_device *pPci, char **namep)
diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.c b/xorg-server/hw/xfree86/i2c/xf86i2c.c
index 2d261d4..cf2cd09 100644
--- a/xorg-server/hw/xfree86/i2c/xf86i2c.c
+++ b/xorg-server/hw/xfree86/i2c/xf86i2c.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1998 Itai Nahshon, Michael Schimek
  *
- * The original code was derived from and inspired by 
+ * The original code was derived from and inspired by
  * the I2C driver from the Linux kernel.
  *      (c) 1998 Gerd Knorr <kraxel at cs.tu-berlin.de>
  */
@@ -52,7 +52,7 @@ I2CUDelay(I2CBusPtr b, int usec)
     if (usec > 0) {
         X_GETTIMEOFDAY(&begin);
         do {
-            /* It would be nice to use {xf86}usleep, 
+            /* It would be nice to use {xf86}usleep,
              * but usleep (1) takes >10000 usec !
              */
             X_GETTIMEOFDAY(&cur);
@@ -74,7 +74,7 @@ I2CUDelay(I2CBusPtr b, int usec)
 
 #define RISEFALLTIME 2          /* usec, actually 300 to 1000 ns according to the i2c specs */
 
-/* Some devices will hold SCL low to slow down the bus or until 
+/* Some devices will hold SCL low to slow down the bus or until
  * ready for transmission.
  *
  * This condition will be noticed when the master tries to raise
@@ -206,7 +206,7 @@ I2CReadBit(I2CBusPtr b, int *psda, int timeout)
 /* This is the default I2CPutByte function if not supplied by the driver.
  *
  * A single byte is sent to the device.
- * The function returns FALSE if a timeout occurs, you should send 
+ * The function returns FALSE if a timeout occurs, you should send
  * a stop condition afterwards to reset the bus.
  *
  * A timeout occurs,
@@ -267,7 +267,7 @@ I2CPutByte(I2CDevPtr d, I2CByte data)
  * A single byte is read from the device.
  * The function returns FALSE if a timeout occurs, you should send
  * a stop condition afterwards to reset the bus.
- * 
+ *
  * A timeout occurs,
  * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
  * or slows down the bus for more than b->BitTimeout usecs for each bit.
@@ -275,7 +275,7 @@ I2CPutByte(I2CDevPtr d, I2CByte data)
  * ByteTimeout must be at least b->HoldTime, the other timeouts can be
  * zero according to the comment on I2CRaiseSCL.
  *
- * For the <last> byte in a sequence the acknowledge bit NACK (1), 
+ * For the <last> byte in a sequence the acknowledge bit NACK (1),
  * otherwise ACK (0) will be sent.
  */
 
@@ -311,11 +311,11 @@ I2CGetByte(I2CDevPtr d, I2CByte * data, Bool last)
  *
  * It creates the start condition, followed by the d->SlaveAddr.
  * Higher level functions must call this routine rather than
- * I2CStart/PutByte because a hardware I2C master may not be able 
+ * I2CStart/PutByte because a hardware I2C master may not be able
  * to send a slave address without a start condition.
  *
  * The same timeouts apply as with I2CPutByte and additional a
- * StartTimeout, similar to the ByteTimeout but for the start 
+ * StartTimeout, similar to the ByteTimeout but for the start
  * condition.
  *
  * In case of a timeout, the bus is left in a clean idle condition.
@@ -325,7 +325,7 @@ I2CGetByte(I2CDevPtr d, I2CByte * data, Bool last)
  * in the least significant byte. This is, the slave address must include the
  * R/_W flag as least significant bit.
  *
- * The most significant byte of the address will be sent _after_ the LSB, 
+ * The most significant byte of the address will be sent _after_ the LSB,
  * but only if the LSB indicates:
  * a) an 11 bit address, this is LSB = 1111 0xxx.
  * b) a 'general call address', this is LSB = 0000 000x - see the I2C specs
@@ -354,7 +354,7 @@ I2CAddress(I2CDevPtr d, I2CSlaveAddr addr)
  * ========================================================
  */
 
-/* Function for probing. Just send the slave address 
+/* Function for probing. Just send the slave address
  * and return true if the device responds. The slave address
  * must have the lsb set to reflect a read (1) or write (0) access.
  * Don't expect a read- or write-only device will respond otherwise.
@@ -403,7 +403,7 @@ xf86I2CProbeAddress(I2CBusPtr b, I2CSlaveAddr addr)
  *
  * The functions exits immediately when an error occures,
  * not proceeding any data left. However, step 3 will
- * be executed anyway to leave the bus in clean idle state. 
+ * be executed anyway to leave the bus in clean idle state.
  */
 
 static Bool
@@ -470,7 +470,7 @@ xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte)
     return xf86I2CWriteRead(d, &subaddr, 1, pbyte, 1);
 }
 
-/* Read bytes from subsequent registers determined by the 
+/* Read bytes from subsequent registers determined by the
  * sub-address of the first register.
  */
 
@@ -480,7 +480,7 @@ xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte, int n)
     return xf86I2CWriteRead(d, &subaddr, 1, pbyte, n);
 }
 
-/* Read a word (high byte, then low byte) from one of the registers 
+/* Read a word (high byte, then low byte) from one of the registers
  * determined by its sub-address.
  */
 
@@ -511,7 +511,7 @@ xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte)
     return xf86I2CWriteRead(d, wb, 2, NULL, 0);
 }
 
-/* Write bytes to subsequent registers determined by the 
+/* Write bytes to subsequent registers determined by the
  * sub-address of the first register.
  */
 
@@ -537,7 +537,7 @@ xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
     return r;
 }
 
-/* Write a word (high byte, then low byte) to one of the registers 
+/* Write a word (high byte, then low byte) to one of the registers
  * determined by its sub-address.
  */
 
@@ -553,7 +553,7 @@ xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word)
     return xf86I2CWriteRead(d, wb, 3, NULL, 0);
 }
 
-/* Write a vector of bytes to not adjacent registers. This vector is, 
+/* Write a vector of bytes to not adjacent registers. This vector is,
  * 1st byte sub-address, 2nd byte value, 3rd byte sub-address asf.
  * This function is intended to initialize devices. Note this function
  * exits immediately when an error occurs, some registers may
@@ -637,7 +637,7 @@ xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc)
 /* I2C transmissions are related to an I2CDevRec you must link to a
  * previously registered bus (see xf86I2CBusInit) before attempting
  * to read and write data. You may call xf86I2CProbeAddress first to
- * see if the device in question is present on this bus. 
+ * see if the device in question is present on this bus.
  *
  * xf86I2CDevInit will not allocate an I2CBusRec for you, instead you
  * may enter a pointer to a statically allocated I2CDevRec or the (modified)
@@ -779,9 +779,9 @@ xf86DestroyI2CBusRec(I2CBusPtr b, Bool unalloc, Bool devs_too)
 Bool
 xf86I2CBusInit(I2CBusPtr b)
 {
-    /* I2C buses must be identified by a unique scrnIndex 
-     * and name. If scrnIndex is unspecified (a negative value), 
-     * then the name must be unique throughout the server. 
+    /* I2C buses must be identified by a unique scrnIndex
+     * and name. If scrnIndex is unspecified (a negative value),
+     * then the name must be unique throughout the server.
      */
 
     if (b->BusName == NULL || xf86I2CFindBus(b->scrnIndex, b->BusName) != NULL)
diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.h b/xorg-server/hw/xfree86/i2c/xf86i2c.h
index 26303ff..7b0ccdf 100644
--- a/xorg-server/hw/xfree86/i2c/xf86i2c.h
+++ b/xorg-server/hw/xfree86/i2c/xf86i2c.h
@@ -1,4 +1,4 @@
-/* 
+/*
  *  Copyright (C) 1998 Itai Nahshon, Michael Schimek
  */
 
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index 7021bdd..fdf5bd8 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -918,7 +918,7 @@ LoadModule(const char *module, const char *path, const char **subdirlist,
         goto LoadModule_fail;
     }
 
-    /* 
+    /*
      * if the module name is not a full pathname, we need to
      * check the elements in the path
      */
@@ -938,7 +938,7 @@ LoadModule(const char *module, const char *path, const char **subdirlist,
         }
     }
 
-    /* 
+    /*
      * did we find the module?
      */
     if (!found) {
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index 87ba0b7..9d592a7 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -1072,7 +1072,7 @@ xf86DefaultScreenLimits(ScrnInfoPtr scrn, int *widthp, int *heightp,
 #define POSITION_UNSET	-100000
 
 /*
- * check if the user configured any outputs at all 
+ * check if the user configured any outputs at all
  * with either a position or a relative setting or a mode.
  */
 static Bool
@@ -1736,7 +1736,7 @@ xf86ProbeOutputModes(ScrnInfoPtr scrn, int maxX, int maxY)
             xf86ValidateModesReducedBlanking(scrn, default_modes);
 
         if (sync_source == sync_config) {
-            /* 
+            /*
              * Check output and config modes against sync range from config file
              */
             xf86ValidateModesSync(scrn, output_modes, &mon_rec);
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index eebe6f4..692bf40 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -242,7 +242,7 @@ struct _xf86Crtc {
     /**
      * Desired state of this CRTC
      *
-     * Set when this CRTC should be driving one or more outputs 
+     * Set when this CRTC should be driving one or more outputs
      */
     Bool enabled;
 
@@ -304,7 +304,7 @@ struct _xf86Crtc {
      */
     Bool cursor_argb;
     /**
-     * Track whether cursor is within CRTC range 
+     * Track whether cursor is within CRTC range
      */
     Bool cursor_in_range;
     /**
@@ -608,7 +608,7 @@ struct _xf86Output {
 #else
     void *randr_output;
 #endif
-    /** 
+    /**
      * Desired initial panning
      * Added in ABI version 2
      */
@@ -922,7 +922,7 @@ extern _X_EXPORT void
  xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen);
 
 /*
- * Get a standard string name for a connector type 
+ * Get a standard string name for a connector type
  */
 extern _X_EXPORT const char *xf86ConnectorGetName(xf86ConnectorType connector);
 
@@ -947,7 +947,7 @@ extern _X_EXPORT Bool
  * Called when anything on the screen is reconfigured.
  *
  * Reloads cursor images as needed, then adjusts cursor positions.
- * 
+ *
  * Driver should call this from crtc commit function.
  */
 extern _X_EXPORT void
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index 8a04dfc..b1c306a 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -1072,7 +1072,7 @@ xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc)
             randr_output = output->randr_output;
             randr_outputs[numOutputs++] = randr_output;
             /*
-             * We make copies of modes, so pointer equality 
+             * We make copies of modes, so pointer equality
              * isn't sufficient
              */
             for (j = 0; j < randr_output->numModes + randr_output->numUserModes;
@@ -1890,7 +1890,7 @@ xf86RandR14ProviderDestroy(ScreenPtr screen, RRProviderPtr provider)
 {
     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
-    
+
     if (config->randr_provider == provider) {
         if (config->randr_provider->offload_sink) {
             DetachOffloadGPU(screen);
diff --git a/xorg-server/hw/xfree86/modes/xf86cvt.c b/xorg-server/hw/xfree86/modes/xf86cvt.c
index 8b7bb8b..b6c1bc8 100644
--- a/xorg-server/hw/xfree86/modes/xf86cvt.c
+++ b/xorg-server/hw/xfree86/modes/xf86cvt.c
@@ -54,7 +54,7 @@
  * likely though).
  *
  * About margins; i'm sure that they are to be the bit between HDisplay and
- * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and 
+ * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and
  * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking
  * outside sync "margin" for some reason. Since we prefer seeing proper
  * blanking instead of the overscan colour, and since the Crtc* values will
@@ -154,7 +154,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
 
     if (!Reduced) {             /* simplified GTF calculation */
 
-        /* 4) Minimum time of vertical sync + back porch interval (µs) 
+        /* 4) Minimum time of vertical sync + back porch interval (µs)
          * default 550.0 */
 #define CVT_MIN_VSYNC_BP 550.0
 
diff --git a/xorg-server/hw/xfree86/modes/xf86gtf.c b/xorg-server/hw/xfree86/modes/xf86gtf.c
index 0a80784..17c2f32 100644
--- a/xorg-server/hw/xfree86/modes/xf86gtf.c
+++ b/xorg-server/hw/xfree86/modes/xf86gtf.c
@@ -5,11 +5,11 @@
  *
  * Copyright (c) 2001, Andy Ritger  aritger at nvidia.com
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * o Redistributions of source code must retain the above copyright
  *   notice, this list of conditions and the following disclaimer.
  * o Redistributions in binary form must reproduce the above copyright
@@ -50,7 +50,7 @@
  * of suitability for any purpose. The sample code contained within
  * this standard may be used without restriction.
  *
- * 
+ *
  *
  * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
  * implementation of the GTF Timing Standard, is available at:
@@ -147,7 +147,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
      *  by the calculation must be halved, as the computation calculates
      *  the number of vertical lines per field. In either case, the
      *  number of lines is rounded to the nearest integer.
-     *   
+     *
      *  [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0),
      *                                     ROUND([V LINES],0))
      */
@@ -183,7 +183,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
         margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
 
     /*  6. If interlace is required, then set variable [INTERLACE]=0.5:
-     *   
+     *
      *  [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
      */
 
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
index 236def6..b4038bd 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
index 3a639b8..dd1020e 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
@@ -28,7 +28,7 @@
  *
  * Copyright 1997
  * Digital Equipment Corporation. All rights reserved.
- * This software is furnished under license and may be used and copied only in 
+ * This software is furnished under license and may be used and copied only in
  * accordance with the following terms and conditions.  Subject to these
  * conditions, you may download, copy, install, use, modify and distribute
  * this software in source and/or binary form. No title or ownership is
@@ -38,7 +38,7 @@
  *    this copyright notice and list of conditions as they appear in the
  *    source file.
  *
- * 2) No right is granted to use any trade name, trademark, or logo of Digital 
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
  *    Equipment Corporation. Neither the "Digital Equipment Corporation"
  *    name nor any trademark or logo of Digital Equipment Corporation may be
  *    used to endorse or promote products derived from this software without
@@ -50,9 +50,9 @@
  *    In no event shall DIGITAL be liable for any damages whatsoever, and in
  *    particular, DIGITAL shall not be liable for special, indirect,
  *    consequential, or incidental damages or damages for lost profits, loss
- *    of revenue or loss of use, whether such damages arise in contract, 
+ *    of revenue or loss of use, whether such damages arise in contract,
  *    negligence, tort, under statute, in equity, at law or otherwise, even
- *    if advised of the possibility of such damage. 
+ *    if advised of the possibility of such damage.
  *
  */
 
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
index 1b92962..60a19d7 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
@@ -53,7 +53,7 @@ bsdToXF86(int type)
 }
 
 /*
- * APM events can be requested direclty from /dev/apm 
+ * APM events can be requested direclty from /dev/apm
  */
 static int
 bsdPMGetEventFromOS(int fd, pmEvent * events, int num)
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
index f6643ee..19d1f48 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Dawes make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Dawes make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
index c9f8233..38dfde1 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
@@ -173,7 +173,7 @@ xf86OpenConsole()
         if (!KeepTty) {
             /*
              * detaching the controlling tty solves problems of kbd character
-             * loss.  This is not interesting for CO driver, because it is 
+             * loss.  This is not interesting for CO driver, because it is
              * exclusive.
              */
             setpgrp(0, getpid());
@@ -631,7 +631,7 @@ int
 xf86ProcessArgument(int argc, char *argv[], int i)
 {
     /*
-     * Keep server from detaching from controlling tty.  This is useful 
+     * Keep server from detaching from controlling tty.  This is useful
      * when debugging (so the server can receive keyboard signals.
      */
     if (!strcmp(argv[i], "-keeptty")) {
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
index 32ea489..1756612 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 The XFree86 Project, 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
@@ -8,10 +8,10 @@
  * distribute, sublicense, 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 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 NONINFRINGEMENT.
@@ -19,7 +19,7 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the XFree86 Project
  * shall not be used in advertising or otherwise to promote the sale, use
  * or other dealings in this Software without prior written authorization
@@ -86,7 +86,7 @@ bsdToXF86(int type)
 }
 
 /*
- * APM events can be requested direclty from /dev/apm 
+ * APM events can be requested direclty from /dev/apm
  */
 static int
 bsdPMGetEventFromOS(int kq, pmEvent * events, int num)
@@ -113,9 +113,9 @@ bsdPMGetEventFromOS(int kq, pmEvent * events, int num)
 
 /*
  * If apmd(8) is running, he will get the events and handle them,
- * so, we've nothing to do here. 
- * Otherwise, opening /dev/apmctl will succeed and we have to send the 
- * confirmations to /dev/apmctl. 
+ * so, we've nothing to do here.
+ * Otherwise, opening /dev/apmctl will succeed and we have to send the
+ * confirmations to /dev/apmctl.
  */
 static pmWait
 bsdPMConfirmEventToOs(int dummyfd, pmEvent event)
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
index 6c3bbcb..a38a7de 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
@@ -238,7 +238,7 @@ xf86DisableIO()
     if (amd64_iopl(FALSE) == 0) {
         ExtendedEnabled = FALSE;
     }
-    /* Otherwise, the X server has revoqued its root uid, 
+    /* Otherwise, the X server has revoqued its root uid,
        and thus cannot give up IO privileges any more */
 
     return;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
index b1cf7eb..5a58da1 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
index 5bed017..3f8cccd 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -6,19 +6,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  Rich Murphey and
- * David Wexelblat make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
index 2a96393..ac24f19 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
@@ -40,11 +40,11 @@
 #include "xf86OSpriv.h"
 
 /**************************************************************************
- * Video Memory Mapping section                                            
+ * Video Memory Mapping section
  ***************************************************************************/
 
 /**************************************************************************
- * I/O Permissions section                                                 
+ * I/O Permissions section
  ***************************************************************************/
 
 /*
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
index e1fa3f8..2a28c6a 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
@@ -92,8 +92,8 @@ GARTInit(int screenNum)
     xf86ReleaseGART(-1);
 
 #if defined(linux)
-    /* Per Dave Jones, every effort will be made to keep the 
-     * agpgart interface backwards compatible, so allow all 
+    /* Per Dave Jones, every effort will be made to keep the
+     * agpgart interface backwards compatible, so allow all
      * future versions.
      */
     if (
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c b/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c
index f5917ee..6d12226 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c
@@ -69,7 +69,7 @@ xf86LoadKernelModule(const char *modName)
     switch (pid = fork()) {
     case 0:                    /* child */
         /* change real/effective user ID to 0/0 as we need to
-         * preinstall agpgart module for some DRM modules 
+         * preinstall agpgart module for some DRM modules
          */
         if (setreuid(0, 0)) {
             xf86Msg(X_WARNING, "LoadKernelModule: "
diff --git a/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c b/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c
index 73a8d55..49758f4 100644
--- a/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c
@@ -387,7 +387,7 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
     LogMessage(X_INFO, "systemd-logind: got %s for %u:%u\n",
                pause ? "pause" : "resume", major, minor);
 
-    pdev = xf86_find_platform_device_by_devnum(major, minor);        
+    pdev = xf86_find_platform_device_by_devnum(major, minor);
     if (!pdev)
         pInfo = systemd_logind_find_info_ptr_by_devnum(xf86InputDevs,
                                                        major, minor);
diff --git a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
index 254748f..4f4881c 100644
--- a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
+++ b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -2,14 +2,14 @@
   for Alpha Linux
 *******************************************************************************/
 
-/* 
+/*
  *   Create a dependency that should be immune from the effect of register
  *   renaming as is commonly seen in superscalar processors.  This should
  *   insert a minimum of 100-ns delays between reads/writes at clock rates
  *   up to 100 MHz---GGL
- *   
- *   Slowbcopy(char *src, char *dst, int count)   
- *   
+ *
+ *   Slowbcopy(char *src, char *dst, int count)
+ *
  */
 
 #ifdef HAVE_XORG_CONFIG_H
diff --git a/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c
index eeacee9..de5fb9b 100644
--- a/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c
+++ b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c
@@ -22,7 +22,7 @@
  */
 
 /*
- * Some platforms don't bother with I/O permissions, 
+ * Some platforms don't bother with I/O permissions,
  * or the permissions are implicit with opening/enabling the console.
  */
 
diff --git a/xorg-server/hw/xfree86/os-support/shared/sigio.c b/xorg-server/hw/xfree86/os-support/shared/sigio.c
index f3c153b..45949f7 100644
--- a/xorg-server/hw/xfree86/os-support/shared/sigio.c
+++ b/xorg-server/hw/xfree86/os-support/shared/sigio.c
@@ -10,11 +10,11 @@
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -22,7 +22,7 @@
  * 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: Rickard E. (Rik) Faith <faith at valinux.com>
  */
 /*
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
index 38fa5ec..4d4dbc1 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
@@ -129,7 +129,7 @@ sunToXF86(int type)
 }
 
 /*
- * APM events can be requested direclty from /dev/apm 
+ * APM events can be requested direclty from /dev/apm
  */
 static int
 sunPMGetEventFromOS(int fd, pmEvent * events, int num)
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
index 9120bd7..3a83f34 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
@@ -15,19 +15,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of the above listed copyright holders 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of the above listed copyright holders
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  The above listed
- * copyright holders make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD 
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE 
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
@@ -37,7 +37,7 @@
  *
  * Copyright 1997
  * Digital Equipment Corporation. All rights reserved.
- * This software is furnished under license and may be used and copied only in 
+ * This software is furnished under license and may be used and copied only in
  * accordance with the following terms and conditions.  Subject to these
  * conditions, you may download, copy, install, use, modify and distribute
  * this software in source and/or binary form. No title or ownership is
@@ -47,7 +47,7 @@
  *    this copyright notice and list of conditions as they appear in the
  *    source file.
  *
- * 2) No right is granted to use any trade name, trademark, or logo of Digital 
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
  *    Equipment Corporation. Neither the "Digital Equipment Corporation"
  *    name nor any trademark or logo of Digital Equipment Corporation may be
  *    used to endorse or promote products derived from this software without
@@ -59,9 +59,9 @@
  *    In no event shall DIGITAL be liable for any damages whatsoever, and in
  *    particular, DIGITAL shall not be liable for special, indirect,
  *    consequential, or incidental damages or damages for lost profits, loss
- *    of revenue or loss of use, whether such damages arise in contract, 
+ *    of revenue or loss of use, whether such damages arise in contract,
  *    negligence, tort, under statute, in equity, at law or otherwise, even
- *    if advised of the possibility of such damage. 
+ *    if advised of the possibility of such damage.
  *
  */
 
@@ -331,7 +331,7 @@ struct pcvtid {
 /* For PATH_MAX */
 #include "misc.h"
 
-/* 
+/*
  * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
  * and it's safe, so just do it.
  */
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
index 822bab2..fa3ff0e 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
@@ -14,19 +14,19 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of the above listed copyright holders 
- * not be used in advertising or publicity pertaining to distribution of 
+ * documentation, and that the names of the above listed copyright holders
+ * not be used in advertising or publicity pertaining to distribution of
  * the software without specific, written prior permission.  The above listed
- * copyright holders make no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
  * implied warranty.
  *
- * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD 
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE 
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
@@ -36,7 +36,7 @@
  *
  * Copyright 1997
  * Digital Equipment Corporation. All rights reserved.
- * This software is furnished under license and may be used and copied only in 
+ * This software is furnished under license and may be used and copied only in
  * accordance with the following terms and conditions.  Subject to these
  * conditions, you may download, copy, install, use, modify and distribute
  * this software in source and/or binary form. No title or ownership is
@@ -46,7 +46,7 @@
  *    this copyright notice and list of conditions as they appear in the
  *    source file.
  *
- * 2) No right is granted to use any trade name, trademark, or logo of Digital 
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
  *    Equipment Corporation. Neither the "Digital Equipment Corporation"
  *    name nor any trademark or logo of Digital Equipment Corporation may be
  *    used to endorse or promote products derived from this software without
@@ -58,9 +58,9 @@
  *    In no event shall DIGITAL be liable for any damages whatsoever, and in
  *    particular, DIGITAL shall not be liable for special, indirect,
  *    consequential, or incidental damages or damages for lost profits, loss
- *    of revenue or loss of use, whether such damages arise in contract, 
+ *    of revenue or loss of use, whether such damages arise in contract,
  *    negligence, tort, under statute, in equity, at law or otherwise, even
- *    if advised of the possibility of such damage. 
+ *    if advised of the possibility of such damage.
  *
  */
 
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index e853220..31035ae 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -1,17 +1,17 @@
 /*
- * 
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
@@ -52,7 +52,7 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-/* 
+/*
  * These definitions are used through out the configuration file parser, but
  * they should not be visible outside of the parser.
  */
@@ -122,7 +122,7 @@ else\
 		xf86parseError (__VA_ARGS__); CLEANUP (ptr); return NULL; \
 		   } while (0)
 
-/* 
+/*
  * These are defines for error messages to promote consistency.
  * error messages are preceded by the line number, section and file name,
  * so these messages should be about the specific keyword and syntax in error.
diff --git a/xorg-server/hw/xfree86/parser/DRI.c b/xorg-server/hw/xfree86/parser/DRI.c
index 6be32d7..9ed5b9e 100644
--- a/xorg-server/hw/xfree86/parser/DRI.c
+++ b/xorg-server/hw/xfree86/parser/DRI.c
@@ -11,11 +11,11 @@
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -23,8 +23,8 @@
  * 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.
- * 
- * 
+ *
+ *
  */
 
 #ifdef HAVE_XORG_CONFIG_H
diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c
index 28c274d..7e49843 100644
--- a/xorg-server/hw/xfree86/parser/Device.c
+++ b/xorg-server/hw/xfree86/parser/Device.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Files.c b/xorg-server/hw/xfree86/parser/Files.c
index 24940a9..849bf92 100644
--- a/xorg-server/hw/xfree86/parser/Files.c
+++ b/xorg-server/hw/xfree86/parser/Files.c
@@ -1,16 +1,16 @@
-/* 
+/*
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -18,11 +18,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index 71b50ac..5169665 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -1,16 +1,16 @@
-/* 
+/*
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -18,11 +18,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -100,7 +100,7 @@ xf86parseFlagsSection(void)
         case COMMENT:
             ptr->flg_comment = xf86addComment(ptr->flg_comment, xf86_lex_val.str);
             break;
-            /* 
+            /*
              * these old keywords are turned into standard generic options.
              * we fall through here on purpose
              */
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c
index 1bfe5c1..cfacd4e 100644
--- a/xorg-server/hw/xfree86/parser/Input.c
+++ b/xorg-server/hw/xfree86/parser/Input.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index 994b31a..0ace5da 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Module.c b/xorg-server/hw/xfree86/parser/Module.c
index e2d9120..0dcf4ba 100644
--- a/xorg-server/hw/xfree86/parser/Module.c
+++ b/xorg-server/hw/xfree86/parser/Module.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c
index 8aebce0..0a8c081 100644
--- a/xorg-server/hw/xfree86/parser/Monitor.c
+++ b/xorg-server/hw/xfree86/parser/Monitor.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -553,7 +553,7 @@ xf86parseMonitorSection(void)
             if ((token = xf86getSubToken(&(ptr->mon_comment))) != STRING)
                 Error(QUOTE_MSG, "UseModes");
 
-            /* add to the end of the list of modes sections 
+            /* add to the end of the list of modes sections
                referenced here */
             mptr = calloc(1, sizeof(XF86ConfModesLinkRec));
             mptr->list.next = NULL;
diff --git a/xorg-server/hw/xfree86/parser/Pointer.c b/xorg-server/hw/xfree86/parser/Pointer.c
index fe60d95..2f9d505 100644
--- a/xorg-server/hw/xfree86/parser/Pointer.c
+++ b/xorg-server/hw/xfree86/parser/Pointer.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c
index 0e9746a..9d8eda2 100644
--- a/xorg-server/hw/xfree86/parser/Screen.c
+++ b/xorg-server/hw/xfree86/parser/Screen.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Vendor.c b/xorg-server/hw/xfree86/parser/Vendor.c
index 2c870ae..4f6e510 100644
--- a/xorg-server/hw/xfree86/parser/Vendor.c
+++ b/xorg-server/hw/xfree86/parser/Vendor.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c
index 93209c4..666b0ab 100644
--- a/xorg-server/hw/xfree86/parser/Video.c
+++ b/xorg-server/hw/xfree86/parser/Video.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c
index 22f6e6a..327c02a 100644
--- a/xorg-server/hw/xfree86/parser/read.c
+++ b/xorg-server/hw/xfree86/parser/read.c
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -68,7 +68,7 @@ static xf86ConfigSymTabRec TopLevelTab[] = {
 
 #define CLEANUP xf86freeConfig
 
-/* 
+/*
  * This function resolves name references and reports errors if the named
  * objects cannot be found.
  */
@@ -221,7 +221,7 @@ xf86readConfigFile(void)
 
 #undef CLEANUP
 
-/* 
+/*
  * adds an item to the end of the linked list. Any record whose first field
  * is a GenericListRec can be cast to this type and used with this function.
  * A pointer to the head of the list is returned to handle the addition of
@@ -246,7 +246,7 @@ xf86addListItem(GenericListPtr head, GenericListPtr new)
         return new;
 }
 
-/* 
+/*
  * Test if one chained list contains the other.
  * In this case both list have the same endpoint (provided they don't loop)
  */
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index a6c1295..b8a08cf 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -1,16 +1,16 @@
-/* 
+/*
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -18,11 +18,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -241,7 +241,7 @@ xf86getNextLine(void)
     return ret;
 }
 
-/* 
+/*
  * xf86getToken --
  *      Read next Token from the config file. Handle the global variable
  *      pushToken.
@@ -251,7 +251,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
 {
     int c, i;
 
-    /* 
+    /*
      * First check whether pushToken has a different value than LOCK_TOKEN.
      * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
      * oth * case the next token must be read from the input.
@@ -266,9 +266,9 @@ xf86getToken(xf86ConfigSymTabRec * tab)
 
         c = configBuf[configPos];
 
-        /* 
+        /*
          * Get start of next Token. EOF is handled,
-         * whitespaces are skipped. 
+         * whitespaces are skipped.
          */
 
  again:
@@ -344,7 +344,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
             return DASH;
         }
 
-        /* 
+        /*
          * Numbers are returned immediately ...
          */
         if (isdigit(c)) {
@@ -379,7 +379,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
             return NUMBER;
         }
 
-        /* 
+        /*
          * All Strings START with a \" ...
          */
         else if (c == '\"') {
@@ -394,7 +394,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
             return STRING;
         }
 
-        /* 
+        /*
          * ... and now we MUST have a valid token.  The search is
          * handled later along with the pushed tokens.
          */
@@ -414,7 +414,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
     }
     else {
 
-        /* 
+        /*
          * Here we deal with pushed tokens. Reinitialize pushToken again. If
          * the pushed token was NUMBER || STRING return them again ...
          */
@@ -428,7 +428,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
             return temp;
     }
 
-    /* 
+    /*
      * Joop, at last we have to lookup the token ...
      */
     if (tab) {
@@ -1018,7 +1018,7 @@ xf86setSection(const char *section)
     configSection = strdup(section);
 }
 
-/* 
+/*
  * xf86getToken --
  *  Lookup a string if it is actually a token in disguise.
  */
@@ -1040,7 +1040,7 @@ StringToToken(const char *str, xf86ConfigSymTabRec * tab)
     return ERROR_TOKEN;
 }
 
-/* 
+/*
  * Compare two names.  The characters '_', ' ', and '\t' are ignored
  * in the comparison.
  */
diff --git a/xorg-server/hw/xfree86/parser/write.c b/xorg-server/hw/xfree86/parser/write.c
index 472b27b..8792783 100644
--- a/xorg-server/hw/xfree86/parser/write.c
+++ b/xorg-server/hw/xfree86/parser/write.c
@@ -1,16 +1,16 @@
-/* 
+/*
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -18,11 +18,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
diff --git a/xorg-server/hw/xfree86/parser/xf86Optrec.h b/xorg-server/hw/xfree86/parser/xf86Optrec.h
index ea0cb13..dfa9079 100644
--- a/xorg-server/hw/xfree86/parser/xf86Optrec.h
+++ b/xorg-server/hw/xfree86/parser/xf86Optrec.h
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2001 by The XFree86 Project, Inc.
@@ -52,7 +52,7 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-/* 
+/*
  * This file contains the Option Record that is passed between the Parser,
  * and Module setup procs.
  */
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index 73187f3..43e1755 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -52,7 +52,7 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-/* 
+/*
  * This file contains the external interfaces for the XFree86 configuration
  * file parser.
  */
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h
index 8e15f12..9c44970 100644
--- a/xorg-server/hw/xfree86/parser/xf86tokens.h
+++ b/xorg-server/hw/xfree86/parser/xf86tokens.h
@@ -1,17 +1,17 @@
-/* 
- * 
+/*
+ *
  * Copyright (c) 1997  Metro Link Incorporated
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"), 
+ * 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, sublicense,
  * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -19,11 +19,11 @@
  * 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.
- * 
+ *
  * Except as contained in this notice, the name of the Metro Link shall not be
  * used in advertising or otherwise to promote the sale, use or other dealings
  * in this Software without prior written authorization from Metro Link.
- * 
+ *
  */
 /*
  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
@@ -62,7 +62,7 @@
 /* Undefine symbols that some OSs might define */
 #undef IOBASE
 
-/* 
+/*
  * Each token should have a unique value regardless of the section
  * it is used in.
  */
diff --git a/xorg-server/hw/xfree86/ramdac/IBM.c b/xorg-server/hw/xfree86/ramdac/IBM.c
index 45876cf..6822be5 100644
--- a/xorg-server/hw/xfree86/ramdac/IBM.c
+++ b/xorg-server/hw/xfree86/ramdac/IBM.c
@@ -576,7 +576,7 @@ IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
     RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
     int i;
 
-    /* 
+    /*
      * Output the cursor data.  The realize function has put the planes into
      * their correct order, so we can just blast this out.
      */
@@ -591,7 +591,7 @@ IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
     RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
     int i;
 
-    /* 
+    /*
      * Output the cursor data.  The realize function has put the planes into
      * their correct order, so we can just blast this out.
      */
diff --git a/xorg-server/hw/xfree86/ramdac/TI.c b/xorg-server/hw/xfree86/ramdac/TI.c
index 2492bb5..f8081ca 100644
--- a/xorg-server/hw/xfree86/ramdac/TI.c
+++ b/xorg-server/hw/xfree86/ramdac/TI.c
@@ -21,7 +21,7 @@
  *
  * Authors:  Alan Hourihane, <alanh at fairlite.demon.co.uk>
  *
- * Modified from IBM.c to support TI RAMDAC routines 
+ * Modified from IBM.c to support TI RAMDAC routines
  *   by Jens Owen, <jens at tungstengraphics.com>.
  */
 
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
index fac6822..04496d5 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
@@ -332,8 +332,10 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
         ScreenPriv->HotX = cursor->bits->xhot;
         ScreenPriv->HotY = cursor->bits->yhot;
 
-        if (!infoPtr->pScrn->vtSema)
+        if (!infoPtr->pScrn->vtSema) {
             ScreenPriv->SavedCursor = cursor;
+            return;
+        }
 
         if (infoPtr->pScrn->vtSema && xorg_list_is_empty(&pScreen->pixmap_dirty_list) &&
             (ScreenPriv->ForceHWCursorCount ||
@@ -347,7 +349,7 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
                (cursor->bits->height <= infoPtr->MaxHeight) &&
                (cursor->bits->width <= infoPtr->MaxWidth) &&
                (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor) (pScreen, cursor)))))) {
-            
+
             if (ScreenPriv->SWCursor)   /* remove the SW cursor */
                 (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen,
                                                        NullCursor, x, y);
diff --git a/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
index 953c86a..be7154e 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
@@ -214,7 +214,7 @@ xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
     xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
 
 #ifdef ARGB_CURSOR
-    /* recoloring isn't applicable to ARGB cursors and drivers 
+    /* recoloring isn't applicable to ARGB cursors and drivers
        shouldn't have to ignore SetCursorColors requests */
     if (pCurs->bits->argb)
         return;
diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.h b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
index 50a659a..af16b7f 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
+++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
@@ -12,8 +12,8 @@
 
 typedef struct _RamDacRegRec {
 /* This is probably the nastiest assumption, we allocate 1024 slots for
- * ramdac registers, should be enough. I've checked IBM and TVP series 
- * and they seem o.k 
+ * ramdac registers, should be enough. I've checked IBM and TVP series
+ * and they seem o.k
  * Then we allocate 768 entries for the DAC too. IBM640 needs 1024 -FIXME
  */
     unsigned short DacRegs[0x400];      /* register set */
diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh
index d9a4478..2305073 100644
--- a/xorg-server/hw/xfree86/sdksyms.sh
+++ b/xorg-server/hw/xfree86/sdksyms.sh
@@ -216,10 +216,7 @@ cat > sdksyms.c << EOF
 #include "mizerarc.h"
 #include "micoord.h"
 #include "mifillarc.h"
-#include "mispans.h"
-#include "miwideline.h"
 #include "mistruct.h"
-#include "mifpoly.h"
 #include "mioverlay.h"
 
 
diff --git a/xorg-server/hw/xfree86/shadowfb/shadowfb.h b/xorg-server/hw/xfree86/shadowfb/shadowfb.h
index bcf59f9..b3dd448 100644
--- a/xorg-server/hw/xfree86/shadowfb/shadowfb.h
+++ b/xorg-server/hw/xfree86/shadowfb/shadowfb.h
@@ -26,7 +26,7 @@ extern _X_EXPORT Bool
  * ShadowFBInit2 is a more featureful refinement of the original shadowfb.
  * ShadowFBInit2 allows you to specify two callbacks, one to be called
  * immediately before an operation that modifies the framebuffer, and another
- * to be called immediately after.  
+ * to be called immediately after.
  *
  * Returns FALSE in the event of an error
  */
diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c
index 15503bb..e88387d 100644
--- a/xorg-server/hw/xfree86/utils/gtf/gtf.c
+++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c
@@ -4,11 +4,11 @@
  *
  * Copyright (c) 2001, Andy Ritger  aritger at nvidia.com
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * o Redistributions of source code must retain the above copyright
  *   notice, this list of conditions and the following disclaimer.
  * o Redistributions in binary form must reproduce the above copyright
@@ -33,7 +33,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * 
+ *
  *
  * This program is based on the Generalized Timing Formula(GTF TM)
  * Standard Version: 1.0, Revision: 1.0
@@ -52,7 +52,7 @@
  * of suitability for any purpose. The sample code contained within
  * this standard may be used without restriction.
  *
- * 
+ *
  *
  * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
  * implementation of the GTF Timing Standard, is available at:
@@ -77,12 +77,12 @@
  * any experience with this, and 2) neither XServer modelines nor
  * fbset fb.modes provide an obvious way for margin timings to be
  * included in their mode descriptions (needs more investigation).
- * 
+ *
  * The GTF provides for computation of interlaced mode timings;
  * I've implemented the computations but not enabled them, yet.
  * I should probably enable and test this at some point.
  *
- * 
+ *
  *
  * TODO:
  *
@@ -95,7 +95,7 @@
  * o It would be nice if this were more general purpose to do things
  *   outside the scope of the GTF: like generate double scan mode
  *   timings, for example.
- *   
+ *
  * o Printing digits to the right of the decimal point when the
  *   digits are 0 annoys me.
  *
@@ -191,7 +191,7 @@ print_xf86_mode(mode * m)
  * to the portion of the hblank before and after the sync pulse
  * by conceptually wrapping the portion of the blank after the pulse
  * to infront of the visible region; ie:
- * 
+ *
  *
  * Timing description I'm accustomed to:
  *
@@ -202,7 +202,7 @@ print_xf86_mode(mode * m)
  *    |-------------------|_______|       |_______
  *
  *                        R       SS      SE     FL
- *       
+ *
  * 1: visible image
  * 2: blank before sync (aka front porch)
  * 3: sync pulse
@@ -216,10 +216,10 @@ print_xf86_mode(mode * m)
  * But the fb.modes format is:
  *
  *
- *    <--4--> <--------1--------> <--2--> <--3--> 
+ *    <--4--> <--------1--------> <--2--> <--3-->
  *                                       _________
  *    _______|-------------------|_______|       |
- *  
+ *
  * The fb.modes(8) manpage refers to <4> and <2> as the left and
  * right "margin" (as well as upper and lower margin in the vertical
  * direction) -- note that this has nothing to do with the term
@@ -312,7 +312,7 @@ vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
      *  by the calculation must be halved, as the computation calculates
      *  the number of vertical lines per field. In either case, the
      *  number of lines is rounded to the nearest integer.
-     *   
+     *
      *  [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0),
      *                                     ROUND([V LINES],0))
      */
@@ -356,7 +356,7 @@ vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
     print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
 
     /*  6. If interlace is required, then set variable [INTERLACE]=0.5:
-     *   
+     *
      *  [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
      */
 
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c
index d41e61b..5ea0197 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.c
+++ b/xorg-server/hw/xfree86/vbe/vbe.c
@@ -3,10 +3,10 @@
  *                   XFree86 vbe module
  *               Copyright 2000 Egbert Eich
  *
- * The mode query/save/set/restore functions from the vesa driver 
+ * The mode query/save/set/restore functions from the vesa driver
  * have been moved here.
  * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
- * Authors: Paulo César Pereira de Andrade <pcpa at conectiva.com.br> 
+ * Authors: Paulo César Pereira de Andrade <pcpa at conectiva.com.br>
  */
 
 #ifdef HAVE_XORG_CONFIG_H
diff --git a/xorg-server/hw/xfree86/vbe/vbe.h b/xorg-server/hw/xfree86/vbe/vbe.h
index bc36533..c8fb4e4 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.h
+++ b/xorg-server/hw/xfree86/vbe/vbe.h
@@ -3,10 +3,10 @@
  *                   XFree86 vbe module
  *               Copyright 2000 Egbert Eich
  *
- * The mode query/save/set/restore functions from the vesa driver 
+ * The mode query/save/set/restore functions from the vesa driver
  * have been moved here.
  * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
- * Authors: Paulo César Pereira de Andrade <pcpa at conectiva.com.br> 
+ * Authors: Paulo César Pereira de Andrade <pcpa at conectiva.com.br>
  */
 
 #ifndef _VBE_H
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c
index a64f4f8..7223fc0 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c
@@ -1109,7 +1109,7 @@ vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
         hwp->writeDacData(hwp, save->DAC[i]);
 
     if (readError) {
-        /*                       
+        /*
          * save the default lookup table
          */
         memmove(save->DAC, defaultDAC, 768);
@@ -1184,7 +1184,7 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
     regp = &hwp->ModeReg;
 
     /*
-     * compute correct Hsync & Vsync polarity 
+     * compute correct Hsync & Vsync polarity
      */
     if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
         && (mode->Flags & (V_PVSYNC | V_NVSYNC))) {
@@ -1439,7 +1439,7 @@ vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
     CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8);
     CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8;
 
-    /* If width is not known nBits should be 0. In this 
+    /* If width is not known nBits should be 0. In this
      * case BitMask is set to 0 so we can check for it. */
     CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1);
     int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
@@ -1885,7 +1885,7 @@ vgaHWHandleColormaps(ScreenPtr pScreen)
 }
 
 /* ----------------------- DDC support ------------------------*/
-/* 
+/*
  * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total
  * to read out EDID at a faster rate. Allowed maximum is 25kHz with
  * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.h b/xorg-server/hw/xfree86/vgahw/vgaHW.h
index 63a10f4..b979b85 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.h
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.h
@@ -116,7 +116,7 @@ typedef struct _vgaHWRec {
                                    = mmioreg */
     void *FontInfo1;          /* save area for fonts in
                                    plane 2 */
-    void *FontInfo2;          /* save area for fonts in       
+    void *FontInfo2;          /* save area for fonts in
                                    plane 3 */
     void *TextInfo;           /* save area for text */
     vgaRegRec SavedReg;         /* saved registers */
diff --git a/xorg-server/hw/xfree86/x86emu/debug.c b/xorg-server/hw/xfree86/x86emu/debug.c
index 1a8d1d6..cbea994 100644
--- a/xorg-server/hw/xfree86/x86emu/debug.c
+++ b/xorg-server/hw/xfree86/x86emu/debug.c
@@ -103,11 +103,11 @@ disassemble_forward(u16 seg, u16 off, int n)
      * SINGLE_STEP(r,m); which disappear if DEBUG is not defined to
      * the preprocessor.  The TRACE_REGS macro expands to:
      *
-     * if (debug&DEBUG_DISASSEMBLE) 
+     * if (debug&DEBUG_DISASSEMBLE)
      *     {just_disassemble(); goto EndOfInstruction;}
      *     if (debug&DEBUG_TRACE) trace_regs(r,m);
      *
-     * ......  and at the last line of the routine. 
+     * ......  and at the last line of the routine.
      *
      * EndOfInstruction: end_instr();
      *
diff --git a/xorg-server/hw/xfree86/x86emu/ops.c b/xorg-server/hw/xfree86/x86emu/ops.c
index b50badb..853792e 100644
--- a/xorg-server/hw/xfree86/x86emu/ops.c
+++ b/xorg-server/hw/xfree86/x86emu/ops.c
@@ -5530,7 +5530,7 @@ x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
 
         switch (rh) {
@@ -5658,7 +5658,7 @@ x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
 
         switch (rh) {
@@ -5690,7 +5690,7 @@ x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
     }
 #endif
     /*
-     * Know operation, decode the mod byte to find the addressing 
+     * Know operation, decode the mod byte to find the addressing
      * mode.
      */
     switch (mod) {
@@ -5853,7 +5853,7 @@ x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
         switch (rh) {
         case 0:
@@ -5977,7 +5977,7 @@ x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
         switch (rh) {
         case 0:
@@ -7472,7 +7472,7 @@ x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
     CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
 
     /* XXX
-     * 
+     *
      * Hooked interrupt vectors calling into our "BIOS" will cause
      * problems unless all intersegment stuff is checked for BIOS
      * access.  Check needed here.  For moment, let it alone.
@@ -8688,7 +8688,7 @@ x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
 
         switch (rh) {
@@ -8797,7 +8797,7 @@ x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
 
         switch (rh) {
@@ -9700,7 +9700,7 @@ x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
         switch (rh) {
         case 0:
@@ -9795,7 +9795,7 @@ x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
         switch (rh) {
         case 0:
@@ -11538,7 +11538,7 @@ x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
     if (DEBUG_DECODE()) {
         /* XXX DECODE_PRINTF may be changed to something more
            general, so that it is important to leave the strings
-           in the same format, even though the result is that the 
+           in the same format, even though the result is that the
            above test is done twice. */
 
         switch (rh) {
diff --git a/xorg-server/hw/xfree86/x86emu/prim_ops.c b/xorg-server/hw/xfree86/x86emu/prim_ops.c
index 24f76b4..5604c7e 100644
--- a/xorg-server/hw/xfree86/x86emu/prim_ops.c
+++ b/xorg-server/hw/xfree86/x86emu/prim_ops.c
@@ -883,9 +883,9 @@ rcl_byte(u8 d, u8 s)
     /* s is the rotate distance.  It varies from 0 - 8. */
     /* have
 
-       CF  B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 
+       CF  B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0
 
-       want to rotate through the carry by "s" bits.  We could 
+       want to rotate through the carry by "s" bits.  We could
        loop, but that's inefficient.  So the width is 9,
        and we split into three parts:
 
@@ -895,12 +895,12 @@ rcl_byte(u8 d, u8 s)
 
        The new rotate is done mod 9, and given this,
        for a rotation of n bits (mod 9) the new carry flag is
-       then located n bits from the MSB.  The low part is 
+       then located n bits from the MSB.  The low part is
        then shifted up cnt bits, and the high part is or'd
-       in.  Using CAPS for new values, and lowercase for the 
+       in.  Using CAPS for new values, and lowercase for the
        original values, this can be expressed as:
 
-       IF n > 0 
+       IF n > 0
        1) CF <-  b_(8-n)
        2) B_(7) .. B_(n)  <-  b_(8-(n+1)) .. b_0
        3) B_(n-1) <- cf
@@ -912,17 +912,17 @@ rcl_byte(u8 d, u8 s)
         /* CF <-  b_(8-n)             */
         cf = (d >> (8 - cnt)) & 0x1;
 
-        /* get the low stuff which rotated 
+        /* get the low stuff which rotated
            into the range B_7 .. B_cnt */
         /* B_(7) .. B_(n)  <-  b_(8-(n+1)) .. b_0  */
         /* note that the right hand side done by the mask */
         res = (d << cnt) & 0xff;
 
-        /* now the high stuff which rotated around 
+        /* now the high stuff which rotated around
            into the positions B_cnt-2 .. B_0 */
         /* B_(n-2) .. B_0 <-  b_7 .. b_(8-(n-1)) */
-        /* shift it downward, 7-(n-2) = 9-n positions. 
-           and mask off the result before or'ing in. 
+        /* shift it downward, 7-(n-2) = 9-n positions.
+           and mask off the result before or'ing in.
          */
         mask = (1 << (cnt - 1)) - 1;
         res |= (d >> (9 - cnt)) & mask;
@@ -934,7 +934,7 @@ rcl_byte(u8 d, u8 s)
         }
         /* set the new carry flag, based on the variable "cf" */
         CONDITIONAL_SET_FLAG(cf, F_CF);
-        /* OVERFLOW is set *IFF* cnt==1, then it is the 
+        /* OVERFLOW is set *IFF* cnt==1, then it is the
            xor of CF and the most significant bit.  Blecck. */
         /* parenthesized this expression since it appears to
            be causing OF to be misset */
@@ -1003,22 +1003,22 @@ rcr_byte(u8 d, u8 s)
     u32 mask, cf, ocf = 0;
 
     /* rotate right through carry */
-    /* 
+    /*
        s is the rotate distance.  It varies from 0 - 8.
-       d is the byte object rotated.  
+       d is the byte object rotated.
 
-       have 
+       have
 
-       CF  B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 
+       CF  B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0
 
        The new rotate is done mod 9, and given this,
        for a rotation of n bits (mod 9) the new carry flag is
-       then located n bits from the LSB.  The low part is 
+       then located n bits from the LSB.  The low part is
        then shifted up cnt bits, and the high part is or'd
-       in.  Using CAPS for new values, and lowercase for the 
+       in.  Using CAPS for new values, and lowercase for the
        original values, this can be expressed as:
 
-       IF n > 0 
+       IF n > 0
        1) CF <-  b_(n-1)
        2) B_(8-(n+1)) .. B_(0)  <-  b_(7) .. b_(n)
        3) B_(8-n) <- cf
@@ -1033,7 +1033,7 @@ rcr_byte(u8 d, u8 s)
             /* note hackery here.  Access_flag(..) evaluates to either
                0 if flag not set
                non-zero if flag is set.
-               doing access_flag(..) != 0 casts that into either 
+               doing access_flag(..) != 0 casts that into either
                0..1 in any representation of the flags register
                (i.e. packed bit array or unpacked.)
              */
@@ -1044,19 +1044,19 @@ rcr_byte(u8 d, u8 s)
 
         /* B_(8-(n+1)) .. B_(0)  <-  b_(7) .. b_n  */
         /* note that the right hand side done by the mask
-           This is effectively done by shifting the 
+           This is effectively done by shifting the
            object to the right.  The result must be masked,
-           in case the object came in and was treated 
+           in case the object came in and was treated
            as a negative number.  Needed??? */
 
         mask = (1 << (8 - cnt)) - 1;
         res = (d >> cnt) & mask;
 
-        /* now the high stuff which rotated around 
+        /* now the high stuff which rotated around
            into the positions B_cnt-2 .. B_0 */
         /* B_(7) .. B_(8-(n-1)) <-  b_(n-2) .. b_(0) */
-        /* shift it downward, 7-(n-2) = 9-n positions. 
-           and mask off the result before or'ing in. 
+        /* shift it downward, 7-(n-2) = 9-n positions.
+           and mask off the result before or'ing in.
          */
         res |= (d << (9 - cnt));
 
@@ -1067,7 +1067,7 @@ rcr_byte(u8 d, u8 s)
         }
         /* set the new carry flag, based on the variable "cf" */
         CONDITIONAL_SET_FLAG(cf, F_CF);
-        /* OVERFLOW is set *IFF* cnt==1, then it is the 
+        /* OVERFLOW is set *IFF* cnt==1, then it is the
            xor of CF and the most significant bit.  Blecck. */
         /* parenthesized... */
         if (cnt == 1) {
@@ -1154,18 +1154,18 @@ rol_byte(u8 d, u8 s)
     register unsigned int res, cnt, mask;
 
     /* rotate left */
-    /* 
+    /*
        s is the rotate distance.  It varies from 0 - 8.
-       d is the byte object rotated.  
+       d is the byte object rotated.
 
-       have 
+       have
 
-       CF  B_7 ... B_0 
+       CF  B_7 ... B_0
 
        The new rotate is done mod 8.
        Much simpler than the "rcl" or "rcr" operations.
 
-       IF n > 0 
+       IF n > 0
        1) B_(7) .. B_(n)  <-  b_(8-(n+1)) .. b_(0)
        2) B_(n-1) .. B_(0) <-  b_(7) .. b_(8-n)
      */
@@ -1256,17 +1256,17 @@ ror_byte(u8 d, u8 s)
     register unsigned int res, cnt, mask;
 
     /* rotate right */
-    /* 
+    /*
        s is the rotate distance.  It varies from 0 - 8.
-       d is the byte object rotated.  
+       d is the byte object rotated.
 
-       have 
+       have
 
-       B_7 ... B_0 
+       B_7 ... B_0
 
        The rotate is done mod 8.
 
-       IF n > 0 
+       IF n > 0
        1) B_(8-(n+1)) .. B_(0)  <-  b_(7) .. b_(n)
        2) B_(7) .. B_(8-n) <-  b_(n-1) .. b_(0)
      */
@@ -1279,7 +1279,7 @@ ror_byte(u8 d, u8 s)
         mask = (1 << (8 - cnt)) - 1;
         res |= (d >> (cnt)) & mask;
 
-        /* set the new carry flag, Note that it is the low order 
+        /* set the new carry flag, Note that it is the low order
            bit of the result!!!                               */
         CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
         /* OVERFLOW is set *IFF* s==1, then it is the
diff --git a/xorg-server/hw/xfree86/x86emu/sys.c b/xorg-server/hw/xfree86/x86emu/sys.c
index c514dde..5eba358 100644
--- a/xorg-server/hw/xfree86/x86emu/sys.c
+++ b/xorg-server/hw/xfree86/x86emu/sys.c
@@ -183,7 +183,7 @@ RETURNS:
 Byte value read from emulator memory.
 
 REMARKS:
-Reads a byte value from the emulator memory. 
+Reads a byte value from the emulator memory.
 ****************************************************************************/
 u8 X86API
 rdb(u32 addr)
@@ -241,7 +241,7 @@ addr	- Emulator memory address to read
 RETURNS:
 Long value read from emulator memory.
 REMARKS:
-Reads a long value from the emulator memory. 
+Reads a long value from the emulator memory.
 ****************************************************************************/
 u32 X86API
 rdl(u32 addr)
@@ -323,7 +323,7 @@ addr	- Emulator memory address to read
 val		- Value to store
 
 REMARKS:
-Writes a long value to emulator memory. 
+Writes a long value to emulator memory.
 ****************************************************************************/
 void X86API
 wrl(u32 addr, u32 val)
diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/regs.h b/xorg-server/hw/xfree86/x86emu/x86emu/regs.h
index 3a7456e..c040259 100644
--- a/xorg-server/hw/xfree86/x86emu/x86emu/regs.h
+++ b/xorg-server/hw/xfree86/x86emu/x86emu/regs.h
@@ -109,7 +109,7 @@ struct i386_special_regs {
     u32 FLAGS;
 };
 
-/*  
+/*
  * Segment registers here represent the 16 bit quantities
  * CS, DS, ES, SS.
  */
@@ -196,8 +196,8 @@ struct i386_segment_regs {
 #define F_ALWAYS_ON  (0x0002)   /* flag bits always on */
 
 /*
- * Define a mask for only those flag bits we will ever pass back 
- * (via PUSHF) 
+ * Define a mask for only those flag bits we will ever pass back
+ * (via PUSHF)
  */
 #define F_MSK (FB_CF|FB_PF|FB_AF|FB_ZF|FB_SF|FB_TF|FB_IF|FB_DF|FB_OF)
 
@@ -279,8 +279,8 @@ typedef struct {
      *  Delayed flag set        3 bits  (zero, signed, parity)
      *  reserved                6 bits
      *  interrupt #             8 bits  instruction raised interrupt
-     *  BIOS video segregs      4 bits  
-     *  Interrupt Pending       1 bits  
+     *  BIOS video segregs      4 bits
+     *  Interrupt Pending       1 bits
      *  Extern interrupt        1 bits
      *  Halted                  1 bits
      */
diff --git a/xorg-server/hw/xnest/Color.c b/xorg-server/hw/xnest/Color.c
index 95c3343..8d9d356 100644
--- a/xorg-server/hw/xnest/Color.c
+++ b/xorg-server/hw/xnest/Color.c
@@ -239,7 +239,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
         xnestNumOldInstalledColormapWindows = icws.numWindows;
 
 #ifdef DUMB_WINDOW_MANAGERS
-        /* 
+        /*
            This code is for dumb window managers.
            This will only work with default local visual colormaps.
          */
diff --git a/xorg-server/hw/xnest/GC.c b/xorg-server/hw/xnest/GC.c
index 0ec60fc..96af6eb 100644
--- a/xorg-server/hw/xnest/GC.c
+++ b/xorg-server/hw/xnest/GC.c
@@ -194,11 +194,12 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
     BoxPtr pBox;
     XRectangle *pRects;
 
-    xnestDestroyClipHelper(pGC);
+    xnestDestroyClip(pGC);
 
     switch (type) {
     case CT_NONE:
         XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+        pValue = NULL;
         break;
 
     case CT_REGION:
@@ -224,11 +225,9 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
          * Need to change into region, so subsequent uses are with
          * current pixmap contents.
          */
-        pGC->clientClip =
-            (void *) (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue);
+        pGC->clientClip = (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue);
         (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) pValue);
         pValue = pGC->clientClip;
-        type = CT_REGION;
         break;
 
     case CT_UNSORTED:
@@ -264,65 +263,34 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
     case CT_YSORTED:
     case CT_YXSORTED:
     case CT_YXBANDED:
-
-        /*
-         * other parts of server can only deal with CT_NONE,
-         * CT_PIXMAP and CT_REGION client clips.
-         */
-        pGC->clientClip = (void *) RegionFromRects(nRects,
-                                                    (xRectangle *) pValue,
-                                                    type);
+        /* server clip representation is a region */
+        pGC->clientClip = RegionFromRects(nRects, (xRectangle *) pValue, type);
         free(pValue);
         pValue = pGC->clientClip;
-        type = CT_REGION;
-
         break;
     }
 
-    pGC->clientClipType = type;
     pGC->clientClip = pValue;
 }
 
 void
 xnestDestroyClip(GCPtr pGC)
 {
-    xnestDestroyClipHelper(pGC);
-
-    XSetClipMask(xnestDisplay, xnestGC(pGC), None);
-
-    pGC->clientClipType = CT_NONE;
-    pGC->clientClip = NULL;
-}
-
-void
-xnestDestroyClipHelper(GCPtr pGC)
-{
-    switch (pGC->clientClipType) {
-    default:
-    case CT_NONE:
-        break;
-
-    case CT_REGION:
+    if (pGC->clientClip) {
         RegionDestroy(pGC->clientClip);
-        break;
+        XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+        pGC->clientClip = NULL;
     }
 }
 
 void
 xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
 {
-    RegionPtr pRgn;
-
-    switch (pGCSrc->clientClipType) {
-    default:
-    case CT_NONE:
-        xnestDestroyClip(pGCDst);
-        break;
-
-    case CT_REGION:
-        pRgn = RegionCreate(NULL, 1);
+    if (pGCSrc->clientClip) {
+        RegionPtr pRgn = RegionCreate(NULL, 1);
         RegionCopy(pRgn, pGCSrc->clientClip);
         xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
-        break;
+    } else {
+        xnestDestroyClip(pGCDst);
     }
 }
diff --git a/xorg-server/hw/xnest/XNGC.h b/xorg-server/hw/xnest/XNGC.h
index e2f10fb..974173e 100644
--- a/xorg-server/hw/xnest/XNGC.h
+++ b/xorg-server/hw/xnest/XNGC.h
@@ -37,7 +37,6 @@ void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
 void xnestDestroyGC(GCPtr pGC);
 void xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects);
 void xnestDestroyClip(GCPtr pGC);
-void xnestDestroyClipHelper(GCPtr pGC);
 void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
 
 #endif                          /* XNESTGC_H */
diff --git a/xorg-server/hw/xnest/Xnest.h b/xorg-server/hw/xnest/Xnest.h
index adb9daf..37ea6e5 100644
--- a/xorg-server/hw/xnest/Xnest.h
+++ b/xorg-server/hw/xnest/Xnest.h
@@ -28,7 +28,7 @@ from the X Consortium.
 
 */
 
-/* 
+/*
 ** Machines with a 64 bit library interface and a 32 bit server require
 ** name changes to protect the guilty.
 */
diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c
index 29c6438..3403436 100644
--- a/xorg-server/hw/xquartz/darwin.c
+++ b/xorg-server/hw/xquartz/darwin.c
@@ -343,16 +343,16 @@ DarwinMouseProc(DeviceIntPtr pPointer, int what)
         InitValuatorAxisStruct(pPointer, 1, axes_labels[1],
                                NO_AXIS_LIMITS, NO_AXIS_LIMITS,
                                0, 0, 0, Absolute);
-        InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 
+        InitValuatorAxisStruct(pPointer, 2, axes_labels[2],
                                NO_AXIS_LIMITS, NO_AXIS_LIMITS,
                                1, 0, 1, Relative);
-        InitValuatorAxisStruct(pPointer, 3, axes_labels[3], 
+        InitValuatorAxisStruct(pPointer, 3, axes_labels[3],
                                NO_AXIS_LIMITS, NO_AXIS_LIMITS,
                                1, 0, 1, Relative);
-        InitValuatorAxisStruct(pPointer, 4, axes_labels[4], 
+        InitValuatorAxisStruct(pPointer, 4, axes_labels[4],
                                NO_AXIS_LIMITS, NO_AXIS_LIMITS,
                                1, 0, 1, Relative);
-        InitValuatorAxisStruct(pPointer, 5, axes_labels[5], 
+        InitValuatorAxisStruct(pPointer, 5, axes_labels[5],
                                NO_AXIS_LIMITS, NO_AXIS_LIMITS,
                                1, 0, 1, Relative);
 
diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c
index b41c6fd..5a5e4da 100644
--- a/xorg-server/hw/xquartz/darwinEvents.c
+++ b/xorg-server/hw/xquartz/darwinEvents.c
@@ -596,7 +596,7 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
         QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
                            &valuators);
         DarwinPokeEQ();
-    } darwinEvents_unlock();   
+    } darwinEvents_unlock();
 }
 
 void
@@ -645,7 +645,7 @@ DarwinSendScrollEvents(double scroll_x, double scroll_y) {
         QueuePointerEvents(darwinPointer, MotionNotify, 0,
                            POINTER_RELATIVE, &valuators);
         DarwinPokeEQ();
-    } darwinEvents_unlock();    
+    } darwinEvents_unlock();
 }
 
 /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
diff --git a/xorg-server/hw/xwayland/xwayland.c b/xorg-server/hw/xwayland/xwayland.c
index 9132969..37d6d82 100644
--- a/xorg-server/hw/xwayland/xwayland.c
+++ b/xorg-server/hw/xwayland/xwayland.c
@@ -656,6 +656,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     return ret;
 }
 
+_X_NORETURN
 static void _X_ATTRIBUTE_PRINTF(1, 0)
 xwl_log_handler(const char *format, va_list args)
 {
diff --git a/xorg-server/hw/xwin/InitInput.c b/xorg-server/hw/xwin/InitInput.c
index 3e9ee41..6cd9e06 100644
--- a/xorg-server/hw/xwin/InitInput.c
+++ b/xorg-server/hw/xwin/InitInput.c
@@ -52,7 +52,7 @@ DeviceIntPtr g_pwinKeyboard;
 /*
  * All of our keys generate up and down transition notifications,
  * so all of our keys can be used as modifiers.
- * 
+ *
  * An example of a modifier is mapping the A key to the Control key.
  * A has to be a legal modifier.  I think.
  */
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index e867119..fef46a9 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -628,9 +628,9 @@ OsVendorInit(void)
 
     if (!g_fLogInited) {
         /* keep this order. If LogInit fails it calls Abort which then calls
-         * ddxGiveUp where LogInit is called again and creates an infinite 
-         * recursion. If we set g_fLogInited to TRUE before the init we 
-         * avoid the second call 
+         * ddxGiveUp where LogInit is called again and creates an infinite
+         * recursion. If we set g_fLogInited to TRUE before the init we
+         * avoid the second call
          */
         g_fLogInited = TRUE;
         g_pszLogFile = LogInit(g_pszLogFile, NULL);
@@ -885,7 +885,7 @@ ddxUseMsg(void)
 /* See Porting Layer Definition - p. 20 */
 /*
  * Do any global initialization, then initialize each screen.
- * 
+ *
  * NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv
  */
 
@@ -1004,7 +1004,7 @@ winCheckDisplayNumber(void)
     int nDisp;
     HANDLE mutex;
     char name[MAX_PATH];
-    char *pszPrefix = '\0';
+    const char *pszPrefix = '\0';
     OSVERSIONINFO osvi = { 0 };
 
     /* Check display range */
diff --git a/xorg-server/hw/xwin/ddraw.h b/xorg-server/hw/xwin/ddraw.h
index 1871d95..4c9af77 100644
--- a/xorg-server/hw/xwin/ddraw.h
+++ b/xorg-server/hw/xwin/ddraw.h
@@ -1346,7 +1346,7 @@ extern "C" {
 /*****************************************************************************
  * IDirectDraw2 interface
  */
-/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of 
+/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of
  * arguments of SetDisplayMode has changed !
  */
 #undef INTERFACE
@@ -1742,7 +1742,7 @@ extern "C" {
 /*****************************************************************************
  * IDirectDrawSurface2 interface
  */
-/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters 
+/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters
  * have been converted to LPDIRECTDRAWSURFACE2.
  */
 #undef INTERFACE
@@ -1861,7 +1861,7 @@ extern "C" {
 /*****************************************************************************
  * IDirectDrawSurface3 interface
  */
-/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters 
+/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters
  * have been converted to LPDIRECTDRAWSURFACE3.
  */
 #undef INTERFACE
diff --git a/xorg-server/hw/xwin/glx/glshim.c b/xorg-server/hw/xwin/glx/glshim.c
index 7109196..df5a932 100644
--- a/xorg-server/hw/xwin/glx/glshim.c
+++ b/xorg-server/hw/xwin/glx/glshim.c
@@ -36,6 +36,7 @@
 #endif
 
 #define GL_GLEXT_LEGACY
+#define GL_GLEXT_PROTOTYPES
 #include <GL/gl.h>
 #undef GL_ARB_imaging
 #undef GL_VERSION_1_3
@@ -46,6 +47,8 @@
 #include "glwindows.h"
 #include <glx/glxserver.h>
 
+extern void *glXGetProcAddressARB(const char *);
+
 static HMODULE hMod = NULL;
 
 /*
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h
index ed1ad01..b7d20ca 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -706,7 +706,7 @@ extern FARPROC g_fpDirectDrawCreateClipper;
 	winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
 
 /*
- * wrapper macros 
+ * wrapper macros
  */
 #define _WIN_WRAP(priv, real, mem, func) {\
     priv->mem = real->mem; \
diff --git a/xorg-server/hw/xwin/winSetAppUserModelID.c b/xorg-server/hw/xwin/winSetAppUserModelID.c
index 41615e1..f9cb92c 100644
--- a/xorg-server/hw/xwin/winSetAppUserModelID.c
+++ b/xorg-server/hw/xwin/winSetAppUserModelID.c
@@ -90,7 +90,7 @@ winSetAppUserModelID(HWND hWnd, const char *AppID)
         return;
     }
 
-    winDebug("winSetAppUserMOdelID - hwnd 0x%08x appid '%s'\n", hWnd, AppID);
+    winDebug("winSetAppUserMOdelID - hwnd 0x%p appid '%s'\n", hWnd, AppID);
 
     hr = g_pSHGetPropertyStoreForWindow(hWnd, &IID_IPropertyStore,
                                         (void **) &pps);
diff --git a/xorg-server/hw/xwin/winclipboard/xevents.c b/xorg-server/hw/xwin/winclipboard/xevents.c
index d0077b8..33d52aa 100644
--- a/xorg-server/hw/xwin/winclipboard/xevents.c
+++ b/xorg-server/hw/xwin/winclipboard/xevents.c
@@ -126,7 +126,8 @@ void
 winClipboardInitMonitoredSelections(void)
 {
     /* Initialize static variables */
-    for (int i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+    int i;
+    for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
       s_iOwners[i] = None;
 
     lastOwnedSelectionIndex = CLIP_OWN_NONE;
diff --git a/xorg-server/hw/xwin/wincmap.c b/xorg-server/hw/xwin/wincmap.c
index 5dcc8bc..1bdc7df 100644
--- a/xorg-server/hw/xwin/wincmap.c
+++ b/xorg-server/hw/xwin/wincmap.c
@@ -270,7 +270,7 @@ winCreateColormap(ColormapPtr pmap)
      * FIXME: This is some evil hackery to help in handling some X clients
      * that expect the top pixel to be white.  This "help" only lasts until
      * some client overwrites the top colormap entry.
-     * 
+     *
      * We don't want to actually allocate the top entry, as that causes
      * problems with X clients that need 7 planes (128 colors) in the default
      * colormap, such as Magic 7.1.
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c
index a6d3c0a..321dfee 100644
--- a/xorg-server/hw/xwin/winconfig.c
+++ b/xorg-server/hw/xwin/winconfig.c
@@ -239,7 +239,7 @@ winConfigKeyboard(DeviceIntPtr pDevice)
     XkbGetRulesDflts(&g_winInfo.xkb);
 
     /*
-     * Query the windows autorepeat settings and change the xserver defaults.   
+     * Query the windows autorepeat settings and change the xserver defaults.
      */
     {
         int kbd_delay;
@@ -277,7 +277,7 @@ winConfigKeyboard(DeviceIntPtr pDevice)
             layoutNum = strtoul(layoutName, (char **) NULL, 16);
         if ((layoutNum & 0xffff) == 0x411) {
             /* The japanese layouts know a lot of different IMEs which all have
-               different layout numbers set. Map them to a single entry. 
+               different layout numbers set. Map them to a single entry.
                Same might apply for chinese, korean and other symbol languages
                too */
             layoutNum = (layoutNum & 0xffff);
@@ -358,7 +358,7 @@ winConfigKeyboard(DeviceIntPtr pDevice)
         kbdfrom = X_CMDLINE;
 
     /*
-     * Until the layout code is finished, I search for the keyboard 
+     * Until the layout code is finished, I search for the keyboard
      * device and configure the server with it.
      */
 
@@ -653,7 +653,7 @@ winSetPercentOption(void *optlist, const char *name, double deflt)
 
 /*
  * Compare two strings for equality. This is caseinsensitive  and
- * The characters '_', ' ' (space) and '\t' (tab) are treated as 
+ * The characters '_', ' ' (space) and '\t' (tab) are treated as
  * not existing.
  */
 
@@ -696,7 +696,7 @@ winNameCompare(const char *s1, const char *s2)
 
 #ifdef XWIN_XF86CONFIG
 /*
- * Find the named option in the list. 
+ * Find the named option in the list.
  * @return the pointer to the option record, or NULL if not found.
  */
 
diff --git a/xorg-server/hw/xwin/wincreatewnd.c b/xorg-server/hw/xwin/wincreatewnd.c
index 9f72016..6c5b21d 100644
--- a/xorg-server/hw/xwin/wincreatewnd.c
+++ b/xorg-server/hw/xwin/wincreatewnd.c
@@ -160,8 +160,8 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
         && !pScreenInfo->fMultiWindow
 #endif
         ) {
-        /* Try to handle startup via run.exe. run.exe instructs Windows to 
-         * hide all created windows. Detect this case and make sure the 
+        /* Try to handle startup via run.exe. run.exe instructs Windows to
+         * hide all created windows. Detect this case and make sure the
          * window is shown nevertheless */
         STARTUPINFO startupInfo;
 
diff --git a/xorg-server/hw/xwin/wincursor.c b/xorg-server/hw/xwin/wincursor.c
index f3ac0f7..bddd6b7 100644
--- a/xorg-server/hw/xwin/wincursor.c
+++ b/xorg-server/hw/xwin/wincursor.c
@@ -106,7 +106,7 @@ winPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
         MapWindowPoints(pScreenPriv->hwndScreen,
                         HWND_DESKTOP, (LPPOINT) &rcClient, 2);
 
-        /* 
+        /*
          * Update the Windows cursor position so that we don't
          * immediately warp back to the current position.
          */
@@ -169,7 +169,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
                   pCursor->bits->width, pCursor->bits->height,
                   pCursor->bits->xhot, pCursor->bits->yhot);
 
-    /* We can use only White and Black, so calc brightness of color 
+    /* We can use only White and Black, so calc brightness of color
      * Also check if the cursor is inverted */
     dForeY = BRIGHTNESS(pCursor->fore);
     dBackY = BRIGHTNESS(pCursor->back);
@@ -184,8 +184,8 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
                       pCursor->bits->width, pCursor->bits->height);
     }
 
-    /* Get the number of bytes required to store the whole cursor image 
-     * This is roughly (sm_cx * sm_cy) / 8 
+    /* Get the number of bytes required to store the whole cursor image
+     * This is roughly (sm_cx * sm_cy) / 8
      * round up to 8 pixel boundary so we can convert whole bytes */
     nBytes =
         bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
@@ -199,7 +199,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
     memset(pAnd, 0xFF, nBytes);
     pXor = calloc(1, nBytes);
 
-    /* Convert the X11 bitmap to a win32 bitmap 
+    /* Convert the X11 bitmap to a win32 bitmap
      * The first is for an empty mask */
     if (pCursor->bits->emptyMask) {
         int x, y, xmax = bits_to_bytes(nCX);
diff --git a/xorg-server/hw/xwin/windialogs.c b/xorg-server/hw/xwin/windialogs.c
index 61f7fe0..6fe3fc4 100644
--- a/xorg-server/hw/xwin/windialogs.c
+++ b/xorg-server/hw/xwin/windialogs.c
@@ -389,8 +389,8 @@ winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv)
     }
 
     /*
-     * Display a notification to the user that the visual 
-     * will not be displayed until the Windows display depth 
+     * Display a notification to the user that the visual
+     * will not be displayed until the Windows display depth
      * is restored to the original value.
      */
     g_hDlgDepthChange = CreateDialogParam(g_hInstance,
@@ -411,7 +411,7 @@ winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv)
 
 /*
  * Process messages for the dialog that is displayed for
- * disruptive screen depth changes. 
+ * disruptive screen depth changes.
  */
 
 static INT_PTR CALLBACK
@@ -437,8 +437,8 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
         s_pScreenInfo = s_pScreenPriv->pScreenInfo;
 
 #if CYGDEBUG
-        winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
-                 "s_pScreenInfo: %08x\n",
+        winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %p, "
+                 "s_pScreenInfo: %p\n",
                  s_pScreenPriv, s_pScreenInfo);
 #endif
 
@@ -481,7 +481,7 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
         case IDCANCEL:
             winDebug("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
 
-            /* 
+            /*
              * User dismissed the dialog, hide it until the
              * display mode is restored.
              */
diff --git a/xorg-server/hw/xwin/winlayouts.h b/xorg-server/hw/xwin/winlayouts.h
index 8b6b984..a61fd7a 100644
--- a/xorg-server/hw/xwin/winlayouts.h
+++ b/xorg-server/hw/xwin/winlayouts.h
@@ -23,7 +23,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* Definitions for various keyboard layouts from windows and their 
+/* Definitions for various keyboard layouts from windows and their
  * XKB settings.
  */
 
diff --git a/xorg-server/hw/xwin/winmsgwindow.c b/xorg-server/hw/xwin/winmsgwindow.c
index 59f1da5..f5649b7 100644
--- a/xorg-server/hw/xwin/winmsgwindow.c
+++ b/xorg-server/hw/xwin/winmsgwindow.c
@@ -96,7 +96,6 @@ static HWND
 winCreateMsgWindow(void)
 {
     HWND hwndMsg;
-    wATOM winClass;
 
     // register window class
     {
@@ -114,7 +113,7 @@ winCreateMsgWindow(void)
         wcx.lpszMenuName = NULL;
         wcx.lpszClassName = WINDOW_CLASS_X_MSG;
         wcx.hIconSm = NULL;
-        winClass = RegisterClassEx(&wcx);
+        RegisterClassEx(&wcx);
     }
 
     // Create the msg window.
@@ -136,7 +135,7 @@ winCreateMsgWindow(void)
         return NULL;
     }
 
-    winDebug("winCreateMsgWindow - Created msg window hwnd 0x%x\n", hwndMsg);
+    winDebug("winCreateMsgWindow - Created msg window hwnd 0x%p\n", hwndMsg);
 
     return hwndMsg;
 }
diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c
index 93d389d..c22e688 100644
--- a/xorg-server/hw/xwin/winmultiwindowicons.c
+++ b/xorg-server/hw/xwin/winmultiwindowicons.c
@@ -382,7 +382,7 @@ winXIconToHICON(Display * pDisplay, Window id, int iconSize)
     static int generation;
     uint32_t *icon, *icon_data = NULL;
     unsigned long int size;
-    unsigned long int type;
+    Atom type;
     int format;
     unsigned long int left;
 
@@ -465,7 +465,7 @@ winXIconToHICON(Display * pDisplay, Window id, int iconSize)
                 xImageIcon =
                     XGetImage(pDisplay, hints->icon_pixmap, 0, 0, width, height,
                               0xFFFFFFFF, ZPixmap);
-                winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%x\n", id,
+                winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%p\n", id,
                          xImageIcon);
 
                 if (hints->icon_mask)
diff --git a/xorg-server/hw/xwin/winmultiwindowshape.c b/xorg-server/hw/xwin/winmultiwindowshape.c
index cb0f389..73afaea 100644
--- a/xorg-server/hw/xwin/winmultiwindowshape.c
+++ b/xorg-server/hw/xwin/winmultiwindowshape.c
@@ -47,7 +47,7 @@ winSetShapeMultiWindow(WindowPtr pWin, int kind)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
+    ErrorF("winSetShapeMultiWindow - pWin: %p kind: %i\n", pWin, kind);
 #endif
 
     WIN_UNWRAP(SetShape);
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index f2e7907..c22d690 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -286,7 +286,7 @@ winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winChangeWindowAttributesMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(ChangeWindowAttributes);
@@ -315,7 +315,7 @@ winUnmapWindowMultiWindow(WindowPtr pWin)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winUnmapWindowMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(UnrealizeWindow);
@@ -346,7 +346,7 @@ winMapWindowMultiWindow(WindowPtr pWin)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winMapWindowMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winMapWindowMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(RealizeWindow);
@@ -378,7 +378,7 @@ winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent)
     winScreenPriv(pScreen);
 
     winDebug
-        ("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
+        ("winReparentMultiWindow - pWin:%p XID:0x%x, reparent from pWin:%p XID:0x%x to pWin:%p XID:0x%x\n",
          pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id,
          pWin->parent, pWin->parent->drawable.id);
 
@@ -409,7 +409,7 @@ winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
-    winTrace("winRestackMultiWindow - %08x\n", pWin);
+    winTrace("winRestackMultiWindow - %p\n", pWin);
 #endif
 
     WIN_UNWRAP(RestackWindow);
@@ -492,7 +492,7 @@ winCreateWindowsWindow(WindowPtr pWin)
 
     winInitMultiWindowClass();
 
-    winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin,
+    winDebug("winCreateWindowsTopLevelWindow - pWin:%p XID:0x%x \n", pWin,
              pWin->drawable.id);
 
     iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
@@ -618,7 +618,7 @@ winDestroyWindowsWindow(WindowPtr pWin)
     HICON hIcon;
     HICON hIconSm;
 
-    winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin,
+    winDebug("winDestroyWindowsWindow - pWin:%p XID:0x%x \n", pWin,
              pWin->drawable.id);
 
     /* Bail out if the Windows window handle is invalid */
@@ -700,7 +700,7 @@ winUpdateWindowsWindow(WindowPtr pWin)
 }
 
 /*
- * winGetWindowID - 
+ * winGetWindowID -
  */
 
 XID
@@ -720,7 +720,7 @@ winGetWindowID(WindowPtr pWin)
 }
 
 /*
- * winFindWindow - 
+ * winFindWindow -
  */
 
 static void
@@ -734,7 +734,7 @@ winFindWindow(void *value, XID id, void *cdata)
 }
 
 /*
- * winReorderWindowsMultiWindow - 
+ * winReorderWindowsMultiWindow -
  */
 
 void
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index e17a950..6599dfb 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -339,7 +339,7 @@ PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
 
 #if 0
 /*
- * HaveMessage - 
+ * HaveMessage -
  */
 
 static Bool
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index 17823ba..d296f0f 100644
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -140,7 +140,7 @@ ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp)
      *
      * minAspectX * dheight > minAspectY * dwidth
      * maxAspectX * dheight < maxAspectY * dwidth
-     * 
+     *
      */
 
     if (hints.flags & PAspect) {
@@ -271,7 +271,7 @@ winRaiseWindow(WindowPtr pWin)
         BOOL oldstate = winInRaiseWindow;
         XID vlist[1] = { 0 };
         winInRaiseWindow = TRUE;
-        /* Call configure window directly to make sure it gets processed 
+        /* Call configure window directly to make sure it gets processed
          * in time
          */
         ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c
index 53abc16..5052927 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -625,7 +625,7 @@ winIconIsOverride(HICON hicon)
  * If @path is NULL, use the built-in default.
  */
 static int
-winPrefsLoadPreferences(char *path)
+winPrefsLoadPreferences(const char *path)
 {
     FILE *prefFile = NULL;
 
diff --git a/xorg-server/hw/xwin/winprefslex.l b/xorg-server/hw/xwin/winprefslex.l
index fd13edc..9e6f0d6 100644
--- a/xorg-server/hw/xwin/winprefslex.l
+++ b/xorg-server/hw/xwin/winprefslex.l
@@ -37,8 +37,6 @@
 #include <string.h>
 #include "winprefsyacc.h"
 
-extern int yyparse(void);
-
 extern void ErrorF (const char* /*f*/, ...);
 
 /* Copy the parsed string, must be free()d in yacc parser */
diff --git a/xorg-server/hw/xwin/winprefsyacc.y b/xorg-server/hw/xwin/winprefsyacc.y
index 683fc44..9bb28ae 100644
--- a/xorg-server/hw/xwin/winprefsyacc.y
+++ b/xorg-server/hw/xwin/winprefsyacc.y
@@ -64,7 +64,7 @@ static void SetDefaultSysMenu (char *menu, int pos);
 static void SetTrayIcon (char *fname);
 
 static void OpenMenu(char *menuname);
-static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
+static void AddMenuLine(const char *name, MENUCOMMANDTYPE cmd, const char *param);
 static void CloseMenu(void);
 
 static void OpenIcons(void);
@@ -79,9 +79,10 @@ static void OpenSysMenu(void);
 static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
 static void CloseSysMenu(void);
 
-static int yyerror (char *s);
+static int yyerror (const char *s);
 
 extern char *yytext;
+extern int yylineno;
 extern int yylex(void);
 
 %}
@@ -252,10 +253,8 @@ debug: 	DEBUGOUTPUT STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($
  * Errors in parsing abort and print log messages
  */
 static int
-yyerror (char *s) 
+yyerror (const char *s)
 {
-  extern int yylineno; /* Handled by flex internally */
-
   ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
   return 1;
 }
@@ -308,7 +307,7 @@ OpenMenu (char *menuname)
 }
 
 static void
-AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
+AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
 {
   if (menu.menuItem==NULL)
     menu.menuItem = malloc(sizeof(MENUITEM));
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c
index ed1773c..ce0aada 100644
--- a/xorg-server/hw/xwin/winscrinit.c
+++ b/xorg-server/hw/xwin/winscrinit.c
@@ -185,7 +185,7 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
     /* Are we using multiple monitors? */
     if (pScreenInfo->fMultipleMonitors) {
-        /* 
+        /*
          * In this case, some of the defaults set in
          * winInitializeScreenDefaults() are not correct ...
          */
@@ -345,7 +345,7 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
          pVisual->vid != pScreen->rootVisual; pVisual++);
     pScreenPriv->pRootVisual = pVisual;
 
-    /* 
+    /*
      * Setup points to the block and wakeup handlers.  Pass a pointer
      * to the current screen as pWakeupdata.
      */
diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c
index 5f3b658..4904eb4 100644
--- a/xorg-server/hw/xwin/winshaddd.c
+++ b/xorg-server/hw/xwin/winshaddd.c
@@ -173,7 +173,7 @@ winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen)
 /*
  * Create a DirectDraw surface for the shadow framebuffer; also create
  * a primary surface object so we can blit to the display.
- * 
+ *
  * Install a DirectDraw clipper on our primary surface object
  * that clips our blits to the unobscured client area of our display window.
  */
@@ -518,7 +518,7 @@ winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf)
 
     /*
      * Handle small regions with multiple blits,
-     * handle large regions by creating a clipping region and 
+     * handle large regions by creating a clipping region and
      * doing a single blit constrained to that clipping region.
      */
     if (pScreenInfo->dwClipUpdatesNBoxes == 0
@@ -619,7 +619,7 @@ winInitScreenShadowDD(ScreenPtr pScreen)
 
 /*
  * Call the wrapped CloseScreen function.
- * 
+ *
  * Free our resources and private structures.
  */
 
@@ -683,7 +683,7 @@ winCloseScreenShadowDD(ScreenPtr pScreen)
 
 /*
  * Tell mi what sort of visuals we need.
- * 
+ *
  * Generally we only need one visual, as our screen can only
  * handle one format at a time, I believe.  You may want
  * to verify that last sentence.
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c
index cb326dc..48599b2 100644
--- a/xorg-server/hw/xwin/winshadddnl.c
+++ b/xorg-server/hw/xwin/winshadddnl.c
@@ -184,7 +184,7 @@ winReleasePrimarySurfaceShadowDDNL(ScreenPtr pScreen)
 /*
  * Create a DirectDraw surface for the shadow framebuffer; also create
  * a primary surface object so we can blit to the display.
- * 
+ *
  * Install a DirectDraw clipper on our primary surface object
  * that clips our blits to the unobscured client area of our display window.
  */
@@ -216,7 +216,7 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
     }
 
     /*
-     * Initialize the framebuffer memory so we don't get a 
+     * Initialize the framebuffer memory so we don't get a
      * strange display at startup
      */
     ZeroMemory(lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
@@ -545,7 +545,7 @@ winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf)
 
     /*
      * Handle small regions with multiple blits,
-     * handle large regions by creating a clipping region and 
+     * handle large regions by creating a clipping region and
      * doing a single blit constrained to that clipping region.
      */
     if (pScreenInfo->dwClipUpdatesNBoxes == 0
@@ -988,7 +988,7 @@ winRedrawScreenShadowDDNL(ScreenPtr pScreen)
 
     /* Return immediately if we didn't get needed surfaces */
     if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
-        return;
+        return FALSE;
 
     /* Get the origin of the window in the screen coords */
     ptOrigin.x = pScreenInfo->dwXOffset;
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c
index 5c815eb..3d222ad 100644
--- a/xorg-server/hw/xwin/winshadgdi.c
+++ b/xorg-server/hw/xwin/winshadgdi.c
@@ -155,7 +155,7 @@ winQueryRGBBitsAndMasks(ScreenPtr pScreen)
 
     /* Color masks for 8 bpp are standardized */
     if (GetDeviceCaps(pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE) {
-        /* 
+        /*
          * RGB BPP for 8 bit palletes is always 8
          * and the color masks are always 0.
          */
@@ -381,7 +381,7 @@ winAllocateFBShadowGDI(ScreenPtr pScreen)
 #if 0
         return FALSE;
 #else
-        /* ago: ignore this error. The blit fails with wine, but does not 
+        /* ago: ignore this error. The blit fails with wine, but does not
          * cause any problems later. */
 
         fReturn = TRUE;
@@ -474,7 +474,7 @@ winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
 
     /*
      * Handle small regions with multiple blits,
-     * handle large regions by creating a clipping region and 
+     * handle large regions by creating a clipping region and
      * doing a single blit constrained to that clipping region.
      */
     if (!pScreenInfo->fMultiWindow &&
@@ -634,7 +634,7 @@ winCloseScreenShadowGDI(ScreenPtr pScreen)
 
 /*
  * Tell mi what sort of visuals we need.
- * 
+ *
  * Generally we only need one visual, as our screen can only
  * handle one format at a time, I believe.  You may want
  * to verify that last sentence.
@@ -815,7 +815,7 @@ winActivateAppShadowGDI(ScreenPtr pScreen)
      */
     if (pScreenPriv->fActive && pScreenInfo->fFullScreen) {
         /*
-         * Activating, attempt to bring our window 
+         * Activating, attempt to bring our window
          * to the top of the display
          */
         ShowWindow(pScreenPriv->hwndScreen, SW_RESTORE);
diff --git a/xorg-server/hw/xwin/winwin32rootlesswndproc.c b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
index 001d0d2..f65811c 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswndproc.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
@@ -147,7 +147,7 @@ ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp)
      *
      * minAspectX * dheight > minAspectY * dwidth
      * maxAspectX * dheight < maxAspectY * dwidth
-     * 
+     *
      */
 
     if (hints.flags & PAspect) {
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c
index 2805ff7..db41d6b 100644
--- a/xorg-server/hw/xwin/winwindowswm.c
+++ b/xorg-server/hw/xwin/winwindowswm.c
@@ -284,7 +284,7 @@ ProcWindowsWMReenableUpdate(ClientPtr client)
 {
     REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
 
-    //winEnableUpdate(); 
+    //winEnableUpdate();
 
     return Success;
 }
diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c
index 1b09921..0c434c9 100644
--- a/xorg-server/hw/xwin/winwndproc.c
+++ b/xorg-server/hw/xwin/winwndproc.c
@@ -403,7 +403,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
 
         /*
-         * NOTE: Scrollbars may have moved if they were at the 
+         * NOTE: Scrollbars may have moved if they were at the
          * far right/bottom, so we query their current position.
          */
 
@@ -621,7 +621,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         int iBorderHeight, iBorderWidth;
 
 #if CYGDEBUG
-        winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
+        winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %p\n",
                  s_pScreenInfo);
 #endif
 
@@ -1053,12 +1053,12 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         if (winIsFakeCtrl_L(message, wParam, lParam))
             return 0;
 
-        /* 
+        /*
          * Discard presses generated from Windows auto-repeat
          */
         if (lParam & (1 << 30)) {
             switch (wParam) {
-                /* ago: Pressing LControl while RControl is pressed is 
+                /* ago: Pressing LControl while RControl is pressed is
                  * Indicated as repeat. Fix this!
                  */
             case VK_CONTROL:
diff --git a/xorg-server/include/closure.h b/xorg-server/include/closure.h
index 0a7dae6..0d941df 100644
--- a/xorg-server/include/closure.h
+++ b/xorg-server/include/closure.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/colormap.h b/xorg-server/include/colormap.h
index b89bbe1..5f6b97f 100644
--- a/xorg-server/include/colormap.h
+++ b/xorg-server/include/colormap.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/colormapst.h b/xorg-server/include/colormapst.h
index ac0c62e..53b61cb 100644
--- a/xorg-server/include/colormapst.h
+++ b/xorg-server/include/colormapst.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/cursor.h b/xorg-server/include/cursor.h
index 1e483ac..281d88b 100644
--- a/xorg-server/include/cursor.h
+++ b/xorg-server/include/cursor.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/cursorstr.h b/xorg-server/include/cursorstr.h
index 2157954..221cd70 100644
--- a/xorg-server/include/cursorstr.h
+++ b/xorg-server/include/cursorstr.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -49,7 +49,7 @@ SOFTWARE.
 
 #include "cursor.h"
 #include "privates.h"
-/* 
+/*
  * device-independent cursor storage
  */
 
diff --git a/xorg-server/include/dbus-core.h b/xorg-server/include/dbus-core.h
index b2d6d1b..d6260dc 100644
--- a/xorg-server/include/dbus-core.h
+++ b/xorg-server/include/dbus-core.h
@@ -27,7 +27,7 @@
 #define DBUS_CORE_H
 
 #ifdef NEED_DBUS
-typedef struct DBusConnection DBusConnection;
+#include <dbus/dbus.h>
 
 typedef void (*dbus_core_connect_hook) (DBusConnection * connection,
                                                void *data);
diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h
index 116da2e..991a3ce 100644
--- a/xorg-server/include/dix.h
+++ b/xorg-server/include/dix.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/extension.h b/xorg-server/include/extension.h
index 7c09af1..a4c09de 100644
--- a/xorg-server/include/extension.h
+++ b/xorg-server/include/extension.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/extnsionst.h b/xorg-server/include/extnsionst.h
index fbdb73c..636f0a8 100644
--- a/xorg-server/include/extnsionst.h
+++ b/xorg-server/include/extnsionst.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -72,7 +72,7 @@ typedef struct _ExtensionEntry {
     PrivateRec *devPrivates;
 } ExtensionEntry;
 
-/* 
+/*
  * The arguments may be different for extension event swapping functions.
  * Deal with this by casting when initializing the event's EventSwapVector[]
  * entries.
diff --git a/xorg-server/include/gc.h b/xorg-server/include/gc.h
index eb0a583..53f9c29 100644
--- a/xorg-server/include/gc.h
+++ b/xorg-server/include/gc.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/gcstruct.h b/xorg-server/include/gcstruct.h
index 6358b8c..e48d610 100644
--- a/xorg-server/include/gcstruct.h
+++ b/xorg-server/include/gcstruct.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -254,16 +254,15 @@ typedef struct _GC {
     unsigned int arcMode:1;
     unsigned int subWindowMode:1;
     unsigned int graphicsExposures:1;
-    unsigned int clientClipType:2;      /* CT_<kind> */
     unsigned int miTranslate:1; /* should mi things translate? */
     unsigned int tileIsPixel:1; /* tile is solid pixel */
     unsigned int fExpose:1;     /* Call exposure handling */
     unsigned int freeCompClip:1;        /* Free composite clip */
     unsigned int scratch_inuse:1;       /* is this GC in a pool for reuse? */
-    unsigned int unused:13;     /* see comment above */
-    unsigned long planemask;
-    unsigned long fgPixel;
-    unsigned long bgPixel;
+    unsigned int unused:15;     /* see comment above */
+    unsigned int planemask;
+    unsigned int fgPixel;
+    unsigned int bgPixel;
     /*
      * alas -- both tile and stipple must be here as they
      * are independently specifiable
@@ -271,11 +270,11 @@ typedef struct _GC {
     PixUnion tile;
     PixmapPtr stipple;
     DDXPointRec patOrg;         /* origin for (tile, stipple) */
-    struct _Font *font;
     DDXPointRec clipOrg;
-    void *clientClip;
-    unsigned long stateChanges; /* masked with GC_<kind> */
-    unsigned long serialNumber;
+    struct _Font *font;
+    RegionPtr clientClip;
+    unsigned int stateChanges; /* masked with GC_<kind> */
+    unsigned int serialNumber;
     const GCFuncs *funcs;
     const GCOps *ops;
     PrivateRec *devPrivates;
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index 35ceafa..bf22dc7 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index f6cfb04..568f5f9 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/include/inputstr.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -159,7 +159,7 @@ typedef struct _OtherInputMasks {
  */
 
 #define MasksPerDetailMask 8    /* 256 keycodes and 256 possible
-                                   modifier combinations, but only      
+                                   modifier combinations, but only
                                    3 buttons. */
 
 typedef struct _DetailRec {     /* Grab details may be bit masks */
@@ -174,9 +174,9 @@ union _GrabMask {
 };
 
 /**
- * Central struct for device grabs. 
+ * Central struct for device grabs.
  * The same struct is used for both core grabs and device grabs, with
- * different fields being set. 
+ * different fields being set.
  * If the grab is a core grab (GrabPointer/GrabKeyboard), then the eventMask
  * is a combination of standard event masks (i.e. PointerMotionMask |
  * ButtonPressMask).
diff --git a/xorg-server/include/list.h b/xorg-server/include/list.h
index 455c670..39f1985 100644
--- a/xorg-server/include/list.h
+++ b/xorg-server/include/list.h
@@ -117,7 +117,7 @@ struct xorg_list {
  * Example:
  * xorg_list_init(&bar->list_of_foos);
  *
- * @param The list to initialized.
+ * @param list The list to initialize
  */
 static inline void
 xorg_list_init(struct xorg_list *list)
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h
index 9c2f573..9b1c03a 100644
--- a/xorg-server/include/misc.h
+++ b/xorg-server/include/misc.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -43,7 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 SOFTWARE.
 
 Copyright 1992, 1993 Data General Corporation;
-Copyright 1992, 1993 OMRON Corporation  
+Copyright 1992, 1993 OMRON Corporation
 
 Permission to use, copy, modify, distribute, and sell this software and its
 documentation for any purpose is hereby granted without fee, provided that the
@@ -51,9 +51,9 @@ above copyright notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting documentation, and that
 neither the name OMRON or DATA GENERAL be used in advertising or publicity
 pertaining to distribution of the software without specific, written prior
-permission of the party whose name is to be used.  Neither OMRON or 
+permission of the party whose name is to be used.  Neither OMRON or
 DATA GENERAL make any representation about the suitability of this software
-for any purpose.  It is provided "as is" without express or implied warranty.  
+for any purpose.  It is provided "as is" without express or implied warranty.
 
 OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
@@ -67,7 +67,7 @@ OF THIS SOFTWARE.
 #ifndef MISC_H
 #define MISC_H 1
 /*
- *  X internal definitions 
+ *  X internal definitions
  *
  */
 
@@ -138,7 +138,7 @@ lswapl(uint32_t x)
 static inline uint16_t
 lswaps(uint16_t x)
 {
-    return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
+    return (uint16_t)((x & 0xff) << 8) | ((x >> 8) & 0xff);
 }
 
 #undef min
diff --git a/xorg-server/include/miscstruct.h b/xorg-server/include/miscstruct.h
index dbab10f..589a6cb 100644
--- a/xorg-server/include/miscstruct.h
+++ b/xorg-server/include/miscstruct.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h
index e4ec4b1..3e68c49 100644
--- a/xorg-server/include/os.h
+++ b/xorg-server/include/os.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/pixmap.h b/xorg-server/include/pixmap.h
index 4b8fc24..9656c3a 100644
--- a/xorg-server/include/pixmap.h
+++ b/xorg-server/include/pixmap.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/pixmapstr.h b/xorg-server/include/pixmapstr.h
index 2bdff98..380e483 100644
--- a/xorg-server/include/pixmapstr.h
+++ b/xorg-server/include/pixmapstr.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -67,7 +67,7 @@ typedef struct _Drawable {
 } DrawableRec;
 
 /*
- * PIXMAP -- device dependent 
+ * PIXMAP -- device dependent
  */
 
 typedef struct _Pixmap {
diff --git a/xorg-server/include/property.h b/xorg-server/include/property.h
index cae4471..e350513 100644
--- a/xorg-server/include/property.h
+++ b/xorg-server/include/property.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/propertyst.h b/xorg-server/include/propertyst.h
index da99576..d8ca840 100644
--- a/xorg-server/include/propertyst.h
+++ b/xorg-server/include/propertyst.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -49,7 +49,7 @@ SOFTWARE.
 #include "misc.h"
 #include "property.h"
 #include "privates.h"
-/* 
+/*
  *   PROPERTY -- property element
  */
 
diff --git a/xorg-server/include/region.h b/xorg-server/include/region.h
index 11dd59e..14d283f 100644
--- a/xorg-server/include/region.h
+++ b/xorg-server/include/region.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/regionstr.h b/xorg-server/include/regionstr.h
index 4a0725d..515e93f 100644
--- a/xorg-server/include/regionstr.h
+++ b/xorg-server/include/regionstr.h
@@ -125,7 +125,7 @@ RegionEnd(RegionPtr reg)
 }
 
 static inline size_t
-RegionSizeof(int n)
+RegionSizeof(size_t n)
 {
     return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
 }
diff --git a/xorg-server/include/resource.h b/xorg-server/include/resource.h
index fe56bb2..772f363 100644
--- a/xorg-server/include/resource.h
+++ b/xorg-server/include/resource.h
@@ -26,13 +26,13 @@ Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -50,7 +50,7 @@ SOFTWARE.
 #include "dixaccess.h"
 
 /*****************************************************************
- * STUFF FOR RESOURCES 
+ * STUFF FOR RESOURCES
  *****************************************************************/
 
 /* classes for Resource routines */
diff --git a/xorg-server/include/rgb.h b/xorg-server/include/rgb.h
index ddfb1d8..449bc54 100644
--- a/xorg-server/include/rgb.h
+++ b/xorg-server/include/rgb.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/screenint.h b/xorg-server/include/screenint.h
index e61cd33..e383848 100644
--- a/xorg-server/include/screenint.h
+++ b/xorg-server/include/screenint.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/scrnintstr.h b/xorg-server/include/scrnintstr.h
index 269ff5a..faf0563 100644
--- a/xorg-server/include/scrnintstr.h
+++ b/xorg-server/include/scrnintstr.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/selection.h b/xorg-server/include/selection.h
index 37e4f5e..7a516f1 100644
--- a/xorg-server/include/selection.h
+++ b/xorg-server/include/selection.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -51,7 +51,7 @@ SOFTWARE.
 #include "privates.h"
 
 /*
- *  Selection data structures 
+ *  Selection data structures
  */
 
 typedef struct _Selection {
diff --git a/xorg-server/include/servermd.h b/xorg-server/include/servermd.h
index c88a542..a3b5c3a 100644
--- a/xorg-server/include/servermd.h
+++ b/xorg-server/include/servermd.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -86,7 +86,7 @@ SOFTWARE.
 #endif
 
 #include <X11/Xfuncproto.h>
-/* 
+/*
  *   This returns the number of padding units, for depth d and width w.
  * For bitmaps this can be calculated with the macros above.
  * Other depths require either grovelling over the formats field of the
diff --git a/xorg-server/include/site.h b/xorg-server/include/site.h
index 25caabb..9bd8e2f 100644
--- a/xorg-server/include/site.h
+++ b/xorg-server/include/site.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -66,8 +66,8 @@ SOFTWARE.
 /*
  * The following constants are provided solely as a last line of defense.  The
  * normal build ALWAYS overrides them using a special rule given in
- * server/dix/Imakefile.  If you want to change either of these constants, 
- * you should set the DefaultFontPath or DefaultRGBDatabase configuration 
+ * server/dix/Imakefile.  If you want to change either of these constants,
+ * you should set the DefaultFontPath or DefaultRGBDatabase configuration
  * parameters.
  * DO NOT CHANGE THESE VALUES OR THE DIX IMAKEFILE!
  */
@@ -76,7 +76,7 @@ SOFTWARE.
 #endif
 
 /*
- * The following constants contain default values for all of the variables 
+ * The following constants contain default values for all of the variables
  * that can be initialized on the server command line or in the environment.
  */
 #define COMPILEDDEFAULTFONT	"fixed"
diff --git a/xorg-server/include/window.h b/xorg-server/include/window.h
index c123728..6daec85 100644
--- a/xorg-server/include/window.h
+++ b/xorg-server/include/window.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/windowstr.h b/xorg-server/include/windowstr.h
index 740f4a6..53eef37 100644
--- a/xorg-server/include/windowstr.h
+++ b/xorg-server/include/windowstr.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/include/xkbfile.h b/xorg-server/include/xkbfile.h
index 9f3b04c..f93d31a 100644
--- a/xorg-server/include/xkbfile.h
+++ b/xorg-server/include/xkbfile.h
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/include/xkbsrv.h b/xorg-server/include/xkbsrv.h
index a4878fc..cc6307a 100644
--- a/xorg-server/include/xkbsrv.h
+++ b/xorg-server/include/xkbsrv.h
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/include/xkbstr.h b/xorg-server/include/xkbstr.h
index 935330c..8d71557 100644
--- a/xorg-server/include/xkbstr.h
+++ b/xorg-server/include/xkbstr.h
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -417,7 +417,7 @@ typedef struct _XkbKeyAliasRec {
 } XkbKeyAliasRec, *XkbKeyAliasPtr;
 
         /*
-         * Names for everything 
+         * Names for everything
          */
 typedef struct _XkbNamesRec {
     Atom keycodes;
@@ -554,7 +554,7 @@ typedef struct _XkbChanges {
 } XkbChangesRec, *XkbChangesPtr;
 
         /*
-         * These data structures are used to construct a keymap from 
+         * These data structures are used to construct a keymap from
          * a set of components or to list components in the server
          * database.
          */
@@ -587,8 +587,8 @@ typedef struct _XkbComponentList {
 } XkbComponentListRec, *XkbComponentListPtr;
 
         /*
-         * The following data structures describe and track changes to a 
-         * non-keyboard extension device 
+         * The following data structures describe and track changes to a
+         * non-keyboard extension device
          */
 typedef struct _XkbDeviceLedInfo {
     unsigned short led_class;
diff --git a/xorg-server/include/xsha1.h b/xorg-server/include/xsha1.h
index aab7106..60c6a90 100644
--- a/xorg-server/include/xsha1.h
+++ b/xorg-server/include/xsha1.h
@@ -12,7 +12,7 @@ int x_sha1_update(void *ctx, void *data, int size);
 
 /*
  * Place the hash in result, and free ctx.
- * Returns 0 on error, 1 on success. 
+ * Returns 0 on error, 1 on success.
  */
 int x_sha1_final(void *ctx, unsigned char result[20]);
 
diff --git a/xorg-server/mi/Makefile.am b/xorg-server/mi/Makefile.am
index 0cef779..110c3f5 100644
--- a/xorg-server/mi/Makefile.am
+++ b/xorg-server/mi/Makefile.am
@@ -2,8 +2,8 @@ noinst_LTLIBRARIES = libmi.la
 
 if XORG
 sdk_HEADERS = micmap.h miline.h mipointer.h mi.h \
-              migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
-              mispans.h miwideline.h mistruct.h mifpoly.h mioverlay.h
+              migc.h mipointrst.h mizerarc.h micoord.h \
+              mistruct.h mioverlay.h
 endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
@@ -16,7 +16,6 @@ libmi_la_SOURCES = 	\
 	micmap.h	\
 	micoord.h	\
 	micopy.c	\
-	micursor.c	\
 	midash.c	\
 	midispcur.c	\
 	mieq.c		\
@@ -24,7 +23,6 @@ libmi_la_SOURCES = 	\
 	mifillarc.c	\
 	mifillarc.h	\
 	mifillrct.c	\
-	mifpolycon.c	\
 	mifpoly.h	\
 	migc.c		\
 	migc.h		\
@@ -37,18 +35,13 @@ libmi_la_SOURCES = 	\
 	mipointrst.h	\
 	mipoly.c	\
 	mipoly.h	\
-	mipolycon.c	\
-	mipolygen.c	\
 	mipolypnt.c	\
 	mipolyrect.c	\
 	mipolyseg.c	\
 	mipolytext.c	\
-	mipolyutil.c	\
 	mipushpxl.c	\
 	miscanfill.h	\
 	miscrinit.c	\
-	mispans.c	\
-	mispans.h	\
 	misprite.c	\
 	misprite.h	\
 	mistruct.h	\
diff --git a/xorg-server/mi/mi.h b/xorg-server/mi/mi.h
index 5a455c9..db62c91 100644
--- a/xorg-server/mi/mi.h
+++ b/xorg-server/mi/mi.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -288,22 +288,6 @@ extern _X_EXPORT void miFillPolygon(DrawablePtr /*dst */ ,
                                     DDXPointPtr /*pPts */
     );
 
-/* mipolycon.c */
-
-extern _X_EXPORT Bool miFillConvexPoly(DrawablePtr /*dst */ ,
-                                       GCPtr /*pgc */ ,
-                                       int /*count */ ,
-                                       DDXPointPtr      /*ptsIn */
-    );
-
-/* mipolygen.c */
-
-extern _X_EXPORT Bool miFillGeneralPoly(DrawablePtr /*dst */ ,
-                                        GCPtr /*pgc */ ,
-                                        int /*count */ ,
-                                        DDXPointPtr     /*ptsIn */
-    );
-
 /* mipolypnt.c */
 
 extern _X_EXPORT void miPolyPoint(DrawablePtr /*pDrawable */ ,
diff --git a/xorg-server/mi/miarc.c b/xorg-server/mi/miarc.c
index e55108a..e8bc87e 100644
--- a/xorg-server/mi/miarc.c
+++ b/xorg-server/mi/miarc.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -63,6 +63,22 @@ SOFTWARE.
 #include "mifillarc.h"
 #include <X11/Xfuncproto.h>
 
+#define EPSILON	0.000001
+#define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON)
+#define UNEQUAL(a,b) (fabs((a) - (b)) > EPSILON)
+#define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
+#define SQSECANT 108.856472512142   /* 1/sin^2(11/2) - for 11o miter cutoff */
+
+/* Point with sub-pixel positioning. */
+typedef struct _SppPoint {
+    double x, y;
+} SppPointRec, *SppPointPtr;
+
+typedef struct _SppArc {
+    double x, y, width, height;
+    double angle1, angle2;
+} SppArcRec, *SppArcPtr;
+
 static double miDsin(double a);
 static double miDcos(double a);
 static double miDasin(double v);
@@ -82,7 +98,7 @@ cbrt(double x)
 /*
  * some interesting sematic interpretation of the protocol:
  *
- * Self intersecting arcs (i.e. those spanning 360 degrees) 
+ * Self intersecting arcs (i.e. those spanning 360 degrees)
  *  never join with other arcs, and are drawn without caps
  *  (unless on/off dashed, in which case each dash segment
  *  is capped, except when the last segment meets the
@@ -99,21 +115,6 @@ cbrt(double x)
  *
  */
 
-#undef max
-#undef min
-
-_X_INLINE static int
-max(const int x, const int y)
-{
-    return x > y ? x : y;
-}
-
-_X_INLINE static int
-min(const int x, const int y)
-{
-    return x < y ? x : y;
-}
-
 struct bound {
     double min, max;
 };
@@ -353,7 +354,7 @@ of the two quadratics
 
 y^2 + ((b+A)/2)y + (Z + (bZ - d)/A) = 0
 
-where 
+where
 
 A = +/- sqrt(8Z + b^2 - 4c)
 b, c, d are the cubic, quadratic, and linear coefficients of the quartic
@@ -1110,6 +1111,195 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
     }
 }
 
+/* Find the index of the point with the smallest y.also return the
+ * smallest and largest y */
+static int
+GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans, int *by, int *ty)
+{
+    SppPointPtr ptMin;
+    double ymin, ymax;
+    SppPointPtr ptsStart = pts;
+
+    ptMin = pts;
+    ymin = ymax = (pts++)->y;
+
+    while (--n > 0) {
+        if (pts->y < ymin) {
+            ptMin = pts;
+            ymin = pts->y;
+        }
+        if (pts->y > ymax)
+            ymax = pts->y;
+
+        pts++;
+    }
+
+    *by = ICEIL(ymin + yFtrans);
+    *ty = ICEIL(ymax + yFtrans - 1);
+    return ptMin - ptsStart;
+}
+
+/*
+ *	miFillSppPoly written by Todd Newman; April. 1987.
+ *
+ *	Fill a convex polygon.  If the given polygon
+ *	is not convex, then the result is undefined.
+ *	The algorithm is to order the edges from smallest
+ *	y to largest by partitioning the array into a left
+ *	edge list and a right edge list.  The algorithm used
+ *	to traverse each edge is digital differencing analyzer
+ *	line algorithm with y as the major axis. There's some funny linear
+ *	interpolation involved because of the subpixel postioning.
+ */
+static void
+miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count,    /* number of points */
+              SppPointPtr ptsIn,        /* the points */
+              int xTrans, int yTrans,   /* Translate each point by this */
+              double xFtrans, double yFtrans    /* translate before conversion
+                                                   by this amount.  This provides
+                                                   a mechanism to match rounding
+                                                   errors with any shape that must
+                                                   meet the polygon exactly.
+                                                 */
+    )
+{
+    double xl = 0.0, xr = 0.0,  /* x vals of left and right edges */
+        ml = 0.0,               /* left edge slope */
+        mr = 0.0,               /* right edge slope */
+        dy,                     /* delta y */
+        i;                      /* loop counter */
+    int y,                      /* current scanline */
+     j, imin,                   /* index of vertex with smallest y */
+     ymin,                      /* y-extents of polygon */
+     ymax, *width, *FirstWidth, /* output buffer */
+    *Marked;                    /* set if this vertex has been used */
+    int left, right,            /* indices to first endpoints */
+     nextleft, nextright;       /* indices to second endpoints */
+    DDXPointPtr ptsOut, FirstPoint;     /* output buffer */
+
+    if (pgc->miTranslate) {
+        xTrans += dst->x;
+        yTrans += dst->y;
+    }
+
+    imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
+
+    y = ymax - ymin + 1;
+    if ((count < 3) || (y <= 0))
+        return;
+    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
+    width = FirstWidth = malloc(sizeof(int) * y);
+    Marked = malloc(sizeof(int) * count);
+
+    if (!ptsOut || !width || !Marked) {
+        free(Marked);
+        free(width);
+        free(ptsOut);
+        return;
+    }
+
+    for (j = 0; j < count; j++)
+        Marked[j] = 0;
+    nextleft = nextright = imin;
+    Marked[imin] = -1;
+    y = ICEIL(ptsIn[nextleft].y + yFtrans);
+
+    /*
+     *  loop through all edges of the polygon
+     */
+    do {
+        /* add a left edge if we need to */
+        if ((y > (ptsIn[nextleft].y + yFtrans) ||
+             ISEQUAL(y, ptsIn[nextleft].y + yFtrans)) &&
+            Marked[nextleft] != 1) {
+            Marked[nextleft]++;
+            left = nextleft++;
+
+            /* find the next edge, considering the end conditions */
+            if (nextleft >= count)
+                nextleft = 0;
+
+            /* now compute the starting point and slope */
+            dy = ptsIn[nextleft].y - ptsIn[left].y;
+            if (dy != 0.0) {
+                ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
+                dy = y - (ptsIn[left].y + yFtrans);
+                xl = (ptsIn[left].x + xFtrans) + ml * max(dy, 0);
+            }
+        }
+
+        /* add a right edge if we need to */
+        if ((y > ptsIn[nextright].y + yFtrans) ||
+            (ISEQUAL(y, ptsIn[nextright].y + yFtrans)
+             && Marked[nextright] != 1)) {
+            Marked[nextright]++;
+            right = nextright--;
+
+            /* find the next edge, considering the end conditions */
+            if (nextright < 0)
+                nextright = count - 1;
+
+            /* now compute the starting point and slope */
+            dy = ptsIn[nextright].y - ptsIn[right].y;
+            if (dy != 0.0) {
+                mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
+                dy = y - (ptsIn[right].y + yFtrans);
+                xr = (ptsIn[right].x + xFtrans) + mr * max(dy, 0);
+            }
+        }
+
+        /*
+         *  generate scans to fill while we still have
+         *  a right edge as well as a left edge.
+         */
+        i = (min(ptsIn[nextleft].y, ptsIn[nextright].y) + yFtrans) - y;
+
+        if (i < EPSILON) {
+            if (Marked[nextleft] && Marked[nextright]) {
+                /* Arrgh, we're trapped! (no more points)
+                 * Out, we've got to get out of here before this decadence saps
+                 * our will completely! */
+                break;
+            }
+            continue;
+        }
+        else {
+            j = (int) i;
+            if (!j)
+                j++;
+        }
+        while (j > 0) {
+            int cxl, cxr;
+
+            ptsOut->y = (y) + yTrans;
+
+            cxl = ICEIL(xl);
+            cxr = ICEIL(xr);
+            /* reverse the edges if necessary */
+            if (xl < xr) {
+                *(width++) = cxr - cxl;
+                (ptsOut++)->x = cxl + xTrans;
+            }
+            else {
+                *(width++) = cxl - cxr;
+                (ptsOut++)->x = cxr + xTrans;
+            }
+            y++;
+
+            /* increment down the edges */
+            xl += ml;
+            xr += mr;
+            j--;
+        }
+    } while (y <= ymax);
+
+    /* Finally, fill the spans we've collected */
+    (*pgc->ops->FillSpans) (dst, pgc,
+                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
+    free(Marked);
+    free(FirstWidth);
+    free(FirstPoint);
+}
 static double
 angleBetween(SppPointRec center, SppPointRec point1, SppPointRec point2)
 {
@@ -1291,7 +1481,7 @@ miArcCap(DrawablePtr pDraw,
 /* MIROUNDCAP -- a private helper function
  * Put Rounded cap on end. pCenter is the center of this end of the line
  * pEnd is the center of the other end of the line. pCorner is one of the
- * two corners at this end of the line.  
+ * two corners at this end of the line.
  * NOTE:  pOtherCorner must be counter-clockwise from pCorner.
  */
  /*ARGSUSED*/ static void
@@ -1443,7 +1633,7 @@ miDatan2(double dy, double dx)
  * array. (For example, if we want to leave a spare point to make sectors
  * instead of segments.)  So we pass in the malloc()ed chunk that contains the
  * array and an index saying where we should start stashing the points.
- * If there isn't an array already, we just pass in a null pointer and 
+ * If there isn't an array already, we just pass in a null pointer and
  * count on realloc() to handle the null pointer correctly.
  */
 static int
@@ -1462,7 +1652,7 @@ miGetArcPts(SppArcPtr parc,     /* points to an arc */
     SppPointPtr poly;
 
     /* The spec says that positive angles indicate counterclockwise motion.
-     * Given our coordinate system (with 0,0 in the upper left corner), 
+     * Given our coordinate system (with 0,0 in the upper left corner),
      * the screen appears flipped in Y.  The easiest fix is to negate the
      * angles given */
 
@@ -2548,7 +2738,7 @@ computeBound(struct arc_def *def,
 }
 
 /*
- * this section computes the x value of the span at y 
+ * this section computes the x value of the span at y
  * intersected with the specified face of the ellipse.
  *
  * this is the min/max X value over the set of normal
@@ -2561,7 +2751,7 @@ computeBound(struct arc_def *def,
  *
  * compute the derivative with-respect-to ellipse_y and solve
  * for zero:
- *    
+ *
  *       (w^2 - h^2) ellipse_y^3 + h^4 y
  * 0 = - ----------------------------------
  *       h w ellipse_y^2 sqrt (h^2 - ellipse_y^2)
@@ -2588,7 +2778,7 @@ computeBound(struct arc_def *def,
  *
  * or (to use accelerators),
  *
- * y0^3 (h^2 - w^2) - h^2 y (3y0^2 - 2h^2) 
+ * y0^3 (h^2 - w^2) - h^2 y (3y0^2 - 2h^2)
  *
  */
 
diff --git a/xorg-server/mi/mibitblt.c b/xorg-server/mi/mibitblt.c
index 114f72d..7243963 100644
--- a/xorg-server/mi/mibitblt.c
+++ b/xorg-server/mi/mibitblt.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -66,7 +66,7 @@ SOFTWARE.
 extern int ffs(int);
 #endif
 
-/* MICOPYAREA -- public entry for the CopyArea request 
+/* MICOPYAREA -- public entry for the CopyArea request
  * For each rectangle in the source region
  *     get the pixels with GetSpans
  *     set them in the destination with SetSpans
@@ -253,7 +253,7 @@ miCopyArea(DrawablePtr pSrcDrawable,
 }
 
 /* MIGETPLANE -- gets a bitmap representing one plane of pDraw
- * A helper used for CopyPlane and XY format GetImage 
+ * A helper used for CopyPlane and XY format GetImage
  * No clever strategy here, we grab a scanline at a time, pull out the
  * bits and then stuff them in a 1 bit deep map.
  */
@@ -358,9 +358,9 @@ miGetPlane(DrawablePtr pDraw, int planeNum,     /* number of the bitPlane */
 }
 
 /* MIOPQSTIPDRAWABLE -- use pbits as an opaque stipple for pDraw.
- * Drawing through the clip mask we SetSpans() the bits into a 
+ * Drawing through the clip mask we SetSpans() the bits into a
  * bitmap and stipple those bits onto the destination drawable by doing a
- * PolyFillRect over the whole drawable, 
+ * PolyFillRect over the whole drawable,
  * then we invert the bitmap by copying it onto itself with an alu of
  * GXinvert, invert the foreground/background colors of the gc, and draw
  * the background bits.
@@ -504,10 +504,10 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
 }
 
 /* MICOPYPLANE -- public entry for the CopyPlane request.
- * strategy: 
- * First build up a bitmap out of the bits requested 
+ * strategy:
+ * First build up a bitmap out of the bits requested
  * build a source clip
- * Use the bitmap we've built up as a Stipple for the destination 
+ * Use the bitmap we've built up as a Stipple for the destination
  */
 _X_COLD RegionPtr
 miCopyPlane(DrawablePtr pSrcDrawable,
@@ -670,16 +670,16 @@ miGetImage(DrawablePtr pDraw, int sx, int sy, int w, int h,
 
 /* MIPUTIMAGE -- public entry for the PutImage request
  * Here we benefit from knowing the format of the bits pointed to by pImage,
- * even if we don't know how pDraw represents them.  
- * Three different strategies are used depending on the format 
+ * even if we don't know how pDraw represents them.
+ * Three different strategies are used depending on the format
  * XYBitmap Format:
  * 	we just use the Opaque Stipple helper function to cover the destination
- * 	Note that this covers all the planes of the drawable with the 
+ * 	Note that this covers all the planes of the drawable with the
  *	foreground color (masked with the GC planemask) where there are 1 bits
  *	and the background color (masked with the GC planemask) where there are
  *	0 bits
  * XYPixmap format:
- *	what we're called with is a series of XYBitmaps, but we only want 
+ *	what we're called with is a series of XYBitmaps, but we only want
  *	each XYPixmap to update 1 plane, instead of updating all of them.
  * 	we set the foreground color to be all 1s and the background to all 0s
  *	then for each plane, we set the plane mask to only effect that one
diff --git a/xorg-server/mi/micopy.c b/xorg-server/mi/micopy.c
index a52b0a7..2409c78 100644
--- a/xorg-server/mi/micopy.c
+++ b/xorg-server/mi/micopy.c
@@ -167,7 +167,7 @@ miDoCopy(DrawablePtr pSrcDrawable,
 
     /* Compute source clip region */
     if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
-        if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+        if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip))
             prgnSrcClip = miGetCompositeClip(pGC);
         else
             fastSrc = TRUE;
@@ -186,8 +186,7 @@ miDoCopy(DrawablePtr pSrcDrawable,
                  */
                 fastSrc = TRUE;
             }
-            else if ((pSrcDrawable == pDstDrawable) &&
-                     (pGC->clientClipType == CT_NONE)) {
+            else if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip)) {
                 prgnSrcClip = miGetCompositeClip(pGC);
             }
             else {
diff --git a/xorg-server/mi/micursor.c b/xorg-server/mi/micursor.c
deleted file mode 100644
index 13ce776..0000000
--- a/xorg-server/mi/micursor.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "scrnintstr.h"
-#include "cursor.h"
-#include "misc.h"
-#include "mi.h"
-#include "inputstr.h"
-
-void
-miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
-                CursorPtr pCurs, Bool displayed)
-{
-    /*
-     * This is guaranteed to correct any color-dependent state which may have
-     * been bound up in private state created by RealizeCursor
-     */
-    pScr->UnrealizeCursor(pDev, pScr, pCurs);
-    pScr->RealizeCursor(pDev, pScr, pCurs);
-    if (displayed)
-        pScr->DisplayCursor(pDev, pScr, pCurs);
-}
diff --git a/xorg-server/mi/midash.c b/xorg-server/mi/midash.c
index 78cbaf2..08f11aa 100644
--- a/xorg-server/mi/midash.c
+++ b/xorg-server/mi/midash.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -49,7 +49,6 @@ SOFTWARE.
 
 #include "regionstr.h"
 #include "mistruct.h"
-#include "mifpoly.h"
 
 void
 miStepDash(int dist,            /* distance to step */
diff --git a/xorg-server/mi/midispcur.c b/xorg-server/mi/midispcur.c
index 8cca5fe..50f0dd2 100644
--- a/xorg-server/mi/midispcur.c
+++ b/xorg-server/mi/midispcur.c
@@ -78,9 +78,9 @@ typedef struct {
   (miDCBufferPtr)dixLookupScreenPrivate(&dev->devPrivates, miDCDeviceKey, screen) : \
   (miDCBufferPtr)dixLookupScreenPrivate(&GetMaster(dev, MASTER_POINTER)->devPrivates, miDCDeviceKey, screen))
 
-/* 
+/*
  * The core pointer buffer will point to the index of the virtual pointer
- * in the pCursorBuffers array. 
+ * in the pCursorBuffers array.
  */
 typedef struct {
     CloseScreenProcPtr CloseScreen;
diff --git a/xorg-server/mi/miexpose.c b/xorg-server/mi/miexpose.c
index de8ee6c..fc4dbc0 100644
--- a/xorg-server/mi/miexpose.c
+++ b/xorg-server/mi/miexpose.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -107,7 +107,7 @@ the region package can call this.
 #define RECTLIMIT 25            /* pick a number, any number > 8 */
 #endif
 
-/* miHandleExposures 
+/* miHandleExposures
     generate a region for exposures for areas that were copied from obscured or
 non-existent areas to non-obscured areas of the destination.  Paint the
 background for the region, if the destination is a window.
@@ -131,8 +131,8 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
     RegionRec rgnExposed;       /* exposed region, calculated source-
                                    relative, made dst relative to
                                    intersect with visible parts of
-                                   dest and send events to client, 
-                                   and then screen relative to paint 
+                                   dest and send events to client,
+                                   and then screen relative to paint
                                    the window background
                                  */
     WindowPtr pSrcWin;
@@ -230,7 +230,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
     RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
 
     /* intersect with client clip region. */
-    if (pGC->clientClipType == CT_REGION)
+    if (pGC->clientClip)
         RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
 
     /*
@@ -564,7 +564,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 }
 
 /* MICLEARDRAWABLE -- sets the entire drawable to the background color of
- * the GC.  Useful when we have a scratch drawable and need to initialize 
+ * the GC.  Useful when we have a scratch drawable and need to initialize
  * it. */
 void
 miClearDrawable(DrawablePtr pDraw, GCPtr pGC)
diff --git a/xorg-server/mi/mifillarc.c b/xorg-server/mi/mifillarc.c
index 08484d7..246d70f 100644
--- a/xorg-server/mi/mifillarc.c
+++ b/xorg-server/mi/mifillarc.c
@@ -36,7 +36,6 @@ Author:  Bob Scheifler, MIT X Consortium
 #include "regionstr.h"
 #include "gcstruct.h"
 #include "pixmapstr.h"
-#include "mifpoly.h"
 #include "mi.h"
 #include "mifillarc.h"
 
@@ -51,7 +50,7 @@ Author:  Bob Scheifler, MIT X Consortium
 #define Dsin(d)	sin((double)d*(M_PI/11520.0))
 #define Dcos(d)	cos((double)d*(M_PI/11520.0))
 
-void
+static void
 miFillArcSetup(xArc * arc, miFillArcRec * info)
 {
     info->y = arc->height >> 1;
@@ -277,7 +276,7 @@ miGetPieEdge(xArc * arc, int angle, miSliceEdgePtr edge, Bool top, Bool left)
     miGetArcEdge(arc, edge, k, top, left);
 }
 
-void
+static void
 miFillArcSliceSetup(xArc * arc, miArcSliceRec * slice, GCPtr pGC)
 {
     int angle1, angle2;
diff --git a/xorg-server/mi/mifillarc.h b/xorg-server/mi/mifillarc.h
index 1478d18..61ab253 100644
--- a/xorg-server/mi/mifillarc.h
+++ b/xorg-server/mi/mifillarc.h
@@ -175,13 +175,4 @@ typedef struct _miArcSlice {
 #define miFillInArcLower(slw) (((iny + dy) != 0) && \
 			       ((slw > 1) || (ine != inxk)))
 
-extern _X_EXPORT void miFillArcSetup(xArc * /*arc */ ,
-                                     miFillArcRec *     /*info */
-    );
-
-extern _X_EXPORT void miFillArcSliceSetup(xArc * /*arc */ ,
-                                          miArcSliceRec * /*slice */ ,
-                                          GCPtr /*pGC */
-    );
-
 #endif                          /* __MIFILLARC_H__ */
diff --git a/xorg-server/mi/mifillrct.c b/xorg-server/mi/mifillrct.c
index faf6049..28f2322 100644
--- a/xorg-server/mi/mifillrct.c
+++ b/xorg-server/mi/mifillrct.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mifpoly.h b/xorg-server/mi/mifpoly.h
index f853fb4..3202476 100644
--- a/xorg-server/mi/mifpoly.h
+++ b/xorg-server/mi/mifpoly.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -49,24 +49,6 @@ SOFTWARE.
 
 #include <X11/Xfuncproto.h>
 
-#define EPSILON	0.000001
-#define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON)
-#define UNEQUAL(a,b) (fabs((a) - (b)) > EPSILON)
-#define WITHINHALF(a, b) (((a) - (b) > 0.0) ? (a) - (b) < 0.5 : \
-					     (b) - (a) <= 0.5)
-#define ROUNDTOINT(x)   ((int) (((x) > 0.0) ? ((x) + 0.5) : ((x) - 0.5)))
-#define ISZERO(x) 	(fabs((x)) <= EPSILON)
-#define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
-#define PTUNEQUAL(a,b) (UNEQUAL(a.x,b.x) || UNEQUAL(a.y,b.y))
-#define PtEqual(a, b) (((a).x == (b).x) && ((a).y == (b).y))
-
-#define NotEnd		0
-#define FirstEnd	1
-#define SecondEnd	2
-
-#define SQSECANT 108.856472512142       /* 1/sin^2(11/2) - for 11o miter cutoff */
-#define D2SECANT 5.21671526231167       /* 1/2*sin(11/2) - max extension per width */
-
 static _X_INLINE int
 ICEIL(double x)
 {
@@ -75,28 +57,4 @@ ICEIL(double x)
     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp + 1;
 }
 
-/* Point with sub-pixel positioning.  In this case we use doubles, but
- * see mifpolycon.c for other suggestions 
- */
-typedef struct _SppPoint {
-    double x, y;
-} SppPointRec, *SppPointPtr;
-
-typedef struct _SppArc {
-    double x, y, width, height;
-    double angle1, angle2;
-} SppArcRec, *SppArcPtr;
-
-/* mifpolycon.c */
-
-extern _X_EXPORT void miFillSppPoly(DrawablePtr /*dst */ ,
-                                    GCPtr /*pgc */ ,
-                                    int /*count */ ,
-                                    SppPointPtr /*ptsIn */ ,
-                                    int /*xTrans */ ,
-                                    int /*yTrans */ ,
-                                    double /*xFtrans */ ,
-                                    double      /*yFtrans */
-    );
-
 #endif                          /* __MIFPOLY_H__ */
diff --git a/xorg-server/mi/mifpolycon.c b/xorg-server/mi/mifpolycon.c
deleted file mode 100644
index b133731..0000000
--- a/xorg-server/mi/mifpolycon.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <math.h>
-#include <X11/X.h>
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "mifpoly.h"
-
-static int GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans,
-                           int *by, int *ty);
-
-/*
- *	Written by Todd Newman; April. 1987.
- *
- *	Fill a convex polygon.  If the given polygon
- *	is not convex, then the result is undefined.
- *	The algorithm is to order the edges from smallest
- *	y to largest by partitioning the array into a left
- *	edge list and a right edge list.  The algorithm used
- *	to traverse each edge is digital differencing analyzer
- *	line algorithm with y as the major axis. There's some funny linear
- *	interpolation involved because of the subpixel postioning.
- */
-void
-miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count,    /* number of points */
-              SppPointPtr ptsIn,        /* the points */
-              int xTrans, int yTrans,   /* Translate each point by this */
-              double xFtrans, double yFtrans    /* translate before conversion
-                                                   by this amount.  This provides
-                                                   a mechanism to match rounding
-                                                   errors with any shape that must
-                                                   meet the polygon exactly.
-                                                 */
-    )
-{
-    double xl = 0.0, xr = 0.0,  /* x vals of left and right edges */
-        ml = 0.0,               /* left edge slope */
-        mr = 0.0,               /* right edge slope */
-        dy,                     /* delta y */
-        i;                      /* loop counter */
-    int y,                      /* current scanline */
-     j, imin,                   /* index of vertex with smallest y */
-     ymin,                      /* y-extents of polygon */
-     ymax, *width, *FirstWidth, /* output buffer */
-    *Marked;                    /* set if this vertex has been used */
-    int left, right,            /* indices to first endpoints */
-     nextleft, nextright;       /* indices to second endpoints */
-    DDXPointPtr ptsOut, FirstPoint;     /* output buffer */
-
-    if (pgc->miTranslate) {
-        xTrans += dst->x;
-        yTrans += dst->y;
-    }
-
-    imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
-
-    y = ymax - ymin + 1;
-    if ((count < 3) || (y <= 0))
-        return;
-    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
-    width = FirstWidth = malloc(sizeof(int) * y);
-    Marked = malloc(sizeof(int) * count);
-
-    if (!ptsOut || !width || !Marked) {
-        free(Marked);
-        free(width);
-        free(ptsOut);
-        return;
-    }
-
-    for (j = 0; j < count; j++)
-        Marked[j] = 0;
-    nextleft = nextright = imin;
-    Marked[imin] = -1;
-    y = ICEIL(ptsIn[nextleft].y + yFtrans);
-
-    /*
-     *  loop through all edges of the polygon
-     */
-    do {
-        /* add a left edge if we need to */
-        if ((y > (ptsIn[nextleft].y + yFtrans) ||
-             ISEQUAL(y, ptsIn[nextleft].y + yFtrans)) &&
-            Marked[nextleft] != 1) {
-            Marked[nextleft]++;
-            left = nextleft++;
-
-            /* find the next edge, considering the end conditions */
-            if (nextleft >= count)
-                nextleft = 0;
-
-            /* now compute the starting point and slope */
-            dy = ptsIn[nextleft].y - ptsIn[left].y;
-            if (dy != 0.0) {
-                ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
-                dy = y - (ptsIn[left].y + yFtrans);
-                xl = (ptsIn[left].x + xFtrans) + ml * max(dy, 0);
-            }
-        }
-
-        /* add a right edge if we need to */
-        if ((y > ptsIn[nextright].y + yFtrans) ||
-            (ISEQUAL(y, ptsIn[nextright].y + yFtrans)
-             && Marked[nextright] != 1)) {
-            Marked[nextright]++;
-            right = nextright--;
-
-            /* find the next edge, considering the end conditions */
-            if (nextright < 0)
-                nextright = count - 1;
-
-            /* now compute the starting point and slope */
-            dy = ptsIn[nextright].y - ptsIn[right].y;
-            if (dy != 0.0) {
-                mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
-                dy = y - (ptsIn[right].y + yFtrans);
-                xr = (ptsIn[right].x + xFtrans) + mr * max(dy, 0);
-            }
-        }
-
-        /*
-         *  generate scans to fill while we still have
-         *  a right edge as well as a left edge.
-         */
-        i = (min(ptsIn[nextleft].y, ptsIn[nextright].y) + yFtrans) - y;
-
-        if (i < EPSILON) {
-            if (Marked[nextleft] && Marked[nextright]) {
-                /* Arrgh, we're trapped! (no more points) 
-                 * Out, we've got to get out of here before this decadence saps
-                 * our will completely! */
-                break;
-            }
-            continue;
-        }
-        else {
-            j = (int) i;
-            if (!j)
-                j++;
-        }
-        while (j > 0) {
-            int cxl, cxr;
-
-            ptsOut->y = (y) + yTrans;
-
-            cxl = ICEIL(xl);
-            cxr = ICEIL(xr);
-            /* reverse the edges if necessary */
-            if (xl < xr) {
-                *(width++) = cxr - cxl;
-                (ptsOut++)->x = cxl + xTrans;
-            }
-            else {
-                *(width++) = cxl - cxr;
-                (ptsOut++)->x = cxr + xTrans;
-            }
-            y++;
-
-            /* increment down the edges */
-            xl += ml;
-            xr += mr;
-            j--;
-        }
-    } while (y <= ymax);
-
-    /* Finally, fill the spans we've collected */
-    (*pgc->ops->FillSpans) (dst, pgc,
-                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
-    free(Marked);
-    free(FirstWidth);
-    free(FirstPoint);
-}
-

-/* Find the index of the point with the smallest y.also return the
- * smallest and largest y */
-static
-    int
-GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans, int *by, int *ty)
-{
-    SppPointPtr ptMin;
-    double ymin, ymax;
-    SppPointPtr ptsStart = pts;
-
-    ptMin = pts;
-    ymin = ymax = (pts++)->y;
-
-    while (--n > 0) {
-        if (pts->y < ymin) {
-            ptMin = pts;
-            ymin = pts->y;
-        }
-        if (pts->y > ymax)
-            ymax = pts->y;
-
-        pts++;
-    }
-
-    *by = ICEIL(ymin + yFtrans);
-    *ty = ICEIL(ymax + yFtrans - 1);
-    return ptMin - ptsStart;
-}
diff --git a/xorg-server/mi/migc.c b/xorg-server/mi/migc.c
index 9bbe884..8fdd481 100644
--- a/xorg-server/mi/migc.c
+++ b/xorg-server/mi/migc.c
@@ -55,20 +55,9 @@ miDestroyGC(GCPtr pGC)
 void
 miDestroyClip(GCPtr pGC)
 {
-    if (pGC->clientClipType == CT_NONE)
-        return;
-    else if (pGC->clientClipType == CT_PIXMAP) {
-        (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) (pGC->clientClip));
-    }
-    else {
-        /*
-         * we know we'll never have a list of rectangles, since ChangeClip
-         * immediately turns them into a region
-         */
+    if (pGC->clientClip)
         RegionDestroy(pGC->clientClip);
-    }
     pGC->clientClip = NULL;
-    pGC->clientClipType = CT_NONE;
 }
 
 void
@@ -77,8 +66,7 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
     (*pGC->funcs->DestroyClip) (pGC);
     if (type == CT_PIXMAP) {
         /* convert the pixmap to a region */
-        pGC->clientClip = (void *) BitmapToRegion(pGC->pScreen,
-                                                   (PixmapPtr) pvalue);
+        pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue);
         (*pGC->pScreen->DestroyPixmap) (pvalue);
     }
     else if (type == CT_REGION) {
@@ -86,34 +74,21 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
         pGC->clientClip = pvalue;
     }
     else if (type != CT_NONE) {
-        pGC->clientClip = (void *) RegionFromRects(nrects,
-                                                    (xRectangle *) pvalue,
-                                                    type);
+        pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type);
         free(pvalue);
     }
-    pGC->clientClipType = (type != CT_NONE &&
-                           pGC->clientClip) ? CT_REGION : CT_NONE;
     pGC->stateChanges |= GCClipMask;
 }
 
 void
 miCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 {
-    RegionPtr prgnNew;
-
-    switch (pgcSrc->clientClipType) {
-    case CT_PIXMAP:
-        ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
-        /* Fall through !! */
-    case CT_NONE:
-        (*pgcDst->funcs->ChangeClip) (pgcDst, (int) pgcSrc->clientClipType,
-                                      pgcSrc->clientClip, 0);
-        break;
-    case CT_REGION:
-        prgnNew = RegionCreate(NULL, 1);
+    if (pgcSrc->clientClip) {
+        RegionPtr prgnNew = RegionCreate(NULL, 1);
         RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip));
-        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (void *) prgnNew, 0);
-        break;
+        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, prgnNew, 0);
+    } else {
+        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_NONE, NULL, 0);
     }
 }
 
@@ -149,7 +124,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
          * regions.  (this wins especially if many clients clip by children
          * and have no client clip.)
          */
-        if (pGC->clientClipType == CT_NONE) {
+        if (!pGC->clientClip) {
             if (freeCompClip)
                 RegionDestroy(pGC->pCompositeClip);
             pGC->pCompositeClip = pregWin;
@@ -206,7 +181,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
             pGC->pCompositeClip = RegionCreate(&pixbounds, 1);
         }
 
-        if (pGC->clientClipType == CT_REGION) {
+        if (pGC->clientClip) {
             if (pDrawable->x || pDrawable->y) {
                 RegionTranslate(pGC->clientClip,
                                 pDrawable->x + pGC->clipOrg.x,
diff --git a/xorg-server/mi/miglblt.c b/xorg-server/mi/miglblt.c
index b53ab9c..0183e99 100644
--- a/xorg-server/mi/miglblt.c
+++ b/xorg-server/mi/miglblt.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/miinitext.c b/xorg-server/mi/miinitext.c
index 1d90516..5872bf5 100644
--- a/xorg-server/mi/miinitext.c
+++ b/xorg-server/mi/miinitext.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mioverlay.c b/xorg-server/mi/mioverlay.c
index eb8dda1..2b20fd7 100644
--- a/xorg-server/mi/mioverlay.c
+++ b/xorg-server/mi/mioverlay.c
@@ -1667,7 +1667,7 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
         freeTmpClip = FALSE;
     }
     freeCompClip = pGC->freeCompClip;
-    if (pGC->clientClipType == CT_NONE) {
+    if (!pGC->clientClip) {
         if (freeCompClip)
             RegionDestroy(pGC->pCompositeClip);
         pGC->pCompositeClip = pregWin;
diff --git a/xorg-server/mi/mipointer.c b/xorg-server/mi/mipointer.c
index 6fa416d..2bdd6ca 100644
--- a/xorg-server/mi/mipointer.c
+++ b/xorg-server/mi/mipointer.c
@@ -273,6 +273,20 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
     return TRUE;
 }
 
+void
+miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
+                CursorPtr pCurs, Bool displayed)
+{
+    /*
+     * This is guaranteed to correct any color-dependent state which may have
+     * been bound up in private state created by RealizeCursor
+     */
+    pScr->UnrealizeCursor(pDev, pScr, pCurs);
+    pScr->RealizeCursor(pDev, pScr, pCurs);
+    if (displayed)
+        pScr->DisplayCursor(pDev, pScr, pCurs);
+}
+
 /**
  * Set up sprite information for the device.
  * This function will be called once for each device after it is initialized
@@ -539,10 +553,15 @@ miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
  * The coordinates provided are always absolute. The parameter mode whether
  * it was relative or absolute movement that landed us at those coordinates.
  *
+ * If the cursor was constrained by a barrier, ET_Barrier* events may be
+ * generated and appended to the InternalEvent list provided.
+ *
  * @param pDev The device to move
  * @param mode Movement mode (Absolute or Relative)
  * @param[in,out] screenx The x coordinate in desktop coordinates
  * @param[in,out] screeny The y coordinate in desktop coordinates
+ * @param[in,out] nevents The number of events in events (before/after)
+ * @param[in,out] events The list of events before/after being constrained
  */
 ScreenPtr
 miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx,
diff --git a/xorg-server/mi/mipoly.c b/xorg-server/mi/mipoly.c
index 07d9818..a332376 100644
--- a/xorg-server/mi/mipoly.c
+++ b/xorg-server/mi/mipoly.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -47,11 +47,6 @@ SOFTWARE.
  *  mipoly.c
  *
  *  Written by Brian Kelleher; June 1986
- *
- *  Draw polygons.  This routine translates the point by the
- *  origin if pGC->miTranslate is non-zero, and calls
- *  to the appropriate routine to actually scan convert the
- *  polygon.
  */
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
@@ -62,8 +57,622 @@ SOFTWARE.
 #include "gcstruct.h"
 #include "pixmapstr.h"
 #include "mi.h"
+#include "miscanfill.h"
+#include "mipoly.h"
 #include "regionstr.h"
 
+/*
+ * Insert the given edge into the edge table.  First we must find the correct
+ * bucket in the Edge table, then find the right slot in the bucket.  Finally,
+ * we can insert it.
+ */
+static Bool
+miInsertEdgeInET(EdgeTable * ET, EdgeTableEntry * ETE, int scanline,
+                 ScanLineListBlock ** SLLBlock, int *iSLLBlock)
+{
+    EdgeTableEntry *start, *prev;
+    ScanLineList *pSLL, *pPrevSLL;
+    ScanLineListBlock *tmpSLLBlock;
+
+    /*
+     * find the right bucket to put the edge into
+     */
+    pPrevSLL = &ET->scanlines;
+    pSLL = pPrevSLL->next;
+    while (pSLL && (pSLL->scanline < scanline)) {
+        pPrevSLL = pSLL;
+        pSLL = pSLL->next;
+    }
+
+    /*
+     * reassign pSLL (pointer to ScanLineList) if necessary
+     */
+    if ((!pSLL) || (pSLL->scanline > scanline)) {
+        if (*iSLLBlock > SLLSPERBLOCK - 1) {
+            tmpSLLBlock = malloc(sizeof(ScanLineListBlock));
+            if (!tmpSLLBlock)
+                return FALSE;
+            (*SLLBlock)->next = tmpSLLBlock;
+            tmpSLLBlock->next = NULL;
+            *SLLBlock = tmpSLLBlock;
+            *iSLLBlock = 0;
+        }
+        pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
+
+        pSLL->next = pPrevSLL->next;
+        pSLL->edgelist = NULL;
+        pPrevSLL->next = pSLL;
+    }
+    pSLL->scanline = scanline;
+
+    /*
+     * now insert the edge in the right bucket
+     */
+    prev = NULL;
+    start = pSLL->edgelist;
+    while (start && (start->bres.minor < ETE->bres.minor)) {
+        prev = start;
+        start = start->next;
+    }
+    ETE->next = start;
+
+    if (prev)
+        prev->next = ETE;
+    else
+        pSLL->edgelist = ETE;
+    return TRUE;
+}
+
+static void
+miFreeStorage(ScanLineListBlock * pSLLBlock)
+{
+    ScanLineListBlock *tmpSLLBlock;
+
+    while (pSLLBlock) {
+        tmpSLLBlock = pSLLBlock->next;
+        free(pSLLBlock);
+        pSLLBlock = tmpSLLBlock;
+    }
+}
+
+/*
+ * CreateEdgeTable
+ *
+ * This routine creates the edge table for scan converting polygons.
+ * The Edge Table (ET) looks like:
+ *
+ * EdgeTable
+ *  --------
+ * |  ymax  |        ScanLineLists
+ * |scanline|-->------------>-------------->...
+ *  --------   |scanline|   |scanline|
+ *             |edgelist|   |edgelist|
+ *             ---------    ---------
+ *                 |             |
+ *                 |             |
+ *                 V             V
+ *           list of ETEs   list of ETEs
+ *
+ * where ETE is an EdgeTableEntry data structure, and there is one ScanLineList
+ * per scanline at which an edge is initially entered.
+ */
+
+static Bool
+miCreateETandAET(int count, DDXPointPtr pts, EdgeTable * ET,
+                 EdgeTableEntry * AET, EdgeTableEntry * pETEs,
+                 ScanLineListBlock * pSLLBlock)
+{
+    DDXPointPtr top, bottom;
+    DDXPointPtr PrevPt, CurrPt;
+    int iSLLBlock = 0;
+
+    int dy;
+
+    if (count < 2)
+        return TRUE;
+
+    /*
+     *  initialize the Active Edge Table
+     */
+    AET->next = NULL;
+    AET->back = NULL;
+    AET->nextWETE = NULL;
+    AET->bres.minor = MININT;
+
+    /*
+     *  initialize the Edge Table.
+     */
+    ET->scanlines.next = NULL;
+    ET->ymax = MININT;
+    ET->ymin = MAXINT;
+    pSLLBlock->next = NULL;
+
+    PrevPt = &pts[count - 1];
+
+    /*
+     *  for each vertex in the array of points.
+     *  In this loop we are dealing with two vertices at
+     *  a time -- these make up one edge of the polygon.
+     */
+    while (count--) {
+        CurrPt = pts++;
+
+        /*
+         *  find out which point is above and which is below.
+         */
+        if (PrevPt->y > CurrPt->y) {
+            bottom = PrevPt, top = CurrPt;
+            pETEs->ClockWise = 0;
+        }
+        else {
+            bottom = CurrPt, top = PrevPt;
+            pETEs->ClockWise = 1;
+        }
+
+        /*
+         * don't add horizontal edges to the Edge table.
+         */
+        if (bottom->y != top->y) {
+            pETEs->ymax = bottom->y - 1; /* -1 so we don't get last scanline */
+
+            /*
+             *  initialize integer edge algorithm
+             */
+            dy = bottom->y - top->y;
+            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
+
+            if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) {
+                miFreeStorage(pSLLBlock->next);
+                return FALSE;
+            }
+
+            ET->ymax = max(ET->ymax, PrevPt->y);
+            ET->ymin = min(ET->ymin, PrevPt->y);
+            pETEs++;
+        }
+
+        PrevPt = CurrPt;
+    }
+    return TRUE;
+}
+
+/*
+ * This routine moves EdgeTableEntries from the EdgeTable into the Active Edge
+ * Table, leaving them sorted by smaller x coordinate.
+ */
+
+static void
+miloadAET(EdgeTableEntry * AET, EdgeTableEntry * ETEs)
+{
+    EdgeTableEntry *pPrevAET;
+    EdgeTableEntry *tmp;
+
+    pPrevAET = AET;
+    AET = AET->next;
+    while (ETEs) {
+        while (AET && (AET->bres.minor < ETEs->bres.minor)) {
+            pPrevAET = AET;
+            AET = AET->next;
+        }
+        tmp = ETEs->next;
+        ETEs->next = AET;
+        if (AET)
+            AET->back = ETEs;
+        ETEs->back = pPrevAET;
+        pPrevAET->next = ETEs;
+        pPrevAET = ETEs;
+
+        ETEs = tmp;
+    }
+}
+
+/*
+ * computeWAET
+ *
+ * This routine links the AET by the nextWETE (winding EdgeTableEntry) link for
+ * use by the winding number rule.  The final Active Edge Table (AET) might
+ * look something like:
+ *
+ * AET
+ * ----------  ---------   ---------
+ * |ymax    |  |ymax    |  |ymax    |
+ * | ...    |  |...     |  |...     |
+ * |next    |->|next    |->|next    |->...
+ * |nextWETE|  |nextWETE|  |nextWETE|
+ * ---------   ---------   ^--------
+ *     |                   |       |
+ *     V------------------->       V---> ...
+ *
+ */
+static void
+micomputeWAET(EdgeTableEntry * AET)
+{
+    EdgeTableEntry *pWETE;
+    int inside = 1;
+    int isInside = 0;
+
+    AET->nextWETE = NULL;
+    pWETE = AET;
+    AET = AET->next;
+    while (AET) {
+        if (AET->ClockWise)
+            isInside++;
+        else
+            isInside--;
+
+        if ((!inside && !isInside) || (inside && isInside)) {
+            pWETE->nextWETE = AET;
+            pWETE = AET;
+            inside = !inside;
+        }
+        AET = AET->next;
+    }
+    pWETE->nextWETE = NULL;
+}
+
+/*
+ * Just a simple insertion sort using pointers and back pointers to sort the
+ * Active Edge Table.
+ */
+
+static int
+miInsertionSort(EdgeTableEntry * AET)
+{
+    EdgeTableEntry *pETEchase;
+    EdgeTableEntry *pETEinsert;
+    EdgeTableEntry *pETEchaseBackTMP;
+    int changed = 0;
+
+    AET = AET->next;
+    while (AET) {
+        pETEinsert = AET;
+        pETEchase = AET;
+        while (pETEchase->back->bres.minor > AET->bres.minor)
+            pETEchase = pETEchase->back;
+
+        AET = AET->next;
+        if (pETEchase != pETEinsert) {
+            pETEchaseBackTMP = pETEchase->back;
+            pETEinsert->back->next = AET;
+            if (AET)
+                AET->back = pETEinsert->back;
+            pETEinsert->next = pETEchase;
+            pETEchase->back->next = pETEinsert;
+            pETEchase->back = pETEinsert;
+            pETEinsert->back = pETEchaseBackTMP;
+            changed = 1;
+        }
+    }
+    return changed;
+}
+
+/* Find the index of the point with the smallest y */
+static int
+getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
+{
+    DDXPointPtr ptMin;
+    int ymin, ymax;
+    DDXPointPtr ptsStart = pts;
+
+    ptMin = pts;
+    ymin = ymax = (pts++)->y;
+
+    while (--n > 0) {
+        if (pts->y < ymin) {
+            ptMin = pts;
+            ymin = pts->y;
+        }
+        if (pts->y > ymax)
+            ymax = pts->y;
+
+        pts++;
+    }
+
+    *by = ymin;
+    *ty = ymax;
+    return ptMin - ptsStart;
+}
+
+/*
+ * Written by Brian Kelleher; Dec. 1985.
+ *
+ * Fill a convex polygon.  If the given polygon is not convex, then the result
+ * is undefined.  The algorithm is to order the edges from smallest y to
+ * largest by partitioning the array into a left edge list and a right edge
+ * list.  The algorithm used to traverse each edge is an extension of
+ * Bresenham's line algorithm with y as the major axis.  For a derivation of
+ * the algorithm, see the author of this code.
+ */
+static Bool
+miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
+{
+    int xl = 0, xr = 0;         /* x vals of left and right edges */
+    int dl = 0, dr = 0;         /* decision variables             */
+    int ml = 0, m1l = 0;        /* left edge slope and slope+1    */
+    int mr = 0, m1r = 0;        /* right edge slope and slope+1   */
+    int incr1l = 0, incr2l = 0; /* left edge error increments     */
+    int incr1r = 0, incr2r = 0; /* right edge error increments    */
+    int dy;                     /* delta y                        */
+    int y;                      /* current scanline               */
+    int left, right;            /* indices to first endpoints     */
+    int i;                      /* loop counter                   */
+    int nextleft, nextright;    /* indices to second endpoints    */
+    DDXPointPtr ptsOut, FirstPoint;     /* output buffer               */
+    int *width, *FirstWidth;    /* output buffer                  */
+    int imin;                   /* index of smallest vertex (in y) */
+    int ymin;                   /* y-extents of polygon            */
+    int ymax;
+
+    /*
+     *  find leftx, bottomy, rightx, topy, and the index
+     *  of bottomy. Also translate the points.
+     */
+    imin = getPolyYBounds(ptsIn, count, &ymin, &ymax);
+
+    dy = ymax - ymin + 1;
+    if ((count < 3) || (dy < 0))
+        return TRUE;
+    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
+    width = FirstWidth = malloc(sizeof(int) * dy);
+    if (!FirstPoint || !FirstWidth) {
+        free(FirstWidth);
+        free(FirstPoint);
+        return FALSE;
+    }
+
+    nextleft = nextright = imin;
+    y = ptsIn[nextleft].y;
+
+    /*
+     *  loop through all edges of the polygon
+     */
+    do {
+        /*
+         *  add a left edge if we need to
+         */
+        if (ptsIn[nextleft].y == y) {
+            left = nextleft;
+
+            /*
+             *  find the next edge, considering the end
+             *  conditions of the array.
+             */
+            nextleft++;
+            if (nextleft >= count)
+                nextleft = 0;
+
+            /*
+             *  now compute all of the random information
+             *  needed to run the iterative algorithm.
+             */
+            BRESINITPGON(ptsIn[nextleft].y - ptsIn[left].y,
+                         ptsIn[left].x, ptsIn[nextleft].x,
+                         xl, dl, ml, m1l, incr1l, incr2l);
+        }
+
+        /*
+         *  add a right edge if we need to
+         */
+        if (ptsIn[nextright].y == y) {
+            right = nextright;
+
+            /*
+             *  find the next edge, considering the end
+             *  conditions of the array.
+             */
+            nextright--;
+            if (nextright < 0)
+                nextright = count - 1;
+
+            /*
+             *  now compute all of the random information
+             *  needed to run the iterative algorithm.
+             */
+            BRESINITPGON(ptsIn[nextright].y - ptsIn[right].y,
+                         ptsIn[right].x, ptsIn[nextright].x,
+                         xr, dr, mr, m1r, incr1r, incr2r);
+        }
+
+        /*
+         *  generate scans to fill while we still have
+         *  a right edge as well as a left edge.
+         */
+        i = min(ptsIn[nextleft].y, ptsIn[nextright].y) - y;
+        /* in case we're called with non-convex polygon */
+        if (i < 0) {
+            free(FirstWidth);
+            free(FirstPoint);
+            return TRUE;
+        }
+        while (i-- > 0) {
+            ptsOut->y = y;
+
+            /*
+             *  reverse the edges if necessary
+             */
+            if (xl < xr) {
+                *(width++) = xr - xl;
+                (ptsOut++)->x = xl;
+            }
+            else {
+                *(width++) = xl - xr;
+                (ptsOut++)->x = xr;
+            }
+            y++;
+
+            /* increment down the edges */
+            BRESINCRPGON(dl, xl, ml, m1l, incr1l, incr2l);
+            BRESINCRPGON(dr, xr, mr, m1r, incr1r, incr2r);
+        }
+    } while (y != ymax);
+
+    /*
+     * Finally, fill the <remaining> spans
+     */
+    (*pgc->ops->FillSpans) (dst, pgc,
+                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
+    free(FirstWidth);
+    free(FirstPoint);
+    return TRUE;
+}
+
+/*
+ * Written by Brian Kelleher;  Oct. 1985
+ *
+ * Routine to fill a polygon.  Two fill rules are supported: frWINDING and
+ * frEVENODD.
+ */
+static Bool
+miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
+{
+    EdgeTableEntry *pAET;       /* the Active Edge Table   */
+    int y;                      /* the current scanline    */
+    int nPts = 0;               /* number of pts in buffer */
+    EdgeTableEntry *pWETE;      /* Winding Edge Table      */
+    ScanLineList *pSLL;         /* Current ScanLineList    */
+    DDXPointPtr ptsOut;         /* ptr to output buffers   */
+    int *width;
+    DDXPointRec FirstPoint[NUMPTSTOBUFFER];     /* the output buffers */
+    int FirstWidth[NUMPTSTOBUFFER];
+    EdgeTableEntry *pPrevAET;   /* previous AET entry      */
+    EdgeTable ET;               /* Edge Table header node  */
+    EdgeTableEntry AET;         /* Active ET header node   */
+    EdgeTableEntry *pETEs;      /* Edge Table Entries buff */
+    ScanLineListBlock SLLBlock; /* header for ScanLineList */
+    int fixWAET = 0;
+
+    if (count < 3)
+        return TRUE;
+
+    if (!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
+        return FALSE;
+    ptsOut = FirstPoint;
+    width = FirstWidth;
+    if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock)) {
+        free(pETEs);
+        return FALSE;
+    }
+    pSLL = ET.scanlines.next;
+
+    if (pgc->fillRule == EvenOddRule) {
+        /*
+         *  for each scanline
+         */
+        for (y = ET.ymin; y < ET.ymax; y++) {
+            /*
+             *  Add a new edge to the active edge table when we
+             *  get to the next edge.
+             */
+            if (pSLL && y == pSLL->scanline) {
+                miloadAET(&AET, pSLL->edgelist);
+                pSLL = pSLL->next;
+            }
+            pPrevAET = &AET;
+            pAET = AET.next;
+
+            /*
+             *  for each active edge
+             */
+            while (pAET) {
+                ptsOut->x = pAET->bres.minor;
+                ptsOut++->y = y;
+                *width++ = pAET->next->bres.minor - pAET->bres.minor;
+                nPts++;
+
+                /*
+                 *  send out the buffer when its full
+                 */
+                if (nPts == NUMPTSTOBUFFER) {
+                    (*pgc->ops->FillSpans) (dst, pgc,
+                                            nPts, FirstPoint, FirstWidth, 1);
+                    ptsOut = FirstPoint;
+                    width = FirstWidth;
+                    nPts = 0;
+                }
+                EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+                EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+            }
+            miInsertionSort(&AET);
+        }
+    }
+    else {                      /* default to WindingNumber */
+
+        /*
+         *  for each scanline
+         */
+        for (y = ET.ymin; y < ET.ymax; y++) {
+            /*
+             *  Add a new edge to the active edge table when we
+             *  get to the next edge.
+             */
+            if (pSLL && y == pSLL->scanline) {
+                miloadAET(&AET, pSLL->edgelist);
+                micomputeWAET(&AET);
+                pSLL = pSLL->next;
+            }
+            pPrevAET = &AET;
+            pAET = AET.next;
+            pWETE = pAET;
+
+            /*
+             *  for each active edge
+             */
+            while (pAET) {
+                /*
+                 *  if the next edge in the active edge table is
+                 *  also the next edge in the winding active edge
+                 *  table.
+                 */
+                if (pWETE == pAET) {
+                    ptsOut->x = pAET->bres.minor;
+                    ptsOut++->y = y;
+                    *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
+                    nPts++;
+
+                    /*
+                     *  send out the buffer
+                     */
+                    if (nPts == NUMPTSTOBUFFER) {
+                        (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint,
+                                                FirstWidth, 1);
+                        ptsOut = FirstPoint;
+                        width = FirstWidth;
+                        nPts = 0;
+                    }
+
+                    pWETE = pWETE->nextWETE;
+                    while (pWETE != pAET)
+                        EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+                    pWETE = pWETE->nextWETE;
+                }
+                EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+            }
+
+            /*
+             *  reevaluate the Winding active edge table if we
+             *  just had to resort it or if we just exited an edge.
+             */
+            if (miInsertionSort(&AET) || fixWAET) {
+                micomputeWAET(&AET);
+                fixWAET = 0;
+            }
+        }
+    }
+
+    /*
+     *     Get any spans that we missed by buffering
+     */
+    (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint, FirstWidth, 1);
+    free(pETEs);
+    miFreeStorage(SLLBlock.next);
+    return TRUE;
+}
+
+/*
+ *  Draw polygons.  This routine translates the point by the origin if
+ *  pGC->miTranslate is non-zero, and calls to the appropriate routine to
+ *  actually scan convert the polygon.
+ */
 void
 miFillPolygon(DrawablePtr dst, GCPtr pgc,
               int shape, int mode, int count, DDXPointPtr pPts)
diff --git a/xorg-server/mi/mipoly.h b/xorg-server/mi/mipoly.h
index e37fb48..d67a524 100644
--- a/xorg-server/mi/mipoly.h
+++ b/xorg-server/mi/mipoly.h
@@ -55,7 +55,7 @@ from The Open Group.
  *     the polygon by incrementing the y coordinate.  We
  *     keep a list of edges which the current scanline crosses,
  *     sorted by x.  This list is called the Active Edge Table (AET)
- *     As we change the y-coordinate, we update each entry in 
+ *     As we change the y-coordinate, we update each entry in
  *     in the active edge table to reflect the edges new xcoord.
  *     This list must be sorted at each scanline in case
  *     two edges intersect.
@@ -171,23 +171,3 @@ typedef struct _ScanLineListBlock {
       pAET = pAET->next; \
    } \
 }
-
-/* mipolyutil.c */
-
-extern _X_EXPORT Bool miCreateETandAET(int /*count */ ,
-                                       DDXPointPtr /*pts */ ,
-                                       EdgeTable * /*ET*/,
-                                       EdgeTableEntry * /*AET*/,
-                                       EdgeTableEntry * /*pETEs */ ,
-                                       ScanLineListBlock *      /*pSLLBlock */
-    );
-
-extern _X_EXPORT void miloadAET(EdgeTableEntry * /*AET*/, EdgeTableEntry *      /*ETEs */
-    );
-
-extern _X_EXPORT void micomputeWAET(EdgeTableEntry * /*AET*/);
-
-extern _X_EXPORT int miInsertionSort(EdgeTableEntry * /*AET*/);
-
-extern _X_EXPORT void miFreeStorage(ScanLineListBlock * /*pSLLBlock */
-    );
diff --git a/xorg-server/mi/mipolycon.c b/xorg-server/mi/mipolycon.c
deleted file mode 100644
index e831633..0000000
--- a/xorg-server/mi/mipolycon.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "gcstruct.h"
-#include "pixmap.h"
-#include "mi.h"
-#include "miscanfill.h"
-
-static int getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty);
-
-/*
- *     convexpoly.c
- *
- *     Written by Brian Kelleher; Dec. 1985.
- *
- *     Fill a convex polygon.  If the given polygon
- *     is not convex, then the result is undefined.
- *     The algorithm is to order the edges from smallest
- *     y to largest by partitioning the array into a left
- *     edge list and a right edge list.  The algorithm used
- *     to traverse each edge is an extension of Bresenham's
- *     line algorithm with y as the major axis.
- *     For a derivation of the algorithm, see the author of
- *     this code.
- */
-Bool
-miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points        */
-                 DDXPointPtr ptsIn      /* the points              */
-    )
-{
-    int xl = 0, xr = 0;         /* x vals of left and right edges */
-    int dl = 0, dr = 0;         /* decision variables             */
-    int ml = 0, m1l = 0;        /* left edge slope and slope+1    */
-    int mr = 0, m1r = 0;        /* right edge slope and slope+1   */
-    int incr1l = 0, incr2l = 0; /* left edge error increments     */
-    int incr1r = 0, incr2r = 0; /* right edge error increments    */
-    int dy;                     /* delta y                        */
-    int y;                      /* current scanline               */
-    int left, right;            /* indices to first endpoints     */
-    int i;                      /* loop counter                   */
-    int nextleft, nextright;    /* indices to second endpoints    */
-    DDXPointPtr ptsOut, FirstPoint;     /* output buffer               */
-    int *width, *FirstWidth;    /* output buffer                  */
-    int imin;                   /* index of smallest vertex (in y) */
-    int ymin;                   /* y-extents of polygon            */
-    int ymax;
-
-    /*
-     *  find leftx, bottomy, rightx, topy, and the index
-     *  of bottomy. Also translate the points.
-     */
-    imin = getPolyYBounds(ptsIn, count, &ymin, &ymax);
-
-    dy = ymax - ymin + 1;
-    if ((count < 3) || (dy < 0))
-        return TRUE;
-    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
-    width = FirstWidth = malloc(sizeof(int) * dy);
-    if (!FirstPoint || !FirstWidth) {
-        free(FirstWidth);
-        free(FirstPoint);
-        return FALSE;
-    }
-
-    nextleft = nextright = imin;
-    y = ptsIn[nextleft].y;
-
-    /*
-     *  loop through all edges of the polygon
-     */
-    do {
-        /*
-         *  add a left edge if we need to
-         */
-        if (ptsIn[nextleft].y == y) {
-            left = nextleft;
-
-            /*
-             *  find the next edge, considering the end
-             *  conditions of the array.
-             */
-            nextleft++;
-            if (nextleft >= count)
-                nextleft = 0;
-
-            /*
-             *  now compute all of the random information
-             *  needed to run the iterative algorithm.
-             */
-            BRESINITPGON(ptsIn[nextleft].y - ptsIn[left].y,
-                         ptsIn[left].x, ptsIn[nextleft].x,
-                         xl, dl, ml, m1l, incr1l, incr2l);
-        }
-
-        /*
-         *  add a right edge if we need to
-         */
-        if (ptsIn[nextright].y == y) {
-            right = nextright;
-
-            /*
-             *  find the next edge, considering the end
-             *  conditions of the array.
-             */
-            nextright--;
-            if (nextright < 0)
-                nextright = count - 1;
-
-            /*
-             *  now compute all of the random information
-             *  needed to run the iterative algorithm.
-             */
-            BRESINITPGON(ptsIn[nextright].y - ptsIn[right].y,
-                         ptsIn[right].x, ptsIn[nextright].x,
-                         xr, dr, mr, m1r, incr1r, incr2r);
-        }
-
-        /*
-         *  generate scans to fill while we still have
-         *  a right edge as well as a left edge.
-         */
-        i = min(ptsIn[nextleft].y, ptsIn[nextright].y) - y;
-        /* in case we're called with non-convex polygon */
-        if (i < 0) {
-            free(FirstWidth);
-            free(FirstPoint);
-            return TRUE;
-        }
-        while (i-- > 0) {
-            ptsOut->y = y;
-
-            /*
-             *  reverse the edges if necessary
-             */
-            if (xl < xr) {
-                *(width++) = xr - xl;
-                (ptsOut++)->x = xl;
-            }
-            else {
-                *(width++) = xl - xr;
-                (ptsOut++)->x = xr;
-            }
-            y++;
-
-            /* increment down the edges */
-            BRESINCRPGON(dl, xl, ml, m1l, incr1l, incr2l);
-            BRESINCRPGON(dr, xr, mr, m1r, incr1r, incr2r);
-        }
-    } while (y != ymax);
-
-    /*
-     * Finally, fill the <remaining> spans
-     */
-    (*pgc->ops->FillSpans) (dst, pgc,
-                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
-    free(FirstWidth);
-    free(FirstPoint);
-    return TRUE;
-}
-

-/*
- *     Find the index of the point with the smallest y.
- */
-static int
-getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
-{
-    DDXPointPtr ptMin;
-    int ymin, ymax;
-    DDXPointPtr ptsStart = pts;
-
-    ptMin = pts;
-    ymin = ymax = (pts++)->y;
-
-    while (--n > 0) {
-        if (pts->y < ymin) {
-            ptMin = pts;
-            ymin = pts->y;
-        }
-        if (pts->y > ymax)
-            ymax = pts->y;
-
-        pts++;
-    }
-
-    *by = ymin;
-    *ty = ymax;
-    return ptMin - ptsStart;
-}
diff --git a/xorg-server/mi/mipolygen.c b/xorg-server/mi/mipolygen.c
deleted file mode 100644
index 2031b42..0000000
--- a/xorg-server/mi/mipolygen.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include "gcstruct.h"
-#include "miscanfill.h"
-#include "mipoly.h"
-#include "pixmap.h"
-#include "mi.h"
-
-/*
- *
- *     Written by Brian Kelleher;  Oct. 1985
- *
- *     Routine to fill a polygon.  Two fill rules are
- *     supported: frWINDING and frEVENODD.
- *
- *     See fillpoly.h for a complete description of the algorithm.
- */
-
-Bool
-miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count,        /* number of points        */
-                  DDXPointPtr ptsIn     /* the points              */
-    )
-{
-    EdgeTableEntry *pAET;       /* the Active Edge Table   */
-    int y;                      /* the current scanline    */
-    int nPts = 0;               /* number of pts in buffer */
-    EdgeTableEntry *pWETE;      /* Winding Edge Table      */
-    ScanLineList *pSLL;         /* Current ScanLineList    */
-    DDXPointPtr ptsOut;         /* ptr to output buffers   */
-    int *width;
-    DDXPointRec FirstPoint[NUMPTSTOBUFFER];     /* the output buffers */
-    int FirstWidth[NUMPTSTOBUFFER];
-    EdgeTableEntry *pPrevAET;   /* previous AET entry      */
-    EdgeTable ET;               /* Edge Table header node  */
-    EdgeTableEntry AET;         /* Active ET header node   */
-    EdgeTableEntry *pETEs;      /* Edge Table Entries buff */
-    ScanLineListBlock SLLBlock; /* header for ScanLineList */
-    int fixWAET = 0;
-
-    if (count < 3)
-        return TRUE;
-
-    if (!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
-        return FALSE;
-    ptsOut = FirstPoint;
-    width = FirstWidth;
-    if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock)) {
-        free(pETEs);
-        return FALSE;
-    }
-    pSLL = ET.scanlines.next;
-
-    if (pgc->fillRule == EvenOddRule) {
-        /*
-         *  for each scanline
-         */
-        for (y = ET.ymin; y < ET.ymax; y++) {
-            /*
-             *  Add a new edge to the active edge table when we
-             *  get to the next edge.
-             */
-            if (pSLL && y == pSLL->scanline) {
-                miloadAET(&AET, pSLL->edgelist);
-                pSLL = pSLL->next;
-            }
-            pPrevAET = &AET;
-            pAET = AET.next;
-
-            /*
-             *  for each active edge
-             */
-            while (pAET) {
-                ptsOut->x = pAET->bres.minor;
-                ptsOut++->y = y;
-                *width++ = pAET->next->bres.minor - pAET->bres.minor;
-                nPts++;
-
-                /*
-                 *  send out the buffer when its full
-                 */
-                if (nPts == NUMPTSTOBUFFER) {
-                    (*pgc->ops->FillSpans) (dst, pgc,
-                                            nPts, FirstPoint, FirstWidth, 1);
-                    ptsOut = FirstPoint;
-                    width = FirstWidth;
-                    nPts = 0;
-                }
-                EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
-                    EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
-            }
-            miInsertionSort(&AET);
-        }
-    }
-    else {                      /* default to WindingNumber */
-
-        /*
-         *  for each scanline
-         */
-        for (y = ET.ymin; y < ET.ymax; y++) {
-            /*
-             *  Add a new edge to the active edge table when we
-             *  get to the next edge.
-             */
-            if (pSLL && y == pSLL->scanline) {
-                miloadAET(&AET, pSLL->edgelist);
-                micomputeWAET(&AET);
-                pSLL = pSLL->next;
-            }
-            pPrevAET = &AET;
-            pAET = AET.next;
-            pWETE = pAET;
-
-            /*
-             *  for each active edge
-             */
-            while (pAET) {
-                /*
-                 *  if the next edge in the active edge table is
-                 *  also the next edge in the winding active edge
-                 *  table.
-                 */
-                if (pWETE == pAET) {
-                    ptsOut->x = pAET->bres.minor;
-                    ptsOut++->y = y;
-                    *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
-                    nPts++;
-
-                    /*
-                     *  send out the buffer
-                     */
-                    if (nPts == NUMPTSTOBUFFER) {
-                        (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint,
-                                                FirstWidth, 1);
-                        ptsOut = FirstPoint;
-                        width = FirstWidth;
-                        nPts = 0;
-                    }
-
-                    pWETE = pWETE->nextWETE;
-                    while (pWETE != pAET)
-                        EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
-                    pWETE = pWETE->nextWETE;
-                }
-                EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
-            }
-
-            /*
-             *  reevaluate the Winding active edge table if we
-             *  just had to resort it or if we just exited an edge.
-             */
-            if (miInsertionSort(&AET) || fixWAET) {
-                micomputeWAET(&AET);
-                fixWAET = 0;
-            }
-        }
-    }
-
-    /*
-     *     Get any spans that we missed by buffering
-     */
-    (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint, FirstWidth, 1);
-    free(pETEs);
-    miFreeStorage(SLLBlock.next);
-    return TRUE;
-}
diff --git a/xorg-server/mi/mipolypnt.c b/xorg-server/mi/mipolypnt.c
index 086502b..4fa521d 100644
--- a/xorg-server/mi/mipolypnt.c
+++ b/xorg-server/mi/mipolypnt.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mipolyrect.c b/xorg-server/mi/mipolyrect.c
index e316ae0..8308225 100644
--- a/xorg-server/mi/mipolyrect.c
+++ b/xorg-server/mi/mipolyrect.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mipolyseg.c b/xorg-server/mi/mipolyseg.c
index d6f1807..7909b39 100644
--- a/xorg-server/mi/mipolyseg.c
+++ b/xorg-server/mi/mipolyseg.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -61,7 +61,7 @@ SOFTWARE.
  *    lines are drawn in the order listed.
  *
  *    Walks the segments, compressing them into format for PolyLines.
- *    
+ *
  *****************************************************************/
 
 void
diff --git a/xorg-server/mi/mipolytext.c b/xorg-server/mi/mipolytext.c
index 02c4588..f1e5ed8 100644
--- a/xorg-server/mi/mipolytext.c
+++ b/xorg-server/mi/mipolytext.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mipolyutil.c b/xorg-server/mi/mipolyutil.c
deleted file mode 100644
index 5e6301d..0000000
--- a/xorg-server/mi/mipolyutil.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "regionstr.h"
-#include "gc.h"
-#include "miscanfill.h"
-#include "mipoly.h"
-#include "misc.h"               /* MAXINT */
-
-/*
- *     fillUtils.c
- *
- *     Written by Brian Kelleher;  Oct. 1985
- *
- *     This module contains all of the utility functions
- *     needed to scan convert a polygon.
- *
- */
-

-/*
- *     InsertEdgeInET
- *
- *     Insert the given edge into the edge table.
- *     First we must find the correct bucket in the
- *     Edge table, then find the right slot in the
- *     bucket.  Finally, we can insert it.
- *
- */
-static Bool
-miInsertEdgeInET(EdgeTable * ET, EdgeTableEntry * ETE, int scanline,
-                 ScanLineListBlock ** SLLBlock, int *iSLLBlock)
-{
-    EdgeTableEntry *start, *prev;
-    ScanLineList *pSLL, *pPrevSLL;
-    ScanLineListBlock *tmpSLLBlock;
-
-    /*
-     * find the right bucket to put the edge into
-     */
-    pPrevSLL = &ET->scanlines;
-    pSLL = pPrevSLL->next;
-    while (pSLL && (pSLL->scanline < scanline)) {
-        pPrevSLL = pSLL;
-        pSLL = pSLL->next;
-    }
-
-    /*
-     * reassign pSLL (pointer to ScanLineList) if necessary
-     */
-    if ((!pSLL) || (pSLL->scanline > scanline)) {
-        if (*iSLLBlock > SLLSPERBLOCK - 1) {
-            tmpSLLBlock = malloc(sizeof(ScanLineListBlock));
-            if (!tmpSLLBlock)
-                return FALSE;
-            (*SLLBlock)->next = tmpSLLBlock;
-            tmpSLLBlock->next = NULL;
-            *SLLBlock = tmpSLLBlock;
-            *iSLLBlock = 0;
-        }
-        pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
-
-        pSLL->next = pPrevSLL->next;
-        pSLL->edgelist = NULL;
-        pPrevSLL->next = pSLL;
-    }
-    pSLL->scanline = scanline;
-
-    /*
-     * now insert the edge in the right bucket
-     */
-    prev = NULL;
-    start = pSLL->edgelist;
-    while (start && (start->bres.minor < ETE->bres.minor)) {
-        prev = start;
-        start = start->next;
-    }
-    ETE->next = start;
-
-    if (prev)
-        prev->next = ETE;
-    else
-        pSLL->edgelist = ETE;
-    return TRUE;
-}
-

-/*
- *     CreateEdgeTable
- *
- *     This routine creates the edge table for
- *     scan converting polygons. 
- *     The Edge Table (ET) looks like:
- *
- *    EdgeTable
- *     --------
- *    |  ymax  |        ScanLineLists
- *    |scanline|-->------------>-------------->...
- *     --------   |scanline|   |scanline|
- *                |edgelist|   |edgelist|
- *                ---------    ---------
- *                    |             |
- *                    |             |
- *                    V             V
- *              list of ETEs   list of ETEs
- *
- *     where ETE is an EdgeTableEntry data structure,
- *     and there is one ScanLineList per scanline at
- *     which an edge is initially entered.
- *
- */
-
-Bool
-miCreateETandAET(int count, DDXPointPtr pts, EdgeTable * ET,
-                 EdgeTableEntry * AET, EdgeTableEntry * pETEs,
-                 ScanLineListBlock * pSLLBlock)
-{
-    DDXPointPtr top, bottom;
-    DDXPointPtr PrevPt, CurrPt;
-    int iSLLBlock = 0;
-
-    int dy;
-
-    if (count < 2)
-        return TRUE;
-
-    /*
-     *  initialize the Active Edge Table
-     */
-    AET->next = NULL;
-    AET->back = NULL;
-    AET->nextWETE = NULL;
-    AET->bres.minor = MININT;
-
-    /*
-     *  initialize the Edge Table.
-     */
-    ET->scanlines.next = NULL;
-    ET->ymax = MININT;
-    ET->ymin = MAXINT;
-    pSLLBlock->next = NULL;
-
-    PrevPt = &pts[count - 1];
-
-    /*
-     *  for each vertex in the array of points.
-     *  In this loop we are dealing with two vertices at
-     *  a time -- these make up one edge of the polygon.
-     */
-    while (count--) {
-        CurrPt = pts++;
-
-        /*
-         *  find out which point is above and which is below.
-         */
-        if (PrevPt->y > CurrPt->y) {
-            bottom = PrevPt, top = CurrPt;
-            pETEs->ClockWise = 0;
-        }
-        else {
-            bottom = CurrPt, top = PrevPt;
-            pETEs->ClockWise = 1;
-        }
-
-        /*
-         * don't add horizontal edges to the Edge table.
-         */
-        if (bottom->y != top->y) {
-            pETEs->ymax = bottom->y - 1;        /* -1 so we don't get last scanline */
-
-            /*
-             *  initialize integer edge algorithm
-             */
-            dy = bottom->y - top->y;
-            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
-
-            if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) {
-                miFreeStorage(pSLLBlock->next);
-                return FALSE;
-            }
-
-            ET->ymax = max(ET->ymax, PrevPt->y);
-            ET->ymin = min(ET->ymin, PrevPt->y);
-            pETEs++;
-        }
-
-        PrevPt = CurrPt;
-    }
-    return TRUE;
-}
-

-/*
- *     loadAET
- *
- *     This routine moves EdgeTableEntries from the
- *     EdgeTable into the Active Edge Table,
- *     leaving them sorted by smaller x coordinate.
- *
- */
-
-void
-miloadAET(EdgeTableEntry * AET, EdgeTableEntry * ETEs)
-{
-    EdgeTableEntry *pPrevAET;
-    EdgeTableEntry *tmp;
-
-    pPrevAET = AET;
-    AET = AET->next;
-    while (ETEs) {
-        while (AET && (AET->bres.minor < ETEs->bres.minor)) {
-            pPrevAET = AET;
-            AET = AET->next;
-        }
-        tmp = ETEs->next;
-        ETEs->next = AET;
-        if (AET)
-            AET->back = ETEs;
-        ETEs->back = pPrevAET;
-        pPrevAET->next = ETEs;
-        pPrevAET = ETEs;
-
-        ETEs = tmp;
-    }
-}
-

-/*
- *     computeWAET
- *
- *     This routine links the AET by the
- *     nextWETE (winding EdgeTableEntry) link for
- *     use by the winding number rule.  The final 
- *     Active Edge Table (AET) might look something
- *     like:
- *
- *     AET
- *     ----------  ---------   ---------
- *     |ymax    |  |ymax    |  |ymax    | 
- *     | ...    |  |...     |  |...     |
- *     |next    |->|next    |->|next    |->...
- *     |nextWETE|  |nextWETE|  |nextWETE|
- *     ---------   ---------   ^--------
- *         |                   |       |
- *         V------------------->       V---> ...
- *
- */
-void
-micomputeWAET(EdgeTableEntry * AET)
-{
-    EdgeTableEntry *pWETE;
-    int inside = 1;
-    int isInside = 0;
-
-    AET->nextWETE = NULL;
-    pWETE = AET;
-    AET = AET->next;
-    while (AET) {
-        if (AET->ClockWise)
-            isInside++;
-        else
-            isInside--;
-
-        if ((!inside && !isInside) || (inside && isInside)) {
-            pWETE->nextWETE = AET;
-            pWETE = AET;
-            inside = !inside;
-        }
-        AET = AET->next;
-    }
-    pWETE->nextWETE = NULL;
-}
-

-/*
- *     InsertionSort
- *
- *     Just a simple insertion sort using
- *     pointers and back pointers to sort the Active
- *     Edge Table.
- *
- */
-
-int
-miInsertionSort(EdgeTableEntry * AET)
-{
-    EdgeTableEntry *pETEchase;
-    EdgeTableEntry *pETEinsert;
-    EdgeTableEntry *pETEchaseBackTMP;
-    int changed = 0;
-
-    AET = AET->next;
-    while (AET) {
-        pETEinsert = AET;
-        pETEchase = AET;
-        while (pETEchase->back->bres.minor > AET->bres.minor)
-            pETEchase = pETEchase->back;
-
-        AET = AET->next;
-        if (pETEchase != pETEinsert) {
-            pETEchaseBackTMP = pETEchase->back;
-            pETEinsert->back->next = AET;
-            if (AET)
-                AET->back = pETEinsert->back;
-            pETEinsert->next = pETEchase;
-            pETEchase->back->next = pETEinsert;
-            pETEchase->back = pETEinsert;
-            pETEinsert->back = pETEchaseBackTMP;
-            changed = 1;
-        }
-    }
-    return changed;
-}
-

-/*
- *     Clean up our act.
- */
-void
-miFreeStorage(ScanLineListBlock * pSLLBlock)
-{
-    ScanLineListBlock *tmpSLLBlock;
-
-    while (pSLLBlock) {
-        tmpSLLBlock = pSLLBlock->next;
-        free(pSLLBlock);
-        pSLLBlock = tmpSLLBlock;
-    }
-}
diff --git a/xorg-server/mi/mipushpxl.c b/xorg-server/mi/mipushpxl.c
index 9a78f40..f6a1b52 100644
--- a/xorg-server/mi/mipushpxl.c
+++ b/xorg-server/mi/mipushpxl.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/miscrinit.c b/xorg-server/mi/miscrinit.c
index 327bd15..b53c7e4 100644
--- a/xorg-server/mi/miscrinit.c
+++ b/xorg-server/mi/miscrinit.c
@@ -45,7 +45,7 @@ from The Open Group.
 
 /* We use this structure to propogate some information from miScreenInit to
  * miCreateScreenResources.  miScreenInit allocates the structure, fills it
- * in, and puts it into pScreen->devPrivate.  miCreateScreenResources 
+ * in, and puts it into pScreen->devPrivate.  miCreateScreenResources
  * extracts the info and frees the structure.  We could've accomplished the
  * same thing by adding fields to the screen structure, but they would have
  * ended up being redundant, and would have exposed this mi implementation
diff --git a/xorg-server/mi/mispans.c b/xorg-server/mi/mispans.c
deleted file mode 100644
index 11c8a43..0000000
--- a/xorg-server/mi/mispans.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/***********************************************************
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "misc.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#include "mispans.h"
-
-/*
-
-These routines maintain lists of Spans, in order to implement the
-``touch-each-pixel-once'' rules of wide lines and arcs.
-
-Written by Joel McCormack, Summer 1989.
-
-*/
-
-void
-miInitSpanGroup(SpanGroup * spanGroup)
-{
-    spanGroup->size = 0;
-    spanGroup->count = 0;
-    spanGroup->group = NULL;
-    spanGroup->ymin = MAXSHORT;
-    spanGroup->ymax = MINSHORT;
-}                               /* InitSpanGroup */
-
-#define YMIN(spans) (spans->points[0].y)
-#define YMAX(spans)  (spans->points[spans->count-1].y)
-
-static void
-miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
-{
-    int i, subCount, spansCount;
-    int ymin, ymax, xmin, xmax;
-    Spans *spans;
-    DDXPointPtr subPt, spansPt;
-    int *subWid, *spansWid;
-    int extra;
-
-    ymin = YMIN(sub);
-    ymax = YMAX(sub);
-    spans = spanGroup->group;
-    for (i = spanGroup->count; i; i--, spans++) {
-        if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
-            subCount = sub->count;
-            subPt = sub->points;
-            subWid = sub->widths;
-            spansCount = spans->count;
-            spansPt = spans->points;
-            spansWid = spans->widths;
-            extra = 0;
-            for (;;) {
-                while (spansCount && spansPt->y < subPt->y) {
-                    spansPt++;
-                    spansWid++;
-                    spansCount--;
-                }
-                if (!spansCount)
-                    break;
-                while (subCount && subPt->y < spansPt->y) {
-                    subPt++;
-                    subWid++;
-                    subCount--;
-                }
-                if (!subCount)
-                    break;
-                if (subPt->y == spansPt->y) {
-                    xmin = subPt->x;
-                    xmax = xmin + *subWid;
-                    if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax) {
-                        ;
-                    }
-                    else if (xmin <= spansPt->x) {
-                        if (xmax >= spansPt->x + *spansWid) {
-                            memmove(spansPt, spansPt + 1,
-                                    sizeof *spansPt * (spansCount - 1));
-                            memmove(spansWid, spansWid + 1,
-                                    sizeof *spansWid * (spansCount - 1));
-                            spansPt--;
-                            spansWid--;
-                            spans->count--;
-                            extra++;
-                        }
-                        else {
-                            *spansWid = *spansWid - (xmax - spansPt->x);
-                            spansPt->x = xmax;
-                        }
-                    }
-                    else {
-                        if (xmax >= spansPt->x + *spansWid) {
-                            *spansWid = xmin - spansPt->x;
-                        }
-                        else {
-                            if (!extra) {
-                                DDXPointPtr newPt;
-                                int *newwid;
-
-#define EXTRA 8
-                                newPt =
-                                    (DDXPointPtr) realloc(spans->points,
-                                                          (spans->count +
-                                                           EXTRA) *
-                                                          sizeof(DDXPointRec));
-                                if (!newPt)
-                                    break;
-                                spansPt = newPt + (spansPt - spans->points);
-                                spans->points = newPt;
-                                newwid =
-                                    (int *) realloc(spans->widths,
-                                                    (spans->count +
-                                                     EXTRA) * sizeof(int));
-                                if (!newwid)
-                                    break;
-                                spansWid = newwid + (spansWid - spans->widths);
-                                spans->widths = newwid;
-                                extra = EXTRA;
-                            }
-                            memmove(spansPt + 1, spansPt,
-                                    sizeof *spansPt * (spansCount));
-                            memmove(spansWid + 1, spansWid,
-                                    sizeof *spansWid * (spansCount));
-                            spans->count++;
-                            extra--;
-                            *spansWid = xmin - spansPt->x;
-                            spansWid++;
-                            spansPt++;
-                            *spansWid = *spansWid - (xmax - spansPt->x);
-                            spansPt->x = xmax;
-                        }
-                    }
-                }
-                spansPt++;
-                spansWid++;
-                spansCount--;
-            }
-        }
-    }
-}
-
-void
-miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
-{
-    int ymin, ymax;
-    int spansCount;
-
-    spansCount = spans->count;
-    if (spansCount > 0) {
-        if (spanGroup->size == spanGroup->count) {
-            spanGroup->size = (spanGroup->size + 8) * 2;
-            spanGroup->group = (Spans *)
-                realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
-        }
-
-        spanGroup->group[spanGroup->count] = *spans;
-        (spanGroup->count)++;
-        ymin = spans->points[0].y;
-        if (ymin < spanGroup->ymin)
-            spanGroup->ymin = ymin;
-        ymax = spans->points[spansCount - 1].y;
-        if (ymax > spanGroup->ymax)
-            spanGroup->ymax = ymax;
-        if (otherGroup && otherGroup->ymin < ymax && ymin < otherGroup->ymax) {
-            miSubtractSpans(otherGroup, spans);
-        }
-    }
-    else {
-        free(spans->points);
-        free(spans->widths);
-    }
-}                               /* AppendSpans */
-
-void
-miFreeSpanGroup(SpanGroup * spanGroup)
-{
-    free(spanGroup->group);
-}
-
-static void
-QuickSortSpansX(DDXPointRec points[], int widths[], int numSpans)
-{
-    int x;
-    int i, j, m;
-    DDXPointPtr r;
-
-/* Always called with numSpans > 1 */
-/* Sorts only by x, as all y should be the same */
-
-#define ExchangeSpans(a, b)				    \
-{							    \
-    DDXPointRec 	tpt;				    \
-    int    		tw;				    \
-							    \
-    tpt = points[a]; points[a] = points[b]; points[b] = tpt;    \
-    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
-}
-
-    do {
-        if (numSpans < 9) {
-            /* Do insertion sort */
-            int xprev;
-
-            xprev = points[0].x;
-            i = 1;
-            do {                /* while i != numSpans */
-                x = points[i].x;
-                if (xprev > x) {
-                    /* points[i] is out of order.  Move into proper location. */
-                    DDXPointRec tpt;
-                    int tw, k;
-
-                    for (j = 0; x >= points[j].x; j++) {
-                    }
-                    tpt = points[i];
-                    tw = widths[i];
-                    for (k = i; k != j; k--) {
-                        points[k] = points[k - 1];
-                        widths[k] = widths[k - 1];
-                    }
-                    points[j] = tpt;
-                    widths[j] = tw;
-                    x = points[i].x;
-                }               /* if out of order */
-                xprev = x;
-                i++;
-            } while (i != numSpans);
-            return;
-        }
-
-        /* Choose partition element, stick in location 0 */
-        m = numSpans / 2;
-        if (points[m].x > points[0].x)
-            ExchangeSpans(m, 0);
-        if (points[m].x > points[numSpans - 1].x)
-            ExchangeSpans(m, numSpans - 1);
-        if (points[m].x > points[0].x)
-            ExchangeSpans(m, 0);
-        x = points[0].x;
-
-        /* Partition array */
-        i = 0;
-        j = numSpans;
-        do {
-            r = &(points[i]);
-            do {
-                r++;
-                i++;
-            } while (i != numSpans && r->x < x);
-            r = &(points[j]);
-            do {
-                r--;
-                j--;
-            } while (x < r->x);
-            if (i < j)
-                ExchangeSpans(i, j);
-        } while (i < j);
-
-        /* Move partition element back to middle */
-        ExchangeSpans(0, j);
-
-        /* Recurse */
-        if (numSpans - j - 1 > 1)
-            QuickSortSpansX(&points[j + 1], &widths[j + 1], numSpans - j - 1);
-        numSpans = j;
-    } while (numSpans > 1);
-}                               /* QuickSortSpans */
-
-static int
-UniquifySpansX(Spans * spans, DDXPointRec * newPoints, int *newWidths)
-{
-    int newx1, newx2, oldpt, i, y;
-    DDXPointRec *oldPoints;
-    int *oldWidths;
-    int *startNewWidths;
-
-/* Always called with numSpans > 1 */
-/* Uniquify the spans, and stash them into newPoints and newWidths.  Return the
-   number of unique spans. */
-
-    startNewWidths = newWidths;
-
-    oldPoints = spans->points;
-    oldWidths = spans->widths;
-
-    y = oldPoints->y;
-    newx1 = oldPoints->x;
-    newx2 = newx1 + *oldWidths;
-
-    for (i = spans->count - 1; i != 0; i--) {
-        oldPoints++;
-        oldWidths++;
-        oldpt = oldPoints->x;
-        if (oldpt > newx2) {
-            /* Write current span, start a new one */
-            newPoints->x = newx1;
-            newPoints->y = y;
-            *newWidths = newx2 - newx1;
-            newPoints++;
-            newWidths++;
-            newx1 = oldpt;
-            newx2 = oldpt + *oldWidths;
-        }
-        else {
-            /* extend current span, if old extends beyond new */
-            oldpt = oldpt + *oldWidths;
-            if (oldpt > newx2)
-                newx2 = oldpt;
-        }
-    }                           /* for */
-
-    /* Write final span */
-    newPoints->x = newx1;
-    *newWidths = newx2 - newx1;
-    newPoints->y = y;
-
-    return (newWidths - startNewWidths) + 1;
-}                               /* UniquifySpansX */
-
-static void
-miDisposeSpanGroup(SpanGroup * spanGroup)
-{
-    int i;
-    Spans *spans;
-
-    for (i = 0; i < spanGroup->count; i++) {
-        spans = spanGroup->group + i;
-        free(spans->points);
-        free(spans->widths);
-    }
-}
-
-void
-miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
-{
-    int i;
-    Spans *spans;
-    Spans *yspans;
-    int *ysizes;
-    int ymin, ylength;
-
-    /* Outgoing spans for one big call to FillSpans */
-    DDXPointPtr points;
-    int *widths;
-    int count;
-
-    if (spanGroup->count == 0)
-        return;
-
-    if (spanGroup->count == 1) {
-        /* Already should be sorted, unique */
-        spans = spanGroup->group;
-        (*pGC->ops->FillSpans)
-            (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
-        free(spans->points);
-        free(spans->widths);
-    }
-    else {
-        /* Yuck.  Gross.  Radix sort into y buckets, then sort x and uniquify */
-        /* This seems to be the fastest thing to do.  I've tried sorting on
-           both x and y at the same time rather than creating into all those
-           y buckets, but it was somewhat slower. */
-
-        ymin = spanGroup->ymin;
-        ylength = spanGroup->ymax - ymin + 1;
-
-        /* Allocate Spans for y buckets */
-        yspans = malloc(ylength * sizeof(Spans));
-        ysizes = malloc(ylength * sizeof(int));
-
-        if (!yspans || !ysizes) {
-            free(yspans);
-            free(ysizes);
-            miDisposeSpanGroup(spanGroup);
-            return;
-        }
-
-        for (i = 0; i != ylength; i++) {
-            ysizes[i] = 0;
-            yspans[i].count = 0;
-            yspans[i].points = NULL;
-            yspans[i].widths = NULL;
-        }
-
-        /* Go through every single span and put it into the correct bucket */
-        count = 0;
-        for (i = 0, spans = spanGroup->group;
-             i != spanGroup->count; i++, spans++) {
-            int index;
-            int j;
-
-            for (j = 0, points = spans->points, widths = spans->widths;
-                 j != spans->count; j++, points++, widths++) {
-                index = points->y - ymin;
-                if (index >= 0 && index < ylength) {
-                    Spans *newspans = &(yspans[index]);
-
-                    if (newspans->count == ysizes[index]) {
-                        DDXPointPtr newpoints;
-                        int *newwidths;
-
-                        ysizes[index] = (ysizes[index] + 8) * 2;
-                        newpoints = (DDXPointPtr) realloc(newspans->points,
-                                                          ysizes[index] *
-                                                          sizeof(DDXPointRec));
-                        newwidths =
-                            (int *) realloc(newspans->widths,
-                                            ysizes[index] * sizeof(int));
-                        if (!newpoints || !newwidths) {
-                            for (i = 0; i < ylength; i++) {
-                                free(yspans[i].points);
-                                free(yspans[i].widths);
-                            }
-                            free(yspans);
-                            free(ysizes);
-                            free(newpoints);
-                            free(newwidths);
-                            miDisposeSpanGroup(spanGroup);
-                            return;
-                        }
-                        newspans->points = newpoints;
-                        newspans->widths = newwidths;
-                    }
-                    newspans->points[newspans->count] = *points;
-                    newspans->widths[newspans->count] = *widths;
-                    (newspans->count)++;
-                }               /* if y value of span in range */
-            }                   /* for j through spans */
-            count += spans->count;
-            free(spans->points);
-            spans->points = NULL;
-            free(spans->widths);
-            spans->widths = NULL;
-        }                       /* for i thorough Spans */
-
-        /* Now sort by x and uniquify each bucket into the final array */
-        points = malloc(count * sizeof(DDXPointRec));
-        widths = malloc(count * sizeof(int));
-        if (!points || !widths) {
-            for (i = 0; i < ylength; i++) {
-                free(yspans[i].points);
-                free(yspans[i].widths);
-            }
-            free(yspans);
-            free(ysizes);
-            free(points);
-            free(widths);
-            return;
-        }
-        count = 0;
-        for (i = 0; i != ylength; i++) {
-            int ycount = yspans[i].count;
-
-            if (ycount > 0) {
-                if (ycount > 1) {
-                    QuickSortSpansX(yspans[i].points, yspans[i].widths, ycount);
-                    count += UniquifySpansX
-                        (&(yspans[i]), &(points[count]), &(widths[count]));
-                }
-                else {
-                    points[count] = yspans[i].points[0];
-                    widths[count] = yspans[i].widths[0];
-                    count++;
-                }
-                free(yspans[i].points);
-                free(yspans[i].widths);
-            }
-        }
-
-        (*pGC->ops->FillSpans) (pDraw, pGC, count, points, widths, TRUE);
-        free(points);
-        free(widths);
-        free(yspans);
-        free(ysizes);           /* use (DE)xalloc for these? */
-    }
-
-    spanGroup->count = 0;
-    spanGroup->ymin = MAXSHORT;
-    spanGroup->ymax = MINSHORT;
-}
diff --git a/xorg-server/mi/mispans.h b/xorg-server/mi/mispans.h
deleted file mode 100644
index f3148ff..0000000
--- a/xorg-server/mi/mispans.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/***********************************************************
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice 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 NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifndef MISPANS_H
-#define MISPANS_H
-
-typedef struct {
-    int count;                  /* number of spans                  */
-    DDXPointPtr points;         /* pointer to list of start points  */
-    int *widths;                /* pointer to list of widths        */
-} Spans;
-
-typedef struct {
-    int size;                   /* Total number of *Spans allocated     */
-    int count;                  /* Number of *Spans actually in group   */
-    Spans *group;               /* List of Spans                        */
-    int ymin, ymax;             /* Min, max y values encountered        */
-} SpanGroup;
-
-/* Initialize SpanGroup.  MUST BE DONE before use. */
-extern _X_EXPORT void miInitSpanGroup(SpanGroup *       /*spanGroup */
-    );
-
-/* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */
-extern _X_EXPORT void miAppendSpans(SpanGroup * /*spanGroup */ ,
-                                    SpanGroup * /*otherGroup */ ,
-                                    Spans *     /*spans */
-    );
-
-/* Paint a span group, insuring that each pixel is painted at most once */
-extern _X_EXPORT void miFillUniqueSpanGroup(DrawablePtr /*pDraw */ ,
-                                            GCPtr /*pGC */ ,
-                                            SpanGroup * /*spanGroup */
-    );
-
-/* Free up data in a span group.  MUST BE DONE or you'll suffer memory leaks */
-extern _X_EXPORT void miFreeSpanGroup(SpanGroup *       /*spanGroup */
-    );
-
-/* Rops which must use span groups */
-#define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
-#define miSpansEasyRop(rop)	(!miSpansCarefulRop(rop))
-
-#endif                          /* MISPANS_H */
diff --git a/xorg-server/mi/mistruct.h b/xorg-server/mi/mistruct.h
index 17f7d83..00856f1 100644
--- a/xorg-server/mi/mistruct.h
+++ b/xorg-server/mi/mistruct.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mivaltree.c b/xorg-server/mi/mivaltree.c
index 8e4e9a9..ea6889f 100644
--- a/xorg-server/mi/mivaltree.c
+++ b/xorg-server/mi/mivaltree.c
@@ -27,19 +27,19 @@ used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
 
  *
- * Copyright 1987, 1988, 1989 by 
+ * Copyright 1987, 1988, 1989 by
  * Digital Equipment Corporation, Maynard, Massachusetts,
- * 
+ *
  *                         All Rights Reserved
- * 
- * Permission to use, copy, modify, and distribute this software and its 
- * documentation for any purpose and without fee is hereby granted, 
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
  * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in 
+ * both that copyright notice and this permission notice appear in
  * supporting documentation, and that the name of Digital not be
  * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.  
- * 
+ * software without specific, written prior permission.
+ *
  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
@@ -47,7 +47,7 @@ in this Software without prior written authorization from The Open Group.
  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  * SOFTWARE.
- * 
+ *
  ******************************************************************/
 
 /* The panoramix components contained the following notice */
@@ -79,7 +79,7 @@ Equipment Corporation.
 
 ******************************************************************/
 
- /* 
+ /*
   * Aug '86: Susan Angebranndt -- original code
   * July '87: Adam de Boor -- substantially modified and commented
   * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
diff --git a/xorg-server/mi/miwideline.c b/xorg-server/mi/miwideline.c
index 29ba12c..452d74f 100644
--- a/xorg-server/mi/miwideline.c
+++ b/xorg-server/mi/miwideline.c
@@ -24,6 +24,25 @@ not be used in advertising or otherwise to promote the sale, use or
 other dealings in this Software without prior written authorization
 from The Open Group.
 
+Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
 */
 
 /* Author:  Keith Packard, MIT X Consortium */
@@ -52,6 +71,505 @@ from The Open Group.
 #include "miwideline.h"
 #include "mi.h"
 
+#if 0
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#endif
+
+typedef struct {
+    int count;                  /* number of spans                  */
+    DDXPointPtr points;         /* pointer to list of start points  */
+    int *widths;                /* pointer to list of widths        */
+} Spans;
+
+typedef struct {
+    int size;                   /* Total number of *Spans allocated     */
+    int count;                  /* Number of *Spans actually in group   */
+    Spans *group;               /* List of Spans                        */
+    int ymin, ymax;             /* Min, max y values encountered        */
+} SpanGroup;
+
+/* Rops which must use span groups */
+#define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
+#define miSpansEasyRop(rop)	(!miSpansCarefulRop(rop))
+
+/*
+
+These routines maintain lists of Spans, in order to implement the
+``touch-each-pixel-once'' rules of wide lines and arcs.
+
+Written by Joel McCormack, Summer 1989.
+
+*/
+
+static void
+miInitSpanGroup(SpanGroup * spanGroup)
+{
+    spanGroup->size = 0;
+    spanGroup->count = 0;
+    spanGroup->group = NULL;
+    spanGroup->ymin = MAXSHORT;
+    spanGroup->ymax = MINSHORT;
+}                               /* InitSpanGroup */
+
+#define YMIN(spans) (spans->points[0].y)
+#define YMAX(spans)  (spans->points[spans->count-1].y)
+
+static void
+miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
+{
+    int i, subCount, spansCount;
+    int ymin, ymax, xmin, xmax;
+    Spans *spans;
+    DDXPointPtr subPt, spansPt;
+    int *subWid, *spansWid;
+    int extra;
+
+    ymin = YMIN(sub);
+    ymax = YMAX(sub);
+    spans = spanGroup->group;
+    for (i = spanGroup->count; i; i--, spans++) {
+        if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
+            subCount = sub->count;
+            subPt = sub->points;
+            subWid = sub->widths;
+            spansCount = spans->count;
+            spansPt = spans->points;
+            spansWid = spans->widths;
+            extra = 0;
+            for (;;) {
+                while (spansCount && spansPt->y < subPt->y) {
+                    spansPt++;
+                    spansWid++;
+                    spansCount--;
+                }
+                if (!spansCount)
+                    break;
+                while (subCount && subPt->y < spansPt->y) {
+                    subPt++;
+                    subWid++;
+                    subCount--;
+                }
+                if (!subCount)
+                    break;
+                if (subPt->y == spansPt->y) {
+                    xmin = subPt->x;
+                    xmax = xmin + *subWid;
+                    if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax) {
+                        ;
+                    }
+                    else if (xmin <= spansPt->x) {
+                        if (xmax >= spansPt->x + *spansWid) {
+                            memmove(spansPt, spansPt + 1,
+                                    sizeof *spansPt * (spansCount - 1));
+                            memmove(spansWid, spansWid + 1,
+                                    sizeof *spansWid * (spansCount - 1));
+                            spansPt--;
+                            spansWid--;
+                            spans->count--;
+                            extra++;
+                        }
+                        else {
+                            *spansWid = *spansWid - (xmax - spansPt->x);
+                            spansPt->x = xmax;
+                        }
+                    }
+                    else {
+                        if (xmax >= spansPt->x + *spansWid) {
+                            *spansWid = xmin - spansPt->x;
+                        }
+                        else {
+                            if (!extra) {
+                                DDXPointPtr newPt;
+                                int *newwid;
+
+#define EXTRA 8
+                                newPt =
+                                    (DDXPointPtr) realloc(spans->points,
+                                                          (spans->count +
+                                                           EXTRA) *
+                                                          sizeof(DDXPointRec));
+                                if (!newPt)
+                                    break;
+                                spansPt = newPt + (spansPt - spans->points);
+                                spans->points = newPt;
+                                newwid =
+                                    (int *) realloc(spans->widths,
+                                                    (spans->count +
+                                                     EXTRA) * sizeof(int));
+                                if (!newwid)
+                                    break;
+                                spansWid = newwid + (spansWid - spans->widths);
+                                spans->widths = newwid;
+                                extra = EXTRA;
+                            }
+                            memmove(spansPt + 1, spansPt,
+                                    sizeof *spansPt * (spansCount));
+                            memmove(spansWid + 1, spansWid,
+                                    sizeof *spansWid * (spansCount));
+                            spans->count++;
+                            extra--;
+                            *spansWid = xmin - spansPt->x;
+                            spansWid++;
+                            spansPt++;
+                            *spansWid = *spansWid - (xmax - spansPt->x);
+                            spansPt->x = xmax;
+                        }
+                    }
+                }
+                spansPt++;
+                spansWid++;
+                spansCount--;
+            }
+        }
+    }
+}
+
+static void
+miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
+{
+    int ymin, ymax;
+    int spansCount;
+
+    spansCount = spans->count;
+    if (spansCount > 0) {
+        if (spanGroup->size == spanGroup->count) {
+            spanGroup->size = (spanGroup->size + 8) * 2;
+            spanGroup->group = (Spans *)
+                realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
+        }
+
+        spanGroup->group[spanGroup->count] = *spans;
+        (spanGroup->count)++;
+        ymin = spans->points[0].y;
+        if (ymin < spanGroup->ymin)
+            spanGroup->ymin = ymin;
+        ymax = spans->points[spansCount - 1].y;
+        if (ymax > spanGroup->ymax)
+            spanGroup->ymax = ymax;
+        if (otherGroup && otherGroup->ymin < ymax && ymin < otherGroup->ymax) {
+            miSubtractSpans(otherGroup, spans);
+        }
+    }
+    else {
+        free(spans->points);
+        free(spans->widths);
+    }
+}                               /* AppendSpans */
+
+static void
+miFreeSpanGroup(SpanGroup * spanGroup)
+{
+    free(spanGroup->group);
+}
+
+static void
+QuickSortSpansX(DDXPointRec points[], int widths[], int numSpans)
+{
+    int x;
+    int i, j, m;
+    DDXPointPtr r;
+
+/* Always called with numSpans > 1 */
+/* Sorts only by x, as all y should be the same */
+
+#define ExchangeSpans(a, b)				    \
+{							    \
+    DDXPointRec 	tpt;				    \
+    int    		tw;				    \
+							    \
+    tpt = points[a]; points[a] = points[b]; points[b] = tpt;    \
+    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
+}
+
+    do {
+        if (numSpans < 9) {
+            /* Do insertion sort */
+            int xprev;
+
+            xprev = points[0].x;
+            i = 1;
+            do {                /* while i != numSpans */
+                x = points[i].x;
+                if (xprev > x) {
+                    /* points[i] is out of order.  Move into proper location. */
+                    DDXPointRec tpt;
+                    int tw, k;
+
+                    for (j = 0; x >= points[j].x; j++) {
+                    }
+                    tpt = points[i];
+                    tw = widths[i];
+                    for (k = i; k != j; k--) {
+                        points[k] = points[k - 1];
+                        widths[k] = widths[k - 1];
+                    }
+                    points[j] = tpt;
+                    widths[j] = tw;
+                    x = points[i].x;
+                }               /* if out of order */
+                xprev = x;
+                i++;
+            } while (i != numSpans);
+            return;
+        }
+
+        /* Choose partition element, stick in location 0 */
+        m = numSpans / 2;
+        if (points[m].x > points[0].x)
+            ExchangeSpans(m, 0);
+        if (points[m].x > points[numSpans - 1].x)
+            ExchangeSpans(m, numSpans - 1);
+        if (points[m].x > points[0].x)
+            ExchangeSpans(m, 0);
+        x = points[0].x;
+
+        /* Partition array */
+        i = 0;
+        j = numSpans;
+        do {
+            r = &(points[i]);
+            do {
+                r++;
+                i++;
+            } while (i != numSpans && r->x < x);
+            r = &(points[j]);
+            do {
+                r--;
+                j--;
+            } while (x < r->x);
+            if (i < j)
+                ExchangeSpans(i, j);
+        } while (i < j);
+
+        /* Move partition element back to middle */
+        ExchangeSpans(0, j);
+
+        /* Recurse */
+        if (numSpans - j - 1 > 1)
+            QuickSortSpansX(&points[j + 1], &widths[j + 1], numSpans - j - 1);
+        numSpans = j;
+    } while (numSpans > 1);
+}                               /* QuickSortSpans */
+
+static int
+UniquifySpansX(Spans * spans, DDXPointRec * newPoints, int *newWidths)
+{
+    int newx1, newx2, oldpt, i, y;
+    DDXPointRec *oldPoints;
+    int *oldWidths;
+    int *startNewWidths;
+
+/* Always called with numSpans > 1 */
+/* Uniquify the spans, and stash them into newPoints and newWidths.  Return the
+   number of unique spans. */
+
+    startNewWidths = newWidths;
+
+    oldPoints = spans->points;
+    oldWidths = spans->widths;
+
+    y = oldPoints->y;
+    newx1 = oldPoints->x;
+    newx2 = newx1 + *oldWidths;
+
+    for (i = spans->count - 1; i != 0; i--) {
+        oldPoints++;
+        oldWidths++;
+        oldpt = oldPoints->x;
+        if (oldpt > newx2) {
+            /* Write current span, start a new one */
+            newPoints->x = newx1;
+            newPoints->y = y;
+            *newWidths = newx2 - newx1;
+            newPoints++;
+            newWidths++;
+            newx1 = oldpt;
+            newx2 = oldpt + *oldWidths;
+        }
+        else {
+            /* extend current span, if old extends beyond new */
+            oldpt = oldpt + *oldWidths;
+            if (oldpt > newx2)
+                newx2 = oldpt;
+        }
+    }                           /* for */
+
+    /* Write final span */
+    newPoints->x = newx1;
+    *newWidths = newx2 - newx1;
+    newPoints->y = y;
+
+    return (newWidths - startNewWidths) + 1;
+}                               /* UniquifySpansX */
+
+static void
+miDisposeSpanGroup(SpanGroup * spanGroup)
+{
+    int i;
+    Spans *spans;
+
+    for (i = 0; i < spanGroup->count; i++) {
+        spans = spanGroup->group + i;
+        free(spans->points);
+        free(spans->widths);
+    }
+}
+
+static void
+miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
+{
+    int i;
+    Spans *spans;
+    Spans *yspans;
+    int *ysizes;
+    int ymin, ylength;
+
+    /* Outgoing spans for one big call to FillSpans */
+    DDXPointPtr points;
+    int *widths;
+    int count;
+
+    if (spanGroup->count == 0)
+        return;
+
+    if (spanGroup->count == 1) {
+        /* Already should be sorted, unique */
+        spans = spanGroup->group;
+        (*pGC->ops->FillSpans)
+            (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
+        free(spans->points);
+        free(spans->widths);
+    }
+    else {
+        /* Yuck.  Gross.  Radix sort into y buckets, then sort x and uniquify */
+        /* This seems to be the fastest thing to do.  I've tried sorting on
+           both x and y at the same time rather than creating into all those
+           y buckets, but it was somewhat slower. */
+
+        ymin = spanGroup->ymin;
+        ylength = spanGroup->ymax - ymin + 1;
+
+        /* Allocate Spans for y buckets */
+        yspans = malloc(ylength * sizeof(Spans));
+        ysizes = malloc(ylength * sizeof(int));
+
+        if (!yspans || !ysizes) {
+            free(yspans);
+            free(ysizes);
+            miDisposeSpanGroup(spanGroup);
+            return;
+        }
+
+        for (i = 0; i != ylength; i++) {
+            ysizes[i] = 0;
+            yspans[i].count = 0;
+            yspans[i].points = NULL;
+            yspans[i].widths = NULL;
+        }
+
+        /* Go through every single span and put it into the correct bucket */
+        count = 0;
+        for (i = 0, spans = spanGroup->group;
+             i != spanGroup->count; i++, spans++) {
+            int index;
+            int j;
+
+            for (j = 0, points = spans->points, widths = spans->widths;
+                 j != spans->count; j++, points++, widths++) {
+                index = points->y - ymin;
+                if (index >= 0 && index < ylength) {
+                    Spans *newspans = &(yspans[index]);
+
+                    if (newspans->count == ysizes[index]) {
+                        DDXPointPtr newpoints;
+                        int *newwidths;
+
+                        ysizes[index] = (ysizes[index] + 8) * 2;
+                        newpoints = (DDXPointPtr) realloc(newspans->points,
+                                                          ysizes[index] *
+                                                          sizeof(DDXPointRec));
+                        newwidths =
+                            (int *) realloc(newspans->widths,
+                                            ysizes[index] * sizeof(int));
+                        if (!newpoints || !newwidths) {
+                            for (i = 0; i < ylength; i++) {
+                                free(yspans[i].points);
+                                free(yspans[i].widths);
+                            }
+                            free(yspans);
+                            free(ysizes);
+                            free(newpoints);
+                            free(newwidths);
+                            miDisposeSpanGroup(spanGroup);
+                            return;
+                        }
+                        newspans->points = newpoints;
+                        newspans->widths = newwidths;
+                    }
+                    newspans->points[newspans->count] = *points;
+                    newspans->widths[newspans->count] = *widths;
+                    (newspans->count)++;
+                }               /* if y value of span in range */
+            }                   /* for j through spans */
+            count += spans->count;
+            free(spans->points);
+            spans->points = NULL;
+            free(spans->widths);
+            spans->widths = NULL;
+        }                       /* for i thorough Spans */
+
+        /* Now sort by x and uniquify each bucket into the final array */
+        points = malloc(count * sizeof(DDXPointRec));
+        widths = malloc(count * sizeof(int));
+        if (!points || !widths) {
+            for (i = 0; i < ylength; i++) {
+                free(yspans[i].points);
+                free(yspans[i].widths);
+            }
+            free(yspans);
+            free(ysizes);
+            free(points);
+            free(widths);
+            return;
+        }
+        count = 0;
+        for (i = 0; i != ylength; i++) {
+            int ycount = yspans[i].count;
+
+            if (ycount > 0) {
+                if (ycount > 1) {
+                    QuickSortSpansX(yspans[i].points, yspans[i].widths, ycount);
+                    count += UniquifySpansX
+                        (&(yspans[i]), &(points[count]), &(widths[count]));
+                }
+                else {
+                    points[count] = yspans[i].points[0];
+                    widths[count] = yspans[i].widths[0];
+                    count++;
+                }
+                free(yspans[i].points);
+                free(yspans[i].widths);
+            }
+        }
+
+        (*pGC->ops->FillSpans) (pDraw, pGC, count, points, widths, TRUE);
+        free(points);
+        free(widths);
+        free(yspans);
+        free(ysizes);           /* use (DE)xalloc for these? */
+    }
+
+    spanGroup->count = 0;
+    spanGroup->ymin = MAXSHORT;
+    spanGroup->ymax = MINSHORT;
+}
+
 static Bool
 InitSpans(Spans * spans, size_t nspans)
 {
@@ -273,7 +791,7 @@ miFillRectPolyHelper(DrawablePtr pDrawable,
     }
 }
 
-/* static */ int
+static int
 miPolyBuildEdge(double x0, double y0, double k, /* x0 * dy - y0 * dx */
                 int dx, int dy, int xi, int yi, int left, PolyEdgePtr edge)
 {
@@ -325,7 +843,7 @@ miPolyBuildEdge(double x0, double y0, double k, /* x0 * dy - y0 * dx */
 
 #define StepAround(v, incr, max) (((v) + (incr) < 0) ? (max - 1) : ((v) + (incr) == max) ? 0 : ((v) + (incr)))
 
-/* static */ int
+static int
 miPolyBuildPoly(PolyVertexPtr vertices,
                 PolySlopePtr slopes,
                 int count,
@@ -865,7 +1383,7 @@ miRoundJoinFace(LineFacePtr face, PolyEdgePtr edge, Bool *leftEdge)
     return y;
 }
 
-void
+static void
 miRoundJoinClip(LineFacePtr pLeft, LineFacePtr pRight,
                 PolyEdgePtr edge1, PolyEdgePtr edge2,
                 int *y1, int *y2, Bool *left1, Bool *left2)
@@ -886,7 +1404,7 @@ miRoundJoinClip(LineFacePtr pLeft, LineFacePtr pRight,
     *y2 = miRoundJoinFace(pRight, edge2, left2);
 }
 
-int
+static int
 miRoundCapClip(LineFacePtr face, Bool isInt, PolyEdgePtr edge, Bool *leftEdge)
 {
     int y;
diff --git a/xorg-server/mi/miwideline.h b/xorg-server/mi/miwideline.h
index 1105411..88bc3d6 100644
--- a/xorg-server/mi/miwideline.h
+++ b/xorg-server/mi/miwideline.h
@@ -28,7 +28,6 @@ from The Open Group.
 
 /* Author:  Keith Packard, MIT X Consortium */
 
-#include "mispans.h"
 #include "mifpoly.h"            /* for ICEIL */
 
 /*
@@ -92,28 +91,3 @@ typedef struct _LineFace {
 	ValidateGC (pDrawable, pGC); \
     } \
 }
-
-extern _X_EXPORT void miRoundJoinClip(LineFacePtr /*pLeft */ ,
-                                      LineFacePtr /*pRight */ ,
-                                      PolyEdgePtr /*edge1 */ ,
-                                      PolyEdgePtr /*edge2 */ ,
-                                      int * /*y1 */ ,
-                                      int * /*y2 */ ,
-                                      Bool * /*left1 */ ,
-                                      Bool *    /*left2 */
-    );
-
-extern _X_EXPORT int miRoundCapClip(LineFacePtr /*face */ ,
-                                    Bool /*isInt */ ,
-                                    PolyEdgePtr /*edge */ ,
-                                    Bool *      /*leftEdge */
-    );
-
-extern _X_EXPORT int miPolyBuildEdge(double x0, double y0, double k, int dx,
-                                     int dy, int xi, int yi, int left,
-                                     PolyEdgePtr edge);
-extern _X_EXPORT int miPolyBuildPoly(PolyVertexPtr vertices,
-                                     PolySlopePtr slopes, int count, int xi,
-                                     int yi, PolyEdgePtr left,
-                                     PolyEdgePtr right, int *pnleft,
-                                     int *pnright, int *h);
diff --git a/xorg-server/mi/miwindow.c b/xorg-server/mi/miwindow.c
index 0cf5046..a1af3a7 100644
--- a/xorg-server/mi/miwindow.c
+++ b/xorg-server/mi/miwindow.c
@@ -27,13 +27,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mizerclip.c b/xorg-server/mi/mizerclip.c
index d05bf67..0ae9641 100644
--- a/xorg-server/mi/mizerclip.c
+++ b/xorg-server/mi/mizerclip.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/mi/mizerline.c b/xorg-server/mi/mizerline.c
index f30e012..5a24470 100644
--- a/xorg-server/mi/mizerline.c
+++ b/xorg-server/mi/mizerline.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -235,7 +235,7 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode,      /* Origin or Previous */
                 length = abs(new_x2 - new_x1);
 
                 /* if we've clipped the endpoint, always draw the full length
-                 * of the segment, because then the capstyle doesn't matter 
+                 * of the segment, because then the capstyle doesn't matter
                  */
                 if (pt2_clipped)
                     length++;
@@ -295,7 +295,7 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode,      /* Origin or Previous */
                 length = abs(new_y2 - new_y1);
 
                 /* if we've clipped the endpoint, always draw the full length
-                 * of the segment, because then the capstyle doesn't matter 
+                 * of the segment, because then the capstyle doesn't matter
                  */
                 if (pt2_clipped)
                     length++;
diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c
index 9bd9c84..6ef7f9d 100644
--- a/xorg-server/miext/damage/damage.c
+++ b/xorg-server/miext/damage/damage.c
@@ -1591,7 +1591,7 @@ miDamageCreate(DamagePtr pDamage)
  * Since we can't know if a GC has been validated against one of the affected
  * children, just bump them all to be safe.
  */
-static int 
+static int
 damageRegisterVisit(WindowPtr pWin, void *data)
 {
     pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
diff --git a/xorg-server/miext/rootless/rootless.h b/xorg-server/miext/rootless/rootless.h
index a3f38b6..1be61cd 100644
--- a/xorg-server/miext/rootless/rootless.h
+++ b/xorg-server/miext/rootless/rootless.h
@@ -319,7 +319,7 @@ typedef struct _RootlessFrameProcs {
 Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs);
 
 /*
- * Return the frame ID for the physical window displaying the given window. 
+ * Return the frame ID for the physical window displaying the given window.
  *
  *  create      If true and the window has no frame, attempt to create one
  */
diff --git a/xorg-server/miext/rootless/rootlessGC.c b/xorg-server/miext/rootless/rootlessGC.c
index 23ff393..4fba26c 100644
--- a/xorg-server/miext/rootless/rootlessGC.c
+++ b/xorg-server/miext/rootless/rootlessGC.c
@@ -297,7 +297,7 @@ RootlessCreateGC(GCPtr pGC)
  * All the others just unwrap and call.
  */
 
-// GCFUNC_UNRAP assumes funcs have been wrapped and 
+// GCFUNC_UNRAP assumes funcs have been wrapped and
 // does not assume ops have been wrapped
 #define GCFUNC_UNWRAP(pGC) \
     RootlessGCRec *gcrec = (RootlessGCRec *) \
diff --git a/xorg-server/miext/rootless/rootlessValTree.c b/xorg-server/miext/rootless/rootlessValTree.c
index c7c2c99..0f7b76c 100644
--- a/xorg-server/miext/rootless/rootlessValTree.c
+++ b/xorg-server/miext/rootless/rootlessValTree.c
@@ -29,19 +29,19 @@ used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
 
  *
- * Copyright 1987, 1988, 1989 by 
+ * Copyright 1987, 1988, 1989 by
  * Digital Equipment Corporation, Maynard, Massachusetts,
- * 
+ *
  *                         All Rights Reserved
- * 
- * Permission to use, copy, modify, and distribute this software and its 
- * documentation for any purpose and without fee is hereby granted, 
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
  * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in 
+ * both that copyright notice and this permission notice appear in
  * supporting documentation, and that the name of Digital not be
  * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.  
- * 
+ * software without specific, written prior permission.
+ *
  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
@@ -49,7 +49,7 @@ in this Software without prior written authorization from The Open Group.
  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  * SOFTWARE.
- * 
+ *
  ******************************************************************/
 
 /* The panoramix components contained the following notice */
@@ -80,7 +80,7 @@ dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 
 ******************************************************************/
- /* 
+ /*
   * Aug '86: Susan Angebranndt -- original code
   * July '87: Adam de Boor -- substantially modified and commented
   * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
@@ -456,9 +456,9 @@ RootlessTreeObscured(WindowPtr pParent)
  *
  *-----------------------------------------------------------------------
  */
-/* 
+/*
    Quartz version: used for validate from root in rootless mode.
-   We need to make sure top-level windows don't clip each other, 
+   We need to make sure top-level windows don't clip each other,
    and that top-level windows aren't clipped to the root window.
 */
  /*ARGSUSED*/
@@ -491,9 +491,9 @@ RootlessMiValidateTree(WindowPtr pRoot, /* Parent to validate */
         ErrorF("ValidateTree: BUSTED!\n");
     }
 
-    /* 
-     * Recursively compute the clips for all children of the root. 
-     * They don't clip against each other or the root itself, so 
+    /*
+     * Recursively compute the clips for all children of the root.
+     * They don't clip against each other or the root itself, so
      * childClip is always reset to that child's size.
      */
 
@@ -520,7 +520,7 @@ RootlessMiValidateTree(WindowPtr pRoot, /* Parent to validate */
 
     RegionUninit(&childClip);
 
-    /* The root is never clipped by its children, so nothing on the root 
+    /* The root is never clipped by its children, so nothing on the root
        is ever exposed by moving or mapping its children. */
     RegionNull(&pRoot->valdata->after.exposed);
     RegionNull(&pRoot->valdata->after.borderExposed);
diff --git a/xorg-server/miext/rootless/rootlessWindow.c b/xorg-server/miext/rootless/rootlessWindow.c
index 3dbd588..a8f296a 100644
--- a/xorg-server/miext/rootless/rootlessWindow.c
+++ b/xorg-server/miext/rootless/rootlessWindow.c
@@ -128,7 +128,7 @@ RootlessNativeWindowMoved(WindowPtr pWin)
         return;
     }
 
-    /* Don't want to do anything to the physical window (avoids 
+    /* Don't want to do anything to the physical window (avoids
        notification-response feedback loops) */
 
     no_configure_window = TRUE;
@@ -477,7 +477,7 @@ RootlessRealizeWindow(WindowPtr pWin)
 
 /*
  * RootlessFrameForWindow
- *  Returns the frame ID for the physical window displaying the given window. 
+ *  Returns the frame ID for the physical window displaying the given window.
  *  If CREATE is true and the window has no frame, attempt to create one.
  */
 RootlessFrameID
@@ -559,7 +559,7 @@ RootlessReorderWindow(WindowPtr pWin)
 
         RootlessStopDrawing(pWin, FALSE);
 
-        /* Find the next window above this one that has a mapped frame. 
+        /* Find the next window above this one that has a mapped frame.
          * Only include cases where the windows are in the same category of
          * hittability to ensure offscreen windows dont get restacked
          * relative to onscreen ones (but that the offscreen ones maintain
diff --git a/xorg-server/miext/shadow/shrotate.c b/xorg-server/miext/shadow/shrotate.c
index 779a905..a0fc4ec 100644
--- a/xorg-server/miext/shadow/shrotate.c
+++ b/xorg-server/miext/shadow/shrotate.c
@@ -259,7 +259,7 @@ shadowUpdateRotatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
                     p = pixelsPerBits;
                     /*
                      * Build one word of output from multiple inputs
-                     * 
+                     *
                      * Note that for 90/270 rotations, this will walk
                      * down the shadow hitting each scanline once.
                      * This is probably not very efficient.
diff --git a/xorg-server/miext/sync/misyncfd.c b/xorg-server/miext/sync/misyncfd.c
index 93ff85f..92f3b22 100644
--- a/xorg-server/miext/sync/misyncfd.c
+++ b/xorg-server/miext/sync/misyncfd.c
@@ -77,7 +77,7 @@ _X_EXPORT Bool miSyncFdScreenInit(ScreenPtr pScreen,
 
     if (!miSyncSetup(pScreen))
         return FALSE;
-    
+
     if (!dixPrivateKeyRegistered(&syncFdScreenPrivateKey)) {
         if (!dixRegisterPrivateKey(&syncFdScreenPrivateKey, PRIVATE_SCREEN, 0))
             return FALSE;
@@ -94,6 +94,6 @@ _X_EXPORT Bool miSyncFdScreenInit(ScreenPtr pScreen,
     priv->funcs = *funcs;
 
     dixSetPrivate(&pScreen->devPrivates, &syncFdScreenPrivateKey, priv);
-    
+
     return TRUE;
 }
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c
index 3eb15b9..86d96c8 100644
--- a/xorg-server/os/WaitFor.c
+++ b/xorg-server/os/WaitFor.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -82,7 +82,7 @@ SOFTWARE.
 #define EINVAL WSAEINVAL
 #undef EBADF
 #define EBADF WSAENOTSOCK
-/* Windows select does not set errno. Use GetErrno as wrapper for 
+/* Windows select does not set errno. Use GetErrno as wrapper for
    WSAGetLastError */
 #define GetErrno WSAGetLastError
 #else
@@ -167,7 +167,7 @@ WaitForSomething(int *pClientsReady)
     busfault_check();
 #endif
 
-    /* We need a while loop here to handle 
+    /* We need a while loop here to handle
        crashed connections and the screen saver timeout */
     while (1) {
         /* deal with any blocked jobs */
@@ -343,14 +343,14 @@ WaitForSomething(int *pClientsReady)
              *  ready, they are all returned.  This means that an
              *  aggressive client could take over the server.
              *  This was not considered a big problem because
-             *  aggressive clients can hose the server in so many 
+             *  aggressive clients can hose the server in so many
              *  other ways :)
              */
             client_priority = clients[client_index]->priority;
             if (nready == 0 || client_priority > highest_priority) {
                 /*  Either we found the first client, or we found
                  *  a client whose priority is greater than all others
-                 *  that have been found so far.  Either way, we want 
+                 *  that have been found so far.  Either way, we want
                  *  to initialize the list of clients to contain just
                  *  this client.
                  */
@@ -358,7 +358,7 @@ WaitForSomething(int *pClientsReady)
                 highest_priority = client_priority;
                 nready = 1;
             }
-            /*  the following if makes sure that multiple same-priority 
+            /*  the following if makes sure that multiple same-priority
              *  clients get batched together
              */
             else if (client_priority == highest_priority) {
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index 125f35f..5c510de 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -35,13 +35,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -201,7 +201,7 @@ static Bool NewHost(int /*family */ ,
    /etc/X<display>.hosts, we've added a requested field to the HOST struct,
    and a LocalHostRequested variable.  These default to FALSE, but are set
    to TRUE in ResetHosts when reading in /etc/X<display>.hosts.  They are
-   checked in DisableLocalHost(), which is called to disable the default 
+   checked in DisableLocalHost(), which is called to disable the default
    local host entries when stronger authentication is turned on. */
 
 typedef struct _host {
@@ -309,7 +309,7 @@ ifioctl(int fd, int cmd, char *arg)
 /*
  * DefineSelf (fd):
  *
- * Define this host for access control.  Find all the hosts the OS knows about 
+ * Define this host for access control.  Find all the hosts the OS knows about
  * for this fd and add them to the selfhosts list.
  */
 
@@ -712,7 +712,7 @@ DefineSelf(int fd)
                 )
                 continue;
 
-            /* 
+            /*
              * ignore 'localhost' entries as they're not useful
              * on the other end of the wire
              */
@@ -835,7 +835,7 @@ ResetHosts(const char *display)
     } saddr;
 #endif
     int family = 0;
-    void *addr;
+    void *addr = NULL;
     int len;
 
     siTypesInitialize();
@@ -928,8 +928,8 @@ ResetHosts(const char *display)
                             len = a->ai_addrlen;
                             f = ConvertAddr(a->ai_addr, &len,
                                             (void **) &addr);
-                            if ((family == f) ||
-                                ((family == FamilyWild) && (f != -1))) {
+                            if (addr && ((family == f) ||
+                                         ((family == FamilyWild) && (f != -1)))) {
                                 NewHost(f, addr, len, FALSE);
                             }
                         }
@@ -1010,7 +1010,7 @@ ComputeLocalClient(ClientPtr client)
 /*
  * Return the uid and all gids of a connected local client
  * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds
- * 
+ *
  * Used by localuser & localgroup ServerInterpreted access control forms below
  * Used by AuthAudit to log who local connections came from
  */
@@ -1037,8 +1037,8 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec ** lccp)
         return -1;
     ci = ((OsCommPtr) client->osPrivate)->trans_conn;
 #if !(defined(sun) && defined(HAVE_GETPEERUCRED))
-    /* Most implementations can only determine peer credentials for Unix 
-     * domain sockets - Solaris getpeerucred can work with a bit more, so 
+    /* Most implementations can only determine peer credentials for Unix
+     * domain sockets - Solaris getpeerucred can work with a bit more, so
      * we just let it tell us if the connection type is supported or not
      */
     if (!_XSERVTransIsLocal(ci)) {
@@ -1203,7 +1203,7 @@ ForEachHostInFamily(int family, Bool (*func) (unsigned char *addr,
     return FALSE;
 }
 
-/* Add a host to the access control list. This is the internal interface 
+/* Add a host to the access control list. This is the internal interface
  * called when starting or resetting the server */
 static Bool
 NewHost(int family, const void *addr, int len, int addingLocalHosts)
@@ -1352,14 +1352,14 @@ CheckAddr(int family, const void *pAddr, unsigned length)
     return len;
 }
 
-/* Check if a host is not in the access control list. 
+/* Check if a host is not in the access control list.
  * Returns 1 if host is invalid, 0 if we've found it. */
 
 int
 InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
 {
     int family;
-    void *addr;
+    void *addr = NULL;
     register HOST *selfhost, *host;
 
     if (!AccessEnabled)         /* just let them in */
@@ -1370,7 +1370,7 @@ InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
     if (family == FamilyLocal) {
         if (!LocalHostEnabled) {
             /*
-             * check to see if any local address is enabled.  This 
+             * check to see if any local address is enabled.  This
              * implicitly enables local connections.
              */
             for (selfhost = selfhosts; selfhost; selfhost = selfhost->next) {
@@ -1386,12 +1386,12 @@ InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
     }
     for (host = validhosts; host; host = host->next) {
         if (host->family == FamilyServerInterpreted) {
-            if (siAddrMatch(family, addr, len, host, client)) {
+            if (addr && siAddrMatch(family, addr, len, host, client)) {
                 return 0;
             }
         }
         else {
-            if (addrEqual(family, addr, len, host))
+            if (addr && addrEqual(family, addr, len, host))
                 return 0;
         }
 
@@ -1474,7 +1474,7 @@ GetAccessControl(void)
  * See xc/doc/specs/SIAddresses for formal definitions of each type.
  */
 
-/* These definitions and the siTypeAdd function could be exported in the 
+/* These definitions and the siTypeAdd function could be exported in the
  * future to enable loading additional host types, but that was not done for
  * the initial implementation.
  */
@@ -1571,7 +1571,7 @@ siCheckAddr(const char *addrString, int length)
     valueString = (const char *) memchr(addrString, '\0', length);
     if (valueString != NULL) {
         /* Make sure the first string is a recognized address type,
-         * and the second string is a valid address of that type. 
+         * and the second string is a valid address of that type.
          */
         typelen = strlen(addrString) + 1;
         addrlen = length - typelen;
@@ -1638,8 +1638,8 @@ siHostnameAddrMatch(int family, void *addr, int len,
 {
     Bool res = FALSE;
 
-/* Currently only supports checking against IPv4 & IPv6 connections, but 
- * support for other address families, such as DECnet, could be added if 
+/* Currently only supports checking against IPv4 & IPv6 connections, but
+ * support for other address families, such as DECnet, could be added if
  * desired.
  */
 #if defined(IPv6) && defined(AF_INET6)
@@ -1648,7 +1648,7 @@ siHostnameAddrMatch(int family, void *addr, int len,
         struct addrinfo *addresses;
         struct addrinfo *a;
         int f, hostaddrlen;
-        void *hostaddr;
+        void *hostaddr = NULL;
 
         if (siAddrLen >= sizeof(hostname))
             return FALSE;
@@ -1659,7 +1659,7 @@ siHostnameAddrMatch(int family, void *addr, int len,
             for (a = addresses; a != NULL; a = a->ai_next) {
                 hostaddrlen = a->ai_addrlen;
                 f = ConvertAddr(a->ai_addr, &hostaddrlen, &hostaddr);
-                if ((f == family) && (len == hostaddrlen) &&
+                if ((f == family) && (len == hostaddrlen) && hostaddr &&
                     (memcmp(addr, hostaddr, len) == 0)) {
                     res = TRUE;
                     break;
@@ -1717,7 +1717,7 @@ siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
 {
     /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition.
      * We do not use ctype functions here to avoid locale-specific
-     * character sets.  Hostnames must be pure ASCII.  
+     * character sets.  Hostnames must be pure ASCII.
      */
     int len = length;
     int i;
@@ -1771,12 +1771,12 @@ siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
  *
  * Currently supports only IPv6 literal address as specified in IETF RFC 3513
  *
- * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be 
+ * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be
  * added for the scoped address format it specifies.
  */
 
-/* Maximum length of an IPv6 address string - increase when adding support 
- * for scoped address qualifiers.  Includes room for trailing NUL byte. 
+/* Maximum length of an IPv6 address string - increase when adding support
+ * for scoped address qualifiers.  Includes room for trailing NUL byte.
  */
 #define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
 
diff --git a/xorg-server/os/busfault.c b/xorg-server/os/busfault.c
index ac0268f..d4afa6d 100644
--- a/xorg-server/os/busfault.c
+++ b/xorg-server/os/busfault.c
@@ -47,7 +47,7 @@ struct busfault {
     void                *context;
 };
 
-static Bool             busfaulted;        
+static Bool             busfaulted;
 static struct xorg_list busfaults;
 
 struct busfault *
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index f915e12..da3397d 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -26,13 +26,13 @@ Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -421,7 +421,7 @@ CreateWellKnownSockets(void)
     }
     else { /* -displayfd and no explicit display number */
         Bool found = 0;
-        for (i = 0; i < 65535 - X_TCP_PORT; i++) {
+        for (i = 0; i < 65536 - X_TCP_PORT; i++) {
             if (TryCreateSocket(i, &partial) && !partial) {
                 found = 1;
                 break;
@@ -648,8 +648,8 @@ AuthorizationIDOfClient(ClientPtr client)
  *                   CARD8	byteOrder;
  *                   BYTE	pad;
  *                   CARD16	majorVersion, minorVersion;
- *                   CARD16	nbytesAuthProto;    
- *                   CARD16	nbytesAuthString;   
+ *                   CARD16	nbytesAuthProto;
+ *                   CARD16	nbytesAuthString;
  *                 } xConnClientPrefix;
  *
  *     	It is hoped that eventually one protocol will be agreed upon.  In the
@@ -974,7 +974,7 @@ CloseDownFileDescriptor(OsCommPtr oc)
 
 /*****************
  * CheckConnections
- *    Some connection has died, go find which one and shut it down 
+ *    Some connection has died, go find which one and shut it down
  *    The file descriptor has been closed, but is still in AllClients.
  *    If would truly be wonderful if select() would put the bogus
  *    file descriptors in the exception mask, but nooooo.  So we have
@@ -1035,7 +1035,7 @@ CheckConnections(void)
 
 /*****************
  * CloseDownConnection
- *    Delete client from AllClients and free resources 
+ *    Delete client from AllClients and free resources
  *****************/
 
 void
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index 8181a86..bb273bb 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -26,13 +26,13 @@ Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -448,7 +448,7 @@ ReadRequestFromClient(ClientPtr client)
      *  buffer beyond the request we're returning to the caller.
      *  If there is only a partial request, treat like buffer
      *  is empty so that select() will be called again and other clients
-     *  can get into the queue.   
+     *  can get into the queue.
      */
 
     gotnow -= needed;
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 7348ad4..2e3b3f6 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -127,7 +127,7 @@ static char __crashreporter_info_buff__[4096] = { 0 };
 static const char *__crashreporter_info__ __attribute__ ((__used__)) =
     &__crashreporter_info_buff__[0];
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-// This is actually a toolchain requirement, but I'm not sure the correct check,        
+// This is actually a toolchain requirement, but I'm not sure the correct check,
 // but it should be fine to just only include it for Leopard and later.  This line
 // just tells the linker to never strip this symbol (such as for space optimization)
 asm(".desc ___crashreporter_info__, 0x10");
diff --git a/xorg-server/os/oscolor.c b/xorg-server/os/oscolor.c
index a44ed3f..017aab1 100644
--- a/xorg-server/os/oscolor.c
+++ b/xorg-server/os/oscolor.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/os/osdep.h b/xorg-server/os/osdep.h
index 0ccdb62..77a5b53 100644
--- a/xorg-server/os/osdep.h
+++ b/xorg-server/os/osdep.h
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c
index 4d48ea9..ff0979a 100644
--- a/xorg-server/os/osinit.c
+++ b/xorg-server/os/osinit.c
@@ -26,13 +26,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -225,9 +225,9 @@ OsInit(void)
         fclose(stdin);
         fclose(stdout);
 # endif
-        /* 
-         * If a write of zero bytes to stderr returns non-zero, i.e. -1, 
-         * then writing to stderr failed, and we'll write somewhere else 
+        /*
+         * If a write of zero bytes to stderr returns non-zero, i.e. -1,
+         * then writing to stderr failed, and we'll write somewhere else
          * instead. (Apparently this never happens in the Real World.)
          */
         if (write(2, fname, 0) == -1) {
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index 99616d9..b6e97c9 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -562,7 +562,7 @@ XdmcpRegisterDisplayClass(const char *name, int length)
         DisplayClass.data[i] = (CARD8) name[i];
 }
 
-/* 
+/*
  * initialize XDMCP; create the socket, compute the display
  * number, set up the state machine
  */
diff --git a/xorg-server/present/present.c b/xorg-server/present/present.c
index 47566c7..ac9047e 100644
--- a/xorg-server/present/present.c
+++ b/xorg-server/present/present.c
@@ -91,7 +91,7 @@ present_flip_pending_pixmap(ScreenPtr screen)
 
     if (!screen_priv->flip_pending)
         return NULL;
-        
+
     return screen_priv->flip_pending->pixmap;
 }
 
@@ -372,7 +372,7 @@ present_set_tree_pixmap_visit(WindowPtr window, void *data)
     (*screen->SetWindowPixmap)(window, visit->new);
     return WT_WALKCHILDREN;
 }
-    
+
 static void
 present_set_tree_pixmap(WindowPtr window, PixmapPtr pixmap)
 {
@@ -866,7 +866,7 @@ present_pixmap(WindowPtr window,
 
     xorg_list_add(&vblank->event_queue, &present_exec_queue);
     vblank->queued = TRUE;
-    if (target_msc >= crtc_msc) {
+    if ((pixmap && target_msc >= crtc_msc) || (!pixmap && target_msc > crtc_msc)) {
         ret = present_queue_vblank(screen, target_crtc, vblank->event_id, target_msc);
         if (ret != Success) {
             xorg_list_del(&vblank->event_queue);
@@ -929,7 +929,7 @@ present_notify_msc(WindowPtr window,
                           0, 0,
                           NULL,
                           NULL, NULL,
-                          0,
+                          PresentOptionAsync,
                           target_msc, divisor, remainder, NULL, 0);
 }
 
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h
index e142232..13e6a85 100644
--- a/xorg-server/randr/randrstr.h
+++ b/xorg-server/randr/randrstr.h
@@ -984,17 +984,17 @@ extern _X_EXPORT void
 #endif                          /* _RANDRSTR_H_ */
 
 /*
- 
+
 randr extension implementation structure
 
 Query state:
     ProcRRGetScreenInfo/ProcRRGetScreenResources
 	RRGetInfo
- 
+
 	    • Request configuration from driver, either 1.0 or 1.2 style
 	    • These functions only record state changes, all
 	      other actions are pended until RRTellChanged is called
- 
+
 	    ->rrGetInfo
 	    1.0:
 		RRRegisterSize
@@ -1009,15 +1009,15 @@ Query state:
 		RROutputSetSubpixelOrder
 		RROutputSetClones
 		RRCrtcNotify
- 
+
 	• Must delay scanning configuration until after ->rrGetInfo returns
 	  because some drivers will call SetCurrentConfig in the middle
 	  of the ->rrGetInfo operation.
- 
+
 	1.0:
 
 	    • Scan old configuration, mirror to new structures
- 
+
 	    RRScanOldConfig
 		RRCrtcCreate
 		RROutputCreate
@@ -1027,16 +1027,16 @@ Query state:
 		RROldModeAdd	• This adds modes one-at-a-time
 		    RRModeGet
 		RRCrtcNotify
- 
+
 	• send events, reset pointer if necessary
- 
+
 	RRTellChanged
 	    WalkTree (sending events)
- 
+
 	    • when layout has changed:
 		RRPointerScreenConfigured
 		RRSendConfigNotify
- 
+
 Asynchronous state setting (1.2 only)
     When setting state asynchronously, the driver invokes the
     ->rrGetInfo function and then calls RRTellChanged to flush
diff --git a/xorg-server/randr/rrprovider.c b/xorg-server/randr/rrprovider.c
index 4507ba8..bbb8e51 100644
--- a/xorg-server/randr/rrprovider.c
+++ b/xorg-server/randr/rrprovider.c
@@ -159,7 +159,7 @@ ProcRRGetProviderInfo (ClientPtr client)
     ScreenPtr provscreen;
     RRProvider *providers;
     uint32_t *prov_cap;
- 
+
     REQUEST_SIZE_MATCH(xRRGetProviderInfoReq);
     VERIFY_RR_PROVIDER(stuff->provider, provider, DixReadAccess);
 
diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c
index f93181d..c8a2749 100644
--- a/xorg-server/randr/rrtransform.c
+++ b/xorg-server/randr/rrtransform.c
@@ -131,7 +131,7 @@ RRTransformRescale(struct pixman_f_transform *f_transform, double limit)
 
 /*
  * Compute the complete transformation matrix including
- * client-specified transform, rotation/reflection values and the crtc 
+ * client-specified transform, rotation/reflection values and the crtc
  * offset.
  *
  * Return TRUE if the resulting transform is not a simple translation.
diff --git a/xorg-server/randr/rrtransform.h b/xorg-server/randr/rrtransform.h
index 2269b4c..f811d2b 100644
--- a/xorg-server/randr/rrtransform.h
+++ b/xorg-server/randr/rrtransform.h
@@ -59,7 +59,7 @@ extern _X_EXPORT Bool
 
 /*
  * Compute the complete transformation matrix including
- * client-specified transform, rotation/reflection values and the crtc 
+ * client-specified transform, rotation/reflection values and the crtc
  * offset.
  *
  * Return TRUE if the resulting transform is not a simple translation.
diff --git a/xorg-server/randr/rrxinerama.c b/xorg-server/randr/rrxinerama.c
index 76d728c..26894a6 100644
--- a/xorg-server/randr/rrxinerama.c
+++ b/xorg-server/randr/rrxinerama.c
@@ -23,7 +23,7 @@
  * This Xinerama implementation comes from the SiS driver which has
  * the following notice:
  */
-/* 
+/*
  * SiS driver main code
  *
  * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria.
diff --git a/xorg-server/record/record.c b/xorg-server/record/record.c
index c900219..0a466e2 100644
--- a/xorg-server/record/record.c
+++ b/xorg-server/record/record.c
@@ -93,7 +93,7 @@ typedef union {
     } major;
 } RecordMinorOpRec, *RecordMinorOpPtr;
 
-/*  RecordClientsAndProtocolRec, nicknamed RCAP - holds all the client and 
+/*  RecordClientsAndProtocolRec, nicknamed RCAP - holds all the client and
  *  protocol selections passed in a single CreateContext or RegisterClients.
  *  Generally, a context will have one of these from the create and an
  *  additional one for each RegisterClients.  RCAPs are freed when all their
@@ -260,7 +260,7 @@ RecordFlushReplyBuffer(RecordContextPtr pContext,
  *	  is its length in bytes.
  *	padlen is the number of pad bytes from a zeroed array.
  *	futurelen is the number of bytes that will be sent in subsequent
- *	  calls to this function to complete this protocol element.  
+ *	  calls to this function to complete this protocol element.
  *	  In those subsequent calls, futurelen will be -1 to indicate
  *	  that the current data is a continuation of the same protocol
  *	  element.
@@ -1020,8 +1020,8 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
  *
  * Side Effects:
  *	Recording hooks needed by client will be uninstalled if the context
- *	is enabled.  The designated client will be removed from the 
- *	pRCAP->pClientIDs array.  If it was the only client on the RCAP, 
+ *	is enabled.  The designated client will be removed from the
+ *	pRCAP->pClientIDs array.  If it was the only client on the RCAP,
  *	the RCAP is removed from the context and freed.  (Invariant: RCAPs
  *	have at least one client.)
  */
@@ -1064,7 +1064,7 @@ RecordDeleteClientFromRCAP(RecordClientsAndProtocolPtr pRCAP, int position)
  *
  * Side Effects:
  *	Recording hooks needed by client will be installed if the context
- *	is enabled.  The designated client will be added to the 
+ *	is enabled.  The designated client will be added to the
  *	pRCAP->pClientIDs array, which may be realloced.
  *	pRCAP->clientIDsSeparatelyAllocated may be set to 1 if there
  *	is no more room to hold clients internal to the RCAP.
@@ -1173,8 +1173,8 @@ RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs,
  *	pClientspecs is an array of CLIENTSPECs that have been sanity
  *	  checked.
  *	pNumClientspecs is a pointer to the number of elements in pClientspecs.
- *	excludespec, if non-zero, is the resource id base of a client that 
- *	  should not be included in the expansion of XRecordAllClients or 
+ *	excludespec, if non-zero, is the resource id base of a client that
+ *	  should not be included in the expansion of XRecordAllClients or
  *	  XRecordCurrentClients.
  *
  * Returns:
@@ -1379,7 +1379,7 @@ RecordSanityCheckRegisterClients(RecordContextPtr pContext, ClientPtr client,
 }                               /* end RecordSanityCheckRegisterClients */
 
 /* This is a tactical structure used to gather information about all the sets
- * (RecordSetPtr) that need to be created for an RCAP in the process of 
+ * (RecordSetPtr) that need to be created for an RCAP in the process of
  * digesting a list of RECORDRANGEs (converting it to the internal
  * representation).
  */
@@ -1447,7 +1447,7 @@ RecordAllocIntervals(SetInfoPtr psi, int nIntervals)
  * Returns:  BadAlloc if a memory allocation error occurred, else Success.
  *
  * Side Effects:
- *	The slice of pRanges indicated by byteoffset is stored in psi.  
+ *	The slice of pRanges indicated by byteoffset is stored in psi.
  *	If pExtSetInfo is non-NULL, minor opcode intervals are stored
  *	in an existing SetInfoRec if the major opcode interval matches, else
  *	they are stored in a new SetInfoRec, and *pnExtSetInfo is
@@ -2639,7 +2639,7 @@ SProcRecordDispatch(ClientPtr client)
 /* RecordConnectionSetupInfo
  *
  * Arguments:
- *	pContext is an enabled context that specifies recording of 
+ *	pContext is an enabled context that specifies recording of
  *	  connection setup info.
  *	pci holds the connection setup info.
  *
diff --git a/xorg-server/render/animcur.c b/xorg-server/render/animcur.c
index 69f9f88..825ae1f 100644
--- a/xorg-server/render/animcur.c
+++ b/xorg-server/render/animcur.c
@@ -159,7 +159,7 @@ AnimCurScreenBlockHandler(ScreenPtr pScreen,
 
                 /*
                  * Not a simple Unwrap/Wrap as this
-                 * isn't called along the DisplayCursor 
+                 * isn't called along the DisplayCursor
                  * wrapper chain.
                  */
                 DisplayCursor = pScreen->DisplayCursor;
diff --git a/xorg-server/render/glyph.c b/xorg-server/render/glyph.c
index ae38121..f3310db 100644
--- a/xorg-server/render/glyph.c
+++ b/xorg-server/render/glyph.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/render/glyphstr.h b/xorg-server/render/glyphstr.h
index 835c1a7..2df055d 100644
--- a/xorg-server/render/glyphstr.h
+++ b/xorg-server/render/glyphstr.h
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/render/mipict.h b/xorg-server/render/mipict.h
index a16dd31..23ce9e8 100644
--- a/xorg-server/render/mipict.h
+++ b/xorg-server/render/mipict.h
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c
index cd9bc74..711cbc7 100644
--- a/xorg-server/render/picture.c
+++ b/xorg-server/render/picture.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
diff --git a/xorg-server/render/picture.h b/xorg-server/render/picture.h
index c85353a..66c85c5 100644
--- a/xorg-server/render/picture.h
+++ b/xorg-server/render/picture.h
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
@@ -129,7 +129,7 @@ typedef enum _PictFormatShort {
 } PictFormatShort;
 
 /*
- * For dynamic indexed visuals (GrayScale and PseudoColor), these control the 
+ * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
  * selection of colors allocated for drawing to Pictures.  The default
  * policy depends on the size of the colormap:
  *
@@ -189,8 +189,8 @@ typedef pixman_fixed_1_16_t xFixed_1_16;
 typedef pixman_fixed_16_16_t xFixed_16_16;
 
 /*
- * An unadorned "xFixed" is the same as xFixed_16_16, 
- * (since it's quite common in the code) 
+ * An unadorned "xFixed" is the same as xFixed_16_16,
+ * (since it's quite common in the code)
  */
 typedef pixman_fixed_t xFixed;
 
diff --git a/xorg-server/render/render.c b/xorg-server/render/render.c
index 9ac4a98..e3031da 100644
--- a/xorg-server/render/render.c
+++ b/xorg-server/render/render.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
@@ -1548,7 +1548,7 @@ ProcRenderCreateCursor(ClientPtr client)
         FreePicture(pPicture, 0);
     }
     /*
-     * Check whether the cursor can be directly supported by 
+     * Check whether the cursor can be directly supported by
      * the core cursor code
      */
     ncolor = 0;
diff --git a/xorg-server/xfixes/cursor.c b/xorg-server/xfixes/cursor.c
index 31a408f..94d24a8 100644
--- a/xorg-server/xfixes/cursor.c
+++ b/xorg-server/xfixes/cursor.c
@@ -632,7 +632,7 @@ ReplaceCursor(CursorPtr pCursor, TestCursorFunc testCursor, void *closure)
     int resIndex;
     ReplaceCursorLookupRec rcl;
 
-    /* 
+    /*
      * Cursors exist only in the resource database, windows and grabs.
      * All of these are always pointed at by the resource database.  Walk
      * the whole thing looking for cursors
@@ -735,7 +735,7 @@ SProcXFixesChangeCursorByName(ClientPtr client)
 
 /*
  * Routines for manipulating the per-screen hide counts list.
- * This list indicates which clients have requested cursor hiding 
+ * This list indicates which clients have requested cursor hiding
  * for that screen.
  */
 
@@ -772,7 +772,7 @@ createCursorHideCount(ClientPtr pClient, ScreenPtr pScreen)
     pChc->pNext = cs->pCursorHideCounts;
     cs->pCursorHideCounts = pChc;
 
-    /* 
+    /*
      * Create a resource for this element so it can be deleted
      * when the client goes away.
      */
@@ -784,7 +784,7 @@ createCursorHideCount(ClientPtr pClient, ScreenPtr pScreen)
     return Success;
 }
 
-/* 
+/*
  * Delete the given hide-counts list element from its screen list.
  */
 static void
@@ -812,7 +812,7 @@ deleteCursorHideCount(CursorHideCountPtr pChcToDel, ScreenPtr pScreen)
     }
 }
 
-/* 
+/*
  * Delete all the hide-counts list elements for this screen.
  */
 static void
@@ -848,9 +848,9 @@ ProcXFixesHideCursor(ClientPtr client)
         return ret;
     }
 
-    /* 
-     * Has client hidden the cursor before on this screen? 
-     * If so, just increment the count. 
+    /*
+     * Has client hidden the cursor before on this screen?
+     * If so, just increment the count.
      */
 
     pChc = findCursorHideCount(client, pWin->drawable.pScreen);
@@ -859,8 +859,8 @@ ProcXFixesHideCursor(ClientPtr client)
         return Success;
     }
 
-    /* 
-     * This is the first time this client has hid the cursor 
+    /*
+     * This is the first time this client has hid the cursor
      * for this screen.
      */
     ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
@@ -912,7 +912,7 @@ ProcXFixesShowCursor(ClientPtr client)
         return rc;
     }
 
-    /* 
+    /*
      * Has client hidden the cursor on this screen?
      * If not, generate an error.
      */
diff --git a/xorg-server/xfixes/region.c b/xorg-server/xfixes/region.c
index 4cfeee1..4492f12 100644
--- a/xorg-server/xfixes/region.c
+++ b/xorg-server/xfixes/region.c
@@ -222,20 +222,13 @@ ProcXFixesCreateRegionFromGC(ClientPtr client)
     if (rc != Success)
         return rc;
 
-    switch (pGC->clientClipType) {
-    case CT_PIXMAP:
-        pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
-        if (!pRegion)
-            return BadAlloc;
-        break;
-    case CT_REGION:
+    if (pGC->clientClip) {
         pClip = (RegionPtr) pGC->clientClip;
         pRegion = XFixesRegionCopy(pClip);
         if (!pRegion)
             return BadAlloc;
-        break;
-    default:
-        return BadImplementation;       /* assume sane server bits */
+    } else {
+        return BadMatch;
     }
 
     if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c
index 20e0459..78c9837 100644
--- a/xorg-server/xkb/XKBAlloc.c
+++ b/xorg-server/xkb/XKBAlloc.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/XKBGAlloc.c b/xorg-server/xkb/XKBGAlloc.c
index 8880784..25917d3 100644
--- a/xorg-server/xkb/XKBGAlloc.c
+++ b/xorg-server/xkb/XKBGAlloc.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/XKBMAlloc.c b/xorg-server/xkb/XKBMAlloc.c
index 3ffd5da..37ed1a7 100644
--- a/xorg-server/xkb/XKBMAlloc.c
+++ b/xorg-server/xkb/XKBMAlloc.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -357,7 +357,7 @@ XkbResizeKeyType(XkbDescPtr xkb,
      *      might have to be enlarged.
      * If the key type decreased in size:
      *    - keys that have a group width > the old width don't have to be
-     *      resized (because they must have some other wider type associated 
+     *      resized (because they must have some other wider type associated
      *      with some group).
      *    + keys that have a group width == the old width might have to be
      *      shrunk.
diff --git a/xorg-server/xkb/XKBMisc.c b/xorg-server/xkb/XKBMisc.c
index 6abd1d1..df268b5 100644
--- a/xorg-server/xkb/XKBMisc.c
+++ b/xorg-server/xkb/XKBMisc.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxBeep.c b/xorg-server/xkb/ddxBeep.c
index caf78c9..52353ea 100644
--- a/xorg-server/xkb/ddxBeep.c
+++ b/xorg-server/xkb/ddxBeep.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxCtrls.c b/xorg-server/xkb/ddxCtrls.c
index 0805fb2..964ac3d 100644
--- a/xorg-server/xkb/ddxCtrls.c
+++ b/xorg-server/xkb/ddxCtrls.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxKillSrv.c b/xorg-server/xkb/ddxKillSrv.c
index 1cabb1b..7c7e739 100644
--- a/xorg-server/xkb/ddxKillSrv.c
+++ b/xorg-server/xkb/ddxKillSrv.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxLEDs.c b/xorg-server/xkb/ddxLEDs.c
index 81b7b00..e5aecb5 100644
--- a/xorg-server/xkb/ddxLEDs.c
+++ b/xorg-server/xkb/ddxLEDs.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxLoad.c b/xorg-server/xkb/ddxLoad.c
index 1dc0e4e..f71815a 100644
--- a/xorg-server/xkb/ddxLoad.c
+++ b/xorg-server/xkb/ddxLoad.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/ddxVT.c b/xorg-server/xkb/ddxVT.c
index 6529102..f3cd26a 100644
--- a/xorg-server/xkb/ddxVT.c
+++ b/xorg-server/xkb/ddxVT.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c
index 6f5f8cc..28148d9 100644
--- a/xorg-server/xkb/maprules.c
+++ b/xorg-server/xkb/maprules.c
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c
index dc570f0..15c7f34 100644
--- a/xorg-server/xkb/xkb.c
+++ b/xorg-server/xkb/xkb.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -3986,7 +3986,7 @@ _XkbSetNamesCheck(ClientPtr client, DeviceIntPtr dev,
 {
     XkbDescRec *xkb;
     CARD32 *tmp;
-    Atom bad;
+    Atom bad = None;
 
     tmp = data;
     xkb = dev->key->xkbInfo->desc;
diff --git a/xorg-server/xkb/xkbAccessX.c b/xorg-server/xkb/xkbAccessX.c
index 5f3de0d..7fd6a48 100644
--- a/xorg-server/xkb/xkbAccessX.c
+++ b/xorg-server/xkb/xkbAccessX.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -598,7 +598,7 @@ AccessXFilterReleaseEvent(DeviceEvent *event, DeviceIntPtr keybd)
     Bool ignoreKeyEvent = FALSE;
 
     /* Don't transmit the KeyRelease if BounceKeys is on and
-     * this is the release of a key that was ignored due to 
+     * this is the release of a key that was ignored due to
      * BounceKeys.
      */
     if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c
index c44f44b..2a196f1 100644
--- a/xorg-server/xkb/xkbActions.c
+++ b/xorg-server/xkb/xkbActions.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c
index cc9a535..0dbbd6c 100644
--- a/xorg-server/xkb/xkbEvents.c
+++ b/xorg-server/xkb/xkbEvents.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c
index 06ec46e..30e10bd 100644
--- a/xorg-server/xkb/xkbInit.c
+++ b/xorg-server/xkb/xkbInit.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -676,9 +676,9 @@ InitKeyboardDeviceStructFromString(DeviceIntPtr dev,
 /***====================================================================***/
 
         /*
-         * Be very careful about what does and doesn't get freed by this 
-         * function.  To reduce fragmentation, XkbInitDevice allocates a 
-         * single huge block per device and divides it up into most of the 
+         * Be very careful about what does and doesn't get freed by this
+         * function.  To reduce fragmentation, XkbInitDevice allocates a
+         * single huge block per device and divides it up into most of the
          * fixed-size structures for the device.   Don't free anything that
          * is part of this larger block.
          */
diff --git a/xorg-server/xkb/xkbLEDs.c b/xorg-server/xkb/xkbLEDs.c
index e1e22d1..4e16002 100644
--- a/xorg-server/xkb/xkbLEDs.c
+++ b/xorg-server/xkb/xkbLEDs.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -47,8 +47,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
          * XkbIndicatorsToUpdate(dev,changed,check_devs_rtrn)
          *
          * Given a keyboard and a set of state components that have changed,
-         * this function returns the indicators on the default keyboard 
-         * feedback that might be affected.   It also reports whether or not 
+         * this function returns the indicators on the default keyboard
+         * feedback that might be affected.   It also reports whether or not
          * any extension devices might be affected in check_devs_rtrn.
          */
 
@@ -85,10 +85,10 @@ XkbIndicatorsToUpdate(DeviceIntPtr dev,
          * Bool
          *XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
          *
-         * Some indicators "drive" the keyboard when their state is explicitly 
+         * Some indicators "drive" the keyboard when their state is explicitly
          * changed, as described in section 9.2.1 of the XKB protocol spec.
-         * This function updates the state and controls for the keyboard 
-         * specified by 'xkbi' to reflect any changes that are required 
+         * This function updates the state and controls for the keyboard
+         * specified by 'xkbi' to reflect any changes that are required
          * when the indicator described by 'map' is turned on or off.  The
          * extent of the changes is reported in change, which must be defined.
          */
@@ -357,9 +357,9 @@ XkbUpdateAllDeviceIndicators(XkbChangesPtr changes, XkbEventCausePtr cause)
          * attempted change.   If 'changes' is NULL, this function generates
          * XKB events to report any such changes to interested clients.
          *
-         * If 'cause' is non-NULL, it specifies the reason for the change, 
-         * as reported in some XKB events.   If it is NULL, this function 
-         * assumes that the change is the result of a core protocol 
+         * If 'cause' is non-NULL, it specifies the reason for the change,
+         * as reported in some XKB events.   If it is NULL, this function
+         * assumes that the change is the result of a core protocol
          * ChangeKeyboardMapping request.
          */
 
@@ -407,7 +407,7 @@ XkbSetIndicators(DeviceIntPtr dev,
          *
          * Applies the indicator maps for any indicators specified in
          * 'update' from the default keyboard feedback on the device
-         * specified by 'dev.' 
+         * specified by 'dev.'
          *
          * If 'changes' is NULL, this function generates and XKB events
          * required to report the necessary changes, otherwise it simply
@@ -442,9 +442,9 @@ XkbUpdateIndicators(DeviceIntPtr dev,
          * XkbCheckIndicatorMaps(dev,sli,which)
          *
          * Updates the 'indicator accelerators' for the indicators specified
-         * by 'which' in the feedback specified by 'sli.' The indicator 
-         * accelerators are internal to the server and are used to simplify 
-         * and speed up the process of figuring out which indicators might 
+         * by 'which' in the feedback specified by 'sli.' The indicator
+         * accelerators are internal to the server and are used to simplify
+         * and speed up the process of figuring out which indicators might
          * be affected by a particular change in keyboard state or controls.
          */
 
@@ -677,7 +677,7 @@ XkbCopySrvLedInfo(DeviceIntPtr from,
          *
          * Finds the XkbSrvLedInfoPtr for the specified 'class' and 'id'
          * on the device specified by 'dev.'   If the class and id specify
-         * a valid device feedback, this function returns the existing 
+         * a valid device feedback, this function returns the existing
          * feedback or allocates a new one.
          *
          */
@@ -839,7 +839,7 @@ XkbApplyLedNameChanges(DeviceIntPtr dev,
          *
          * Handles all of the secondary effects of the changes to the
          * feedback specified by 'sli' on the device specified by 'dev.'
-         * 
+         *
          * If 'changed_maps' specifies any indicators, this function generates
          * XkbExtensionDeviceNotify events and possibly IndicatorMapNotify
          * events to report the changes, and recalculates the effective
diff --git a/xorg-server/xkb/xkbPrKeyEv.c b/xorg-server/xkb/xkbPrKeyEv.c
index b24fd6c..f7a6b4b 100644
--- a/xorg-server/xkb/xkbPrKeyEv.c
+++ b/xorg-server/xkb/xkbPrKeyEv.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbSwap.c b/xorg-server/xkb/xkbSwap.c
index 076da34..ecec63e 100644
--- a/xorg-server/xkb/xkbSwap.c
+++ b/xorg-server/xkb/xkbSwap.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c
index c14a790..6019f0f 100644
--- a/xorg-server/xkb/xkbUtils.c
+++ b/xorg-server/xkb/xkbUtils.c
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c
index d96ee4b..2ecdcd5 100644
--- a/xorg-server/xkb/xkbfmisc.c
+++ b/xorg-server/xkb/xkbfmisc.c
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbgeom.h b/xorg-server/xkb/xkbgeom.h
index 1999f5c..5ade436 100644
--- a/xorg-server/xkb/xkbgeom.h
+++ b/xorg-server/xkb/xkbgeom.h
@@ -6,19 +6,19 @@ software and its documentation for any purpose and without
 fee is hereby granted, provided that the above copyright
 notice appear in all copies and that both that copyright
 notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
 of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
+Silicon Graphics makes no representation about the suitability
 of this software for any purpose. It is provided "as is"
 without any express or implied warranty.
 
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbout.c b/xorg-server/xkb/xkbout.c
index 7bb6cea..5f77ab0 100644
--- a/xorg-server/xkb/xkbout.c
+++ b/xorg-server/xkb/xkbout.c
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkbtext.c b/xorg-server/xkb/xkbtext.c
index fdf1d17..ffbc546 100644
--- a/xorg-server/xkb/xkbtext.c
+++ b/xorg-server/xkb/xkbtext.c
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkb/xkmread.c b/xorg-server/xkb/xkmread.c
index b6241b5..0b9f0ef 100644
--- a/xorg-server/xkb/xkmread.c
+++ b/xorg-server/xkb/xkmread.c
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- 
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
diff --git a/xorg-server/xkeyboard-config/README b/xorg-server/xkeyboard-config/README
index 2be1ab6..2564025 100644
--- a/xorg-server/xkeyboard-config/README
+++ b/xorg-server/xkeyboard-config/README
@@ -1,28 +1,46 @@
 X Keyboard Extension
 --------------------
 
-The X Keyboard Extension essentially replaces the core protocol definition
-of the keyboard.  The extension makes it possible to clearly and explicitly
-specify most aspects of keyboard behaviour on a per-key basis and to more
-closely track the logical and physical state of the keyboard.  It also
-includes a number of keyboard controls designed to make keyboards more
-accessible to people with physical impairments.
+The X Keyboard (XKB) Extension essentially replaces the core protocol
+definition of a keyboard. The extension makes it possible to specify
+clearly and explicitly most aspects of keyboard behaviour on a per-key
+basis, and to track more closely the logical and physical state of a
+keyboard. It also includes a number of keyboard controls designed to
+make keyboards more accessible to people with physical impairments.
 
-There are five types of components in the server database corresponding to
-five xkb symbolic names (symbols, geometry, keycodes, compat, and types)
-which determine the keyboard behaviour.  These five components can be
-combined into a resulting keyboard mapping using the 'rules' component.
+There are five components that define a complete keyboard mapping:
+symbols, geometry, keycodes, compat, and types; these five components
+can be combined together using the 'rules' component of the database
+provided by this project, xkeyboard-config.
 
-The complete specification can be found in:
-  http://www.x.org/current/doc/kbproto/xkbproto.pdf
+The complete specification for the XKB Extension can be found here:
 
-For XKB configuration information, see the 'docs/README.config' file.
+  http://xfree86.org/current/XKBproto.pdf
 
-For information on how to further enhance XKB configuration, see the
-'docs/README.enhancing' file.
+xkeyboard-config
+----------------
 
-For information on how to replace an existing XKB configuration database
-with XKeyboardConfig, see the 'docs/HOWTO.transition' file.
+This project provides a consistent, well-structured, frequently
+released, open source database of keyboard configuration data. The
+project is targeted to XKB-based systems.
+
+For XKB configuration information, see:
+
+  docs/README.config
+
+For information on how to enhance the database itself, see:
+
+  docs/README.enhancing
+
+For information on how to replace an older XKB configuration database
+with the one provided by this project, see:
+
+  docs/HOWTO.transition
+
+For guidelines to making contributions to this project, see:
 
-Contribution guidelines are described on:
   http://www.freedesktop.org/wiki/Software/XKeyboardConfig/Rules
+
+To submit bug reports (and patches), please use the bugzilla system:
+
+  https://bugs.freedesktop.org/enter_bug.cgi?product=xkeyboard-config

--
Alioth's /srv/git/code.x2go.org/vcxsrv.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/vcxsrv.git


More information about the x2go-commits mailing list