[Xquartz-changes] mesa: Branch 'master' - 20 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Jun 13 21:58:58 PDT 2011


Rebased ref, commits from common ancestor:
commit 097897eb997abce776e7e2acb6ce35c2ea129793
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Jun 13 12:09:47 2011 -0700

    NOT TO ORIGIN: -ggdb3 -O0
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configs/darwin b/configs/darwin
index 9527f61..e33941b 100644
--- a/configs/darwin
+++ b/configs/darwin
@@ -25,9 +25,9 @@ DEFINES =  -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \
 
 ARCH_FLAGS += $(RC_CFLAGS)
 
-CFLAGS =  -ggdb3 -Os -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing -fvisibility=hidden \
+CFLAGS =  -ggdb3 -O0 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing -fvisibility=hidden \
 	-I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
-CXXFLAGS =  -ggdb3 -Os -Wall -fno-strict-aliasing -fvisibility=hidden \
+CXXFLAGS =  -ggdb3 -O0 -Wall -fno-strict-aliasing -fvisibility=hidden \
 	-I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
 
 # Library names (actual file names)
commit 11b673f6923a4670089fcd9c0d383a08e2ed901f
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Jun 13 11:46:46 2011 -0700

    NOT TO ORIGIN: getpid()
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/src/glx/apple/apple_cgl.c b/src/glx/apple/apple_cgl.c
index 648ed86..9875d08 100644
--- a/src/glx/apple/apple_cgl.c
+++ b/src/glx/apple/apple_cgl.c
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <dlfcn.h>
+#include <unistd.h>
 
 #include "apple_cgl.h"
 #include "apple_glx.h"
@@ -69,6 +70,9 @@ apple_cgl_init(void)
    if (initialized)
       return;
 
+   fprintf(stderr, "PID: %d\n", getpid());
+   sleep(20);
+
    opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
    if (!opengl_framework_path) {
       opengl_framework_path = OPENGL_FRAMEWORK_PATH;
commit c38182b6aa3c1b0e966e4d4fa5321ac807ce62c6
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Jun 13 14:38:23 2011 -0700

    NOT TO ORIGIN: hacks to use make_context_current like we used to
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
index ba17535..a25cef3 100644
--- a/src/glx/glxcurrent.c
+++ b/src/glx/glxcurrent.c
@@ -212,7 +212,15 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 {
    struct glx_context *gc = (struct glx_context *) gc_user;
    struct glx_context *oldGC = __glXGetCurrentContext();
-
+#ifdef GLX_USE_APPLEGL
+   bool error = apple_glx_make_current_context(dpy, 
+                   (oldGC && oldGC != &dummyContext) ? oldGC->driContext : NULL, 
+                   gc ? gc->driContext : NULL, draw);
+   
+   apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
+   if(error)
+      return GL_FALSE;
+#else
    /* XXX: If this is left out, then libGL ends up not having this
     * symbol, and drivers using it fail to load.  Compare the
     * implementation of this symbol to _glapi_noop_enable_warnings(),
@@ -242,6 +250,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
    }
 
    _glapi_check_multithread();
+#endif
 
    __glXLock();
    if (oldGC == gc &&
@@ -260,6 +269,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
    }
 
    if (gc) {
+#ifndef GLX_USE_APPLEGL
       /* Attempt to bind the context.  We do this before mucking with
        * gc and __glXSetCurrentContext to properly handle our state in
        * case of an error.
@@ -274,6 +284,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
          __glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
          return GL_FALSE;
       }
+#endif
 
       if (gc->thread_refcount++ == 0) {
 	 gc->currentDpy = dpy;
commit 3dd070f124b631d19593b81e177f945278a5d97a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Jun 13 21:57:38 2011 -0700

    glx: Destroy the old context only after the new one has been bound
    
    This fixes a regression introduced by 49d7e48b33264d94e30af6129c281b6acafa9427
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
index 9027734..ba17535 100644
--- a/src/glx/glxcurrent.c
+++ b/src/glx/glxcurrent.c
@@ -256,13 +256,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 	 oldGC->currentDpy = 0;
 	 oldGC->currentDrawable = None;
 	 oldGC->currentReadable = None;
-
-	 if (oldGC->xid == None && oldGC != gc) {
-	    /* We are switching away from a context that was
-	     * previously destroyed, so we need to free the memory
-	     * for the old handle. */
-	    oldGC->vtable->destroy(oldGC);
-	 }
       }
    }
 
@@ -292,6 +285,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       __glXSetCurrentContextNull();
    }
 
+   if (oldGC->thread_refcount == 0 && oldGC != &dummyContext && oldGC->xid == None) {
+      /* We are switching away from a context that was
+       * previously destroyed, so we need to free the memory
+       * for the old handle. */
+      oldGC->vtable->destroy(oldGC);
+   }
+
    __glXUnlock();
    return GL_TRUE;
 }
commit eb8d629f43c0a4188de5e902beb078f87cd3705a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Jun 13 09:31:21 2011 -0700

    glx: Bind to our context before __glXSetCurrentContext
    
    We want to bind to our context before calling __glXSetCurrentContext or
    messing with the gc rect in order to properly handle error conditions.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
index 064fd71..9027734 100644
--- a/src/glx/glxcurrent.c
+++ b/src/glx/glxcurrent.c
@@ -212,7 +212,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 {
    struct glx_context *gc = (struct glx_context *) gc_user;
    struct glx_context *oldGC = __glXGetCurrentContext();
-   int ret = Success;
 
    /* XXX: If this is left out, then libGL ends up not having this
     * symbol, and drivers using it fail to load.  Compare the
@@ -268,24 +267,32 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
    }
 
    if (gc) {
+      /* Attempt to bind the context.  We do this before mucking with
+       * gc and __glXSetCurrentContext to properly handle our state in
+       * case of an error.
+       *
+       * If an error occurs, set the Null context since we've already
+       * blown away our old context.  The caller is responsible for
+       * figuring out how to handle setting a valid context.
+       */
+      if (gc->vtable->bind(gc, oldGC, draw, read) != Success) {
+         __glXSetCurrentContextNull();
+         __glXUnlock();
+         __glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
+         return GL_FALSE;
+      }
+
       if (gc->thread_refcount++ == 0) {
 	 gc->currentDpy = dpy;
 	 gc->currentDrawable = draw;
 	 gc->currentReadable = read;
       }
       __glXSetCurrentContext(gc);
-      ret = gc->vtable->bind(gc, oldGC, draw, read);
    } else {
       __glXSetCurrentContextNull();
    }
 
    __glXUnlock();
-
-   if (ret) {
-      __glXGenerateError(dpy, None, ret, X_GLXMakeContextCurrent);
-      return GL_FALSE;
-   }
-
    return GL_TRUE;
 }
 
commit c17fb8539fcdeb6ebbc0c8a9ff010d1bc01b695f
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 04:03:17 2011 +0200

    configure.ac: cleanup the gallium-r300 option

diff --git a/configure.ac b/configure.ac
index 3e81441..69513c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1741,6 +1741,14 @@ gallium_check_st() {
     fi
 }
 
+gallium_require_llvm() {
+    if test "x$MESA_LLVM" = x0; then
+        case "$host_cpu" in
+        i*86|x86_64) AC_MSG_ERROR([LLVM is required to build $1 on x86 and x86_64]);;
+        esac
+    fi
+}
+
 
 dnl
 dnl Gallium SVGA configuration
@@ -1793,28 +1801,14 @@ dnl
 dnl Gallium Radeon r300g configuration
 dnl
 AC_ARG_ENABLE([gallium-r300],
-    [AS_HELP_STRING([--enable-gallium-r300],
-        [build gallium r300 @<:@default=build DRI driver only@:>@])],
+    [AS_HELP_STRING([--disable-gallium-r300],
+        [build R300 driver @<:@default=enabled@:>@])],
     [enable_gallium_r300="$enableval"],
-    [enable_gallium_r300=auto])
+    [enable_gallium_r300=yes])
 
-if test "$mesa_driver" != dri ; then
-    if test "x$enable_gallium_r300" = xauto; then
-      enable_gallium_r300=no
-    fi
-fi
+if test "x$enable_gallium_r300" = xyes && test "x$mesa_driver" = xdri; then
+    gallium_require_llvm "Gallium R300"
 
-if test "x$enable_gallium_r300" != xno; then
-    if test "x$MESA_LLVM" = x0; then
-        case "$host_cpu" in
-        i*86|x86_64) AC_MSG_ERROR([LLVM is required to build Gallium R300 on x86 and x86_64]);;
-        esac
-    fi
-fi
-if test "x$enable_gallium_r300" = xauto; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
-    gallium_check_st "radeon/drm" "dri-r300"
-elif test "x$enable_gallium_r300" = xyes; then
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
     gallium_check_st "radeon/drm" "dri-r300" "xorg-r300"
 fi
commit e823ab1b002560c02edc2d9f165e3b150b5e020e
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 03:48:06 2011 +0200

    st/xorg: remove unused variable

diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 234574b..af4992f 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -466,7 +466,6 @@ bind_samplers(struct xorg_xv_port_priv *port)
 {
    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_state sampler;
-   struct pipe_resource **dst = port->yuv[port->current_set];
    struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set];
 
    memset(&sampler, 0, sizeof(struct pipe_sampler_state));
commit f318a15f45b726095ae8d95cabb2c9ce4ce24215
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 01:41:39 2011 +0200

    r600g: do not link with softpipe

diff --git a/src/gallium/targets/dri-r600/Makefile b/src/gallium/targets/dri-r600/Makefile
index c8fae2d..0c4de20 100644
--- a/src/gallium/targets/dri-r600/Makefile
+++ b/src/gallium/targets/dri-r600/Makefile
@@ -7,7 +7,6 @@ PIPE_DRIVERS = \
 	$(TOP)/src/gallium/drivers/r600/libr600.a \
 	$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
 	$(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
-	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
 	$(TOP)/src/gallium/drivers/trace/libtrace.a \
 	$(TOP)/src/gallium/drivers/rbug/librbug.a \
 	$(TOP)/src/gallium/drivers/noop/libnoop.a
commit b5b7d2acc6da4149a0c6b124ad52fa08f68cb136
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 01:41:11 2011 +0200

    r300g: do not link with softpipe

diff --git a/src/gallium/targets/dri-r300/Makefile b/src/gallium/targets/dri-r300/Makefile
index cc77a4b..a1bb753 100644
--- a/src/gallium/targets/dri-r300/Makefile
+++ b/src/gallium/targets/dri-r300/Makefile
@@ -6,7 +6,6 @@ LIBNAME = r300_dri.so
 PIPE_DRIVERS = \
 	$(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
 	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
-	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
 	$(TOP)/src/gallium/drivers/galahad/libgalahad.a \
 	$(TOP)/src/gallium/drivers/trace/libtrace.a \
 	$(TOP)/src/gallium/drivers/rbug/librbug.a \
commit be2b9bdcee67c0bc1d81c3fcec548e8981488ee0
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 01:00:36 2011 +0200

    xorg-radeon: rename to xorg-r300

diff --git a/configure.ac b/configure.ac
index 1e5f9ce..3e81441 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1816,7 +1816,7 @@ if test "x$enable_gallium_r300" = xauto; then
     gallium_check_st "radeon/drm" "dri-r300"
 elif test "x$enable_gallium_r300" = xyes; then
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
-    gallium_check_st "radeon/drm" "dri-r300" "xorg-radeon"
+    gallium_check_st "radeon/drm" "dri-r300" "xorg-r300"
 fi
 
 dnl
diff --git a/src/gallium/targets/xorg-r300/Makefile b/src/gallium/targets/xorg-r300/Makefile
new file mode 100644
index 0000000..195ab81
--- /dev/null
+++ b/src/gallium/targets/xorg-r300/Makefile
@@ -0,0 +1,24 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = r300_drv.so
+
+C_SOURCES = \
+	target.c \
+	xorg.c
+
+DRIVER_DEFINES = \
+	-DHAVE_CONFIG_H -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
+
+DRIVER_PIPES = \
+	$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+	$(TOP)/src/gallium/drivers/r300/libr300.a \
+	$(TOP)/src/gallium/drivers/galahad/libgalahad.a \
+	$(TOP)/src/gallium/drivers/trace/libtrace.a \
+	$(TOP)/src/gallium/drivers/rbug/librbug.a
+
+DRIVER_LINKS = \
+	$(shell pkg-config --libs libdrm)
+
+include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-r300/target.c b/src/gallium/targets/xorg-r300/target.c
new file mode 100644
index 0000000..b48bcad
--- /dev/null
+++ b/src/gallium/targets/xorg-r300/target.c
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+   struct radeon_winsys *sws;
+   struct pipe_screen *screen;
+
+   sws = radeon_drm_winsys_create(fd);
+   if (!sws)
+      return NULL;
+
+   screen = r300_screen_create(sws);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r300", "radeon", create_screen)
diff --git a/src/gallium/targets/xorg-r300/xorg.c b/src/gallium/targets/xorg-r300/xorg.c
new file mode 100644
index 0000000..933bfb8
--- /dev/null
+++ b/src/gallium/targets/xorg-r300/xorg.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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 TUNGSTEN GRAPHICS 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.
+ *
+ *
+ * Author: Alan Hourihane <alanh at tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker at gmail.com>
+ * Author: Corbin Simpson <MostAwesomedude at gmail.com>
+ *
+ */
+
+#include "../../state_trackers/xorg/xorg_winsys.h"
+
+static void r300_xorg_identify(int flags);
+static Bool r300_xorg_pci_probe(DriverPtr driver,
+				 int entity_num,
+				 struct pci_device *device,
+				 intptr_t match_data);
+
+static const struct pci_id_match r300_xorg_device_match[] = {
+    {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec r300_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "ATI R300 Graphics Chipset"},
+    {-1, NULL}
+};
+
+static PciChipsets r300_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo r300_xorg_version = {
+    "r300",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec r300_driver = {
+    1,
+    "r300",
+    r300_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    r300_xorg_device_match,
+    r300_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(r300_xorg_setup);
+
+_X_EXPORT XF86ModuleData r300ModuleData = {
+    &r300_xorg_version,
+    r300_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+r300_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+	setupDone = 1;
+	xf86AddDriver(&r300_driver, module, HaveDriverFuncs);
+
+	/*
+	 * The return value must be non-NULL on success even though there
+	 * is no TearDownProc.
+	 */
+	return (pointer) 1;
+    } else {
+	if (errmaj)
+	    *errmaj = LDR_ONCEONLY;
+	return NULL;
+    }
+}
+
+static void
+r300_xorg_identify(int flags)
+{
+    xf86PrintChipsets("r300", "Driver for Radeon Gallium with KMS",
+		      r300_xorg_chipsets);
+}
+
+static Bool
+r300_xorg_pci_probe(DriverPtr driver,
+	  int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, r300_xorg_pci_devices,
+			       NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+	scrn->driverVersion = 1;
+	scrn->driverName = "r300";
+	scrn->name = "r300";
+	scrn->Probe = NULL;
+
+	entity = xf86GetEntityInfo(entity_num);
+
+	/* Use all the functions from the xorg tracker */
+	xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile
deleted file mode 100644
index 6d5f2c3..0000000
--- a/src/gallium/targets/xorg-radeon/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = radeon_drv.so
-
-C_SOURCES = \
-	radeon_target.c \
-	radeon_xorg.c
-
-DRIVER_DEFINES = \
-	-DHAVE_CONFIG_H -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD
-
-DRIVER_PIPES = \
-	$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
-	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
-	$(TOP)/src/gallium/drivers/r300/libr300.a \
-	$(TOP)/src/gallium/drivers/galahad/libgalahad.a \
-	$(TOP)/src/gallium/drivers/trace/libtrace.a \
-	$(TOP)/src/gallium/drivers/rbug/librbug.a
-
-DRIVER_LINKS = \
-	$(shell pkg-config --libs libdrm)
-
-include ../Makefile.xorg
diff --git a/src/gallium/targets/xorg-radeon/radeon_target.c b/src/gallium/targets/xorg-radeon/radeon_target.c
deleted file mode 100644
index b8410ef..0000000
--- a/src/gallium/targets/xorg-radeon/radeon_target.c
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#include "target-helpers/inline_debug_helper.h"
-#include "state_tracker/drm_driver.h"
-#include "radeon/drm/radeon_drm_public.h"
-#include "r300/r300_public.h"
-
-static struct pipe_screen *
-create_screen(int fd)
-{
-   struct radeon_winsys *sws;
-   struct pipe_screen *screen;
-
-   sws = radeon_drm_winsys_create(fd);
-   if (!sws)
-      return NULL;
-
-   screen = r300_screen_create(sws);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
-DRM_DRIVER_DESCRIPTOR("radeon", "radeon", create_screen)
diff --git a/src/gallium/targets/xorg-radeon/radeon_xorg.c b/src/gallium/targets/xorg-radeon/radeon_xorg.c
deleted file mode 100644
index 0d6aa56..0000000
--- a/src/gallium/targets/xorg-radeon/radeon_xorg.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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 TUNGSTEN GRAPHICS 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.
- *
- *
- * Author: Alan Hourihane <alanh at tungstengraphics.com>
- * Author: Jakob Bornecrantz <wallbraker at gmail.com>
- * Author: Corbin Simpson <MostAwesomedude at gmail.com>
- *
- */
-
-#include "../../state_trackers/xorg/xorg_winsys.h"
-
-static void radeon_xorg_identify(int flags);
-static Bool radeon_xorg_pci_probe(DriverPtr driver,
-				 int entity_num,
-				 struct pci_device *device,
-				 intptr_t match_data);
-
-static const struct pci_id_match radeon_xorg_device_match[] = {
-    {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
-    {0, 0, 0},
-};
-
-static SymTabRec radeon_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "ATI/AMD Radeon Graphics Chipset"},
-    {-1, NULL}
-};
-
-static PciChipsets radeon_xorg_pci_devices[] = {
-    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
-    {-1, -1, NULL}
-};
-
-static XF86ModuleVersionInfo radeon_xorg_version = {
-    "radeong",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0, /* major, minor, patch */
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec radeong = {
-    1,
-    "radeong",
-    radeon_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    radeon_xorg_device_match,
-    radeon_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(radeon_xorg_setup);
-
-_X_EXPORT XF86ModuleData radeongModuleData = {
-    &radeon_xorg_version,
-    radeon_xorg_setup,
-    NULL
-};
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-	setupDone = 1;
-	xf86AddDriver(&radeong, module, HaveDriverFuncs);
-
-	/*
-	 * The return value must be non-NULL on success even though there
-	 * is no TearDownProc.
-	 */
-	return (pointer) 1;
-    } else {
-	if (errmaj)
-	    *errmaj = LDR_ONCEONLY;
-	return NULL;
-    }
-}
-
-static void
-radeon_xorg_identify(int flags)
-{
-    xf86PrintChipsets("radeong", "Driver for Radeon Gallium with KMS",
-		      radeon_xorg_chipsets);
-}
-
-static Bool
-radeon_xorg_pci_probe(DriverPtr driver,
-	  int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, radeon_xorg_pci_devices,
-			       NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-	scrn->driverVersion = 1;
-	scrn->driverName = "radeong";
-	scrn->name = "radeong";
-	scrn->Probe = NULL;
-
-	entity = xf86GetEntityInfo(entity_num);
-
-	/* Use all the functions from the xorg tracker */
-	xorg_tracker_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
commit 63e38bd0f6a1958f174a98e4b06be3fb152048b4
Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jun 14 01:23:20 2011 +0200

    target-helpers: remove copy-pasted function inline_noop_helper

diff --git a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
index 0433da6..c6630c4 100644
--- a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
@@ -22,6 +22,10 @@
 #include "galahad/glhd_public.h"
 #endif
 
+#ifdef GALLIUM_NOOP
+#include "noop/noop_public.h"
+#endif
+
 static INLINE struct pipe_screen *
 debug_screen_wrap(struct pipe_screen *screen)
 {
@@ -38,6 +42,10 @@ debug_screen_wrap(struct pipe_screen *screen)
    screen = galahad_screen_create(screen);
 #endif
 
+#if defined(GALLIUM_NOOP)
+   screen = noop_screen_create(screen);
+#endif
+
    return screen;
 }
 
diff --git a/src/gallium/auxiliary/target-helpers/inline_noop_helper.h b/src/gallium/auxiliary/target-helpers/inline_noop_helper.h
deleted file mode 100644
index 77c7cfd..0000000
--- a/src/gallium/auxiliary/target-helpers/inline_noop_helper.h
+++ /dev/null
@@ -1,51 +0,0 @@
-
-#ifndef INLINE_DEBUG_HELPER_H
-#define INLINE_DEBUG_HELPER_H
-
-#include "pipe/p_compiler.h"
-#include "util/u_debug.h"
-
-
-/* Helper function to wrap a screen with
- * one or more debug driver: rbug, trace.
- */
-
-#ifdef GALLIUM_TRACE
-#include "trace/tr_public.h"
-#endif
-
-#ifdef GALLIUM_RBUG
-#include "rbug/rbug_public.h"
-#endif
-
-#ifdef GALLIUM_GALAHAD
-#include "galahad/glhd_public.h"
-#endif
-
-#ifdef GALLIUM_NOOP
-#include "noop/noop_public.h"
-#endif
-
-static INLINE struct pipe_screen *
-debug_screen_wrap(struct pipe_screen *screen)
-{
-#if defined(GALLIUM_RBUG)
-   screen = rbug_screen_create(screen);
-#endif
-
-#if defined(GALLIUM_TRACE)
-   screen = trace_screen_create(screen);
-#endif
-
-#if defined(GALLIUM_GALAHAD)
-   screen = galahad_screen_create(screen);
-#endif
-
-#if defined(GALLIUM_NOOP)
-   screen = noop_screen_create(screen);
-#endif
-
-   return screen;
-}
-
-#endif
diff --git a/src/gallium/targets/dri-r600/target.c b/src/gallium/targets/dri-r600/target.c
index 2fe3454..8753e2b 100644
--- a/src/gallium/targets/dri-r600/target.c
+++ b/src/gallium/targets/dri-r600/target.c
@@ -1,5 +1,5 @@
 #include "state_tracker/drm_driver.h"
-#include "target-helpers/inline_noop_helper.h"
+#include "target-helpers/inline_debug_helper.h"
 #include "r600/drm/r600_drm_public.h"
 #include "r600/r600_public.h"
 
commit 9346d895e7ff6c1f01b46513694542026ffba5cc
Author: Vadim Girlin <vadimgirlin at gmail.com>
Date:   Mon Jun 13 05:43:47 2011 +0400

    r600g: skip SPI setup for position and face inputs
    
    fixes fdo bug 38145
    
    Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index d111caa..1b9f663 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -63,10 +63,6 @@ int r600_find_vs_semantic_index(struct r600_shader *vs,
 {
 	struct r600_shader_io *input = &ps->input[id];
 
-	/* position/face doesn't get/need a semantic index */
-	if (input->name == TGSI_SEMANTIC_POSITION || input->name == TGSI_SEMANTIC_FACE)
-		return 0;
-
 	for (int i = 0; i < vs->noutput; i++) {
 		if (input->name == vs->output[i].name &&
 			input->sid == vs->output[i].sid) {
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index d58c1f0..fa0c5cb 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -358,6 +358,10 @@ static void r600_spi_update(struct r600_pipe_context *rctx)
 
 	rstate->nregs = 0;
 	for (i = 0; i < rshader->ninput; i++) {
+		if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
+		    rshader->input[i].name == TGSI_SEMANTIC_FACE)
+			continue;
+
 		tmp = S_028644_SEMANTIC(r600_find_vs_semantic_index(&rctx->vs_shader->shader, rshader, i));
 
 		if (rshader->input[i].name == TGSI_SEMANTIC_COLOR ||
commit 2743851c1a73305dd83e42b99edc49906d9c0a51
Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Jun 7 15:41:30 2011 +1000

    r600g: move depth texture flushing out of line.
    
    this needs a piglit run.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 9ebfe54..f86e4d4 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -482,19 +482,27 @@ static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned cou
 	struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
 	struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
 	int i;
+	int has_depth = 0;
 
 	for (i = 0; i < count; i++) {
 		if (&rctx->ps_samplers.views[i]->base != views[i]) {
-			if (resource[i])
+			if (resource[i]) {
+				if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+					has_depth = 1;
 				evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state,
 									     i + R600_MAX_CONST_BUFFERS);
-			else
+			} else
 				evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, NULL,
 									     i + R600_MAX_CONST_BUFFERS);
 
 			pipe_sampler_view_reference(
 				(struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
 				views[i]);
+		} else {
+			if (resource[i]) {
+				if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+					has_depth = 1;
+			}
 		}
 	}
 	for (i = count; i < NUM_TEX_UNITS; i++) {
@@ -504,6 +512,7 @@ static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned cou
 			pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
 		}
 	}
+	rctx->have_depth_texture = has_depth;
 	rctx->ps_samplers.n_views = count;
 }
 
@@ -689,6 +698,9 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
 	surf = (struct r600_surface *)state->cbufs[cb];
 	rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
 
+	if (rtex->depth)
+		rctx->have_depth_fb = TRUE;
+
 	if (rtex->depth && !rtex->is_flushing_texture) {
 	        r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
 		rtex = rtex->flushed_depth_texture;
@@ -870,6 +882,7 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
 	util_copy_framebuffer_state(&rctx->framebuffer, state);
 
 	/* build states */
+	rctx->have_depth_fb = 0;
 	for (int i = 0; i < state->nr_cbufs; i++) {
 		evergreen_cb(rctx, rstate, state, i);
 	}
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index bf7138d..225c17c 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -261,6 +261,7 @@ struct r600_context {
 	struct r600_range vs_resources;
 	struct r600_range fs_resources;
 	int num_ps_resources, num_vs_resources, num_fs_resources;
+	boolean			have_depth_texture, have_depth_fb;
 };
 
 struct r600_draw {
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 151f48a..e9f35c1 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -121,8 +121,6 @@ void r600_flush_depth_textures(struct r600_pipe_context *rctx)
 {
 	unsigned int i;
 
-	if (rctx->blit) return;
-
 	/* FIXME: This handles fragment shader textures only. */
 
 	for (i = 0; i < rctx->ps_samplers.n_views; ++i) {
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 332f932..5e534ca 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -204,6 +204,7 @@ struct r600_pipe_context {
 	struct u_vbuf_mgr		*vbuf_mgr;
 	struct util_slab_mempool	pool_transfers;
 	boolean				blit;
+	boolean				have_depth_texture, have_depth_fb;
 
 	unsigned default_ps_gprs, default_vs_gprs;
 };
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 98f5c51..3b6e2dc 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -518,13 +518,16 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
 	struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
 	struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
 	int i;
+	int has_depth = 0;
 
 	for (i = 0; i < count; i++) {
 		if (&rctx->ps_samplers.views[i]->base != views[i]) {
-			if (resource[i])
+			if (resource[i]) {
+				if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+					has_depth = 1;
 				r600_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state,
 									i + R600_MAX_CONST_BUFFERS);
-			else
+			} else
 				r600_context_pipe_state_set_ps_resource(&rctx->ctx, NULL,
 									i + R600_MAX_CONST_BUFFERS);
 
@@ -532,6 +535,11 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
 				(struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
 				views[i]);
 
+		} else {
+			if (resource[i]) {
+				if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+					has_depth = 1;
+			}
 		}
 	}
 	for (i = count; i < NUM_TEX_UNITS; i++) {
@@ -541,6 +549,7 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
 			pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
 		}
 	}
+	rctx->have_depth_texture = has_depth;
 	rctx->ps_samplers.n_views = count;
 }
 
@@ -724,6 +733,9 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
 	surf = (struct r600_surface *)state->cbufs[cb];
 	rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
 
+	if (rtex->depth)
+		rctx->have_depth_fb = TRUE;
+
 	if (rtex->depth && !rtex->is_flushing_texture) {
 	        r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
 		rtex = rtex->flushed_depth_texture;
@@ -886,6 +898,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 	util_copy_framebuffer_state(&rctx->framebuffer, state);
 
 	/* build states */
+	rctx->have_depth_fb = 0;
 	for (int i = 0; i < state->nr_cbufs; i++) {
 		r600_cb(rctx, rstate, state, i);
 	}
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 1eb9389..d58c1f0 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -530,7 +530,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 	struct r600_drawl draw = {};
 	unsigned prim;
 
-	r600_flush_depth_textures(rctx);
+	if (!rctx->blit) {
+		if (rctx->have_depth_fb || rctx->have_depth_texture)
+			r600_flush_depth_textures(rctx);
+	}
 	u_vbuf_mgr_draw_begin(rctx->vbuf_mgr, info, NULL, NULL);
 	r600_vertex_buffer_update(rctx);
 
commit 296e6b9038131cd246226881208ffebe3c2683c3
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun 8 13:00:51 2011 -0700

    meta: Fix glCopyTexImage(GL_LUMINANCE) from non-GL_LUMINANCE source.
    
    glReadPixels() was performing RGB -> L conversion differently from the
    glTexImage() style conversion appropriate for glCopyTexImage().
    
    Fixes gles2conform copy_texture.

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 979926a..0e58aec 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2691,12 +2691,26 @@ copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
    GLenum format, type;
    GLint bpp;
    void *buf;
+   struct gl_renderbuffer *read_rb = ctx->ReadBuffer->_ColorReadBuffer;
 
    texObj = _mesa_get_current_tex_object(ctx, target);
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
 
    /* Choose format/type for temporary image buffer */
    format = _mesa_base_tex_format(ctx, internalFormat);
+
+   if (format == GL_LUMINANCE &&
+       _mesa_get_format_base_format(read_rb->Format) != GL_LUMINANCE) {
+      /* The glReadPixels() path will convert RGB to luminance by
+       * summing R+G+B.  glCopyTexImage() is supposed to behave as
+       * glCopyPixels, which doesn't do that change, and instead
+       * leaves it up to glTexImage which converts RGB to luminance by
+       * just taking the R channel.  To avoid glReadPixels() trashing
+       * our data, use RGBA for our temporary image.
+       */
+      format = GL_RGBA;
+   }
+
    type = get_temp_image_type(ctx, format);
    bpp = _mesa_bytes_per_pixel(format, type);
    if (bpp <= 0) {
commit df46eb8ec082e020ae7e45d3f584cb1d3dd55653
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun 8 12:06:43 2011 -0700

    intel: Fix mipmap and format handling of blit glCopyPixels().
    
    Fixes fbo-mipmap-copypix.

diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
index e83f1bf..88258d5 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
@@ -40,37 +40,6 @@
 
 #define FILE_DEBUG_FLAG DEBUG_PIXEL
 
-static struct intel_region *
-copypix_src_region(struct intel_context *intel, GLenum type)
-{
-   struct intel_renderbuffer *depth;
-
-   depth = (struct intel_renderbuffer *)
-      &intel->ctx.DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
-
-   switch (type) {
-   case GL_COLOR:
-      return intel_readbuf_region(intel);
-   case GL_DEPTH:
-      /* Don't think this is really possible execpt at 16bpp, when we
-       * have no stencil. */
-      if (depth && depth->region->cpp == 2)
-         return depth->region;
-   case GL_STENCIL:
-      /* Don't think this is really possible. */
-      break;
-   case GL_DEPTH_STENCIL_EXT:
-      /* Does it matter whether it is stencil/depth or depth/stencil?
-       */
-      return depth->region;
-   default:
-      break;
-   }
-
-   return NULL;
-}
-
-
 /**
  * Check if any fragment operations are in effect which might effect
  * glCopyPixels.  Differs from intel_check_blit_fragment_ops in that
@@ -109,8 +78,6 @@ do_blit_copypixels(struct gl_context * ctx,
                    GLint dstx, GLint dsty, GLenum type)
 {
    struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst;
-   struct intel_region *src;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    struct gl_framebuffer *read_fb = ctx->ReadBuffer;
    GLint orig_dstx;
@@ -118,14 +85,56 @@ do_blit_copypixels(struct gl_context * ctx,
    GLint orig_srcx;
    GLint orig_srcy;
    GLboolean flip = GL_FALSE;
+   struct intel_renderbuffer *draw_irb = NULL;
+   struct intel_renderbuffer *read_irb = NULL;
+
+   /* Update draw buffer bounds */
+   _mesa_update_state(ctx);
+
+   switch (type) {
+   case GL_COLOR:
+      if (fb->_NumColorDrawBuffers != 1) {
+	 fallback_debug("glCopyPixels() fallback: MRT\n");
+	 return GL_FALSE;
+      }
 
-   if (type == GL_DEPTH || type == GL_STENCIL) {
-      fallback_debug("glCopyPixels() fallback: GL_DEPTH || GL_STENCIL\n");
+      draw_irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
+      read_irb = intel_renderbuffer(read_fb->_ColorReadBuffer);
+      break;
+   case GL_DEPTH_STENCIL_EXT:
+      draw_irb = intel_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+      read_irb =
+	 intel_renderbuffer(read_fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+      break;
+   case GL_DEPTH:
+      fallback_debug("glCopyPixels() fallback: GL_DEPTH\n");
+      return GL_FALSE;
+   case GL_STENCIL:
+      fallback_debug("glCopyPixels() fallback: GL_STENCIL\n");
+      return GL_FALSE;
+   default:
+      fallback_debug("glCopyPixels(): Unknown type\n");
       return GL_FALSE;
    }
 
-   /* Update draw buffer bounds */
-   _mesa_update_state(ctx);
+   if (!draw_irb) {
+      fallback_debug("glCopyPixels() fallback: missing draw buffer\n");
+      return GL_FALSE;
+   }
+
+   if (!read_irb) {
+      fallback_debug("glCopyPixels() fallback: missing read buffer\n");
+      return GL_FALSE;
+   }
+
+   if (draw_irb->Base.Format != read_irb->Base.Format &&
+       !(draw_irb->Base.Format == MESA_FORMAT_XRGB8888 &&
+	 read_irb->Base.Format == MESA_FORMAT_ARGB8888)) {
+      fallback_debug("glCopyPixels() fallback: mismatched formats (%s -> %s\n",
+		     _mesa_get_format_name(read_irb->Base.Format),
+		     _mesa_get_format_name(draw_irb->Base.Format));
+      return GL_FALSE;
+   }
 
    /* Copypixels can be more than a straight copy.  Ensure all the
     * extra operations are disabled:
@@ -136,12 +145,6 @@ do_blit_copypixels(struct gl_context * ctx,
 
    intel_prepare_render(intel);
 
-   dst = intel_drawbuf_region(intel);
-   src = copypix_src_region(intel, type);
-
-   if (!src || !dst)
-      return GL_FALSE;
-
    intel_flush(&intel->ctx);
 
    /* Clip to destination buffer. */
@@ -179,9 +182,14 @@ do_blit_copypixels(struct gl_context * ctx,
       flip = !flip;
    }
 
+   srcx += read_irb->draw_x;
+   srcy += read_irb->draw_y;
+   dstx += draw_irb->draw_x;
+   dsty += draw_irb->draw_y;
+
    if (!intel_region_copy(intel,
-			  dst, 0, dstx, dsty,
-			  src, 0, srcx, srcy,
+			  draw_irb->region, 0, dstx, dsty,
+			  read_irb->region, 0, srcx, srcy,
 			  width, height, flip,
 			  ctx->Color.ColorLogicOpEnabled ?
 			  ctx->Color.LogicOp : GL_COPY)) {
commit ef0d548838c3da476596ee4dc983cc02b4f67b7b
Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 31 15:38:17 2011 -0700

    intel: Do the drawable x/y offset in intel_renderbuffer_map() for spans.
    
    We were mapping the renderbuffer once, then walking over all the
    buffers to map just the texture ones using the other texture mapping
    function that handled the x/y offset to the image in the region.  But
    then we would go and overwrite *those* mappings with the original
    mappings for depth/stencil, which was wrong.
    
    Instead, just walk over the attachments once and map the attachments.
    Wasn't that easy?

diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index aa83b3c..9343f40 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -185,10 +185,16 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
    rb->Data = irb->region->buffer->virtual;
    rb->RowStride = irb->region->pitch;
 
-   /* Flip orientation if it's the window system buffer */
    if (!rb->Name) {
+      /* Flip orientation of the window system buffer */
       rb->Data += rb->RowStride * (irb->region->height - 1) * irb->region->cpp;
       rb->RowStride = -rb->RowStride;
+   } else {
+      /* Adjust the base pointer of a texture image drawbuffer to the image
+       * within the miptree region (all else has draw_x/y = 0).
+       */
+      rb->Data += irb->draw_x * irb->region->cpp;
+      rb->Data += irb->draw_y * rb->RowStride * irb->region->cpp;
    }
 
    intel_set_span_functions(intel, rb);
@@ -211,71 +217,26 @@ intel_renderbuffer_unmap(struct intel_context *intel,
    rb->RowStride = 0;
 }
 
-/**
- * Map or unmap all the renderbuffers which we may need during
- * software rendering.
- * XXX in the future, we could probably convey extra information to
- * reduce the number of mappings needed.  I.e. if doing a glReadPixels
- * from the depth buffer, we really only need one mapping.
- *
- * XXX Rewrite this function someday.
- * We can probably just loop over all the renderbuffer attachments,
- * map/unmap all of them, and not worry about the _ColorDrawBuffers
- * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields.
- */
 static void
-intel_map_unmap_framebuffer(struct intel_context *intel,
-			    struct gl_framebuffer *fb,
-			    GLboolean map)
+intel_framebuffer_map(struct intel_context *intel, struct gl_framebuffer *fb)
 {
-   GLuint i;
-
-   /* color draw buffers */
-   for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-      if (map)
-         intel_renderbuffer_map(intel, fb->_ColorDrawBuffers[i]);
-      else
-         intel_renderbuffer_unmap(intel, fb->_ColorDrawBuffers[i]);
-   }
-
-   /* color read buffer */
-   if (map)
-      intel_renderbuffer_map(intel, fb->_ColorReadBuffer);
-   else
-      intel_renderbuffer_unmap(intel, fb->_ColorReadBuffer);
+   int i;
 
-   /* check for render to textures */
    for (i = 0; i < BUFFER_COUNT; i++) {
-      struct gl_renderbuffer_attachment *att =
-         fb->Attachment + i;
-      struct gl_texture_object *tex = att->Texture;
-      if (tex) {
-         /* render to texture */
-         ASSERT(att->Renderbuffer);
-         if (map)
-            intel_tex_map_images(intel, intel_texture_object(tex));
-         else
-            intel_tex_unmap_images(intel, intel_texture_object(tex));
-      }
+      intel_renderbuffer_map(intel, fb->Attachment[i].Renderbuffer);
    }
 
-   /* depth buffer (Note wrapper!) */
-   if (fb->_DepthBuffer) {
-      if (map)
-         intel_renderbuffer_map(intel, fb->_DepthBuffer->Wrapped);
-      else
-         intel_renderbuffer_unmap(intel, fb->_DepthBuffer->Wrapped);
-   }
+   intel_check_front_buffer_rendering(intel);
+}
 
-   /* stencil buffer (Note wrapper!) */
-   if (fb->_StencilBuffer) {
-      if (map)
-         intel_renderbuffer_map(intel, fb->_StencilBuffer->Wrapped);
-      else
-         intel_renderbuffer_unmap(intel, fb->_StencilBuffer->Wrapped);
-   }
+static void
+intel_framebuffer_unmap(struct intel_context *intel, struct gl_framebuffer *fb)
+{
+   int i;
 
-   intel_check_front_buffer_rendering(intel);
+   for (i = 0; i < BUFFER_COUNT; i++) {
+      intel_renderbuffer_unmap(intel, fb->Attachment[i].Renderbuffer);
+   }
 }
 
 /**
@@ -302,9 +263,10 @@ intelSpanRenderStart(struct gl_context * ctx)
       }
    }
 
-   intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_TRUE);
-   if (ctx->ReadBuffer != ctx->DrawBuffer)
-      intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_TRUE);
+   intel_framebuffer_map(intel, ctx->DrawBuffer);
+   if (ctx->ReadBuffer != ctx->DrawBuffer) {
+      intel_framebuffer_map(intel, ctx->ReadBuffer);
+   }
 }
 
 /**
@@ -326,9 +288,10 @@ intelSpanRenderFinish(struct gl_context * ctx)
       }
    }
 
-   intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_FALSE);
-   if (ctx->ReadBuffer != ctx->DrawBuffer)
-      intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_FALSE);
+   intel_framebuffer_unmap(intel, ctx->DrawBuffer);
+   if (ctx->ReadBuffer != ctx->DrawBuffer) {
+      intel_framebuffer_unmap(intel, ctx->ReadBuffer);
+   }
 }
 
 
commit fb60e2061b1f2f58a65e908e864704c234b300b0
Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 31 15:33:36 2011 -0700

    intel: Use rb->Data and rb->RowStride to handle spans Y flipping.
    
    This is already pointing at 0 or Height - 1 and with an appropriate
    pitch, so no need to recompute those values per customization of the
    spans code.  Cuts 3 out of 21kb of the compiled size.
    
    Reviewed-by: Chad Versace <chad at chad-versace.us>

diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index a4a1d6b..aa83b3c 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -55,21 +55,18 @@ intel_set_span_functions(struct intel_context *intel,
 
 #define LOCAL_VARS							\
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);		\
-   const GLint yScale = rb->Name ? 1 : -1;				\
-   const GLint yBias = rb->Name ? 0 : rb->Height - 1;			\
    int minx = 0, miny = 0;						\
    int maxx = rb->Width;						\
    int maxy = rb->Height;						\
-   int pitch = irb->region->pitch * irb->region->cpp;			\
-   void *buf = irb->region->buffer->virtual;				\
+   int pitch = rb->RowStride * irb->region->cpp;			\
+   void *buf = rb->Data;						\
    GLuint p;								\
-   (void) p;								\
-   (void)buf; (void)pitch; /* unused for non-gttmap. */			\
+   (void) p;
 
 #define HW_CLIPLOOP()
 #define HW_ENDCLIPLOOP()
 
-#define Y_FLIP(_y) ((_y) * yScale + yBias)
+#define Y_FLIP(_y) (_y)
 
 #define HW_LOCK()
 
commit d29117752f10d9bcb61e7b26064a872017a64ebe
Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 31 15:07:56 2011 -0700

    intel: Clean up intel_render_texture with a rename and a helper function.
    
    The "newImage" isn't particularly new -- it might be the same texture
    that was attached to the same attachment point before.  This function
    also gets called when just rebinding back to an FBO with a texture
    attachment.
    
    Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
    Reviewed-by: Chad Versace <chad at chad-versace.us>

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 3e7e0b9..591df41 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -579,16 +579,12 @@ intel_render_texture(struct gl_context * ctx,
                      struct gl_framebuffer *fb,
                      struct gl_renderbuffer_attachment *att)
 {
-   struct gl_texture_image *newImage
-      = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+   struct gl_texture_image *image = _mesa_get_attachment_teximage(att);
    struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
-   struct intel_texture_image *intel_image;
+   struct intel_texture_image *intel_image = intel_texture_image(image);
 
    (void) fb;
 
-   ASSERT(newImage);
-
-   intel_image = intel_texture_image(newImage);
    if (!intel_image->mt) {
       /* Fallback on drawing to a texture that doesn't have a miptree
        * (has a border, width/height 0, etc.)
@@ -598,7 +594,7 @@ intel_render_texture(struct gl_context * ctx,
       return;
    }
    else if (!irb) {
-      irb = intel_wrap_texture(ctx, newImage);
+      irb = intel_wrap_texture(ctx, image);
       if (irb) {
          /* bind the wrapper to the attachment point */
          _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
@@ -610,7 +606,7 @@ intel_render_texture(struct gl_context * ctx,
       }
    }
 
-   if (!intel_update_wrapper(ctx, irb, newImage)) {
+   if (!intel_update_wrapper(ctx, irb, image)) {
        _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
        _swrast_render_texture(ctx, fb, att);
        return;
@@ -618,7 +614,7 @@ intel_render_texture(struct gl_context * ctx,
 
    DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
        _glthread_GetID(),
-       att->Texture->Name, newImage->Width, newImage->Height,
+       att->Texture->Name, image->Width, image->Height,
        irb->Base.RefCount);
 
    intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
@@ -644,7 +640,7 @@ intel_render_texture(struct gl_context * ctx,
 
       texel_bytes = _mesa_get_format_bytes(intel_image->base.TexFormat);
 
-      new_mt = intel_miptree_create(intel, newImage->TexObject->Target,
+      new_mt = intel_miptree_create(intel, image->TexObject->Target,
 				    intel_image->base._BaseFormat,
 				    intel_image->base.InternalFormat,
 				    intel_image->level,
commit b17aab5753a6d14c9e757bedb186963b2dae8823
Author: Eric Anholt <eric at anholt.net>
Date:   Tue May 31 14:27:18 2011 -0700

    intel: Move the draw_x/draw_y to the renderbuffer where it belongs.
    
    It was originally located in the region because the tracking of
    depth/color buffers was on the regions, and getting back to the irb
    would have been tricky.  Now, we're keying off of the renderbuffer in
    more places, which means we can move these fields where they belong.
    
    This could fix potential rendering failure with a single texture
    having multiple images attached to different renderbuffers across
    shareCtx (as far as I can tell, this was the only failure we could
    cause, since anything else should trigger intel_render_texture in
    between, for example a BindFramebuffer).
    
    Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
    Reviewed-by: Chad Versace <chad at chad-versace.us>

diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 19f0807..08ea287 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -609,6 +609,8 @@ i830_set_draw_region(struct intel_context *intel,
    struct gl_context *ctx = &intel->ctx;
    struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+   struct gl_renderbuffer *drb;
+   struct intel_renderbuffer *idrb = NULL;
    GLuint value;
    struct i830_hw_state *state = &i830->state;
    uint32_t draw_x, draw_y;
@@ -649,6 +651,13 @@ i830_set_draw_region(struct intel_context *intel,
    }
    state->Buffer[I830_DESTREG_DV1] = value;
 
+   drb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+   if (!drb)
+      drb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+
+   if (drb)
+      idrb = intel_renderbuffer(drb);
+
    /* We set up the drawing rectangle to be offset into the color
     * region's location in the miptree.  If it doesn't match with
     * depth's offsets, we can't render to it.
@@ -660,16 +669,15 @@ i830_set_draw_region(struct intel_context *intel,
     * can't do in general due to tiling)
     */
    FALLBACK(intel, I830_FALLBACK_DRAW_OFFSET,
-	    (depth_region && color_regions[0]) &&
-	    (depth_region->draw_x != color_regions[0]->draw_x ||
-	     depth_region->draw_y != color_regions[0]->draw_y));
-
-   if (color_regions[0]) {
-      draw_x = color_regions[0]->draw_x;
-      draw_y = color_regions[0]->draw_y;
-   } else if (depth_region) {
-      draw_x = depth_region->draw_x;
-      draw_y = depth_region->draw_y;
+	    idrb && irb && (idrb->draw_x != irb->draw_x ||
+			    idrb->draw_y != irb->draw_y));
+
+   if (irb) {
+      draw_x = irb->draw_x;
+      draw_y = irb->draw_y;
+   } else if (idrb) {
+      draw_x = idrb->draw_x;
+      draw_y = idrb->draw_y;
    } else {
       draw_x = 0;
       draw_y = 0;
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 820feba..baff49b 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -561,6 +561,8 @@ i915_set_draw_region(struct intel_context *intel,
    struct gl_context *ctx = &intel->ctx;
    struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+   struct gl_renderbuffer *drb;
+   struct intel_renderbuffer *idrb = NULL;
    GLuint value;
    struct i915_hw_state *state = &i915->state;
    uint32_t draw_x, draw_y, draw_offset;
@@ -609,6 +611,13 @@ i915_set_draw_region(struct intel_context *intel,
    }
    state->Buffer[I915_DESTREG_DV1] = value;
 
+   drb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+   if (!drb)
+      drb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+
+   if (drb)
+      idrb = intel_renderbuffer(drb);
+
    /* We set up the drawing rectangle to be offset into the color
     * region's location in the miptree.  If it doesn't match with
     * depth's offsets, we can't render to it.
@@ -620,16 +629,15 @@ i915_set_draw_region(struct intel_context *intel,
     * can't do in general due to tiling)
     */
    FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET,
-	    (depth_region && color_regions[0]) &&
-	    (depth_region->draw_x != color_regions[0]->draw_x ||
-	     depth_region->draw_y != color_regions[0]->draw_y));
-
-   if (color_regions[0]) {
-      draw_x = color_regions[0]->draw_x;
-      draw_y = color_regions[0]->draw_y;
-   } else if (depth_region) {
-      draw_x = depth_region->draw_x;
-      draw_y = depth_region->draw_y;
+	    idrb && irb && (idrb->draw_x != irb->draw_x ||
+			    idrb->draw_y != irb->draw_y));
+
+   if (irb) {
+      draw_x = irb->draw_x;
+      draw_y = irb->draw_y;
+   } else if (idrb) {
+      draw_x = idrb->draw_x;
+      draw_y = idrb->draw_y;
    } else {
       draw_x = 0;
       draw_y = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 3d0983e..2b5ec8a 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -322,7 +322,7 @@ static void emit_depthbuffer(struct brw_context *brw)
 	 return;
       }
 
-      offset = intel_region_tile_offsets(region, &tile_x, &tile_y);
+      offset = intel_renderbuffer_tile_offsets(depth_irb, &tile_x, &tile_y);
 
       assert(intel->gen < 6 || region->tiling == I915_TILING_Y);
       assert(!hiz_region || region->tiling == I915_TILING_Y);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index f560bc3..ac8005d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -477,7 +477,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
 	      format << BRW_SURFACE_FORMAT_SHIFT);
 
    /* reloc */
-   surf[1] = (intel_region_tile_offsets(region, &tile_x, &tile_y) +
+   surf[1] = (intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y) +
 	      region->buffer->offset);
 
    surf[2] = ((rb->Width - 1) << BRW_SURFACE_WIDTH_SHIFT |
diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c
index dd0ccd2..7544f96 100644
--- a/src/mesa/drivers/dri/i965/gen7_misc_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c
@@ -113,7 +113,7 @@ static void emit_depthbuffer(struct brw_context *brw)
       struct intel_region *region = drb->region;
       uint32_t tile_x, tile_y, offset;
 
-      offset = intel_region_tile_offsets(region, &tile_x, &tile_y);
+      offset = intel_renderbuffer_tile_offsets(drb, &tile_x, &tile_y);
 
       assert(region->tiling == I915_TILING_Y);
 
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 00b562f..9994b67 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -273,7 +273,7 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
 
    surf->ss0.surface_type = BRW_SURFACE_2D;
    /* reloc */
-   surf->ss1.base_addr = intel_region_tile_offsets(region, &tile_x, &tile_y);
+   surf->ss1.base_addr = intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y);
    surf->ss1.base_addr += region->buffer->offset; /* reloc */
 
    assert(brw->has_surface_tile_offset);
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 5aac1f6..30be1b9 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -280,10 +280,10 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask)
       write_buffer = intel_region_buffer(intel, irb->region,
 					 all ? INTEL_WRITE_FULL :
 					 INTEL_WRITE_PART);
-      x1 = cx + irb->region->draw_x;
-      y1 = cy + irb->region->draw_y;
-      x2 = cx + cw + irb->region->draw_x;
-      y2 = cy + ch + irb->region->draw_y;
+      x1 = cx + irb->draw_x;
+      y1 = cy + irb->draw_y;
+      x2 = cx + cw + irb->draw_x;
+      y2 = cy + ch + irb->draw_y;
 
       pitch = irb->region->pitch;
       cpp = irb->region->cpp;
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 65f35e1..3e7e0b9 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -513,8 +513,9 @@ intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage)
 }
 
 static void
-intel_set_draw_offset_for_image(struct intel_texture_image *intel_image,
-				int zoffset)
+intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb,
+				   struct intel_texture_image *intel_image,
+				   int zoffset)
 {
    struct intel_mipmap_tree *mt = intel_image->mt;
    unsigned int dst_x, dst_y;
@@ -526,9 +527,45 @@ intel_set_draw_offset_for_image(struct intel_texture_image *intel_image,
 				  zoffset,
 				  &dst_x, &dst_y);
 
-   mt->region->draw_offset = (dst_y * mt->region->pitch + dst_x) * mt->cpp;
-   mt->region->draw_x = dst_x;
-   mt->region->draw_y = dst_y;
+   irb->draw_offset = (dst_y * mt->region->pitch + dst_x) * mt->cpp;
+   irb->draw_x = dst_x;
+   irb->draw_y = dst_y;
+}
+
+/**
+ * Rendering to tiled buffers requires that the base address of the
+ * buffer be aligned to a page boundary.  We generally render to
+ * textures by pointing the surface at the mipmap image level, which
+ * may not be aligned to a tile boundary.
+ *
+ * This function returns an appropriately-aligned base offset
+ * according to the tiling restrictions, plus any required x/y offset
+ * from there.
+ */
+uint32_t
+intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
+				uint32_t *tile_x,
+				uint32_t *tile_y)
+{
+   int cpp = irb->region->cpp;
+   uint32_t pitch = irb->region->pitch * cpp;
+
+   if (irb->region->tiling == I915_TILING_NONE) {
+      *tile_x = 0;
+      *tile_y = 0;
+      return irb->draw_x * cpp + irb->draw_y * pitch;
+   } else if (irb->region->tiling == I915_TILING_X) {
+      *tile_x = irb->draw_x % (512 / cpp);
+      *tile_y = irb->draw_y % 8;
+      return ((irb->draw_y / 8) * (8 * pitch) +
+	      (irb->draw_x - *tile_x) / (512 / cpp) * 4096);
+   } else {
+      assert(irb->region->tiling == I915_TILING_Y);
+      *tile_x = irb->draw_x % (128 / cpp);
+      *tile_y = irb->draw_y % 32;
+      return ((irb->draw_y / 32) * (32 * pitch) +
+	      (irb->draw_x - *tile_x) / (128 / cpp) * 4096);
+   }
 }
 
 /**
@@ -584,12 +621,12 @@ intel_render_texture(struct gl_context * ctx,
        att->Texture->Name, newImage->Width, newImage->Height,
        irb->Base.RefCount);
 
-   intel_set_draw_offset_for_image(intel_image, att->Zoffset);
+   intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
    intel_image->used_as_render_target = GL_TRUE;
 
 #ifndef I915
    if (!brw_context(ctx)->has_surface_tile_offset &&
-       (intel_image->mt->region->draw_offset & 4095) != 0) {
+       (irb->draw_offset & 4095) != 0) {
       /* Original gen4 hardware couldn't draw to a non-tile-aligned
        * destination in a miptree unless you actually setup your
        * renderbuffer as a miptree and used the fragile
@@ -625,7 +662,7 @@ intel_render_texture(struct gl_context * ctx,
 
       intel_miptree_release(intel, &intel_image->mt);
       intel_image->mt = new_mt;
-      intel_set_draw_offset_for_image(intel_image, att->Zoffset);
+      intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
 
       intel_region_release(&irb->region);
       intel_region_reference(&irb->region, intel_image->mt->region);
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index e9929b0..509f588 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -44,6 +44,9 @@ struct intel_renderbuffer
 
    /** Only used by depth renderbuffers for which HiZ is enabled. */
    struct intel_region *hiz_region;
+
+   GLuint draw_offset; /**< Offset of drawing address within the region */
+   GLuint draw_x, draw_y; /**< Offset of drawing within the region */
 };
 
 
@@ -130,6 +133,10 @@ intel_fbo_init(struct intel_context *intel);
 extern void
 intel_flip_renderbuffers(struct gl_framebuffer *fb);
 
+uint32_t
+intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
+				uint32_t *tile_x,
+				uint32_t *tile_y);
 
 static INLINE struct intel_region *
 intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
@@ -141,5 +148,4 @@ intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
       return NULL;
 }
 
-
 #endif /* INTEL_FBO_H */
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 0253bbc..a4da1ce 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -524,38 +524,3 @@ intel_region_buffer(struct intel_context *intel,
 
    return region->buffer;
 }
-
-/**
- * Rendering to tiled buffers requires that the base address of the
- * buffer be aligned to a page boundary.  We generally render to
- * textures by pointing the surface at the mipmap image level, which
- * may not be aligned to a tile boundary.
- *
- * This function returns an appropriately-aligned base offset
- * according to the tiling restrictions, plus any required x/y offset
- * from there.
- */
-uint32_t
-intel_region_tile_offsets(struct intel_region *region,
-			  uint32_t *tile_x,
-			  uint32_t *tile_y)
-{
-   uint32_t pitch = region->pitch * region->cpp;
-
-   if (region->tiling == I915_TILING_NONE) {
-      *tile_x = 0;
-      *tile_y = 0;
-      return region->draw_x * region->cpp + region->draw_y * pitch;
-   } else if (region->tiling == I915_TILING_X) {
-      *tile_x = region->draw_x % (512 / region->cpp);
-      *tile_y = region->draw_y % 8;
-      return ((region->draw_y / 8) * (8 * pitch) +
-	      (region->draw_x - *tile_x) / (512 / region->cpp) * 4096);
-   } else {
-      assert(region->tiling == I915_TILING_Y);
-      *tile_x = region->draw_x % (128 / region->cpp);
-      *tile_y = region->draw_y % 32;
-      return ((region->draw_y / 32) * (32 * pitch) +
-	      (region->draw_x - *tile_x) / (128 / region->cpp) * 4096);
-   }
-}
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index a8a300d..91f7121 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -62,9 +62,6 @@ struct intel_region
    GLubyte *map;    /**< only non-NULL when region is actually mapped */
    GLuint map_refcount;  /**< Reference count for mapping */
 
-   GLuint draw_offset; /**< Offset of drawing address within the region */
-   GLuint draw_x, draw_y; /**< Offset of drawing within the region */
-
    uint32_t tiling; /**< Which tiling mode the region is in */
    struct intel_buffer_object *pbo;     /* zero-copy uploads */
 
@@ -142,10 +139,6 @@ drm_intel_bo *intel_region_buffer(struct intel_context *intel,
 				  struct intel_region *region,
 				  GLuint flag);
 
-uint32_t intel_region_tile_offsets(struct intel_region *region,
-				   uint32_t *tile_x,
-				   uint32_t *tile_y);
-
 void _mesa_copy_rect(GLubyte * dst,
                 GLuint cpp,
                 GLuint dst_pitch,
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index 62d4169..eda07a4 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -152,7 +152,7 @@ intel_copy_texsubimage(struct intel_context *intel,
 			     dst_bo,
 			     0,
 			     intelImage->mt->region->tiling,
-			     irb->region->draw_x + x, irb->region->draw_y + y,
+			     irb->draw_x + x, irb->draw_y + y,
 			     image_x + dstx, image_y + dsty,
 			     width, height,
 			     GL_COPY)) {
commit 4fa01d705f0b795a5df30127925ced8e0522631f
Author: Brian Paul <brianp at vmware.com>
Date:   Mon Jun 13 16:07:32 2011 -0600

    dri: include swrast.h, not s_texrender.h

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 8277477..65f35e1 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -35,7 +35,7 @@
 #include "main/renderbuffer.h"
 #include "main/context.h"
 #include "main/teximage.h"
-#include "swrast/s_texrender.h"
+#include "swrast/swrast.h"
 #include "drivers/common/meta.h"
 
 #include "intel_context.h"
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 0986ade..92c1854 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -35,7 +35,7 @@
 #include "main/framebuffer.h"
 #include "main/renderbuffer.h"
 #include "main/context.h"
-#include "swrast/s_texrender.h"
+#include "swrast/swrast.h"
 #include "drivers/common/meta.h"
 
 #include "radeon_common.h"


More information about the Xquartz-changes mailing list