Merge branch 'gallium-msaa'
authorRoland Scheidegger <sroland@vmware.com>
Fri, 21 May 2010 18:02:22 +0000 (20:02 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Fri, 21 May 2010 18:02:22 +0000 (20:02 +0200)
Conflicts:
src/mesa/state_tracker/st_gen_mipmap.c
src/mesa/state_tracker/st_texture.c

51 files changed:
1  2 
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/util/u_surface.c
src/gallium/docs/source/context.rst
src/gallium/docs/source/screen.rst
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_resource.c
src/gallium/drivers/i965/brw_resource_texture.c
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_state.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_transfer.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/egl/common/egl_g3d.c
src/gallium/state_trackers/vega/vg_context.c
src/gallium/state_trackers/vega/vg_manager.c
src/gallium/state_trackers/xorg/xorg_dri2.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_renderer.c
src/mesa/SConscript
src/mesa/sources.mak
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_blit.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_eglimage.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_gen_mipmap.c
src/mesa/state_tracker/st_texture.c

index f6f6e481d9467bd7341195c75881e674d574d51f,9df5f9a9d26d75011ec9a8b23fdbd68357151b40..d4fbd658f40394af34fc650558feb3d95c66f908
@@@ -48,6 -48,7 +48,6 @@@
  #include "util/u_sampler.h"
  #include "util/u_simple_shaders.h"
  #include "util/u_surface.h"
 -#include "util/u_rect.h"
  
  #include "cso_cache/cso_context.h"
  
@@@ -101,7 -102,8 +101,7 @@@ util_create_blit(struct pipe_context *p
  
     /* rasterizer */
     memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
 -   ctx->rasterizer.front_winding = PIPE_WINDING_CW;
 -   ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
 +   ctx->rasterizer.cull_face = PIPE_FACE_NONE;
     ctx->rasterizer.gl_rasterization_rules = 1;
  
     /* samplers */
@@@ -190,7 -192,6 +190,6 @@@ get_next_slot( struct blit_state *ctx 
     
     return ctx->vbuf_slot++ * sizeof ctx->vertices;
  }
-                                
  
  
  
@@@ -277,10 -278,11 +276,11 @@@ regions_overlap(int srcX0, int srcY0
   */
  void
  util_blit_pixels_writemask(struct blit_state *ctx,
-                            struct pipe_surface *src,
-                            struct pipe_sampler_view *src_sampler_view,
+                            struct pipe_resource *src_tex,
+                            struct pipe_subresource srcsub,
                             int srcX0, int srcY0,
                             int srcX1, int srcY1,
+                            int srcZ0,
                             struct pipe_surface *dst,
                             int dstX0, int dstY0,
                             int dstX1, int dstY1,
     struct pipe_context *pipe = ctx->pipe;
     struct pipe_screen *screen = pipe->screen;
     struct pipe_sampler_view *sampler_view = NULL;
+    struct pipe_sampler_view sv_templ;
     struct pipe_framebuffer_state fb;
     const int srcW = abs(srcX1 - srcX0);
     const int srcH = abs(srcY1 - srcY0);
     assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
            filter == PIPE_TEX_MIPFILTER_LINEAR);
  
-    assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
-                                       PIPE_BIND_SAMPLER_VIEW, 0));
-    assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
-                                       PIPE_BIND_RENDER_TARGET, 0));
+    assert(srcsub.level <= src_tex->last_level);
  
     /* do the regions overlap? */
-    overlap = util_same_surface(src, dst) &&
+    overlap = src_tex == dst->texture &&
+              dst->face == srcsub.face &&
+              dst->level == srcsub.level &&
+              dst->zslice == srcZ0 &&
        regions_overlap(srcX0, srcY0, srcX1, srcY1,
                        dstX0, dstY0, dstX1, dstY1);
  
      * no overlapping.
      * Filter mode should not matter since there's no stretching.
      */
-    if (pipe->surface_copy &&
-        dst->format == src->format &&
+    if (dst->format == src_tex->format &&
         srcX0 < srcX1 &&
         dstX0 < dstX1 &&
         srcY0 < srcY1 &&
         (dstX1 - dstX0) == (srcX1 - srcX0) &&
         (dstY1 - dstY0) == (srcY1 - srcY0) &&
         !overlap) {
-       pipe->surface_copy(pipe,
-                        dst, dstX0, dstY0, /* dest */
-                        src, srcX0, srcY0, /* src */
-                        srcW, srcH);       /* size */
+       struct pipe_subresource subdst;
+       subdst.face = dst->face;
+       subdst.level = dst->level;
+       pipe->resource_copy_region(pipe,
+                                  dst->texture, subdst,
+                                  dstX0, dstY0, dst->zslice,/* dest */
+                                  src_tex, srcsub,
+                                  srcX0, srcY0, srcZ0,/* src */
+                                  srcW, srcH);       /* size */
        return;
     }
-    
-    assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
-                                       PIPE_BIND_RENDER_TARGET, 0));
  
     /* Create a temporary texture when src and dest alias or when src
-     * is anything other than a single-level 2d texture.
+     * is anything other than a 2d texture.
+     * XXX should just use appropriate shader to access 1d / 3d slice / cube face,
+     * much like the u_blitter code does (should be pretty trivial).
      * 
      * This can still be improved upon.
      */
-    if (util_same_surface(src, dst) ||
-        src->texture->target != PIPE_TEXTURE_2D ||
-        src->texture->last_level != 0)
+    if ((src_tex == dst->texture &&
+        dst->face == srcsub.face &&
+        dst->level == srcsub.level &&
+        dst->zslice == srcZ0) ||
+        src_tex->target != PIPE_TEXTURE_2D)
     {
        struct pipe_resource texTemp;
        struct pipe_resource *tex;
        struct pipe_sampler_view sv_templ;
-       struct pipe_surface *texSurf;
+       struct pipe_subresource texsub;
        const int srcLeft = MIN2(srcX0, srcX1);
        const int srcTop = MIN2(srcY0, srcY1);
  
        /* create temp texture */
        memset(&texTemp, 0, sizeof(texTemp));
        texTemp.target = PIPE_TEXTURE_2D;
-       texTemp.format = src->format;
+       texTemp.format = src_tex->format;
        texTemp.last_level = 0;
        texTemp.width0 = srcW;
        texTemp.height0 = srcH;
        if (!tex)
           return;
  
-       u_sampler_view_default_template(&sv_templ, tex, tex->format);
-       sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
-       if (!sampler_view) {
-          pipe_resource_reference(&tex, NULL);
-          return;
-       }
-       texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, 
-                                         PIPE_BIND_BLIT_DESTINATION);
+       texsub.face = 0;
+       texsub.level = 0;
        /* load temp texture */
-       if (pipe->surface_copy) {
-          pipe->surface_copy(pipe,
-                             texSurf, 0, 0,   /* dest */
-                             src, srcLeft, srcTop, /* src */
-                             srcW, srcH);     /* size */
-       } else {
-          util_surface_copy(pipe, FALSE,
-                            texSurf, 0, 0,   /* dest */
-                            src, srcLeft, srcTop, /* src */
-                            srcW, srcH);     /* size */
-       }
+       pipe->resource_copy_region(pipe,
+                                  tex, texsub, 0, 0, 0,  /* dest */
+                                  src_tex, srcsub, srcLeft, srcTop, srcZ0, /* src */
+                                  srcW, srcH);     /* size */
  
-       /* free the surface, update the texture if necessary.
-        */
-       pipe_surface_reference(&texSurf, NULL);
        s0 = 0.0f; 
        s1 = 1.0f;
        t0 = 0.0f;
        t1 = 1.0f;
  
+       u_sampler_view_default_template(&sv_templ, tex, tex->format);
+       sampler_view = pipe->create_sampler_view(pipe, tex, &sv_templ);
+       if (!sampler_view) {
+          pipe_resource_reference(&tex, NULL);
+          return;
+       }
        pipe_resource_reference(&tex, NULL);
     }
     else {
-       pipe_sampler_view_reference(&sampler_view, src_sampler_view);
-       s0 = srcX0 / (float)src->texture->width0;
-       s1 = srcX1 / (float)src->texture->width0;
-       t0 = srcY0 / (float)src->texture->height0;
-       t1 = srcY1 / (float)src->texture->height0;
+       u_sampler_view_default_template(&sv_templ, src_tex, src_tex->format);
+       sv_templ.first_level = sv_templ.last_level = srcsub.level;
+       sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ);
+       if (!sampler_view) {
+          return;
+       }
+       s0 = srcX0 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+       s1 = srcX1 / (float)(u_minify(sampler_view->texture->width0, srcsub.level));
+       t0 = srcY0 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
+       t1 = srcY1 / (float)(u_minify(sampler_view->texture->height0, srcsub.level));
     }
  
-    
+    assert(screen->is_format_supported(screen, sampler_view->format, PIPE_TEXTURE_2D,
+                                       sampler_view->texture->nr_samples,
+                                       PIPE_BIND_SAMPLER_VIEW, 0));
+    assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+                                       dst->texture->nr_samples,
+                                       PIPE_BIND_RENDER_TARGET, 0));
  
     /* save state (restored below) */
     cso_save_blend(ctx->cso);
     /* sampler */
     ctx->sampler.min_img_filter = filter;
     ctx->sampler.mag_img_filter = filter;
+    /* we've limited this already with the sampler view but you never know... */
+    ctx->sampler.min_lod = srcsub.level;
+    ctx->sampler.max_lod = srcsub.level;
     cso_single_sampler(ctx->cso, 0, &ctx->sampler);
     cso_single_sampler_done(ctx->cso);
  
  
  void
  util_blit_pixels(struct blit_state *ctx,
-                  struct pipe_surface *src,
-                  struct pipe_sampler_view *src_sampler_view,
+                  struct pipe_resource *src_tex,
+                  struct pipe_subresource srcsub,
                   int srcX0, int srcY0,
                   int srcX1, int srcY1,
+                  int srcZ,
                   struct pipe_surface *dst,
                   int dstX0, int dstY0,
                   int dstX1, int dstY1,
                   float z, uint filter )
  {
-    util_blit_pixels_writemask( ctx, src, src_sampler_view,
+    util_blit_pixels_writemask( ctx, src_tex,
+                                srcsub,
                                 srcX0, srcY0,
                                 srcX1, srcY1,
+                                srcZ,
                                 dst,
                                 dstX0, dstY0,
                                 dstX1, dstY1,
@@@ -546,7 -562,6 +560,6 @@@ void util_blit_flush( struct blit_stat
  
  /**
   * Copy pixel block from src texture to dst surface.
-  * Overlapping regions are acceptable.
   *
   * XXX Should support selection of level.
   * XXX need some control over blitting Z and/or stencil.
@@@ -580,6 -595,7 +593,7 @@@ util_blit_pixels_tex(struct blit_state 
  
     assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
                                                   PIPE_TEXTURE_2D,
+                                                  dst->texture->nr_samples,
                                                   PIPE_BIND_RENDER_TARGET,
                                                   0));
  
index 3a7c4db6f3445aac7ddbc4f69e48758e8cf3438c,d603c7ac06d43e6d8b65947292d8c0b91961b2ae..e0bd89154cb1883ded0a8bd83adfe5df6028cc8f
@@@ -26,8 -26,8 +26,8 @@@
  
  /**
   * @file
-  * Blitter utility to facilitate acceleration of the clear, surface_copy,
-  * and surface_fill functions.
+  * Blitter utility to facilitate acceleration of the clear, resource_copy_region,
+  * and resource_fill_region functions.
   *
   * @author Marek Olšák
   */
@@@ -44,6 -44,7 +44,6 @@@
  #include "util/u_blitter.h"
  #include "util/u_draw_quad.h"
  #include "util/u_pack_color.h"
 -#include "util/u_rect.h"
  #include "util/u_sampler.h"
  #include "util/u_simple_shaders.h"
  #include "util/u_surface.h"
@@@ -69,8 -70,8 +69,8 @@@ struct blitter_context_pri
     void *vs_tex; /**< Vertex shader which passes {pos, texcoord} to the output.*/
  
     /* Fragment shaders. */
 -   /* FS which outputs a color to multiple color buffers. */
 -   void *fs_col[PIPE_MAX_COLOR_BUFS];
 +   /* The shader at index i outputs color to color buffers 0,1,...,i-1. */
 +   void *fs_col[PIPE_MAX_COLOR_BUFS+1];
  
     /* FS which outputs a color from a texture,
        where the index is PIPE_TEXTURE_* to be sampled. */
@@@ -175,7 -176,8 +175,7 @@@ struct blitter_context *util_blitter_cr
  
     /* rasterizer state */
     memset(&rs_state, 0, sizeof(rs_state));
 -   rs_state.front_winding = PIPE_WINDING_CW;
 -   rs_state.cull_mode = PIPE_WINDING_NONE;
 +   rs_state.cull_face = PIPE_FACE_NONE;
     rs_state.gl_rasterization_rules = 1;
     rs_state.flatshade = 1;
     ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
@@@ -247,7 -249,7 +247,7 @@@ void util_blitter_destroy(struct blitte
           pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
     }
  
 -   for (i = 0; i < PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
 +   for (i = 0; i <= PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
        if (ctx->fs_col[i])
           pipe->delete_fs_state(pipe, ctx->fs_col[i]);
  
@@@ -494,14 -496,15 +494,14 @@@ static INLIN
  void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
  {
     struct pipe_context *pipe = ctx->pipe;
 -   unsigned index = num_cbufs ? num_cbufs - 1 : 0;
  
     assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
  
 -   if (!ctx->fs_col[index])
 -      ctx->fs_col[index] =
 +   if (!ctx->fs_col[num_cbufs])
 +      ctx->fs_col[num_cbufs] =
           util_make_fragment_clonecolor_shader(pipe, num_cbufs);
  
 -   return ctx->fs_col[index];
 +   return ctx->fs_col[num_cbufs];
  }
  
  static INLINE
@@@ -709,53 -712,6 +709,6 @@@ static void util_blitter_do_copy(struc
  
  }
  
- static void util_blitter_overlap_copy(struct blitter_context *blitter,
-                                     struct pipe_surface *dst,
-                                     unsigned dstx, unsigned dsty,
-                                     struct pipe_surface *src,
-                                     unsigned srcx, unsigned srcy,
-                                     unsigned width, unsigned height)
- {
-    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
-    struct pipe_context *pipe = ctx->pipe;
-    struct pipe_screen *screen = pipe->screen;
-    struct pipe_resource texTemp;
-    struct pipe_resource *texture;
-    struct pipe_surface *tex_surf;
-    /* check whether the states are properly saved */
-    blitter_check_saved_CSOs(ctx);
-    memset(&texTemp, 0, sizeof(texTemp));
-    texTemp.target = PIPE_TEXTURE_2D;
-    texTemp.format = dst->texture->format; /* XXX verify supported by driver! */
-    texTemp.last_level = 0;
-    texTemp.width0 = width;
-    texTemp.height0 = height;
-    texTemp.depth0 = 1;
-    texture = screen->resource_create(screen, &texTemp);
-    if (!texture)
-       return;
-    tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
-                                     PIPE_BIND_BLIT_SOURCE | 
-                                     PIPE_BIND_BLIT_DESTINATION);
-    /* blit from the src to the temp */
-    util_blitter_do_copy(blitter, tex_surf, 0, 0,
-                       src, srcx, srcy,
-                       width, height,
-                       FALSE);
-    util_blitter_do_copy(blitter, dst, dstx, dsty,
-                       tex_surf, 0, 0,
-                       width, height,
-                       FALSE);
-    pipe_surface_reference(&tex_surf, NULL);
-    pipe_resource_reference(&texture, NULL);
-    blitter_restore_CSOs(ctx);
- }
  
  void util_blitter_copy(struct blitter_context *blitter,
                         struct pipe_surface *dst,
        return;
  
     if (dst->texture == src->texture) {
-       if (is_overlap(srcx, srcx + width, srcy, srcy + height,
-                            dstx, dstx + width, dsty, dsty + height)) {
-          util_blitter_overlap_copy(blitter, dst, dstx, dsty, src, srcx, srcy,
-                                    width, height);
-          return;
-       }
+       assert(!is_overlap(srcx, srcx + width, srcy, srcy + height,
+              dstx, dstx + width, dsty, dsty + height));
     }
-                  
     is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
     is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
     dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL :
     /* (assuming copying a stencil buffer is not possible) */
     if ((!ignore_stencil && is_stencil) ||
         !screen->is_format_supported(screen, dst->format, dst->texture->target,
-                                     dst_tex_usage, 0) ||
+                                     dst->texture->nr_samples, dst_tex_usage, 0) ||
         !screen->is_format_supported(screen, src->format, src->texture->target,
-                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
-       util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
-                         width, height);
+                                     src->texture->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) {
+       struct pipe_subresource subdst, subsrc;
+       subdst.face = dst->face;
+       subdst.level = dst->level;
+       subsrc.face = src->face;
+       subsrc.level = src->level;
+       util_resource_copy_region(pipe, dst->texture, subdst, dstx, dsty, dst->zslice,
+                                 src->texture, subsrc, srcx, srcy, src->zslice,
+                                 width, height);
        return;
     }
  
@@@ -833,8 -791,13 +788,13 @@@ void util_blitter_fill(struct blitter_c
     /* check if we can render to the surface */
     if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
         !screen->is_format_supported(screen, dst->format, dst->texture->target,
+                                     dst->texture->nr_samples,
                                      PIPE_BIND_RENDER_TARGET, 0)) {
-       util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
+       struct pipe_subresource subdst;
+       subdst.face = dst->face;
+       subdst.level = dst->level;
+       util_resource_fill_region(pipe, dst->texture, subdst, dstx, dsty,
+                                 dst->zslice, width, height, value);
        return;
     }
  
index 1553e08d6cec9b3b02cca4c582bb93f2131fc7af,48ee0427261d240ed033ff762046059de4de0a8d..d19267be72fd932adc015a63ffe6d6c85067a91a
@@@ -1295,7 -1295,8 +1295,7 @@@ util_create_gen_mipmap(struct pipe_cont
  
     /* rasterizer */
     memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
 -   ctx->rasterizer.front_winding = PIPE_WINDING_CW;
 -   ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
 +   ctx->rasterizer.cull_face = PIPE_FACE_NONE;
     ctx->rasterizer.gl_rasterization_rules = 1;
  
     /* sampler state */
@@@ -1493,7 -1494,7 +1493,7 @@@ util_gen_mipmap(struct gen_mipmap_stat
  
     /* check if we can render in the texture's format */
     if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
-                                     PIPE_BIND_RENDER_TARGET, 0)) {
+                                     pt->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) {
        fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
        return;
     }
index 377c48c026602200f84f5f76a1c928488e938fd5,6f49a723557b8884e5885ef4b142b232a34decd0..9adf22c471e86f740313aa25fcdd98557f511e36
@@@ -38,6 -38,7 +38,6 @@@
  
  #include "util/u_format.h"
  #include "util/u_inlines.h"
 -#include "util/u_memory.h"
  #include "util/u_rect.h"
  #include "util/u_surface.h"
  
@@@ -69,7 -70,7 +69,7 @@@ util_create_rgba_surface(struct pipe_sc
     /* Choose surface format */
     for (i = 0; rgbaFormats[i]; i++) {
        if (screen->is_format_supported(screen, rgbaFormats[i],
-                                       target, bind, 0)) {
+                                       target, 0, bind, 0)) {
           format = rgbaFormats[i];
           break;
        }
@@@ -119,44 -120,44 +119,44 @@@ util_destroy_rgba_surface(struct pipe_r
  
  
  /**
-  * Fallback function for pipe->surface_copy().
+  * Fallback function for pipe->resource_copy_region().
   * Note: (X,Y)=(0,0) is always the upper-left corner.
-  * if do_flip, flip the image vertically on its way from src rect to dst rect.
   */
  void
- util_surface_copy(struct pipe_context *pipe,
-                   boolean do_flip,
-                   struct pipe_surface *dst,
-                   unsigned dst_x, unsigned dst_y,
-                   struct pipe_surface *src,
-                   unsigned src_x, unsigned src_y, 
-                   unsigned w, unsigned h)
+ util_resource_copy_region(struct pipe_context *pipe,
+                           struct pipe_resource *dst,
+                           struct pipe_subresource subdst,
+                           unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                           struct pipe_resource *src,
+                           struct pipe_subresource subsrc,
+                           unsigned src_x, unsigned src_y, unsigned src_z,
+                           unsigned w, unsigned h)
  {
     struct pipe_transfer *src_trans, *dst_trans;
     void *dst_map;
     const void *src_map;
     enum pipe_format src_format, dst_format;
  
-    assert(src->texture && dst->texture);
-    if (!src->texture || !dst->texture)
+    assert(src && dst);
+    if (!src || !dst)
        return;
  
-    src_format = src->texture->format;
-    dst_format = dst->texture->format;
+    src_format = src->format;
+    dst_format = dst->format;
  
     src_trans = pipe_get_transfer(pipe,
-                                src->texture,
-                                src->face,
-                                src->level,
-                                src->zslice,
+                                src,
+                                subsrc.face,
+                                subsrc.level,
+                                src_z,
                                 PIPE_TRANSFER_READ,
                                 src_x, src_y, w, h);
  
     dst_trans = pipe_get_transfer(pipe,
-                                dst->texture,
-                                dst->face,
-                                dst->level,
-                                dst->zslice,
+                                dst,
+                                subdst.face,
+                                subdst.level,
+                                src_z,
                                 PIPE_TRANSFER_WRITE,
                                 dst_x, dst_y, w, h);
  
     assert(dst_map);
  
     if (src_map && dst_map) {
-       /* If do_flip, invert src_y position and pass negative src stride */
        util_copy_rect(dst_map,
                       dst_format,
                       dst_trans->stride,
                       0, 0,
                       w, h,
                       src_map,
-                      do_flip ? -(int) src_trans->stride : src_trans->stride,
+                      src_trans->stride,
                       0,
-                      do_flip ? h - 1 : 0);
+                      0);
     }
  
     pipe->transfer_unmap(pipe, src_trans);
  
  
  /**
-  * Fallback for pipe->surface_fill() function.
+  * Fallback for pipe->resource_fill_region() function.
   */
  void
- util_surface_fill(struct pipe_context *pipe,
-                   struct pipe_surface *dst,
-                   unsigned dstx, unsigned dsty,
-                   unsigned width, unsigned height, unsigned value)
+ util_resource_fill_region(struct pipe_context *pipe,
+                           struct pipe_resource *dst,
+                           struct pipe_subresource subdst,
+                           unsigned dstx, unsigned dsty, unsigned dstz,
+                           unsigned width, unsigned height, unsigned value)
  {
     struct pipe_transfer *dst_trans;
     void *dst_map;
  
-    assert(dst->texture);
-    if (!dst->texture)
+    assert(dst);
+    if (!dst)
        return;
     dst_trans = pipe_get_transfer(pipe,
-                                dst->texture,
-                                dst->face,
-                                dst->level,
-                                dst->zslice,
+                                dst,
+                                subdst.face,
+                                subdst.level,
+                                dstz,
                                 PIPE_TRANSFER_WRITE,
                                 dstx, dsty, width, height);
  
     if (dst_map) {
        assert(dst_trans->stride > 0);
  
-       switch (util_format_get_blocksize(dst->texture->format)) {
+       switch (util_format_get_blocksize(dst->format)) {
        case 1:
        case 2:
        case 4:
-          util_fill_rect(dst_map, dst->texture->format,
+          util_fill_rect(dst_map, dst->format,
                        dst_trans->stride,
                          0, 0, width, height, value);
           break;
index ec358e34545c31b50a7526dada590b00829db88e,ac3c3c7bdbd712053f964a41ead94c1634cd0169..89c02b1b703c3467be66405e83ee60b95dba4248
@@@ -54,6 -54,7 +54,7 @@@ objects. They all follow simple, one-me
  * ``set_stencil_ref`` sets the stencil front and back reference values
    which are used as comparison values in stencil test.
  * ``set_blend_color``
+ * ``set_sample_mask``
  * ``set_clip_state``
  * ``set_polygon_stipple``
  * ``set_scissor_state`` sets the bounds for the scissor test, which culls
@@@ -200,16 -201,9 +201,16 @@@ returned).  Otherwise, if the ``wait`` 
  will not block and the return value will be TRUE if the query has
  completed or FALSE otherwise.
  
 -A common type of query is the occlusion query which counts the number of
 -fragments/pixels which are written to the framebuffer (and not culled by
 -Z/stencil/alpha testing or shader KILL instructions).
 +The most common type of query is the occlusion query,
 +``PIPE_QUERY_OCCLUSION_COUNTER``, which counts the number of fragments which
 +are written to the framebuffer without being culled by
 +:ref:`Depth, Stencil, & Alpha` testing or shader KILL instructions.
 +
 +Another type of query, ``PIPE_QUERY_TIME_ELAPSED``, returns the amount of
 +time, in nanoseconds, the context takes to perform operations.
 +
 +Gallium does not guarantee the availability of any query types; one must
 +always check the capabilities of the :ref:`Screen` first.
  
  
  Conditional Rendering
@@@ -259,18 -253,22 +260,22 @@@ Resource Busy Querie
  Blitting
  ^^^^^^^^
  
- These methods emulate classic blitter controls. They are not guaranteed to be
- available; if they are set to NULL, then they are not present.
+ These methods emulate classic blitter controls.
  
- These methods operate directly on ``pipe_surface`` objects, and stand
+ These methods operate directly on ``pipe_resource`` objects, and stand
  apart from any 3D state in the context.  Blitting functionality may be
  moved to a separate abstraction at some point in the future.
  
- ``surface_fill`` performs a fill operation on a section of a surface.
+ ``resource_fill_region`` performs a fill operation on a section of a resource.
  
- ``surface_copy`` blits a region of a surface to a region of another surface,
- provided that both surfaces are the same format. The source and destination
- may be the same surface, and overlapping blits are permitted.
+ ``resource_copy_region`` blits a region of a subresource of a resource to a
+ region of another subresource of a resource, provided that both resources have the
+ same format. The source and destination may be the same resource, but overlapping
+ blits are not permitted.
+ ``resource_resolve`` resolves a multisampled resource into a non-multisampled
+ one. Formats and dimensions must match. This function must be present if a driver
+ supports multisampling.
  
  The interfaces to these calls are likely to change to make it easier
  for a driver to batch multiple blits with the same source and
@@@ -291,6 -289,11 +296,6 @@@ data to be written to the resource at t
  The returned map points to the start of the mapped range according to
  the box region, not the beginning of the resource.
  
 -.. _transfer_flush_region:
 -``transfer_flush_region`` If a transfer was created with TRANFER_FLUSH_EXPLICIT,
 -only the region specified is guaranteed to be written to. This is relative to
 -the mapped range, not the beginning of the resource.
 -
  ``transfer_unmap`` remove the memory mapping for the transfer object.
  Any pointers into the map should be considered invalid and discarded.
  
  Basically get_transfer, transfer_map, data write, transfer_unmap, and
  transfer_destroy all in one.
  
 +.. _transfer_flush_region:
 +
 +transfer_flush_region
 +%%%%%%%%%%%%%%%%%%%%%
 +
 +If a transfer was created with ``FLUSH_EXPLICIT``, it will not automatically
 +be flushed on write or unmap. Flushes must be requested with
 +``transfer_flush_region``. Flush ranges are relative to the mapped range, not
 +the beginning of the resource.
 +
  .. _pipe_transfer:
  
  PIPE_TRANSFER
@@@ -327,4 -320,5 +332,4 @@@ These flags control the behavior of a t
    operations pending on the resource are undefined. Cannot be used with
    ``READ``.
  * ``FLUSH_EXPLICIT``: Written ranges will be notified later with
 -  :ref:`transfer_flush_region`. Cannot be used with
 -  ``READ``.
 +  :ref:`transfer_flush_region`. Cannot be used with ``READ``.
index 96257f93df9161b953fcb975964249ea03498876,5a60ee00a69b8552ead976273c39992bc7be7852..48d9d570b6fcfc9f581e071634786c90e8a4bf23
@@@ -1,5 -1,3 +1,5 @@@
 +.. _screen:
 +
  Screen
  ======
  
@@@ -35,7 -33,6 +35,7 @@@ The integer capabilities
  * ``MAX_RENDER_TARGETS``: The maximum number of render targets that may be
    bound.
  * ``OCCLUSION_QUERY``: Whether occlusion queries are available.
 +* ``TIMER_QUERY``: Whether timer queries are available.
  * ``TEXTURE_SHADOW_MAP``: XXX
  * ``MAX_TEXTURE_2D_LEVELS``: The maximum number of mipmap levels available
    for a 2D texture.
@@@ -104,22 -101,6 +104,22 @@@ The floating-point capabilities
  * ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``,
    ``GUARD_BAND_BOTTOM``: XXX
  
 +Fragment shader limits:
 +
 +* ``PIPE_CAP_MAX_FS_INSTRUCTIONS``: The maximum number of instructions.
 +* ``PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS``: The maximum number of arithmetic instructions.
 +* ``PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS``: The maximum number of texture instructions.
 +* ``PIPE_CAP_MAX_FS_TEX_INDIRECTIONS``: The maximum number of texture indirections.
 +* ``PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH``: The maximum nested control flow depth.
 +* ``PIPE_CAP_MAX_FS_INPUTS``: The maximum number of input registers.
 +* ``PIPE_CAP_MAX_FS_CONSTS``: The maximum number of constants.
 +* ``PIPE_CAP_MAX_FS_TEMPS``: The maximum number of temporary registers.
 +* ``PIPE_CAP_MAX_FS_ADDRS``: The maximum number of address registers.
 +* ``PIPE_CAP_MAX_FS_PREDS``: The maximum number of predicate registers.
 +
 +Vertex shader limits:
 +
 +* ``PIPE_CAP_MAX_VS_*``: Identical to ``PIPE_CAP_MAX_FS_*``.
  
  
  .. _pipe_bind:
@@@ -147,9 -128,6 +147,6 @@@ resources might be created and handled 
  * ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer.
  * ``PIPE_BIND_INDEX_BUFFER``: An vertex index/element buffer.
  * ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants.
- * ``PIPE_BIND_BLIT_SOURCE``: A blit source, as given to surface_copy.
- * ``PIPE_BIND_BLIT_DESTINATION``: A blit destination, as given to surface_copy
-   and surface_fill.
  * ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to.
  * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from.
  * ``PIPE_BIND_CUSTOM``:
@@@ -236,13 -214,15 +233,15 @@@ Determine if a resource in the given fo
  
  **target** one of the PIPE_TEXTURE_x flags
  
+ **sample_count** the number of samples. 0 and 1 mean no multisampling,
+ the maximum allowed legal value is 32.
  **bindings** is a bitmask of :ref:`PIPE_BIND` flags.
  
  **geom_flags** is a bitmask of PIPE_TEXTURE_GEOM_x flags.
  
  Returns TRUE if all usages can be satisfied.
  
  .. _resource_create:
  
  resource_create
index f4c614eef950073ac4e729fcdc2a7b213a9e9f1b,ecc9de4df6605af9f0e5d4a45185fa8e9bf40e74..03f84d295b50b63a0cd7d63719807e3ced435fdf
@@@ -125,6 -125,7 +125,7 @@@ cell_set_stencil_ref(struct pipe_contex
     cell->dirty |= CELL_NEW_DEPTH_STENCIL;
  }
  
  static void
  cell_set_clip_state(struct pipe_context *pipe,
                      const struct pipe_clip_state *clip)
  }
  
  
+ static void
+ cell_set_sample_mask(struct pipe_context *pipe,
+                      unsigned sample_mask)
+ {
+ }
  
  /* Called when driver state tracker notices changes to the viewport
   * matrix:
@@@ -197,7 -204,7 +204,7 @@@ cell_bind_rasterizer_state(struct pipe_
     struct cell_context *cell = cell_context(pipe);
  
     /* pass-through to draw module */
 -   draw_set_rasterizer_state(cell->draw, rasterizer);
 +   draw_set_rasterizer_state(cell->draw, rasterizer, rast);
  
     cell->rasterizer = rasterizer;
  
@@@ -430,7 -437,6 +437,6 @@@ cell_set_framebuffer_state(struct pipe_
  }
  
  
  void
  cell_init_state_functions(struct cell_context *cell)
  {
     cell->pipe.set_blend_color = cell_set_blend_color;
     cell->pipe.set_stencil_ref = cell_set_stencil_ref;
     cell->pipe.set_clip_state = cell_set_clip_state;
+    cell->pipe.set_sample_mask = cell_set_sample_mask;
  
     cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
  
index 750f0aa98ab1add428d876fc9b2e8e4218bf24cd,9bb3abfc9dd84932a276ad79f6e4ecf05a9da923..0f12e0667eb93e28512f048c63674de5b67b08c3
@@@ -55,7 -55,7 +55,7 @@@ cell_get_name(struct pipe_screen *scree
  
  
  static int
 -cell_get_param(struct pipe_screen *screen, int param)
 +cell_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
@@@ -76,8 -76,6 +76,8 @@@
        return 1;
     case PIPE_CAP_OCCLUSION_QUERY:
        return 1;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 0;
     case PIPE_CAP_TEXTURE_SHADOW_MAP:
        return 10;
     case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
  
  
  static float
 -cell_get_paramf(struct pipe_screen *screen, int param)
 +cell_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_LINE_WIDTH:
  
  static boolean
  cell_is_format_supported( struct pipe_screen *screen,
-                           enum pipe_format format, 
+                           enum pipe_format format,
                            enum pipe_texture_target target,
-                           unsigned tex_usage, 
+                           unsigned sample_count,
+                           unsigned tex_usage,
                            unsigned geom_flags )
  {
     struct sw_winsys *winsys = cell_screen(screen)->winsys;
  
+    if (sample_count > 1)
+       return FALSE;
     if (tex_usage & (PIPE_BIND_DISPLAY_TARGET |
                      PIPE_BIND_SCANOUT |
                      PIPE_BIND_SHARED)) {
index 7cf627d975bfa15bd713604844e0796cd837397e,c10ba25d2d524d8c175927a7a1a8c897f75f128c..0897a863dbd2ba01597b03b139006d5223853cc5
@@@ -90,7 -90,7 +90,7 @@@ i915_get_name(struct pipe_screen *scree
  }
  
  static int
 -i915_get_param(struct pipe_screen *screen, int param)
 +i915_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
        return 1;
     case PIPE_CAP_OCCLUSION_QUERY:
        return 0;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 0;
     case PIPE_CAP_TEXTURE_SHADOW_MAP:
        return 1;
     case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
  }
  
  static float
 -i915_get_paramf(struct pipe_screen *screen, int param)
 +i915_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_LINE_WIDTH:
  
  static boolean
  i915_is_format_supported(struct pipe_screen *screen,
-                          enum pipe_format format, 
+                          enum pipe_format format,
                           enum pipe_texture_target target,
-                          unsigned tex_usage, 
+                          unsigned sample_count,
+                          unsigned tex_usage,
                           unsigned geom_flags)
  {
     static const enum pipe_format tex_supported[] = {
        PIPE_FORMAT_Z24_UNORM_S8_USCALED,
        PIPE_FORMAT_NONE  /* list terminator */
     };
-    static const enum pipe_format surface_supported[] = {
+    static const enum pipe_format render_supported[] = {
        PIPE_FORMAT_B8G8R8A8_UNORM,
        PIPE_FORMAT_B5G6R5_UNORM,
+       PIPE_FORMAT_NONE  /* list terminator */
+    };
+    static const enum pipe_format depth_supported[] = {
        PIPE_FORMAT_Z24_UNORM_S8_USCALED,
        PIPE_FORMAT_NONE  /* list terminator */
     };
     const enum pipe_format *list;
     uint i;
  
-    if(tex_usage & PIPE_BIND_RENDER_TARGET)
-       list = surface_supported;
+    if (sample_count > 1)
+       return FALSE;
+    if(tex_usage & PIPE_BIND_DEPTH_STENCIL)
+       list = depth_supported;
+    else if (tex_usage & PIPE_BIND_RENDER_TARGET)
+       list = render_supported;
     else
        list = tex_supported;
  
index cd963e4df75f5fb64f801f51966f7cb4ef2f68b5,e008195a910b1cc0692b7e9cd751bac2127adc72..e767aa9f8f09f174198bdb3bfe09afff452fb572
@@@ -686,23 -686,17 +686,23 @@@ i915_create_rasterizer_state(struct pip
     else
        cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT;
  
 -   switch (rasterizer->cull_mode) {
 -   case PIPE_WINDING_NONE:
 +   switch (rasterizer->cull_face) {
 +   case PIPE_FACE_NONE:
        cso->LIS4 |= S4_CULLMODE_NONE;
        break;
 -   case PIPE_WINDING_CW:
 -      cso->LIS4 |= S4_CULLMODE_CW;
 +   case PIPE_FACE_FRONT:
 +      if (rasterizer->front_ccw)
 +         cso->LIS4 |= S4_CULLMODE_CCW;
 +      else 
 +         cso->LIS4 |= S4_CULLMODE_CW;
        break;
 -   case PIPE_WINDING_CCW:
 -      cso->LIS4 |= S4_CULLMODE_CCW;
 +   case PIPE_FACE_BACK:
 +      if (rasterizer->front_ccw)
 +         cso->LIS4 |= S4_CULLMODE_CW;
 +      else 
 +         cso->LIS4 |= S4_CULLMODE_CCW;
        break;
 -   case PIPE_WINDING_BOTH:
 +   case PIPE_FACE_FRONT_AND_BACK:
        cso->LIS4 |= S4_CULLMODE_BOTH;
        break;
     }
@@@ -812,6 -806,12 +812,12 @@@ i915_delete_vertex_elements_state(struc
     FREE( velems );
  }
  
+ static void
+ i915_set_sample_mask(struct pipe_context *pipe,
+                      unsigned sample_mask)
+ {
+ }
  void
  i915_init_state_functions( struct i915_context *i915 )
  {
     i915->base.set_blend_color = i915_set_blend_color;
     i915->base.set_stencil_ref = i915_set_stencil_ref;
     i915->base.set_clip_state = i915_set_clip_state;
+    i915->base.set_sample_mask = i915_set_sample_mask;
     i915->base.set_constant_buffer = i915_set_constant_buffer;
     i915->base.set_framebuffer_state = i915_set_framebuffer_state;
  
index 069a12b27f7b78762ded1b8ca9f443a4cd68d044,3b9854be588a96a86943c1b573f65c49941ea4bb..1efdb1e0b4d110e08ffc04e29c1bd8942e13a7d6
@@@ -1,4 -1,5 +1,5 @@@
  #include "util/u_debug.h"
+ #include "util/u_surface.h"
  
  #include "brw_resource.h"
  #include "brw_context.h"
@@@ -12,7 -13,7 +13,7 @@@ brw_resource_create(struct pipe_screen 
     if (template->target == PIPE_BUFFER)
        return brw_buffer_create(screen, template);
     else
 -      return brw_resource_create(screen, template);
 +      return brw_texture_create(screen, template);
  
  }
  
@@@ -37,6 -38,8 +38,8 @@@ brw_init_resource_functions(struct brw_
     brw->base.transfer_unmap = u_transfer_unmap_vtbl;
     brw->base.transfer_destroy = u_transfer_destroy_vtbl;
     brw->base.transfer_inline_write = u_transfer_inline_write_vtbl;
+    brw->base.resource_copy_region = util_resource_copy_region;
+    brw->base.resource_fill_region = util_resource_fill_region;
  }
  
  void
index ca09d88fd1203f6808bef8f6e9d0057207d91914,4fbb0c2484dea747599b5aa95f3cffddeaa005b6..ffd0f38672c7e7b32121fea8796d1571c4b72262
@@@ -210,7 -210,7 +210,7 @@@ brw_texture_get_handle(struct pipe_scre
  
     stride = tex->pitch * tex->cpp;
  
 -   return bscreen->sws->bo_get_handle(tex->bo, whandle, stride);
 +   return bscreen->sws->bo_get_handle(tex->bo, whandle, stride) == PIPE_OK;
  }
  
  
@@@ -594,7 -594,8 +594,8 @@@ fail
  boolean brw_is_format_supported( struct pipe_screen *screen,
                                 enum pipe_format format,
                                 enum pipe_texture_target target,
-                                unsigned tex_usage, 
+                                unsigned sample_count,
+                                unsigned tex_usage,
                                 unsigned geom_flags )
  {
     return translate_tex_format(format) != BRW_SURFACEFORMAT_INVALID;
index 1890b640e908469b47d108a71657e3217229e58a,172e222c057547ab5d1b2587e83e47ef0041db9a..7a7b9c1a5a962b42a1d72e34eeee10476e8495bc
@@@ -149,7 -149,7 +149,7 @@@ brw_get_name(struct pipe_screen *screen
  }
  
  static int
 -brw_get_param(struct pipe_screen *screen, int param)
 +brw_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
        return 1;
     case PIPE_CAP_OCCLUSION_QUERY:
        return 0;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 0;
     case PIPE_CAP_TEXTURE_SHADOW_MAP:
        return 1;
     case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
  }
  
  static float
 -brw_get_paramf(struct pipe_screen *screen, int param)
 +brw_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_LINE_WIDTH:
  
  static boolean
  brw_is_format_supported(struct pipe_screen *screen,
-                          enum pipe_format format, 
+                          enum pipe_format format,
                           enum pipe_texture_target target,
-                          unsigned tex_usage, 
+                          unsigned sample_count,
+                          unsigned tex_usage,
                           unsigned geom_flags)
  {
     static const enum pipe_format tex_supported[] = {
     const enum pipe_format *list;
     uint i;
  
+    if (sample_count > 1)
+       return FALSE;
     if (tex_usage & PIPE_BIND_DEPTH_STENCIL)
        list = depth_supported;
     else if (tex_usage & PIPE_BIND_RENDER_TARGET)
index 3c94e04a7a831736e47f17e0914e2b811ffbb1e6,7082d60d1c99bb3b06f19f11bb986f1a511efbfa..f71585e06f81c7f0a399ec605b2e8c722b6e37ba
@@@ -67,7 -67,7 +67,7 @@@ identity_screen_get_vendor(struct pipe_
  
  static int
  identity_screen_get_param(struct pipe_screen *_screen,
 -                          int param)
 +                          enum pipe_cap param)
  {
     struct identity_screen *id_screen = identity_screen(_screen);
     struct pipe_screen *screen = id_screen->screen;
@@@ -78,7 -78,7 +78,7 @@@
  
  static float
  identity_screen_get_paramf(struct pipe_screen *_screen,
 -                           int param)
 +                           enum pipe_cap param)
  {
     struct identity_screen *id_screen = identity_screen(_screen);
     struct pipe_screen *screen = id_screen->screen;
@@@ -91,6 -91,7 +91,7 @@@ static boolea
  identity_screen_is_format_supported(struct pipe_screen *_screen,
                                      enum pipe_format format,
                                      enum pipe_texture_target target,
+                                     unsigned sample_count,
                                      unsigned tex_usage,
                                      unsigned geom_flags)
  {
     return screen->is_format_supported(screen,
                                        format,
                                        target,
+                                       sample_count,
                                        tex_usage,
                                        geom_flags);
  }
index 22fbf381ae0da8af5e2286fb095617523c8549b7,5f50446f8463c469c3b1af02e7c905fb28aa2c88..cedc08e9292225eecf8e008455da4b1f44056017
@@@ -34,7 -34,6 +34,7 @@@
  #include "pipe/p_defines.h"
  #include "pipe/p_screen.h"
  
 +#include "gallivm/lp_bld_limits.h"
  #include "lp_texture.h"
  #include "lp_fence.h"
  #include "lp_jit.h"
@@@ -53,13 -52,16 +53,13 @@@ static const struct debug_named_value l
     { "pipe",   DEBUG_PIPE },
     { "tgsi",   DEBUG_TGSI },
     { "tex",    DEBUG_TEX },
 -   { "asm",    DEBUG_ASM },
     { "setup",  DEBUG_SETUP },
     { "rast",   DEBUG_RAST },
     { "query",  DEBUG_QUERY },
     { "screen", DEBUG_SCREEN },
 -   { "jit",    DEBUG_JIT },
     { "show_tiles",    DEBUG_SHOW_TILES },
     { "show_subtiles", DEBUG_SHOW_SUBTILES },
     { "counters", DEBUG_COUNTERS },
 -   { "nopt", DEBUG_NO_LLVM_OPT },
     {NULL, 0}
  };
  #endif
@@@ -80,7 -82,7 +80,7 @@@ llvmpipe_get_name(struct pipe_screen *s
  
  
  static int
 -llvmpipe_get_param(struct pipe_screen *screen, int param)
 +llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
        return PIPE_MAX_COLOR_BUFS;
     case PIPE_CAP_OCCLUSION_QUERY:
        return 1;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 0;
     case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
        return 1;
     case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
     case PIPE_CAP_BLEND_EQUATION_SEPARATE:
        return 1;
     case PIPE_CAP_INDEP_BLEND_ENABLE:
 -      return 0;
 +      return 1;
     case PIPE_CAP_INDEP_BLEND_FUNC:
        return 0;
     case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
     case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
     case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
        return 0;
 +   case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 +      /* There is no limit in number of instructions beyond available memory */
 +      return 32768;
 +   case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +   case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
 +      return LP_MAX_TGSI_NESTING;
 +   case PIPE_CAP_MAX_VS_INPUTS:
 +   case PIPE_CAP_MAX_FS_INPUTS:
 +      return PIPE_MAX_ATTRIBS;
 +   case PIPE_CAP_MAX_FS_CONSTS:
 +   case PIPE_CAP_MAX_VS_CONSTS:
 +      /* There is no limit in number of constants beyond available memory */
 +      return 32768;
 +   case PIPE_CAP_MAX_VS_TEMPS:
 +   case PIPE_CAP_MAX_FS_TEMPS:
 +      return LP_MAX_TGSI_TEMPS;
 +   case PIPE_CAP_MAX_VS_ADDRS:
 +   case PIPE_CAP_MAX_FS_ADDRS:
 +      return LP_MAX_TGSI_ADDRS;
 +   case PIPE_CAP_MAX_VS_PREDS:
 +   case PIPE_CAP_MAX_FS_PREDS:
 +      return LP_MAX_TGSI_PREDS;
     default:
 +      assert(0);
        return 0;
     }
  }
  
  
  static float
 -llvmpipe_get_paramf(struct pipe_screen *screen, int param)
 +llvmpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_LINE_WIDTH:
        return 16.0; /* not actually signficant at this time */
     case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
        return 16.0; /* arbitrary */
 +   case PIPE_CAP_GUARD_BAND_LEFT:
 +   case PIPE_CAP_GUARD_BAND_TOP:
 +   case PIPE_CAP_GUARD_BAND_RIGHT:
 +   case PIPE_CAP_GUARD_BAND_BOTTOM:
 +      return 0.0;
     default:
 +      assert(0);
        return 0;
     }
  }
   */
  static boolean
  llvmpipe_is_format_supported( struct pipe_screen *_screen,
-                               enum pipe_format format, 
+                               enum pipe_format format,
                                enum pipe_texture_target target,
+                               unsigned sample_count,
                                unsigned bind,
                                unsigned geom_flags )
  {
            target == PIPE_TEXTURE_3D ||
            target == PIPE_TEXTURE_CUBE);
  
+    if (sample_count > 1)
+       return FALSE;
     if (bind & PIPE_BIND_RENDER_TARGET) {
        if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
           return FALSE;
@@@ -302,16 -270,7 +306,16 @@@ llvmpipe_destroy_screen( struct pipe_sc
  struct pipe_screen *
  llvmpipe_create_screen(struct sw_winsys *winsys)
  {
 -   struct llvmpipe_screen *screen = CALLOC_STRUCT(llvmpipe_screen);
 +   struct llvmpipe_screen *screen;
 +
 +#ifdef PIPE_ARCH_X86
 +   /* require SSE2 due to LLVM PR6960. */
 +   util_cpu_detect();
 +   if (!util_cpu_caps.has_sse2)
 +       return NULL;
 +#endif
 +
 +   screen = CALLOC_STRUCT(llvmpipe_screen);
  
  #ifdef DEBUG
     LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
index a91b00b5adafc51ed540a8a7bbe07067ad40c8c1,89d5ffa8aa3e972543563793722dad0e2b18d33c..60bdd7276aa5b9b65126314f581473b8d514cd7e
@@@ -5,7 -5,6 +5,7 @@@
  #include "util/u_memory.h"
  #include "util/u_inlines.h"
  #include "util/u_format.h"
 +#include "util/u_format_s3tc.h"
  
  #include <stdio.h>
  #include <errno.h>
@@@ -52,8 -51,6 +52,6 @@@ nouveau_screen_bo_new(struct pipe_scree
  
        if (bind & (PIPE_BIND_RENDER_TARGET |
                        PIPE_BIND_DEPTH_STENCIL |
-                       PIPE_BIND_BLIT_SOURCE |
-                       PIPE_BIND_BLIT_DESTINATION |
                        PIPE_BIND_SCANOUT |
                        PIPE_BIND_DISPLAY_TARGET |
                        PIPE_BIND_SAMPLER_VIEW))
@@@ -249,8 -246,6 +247,8 @@@ nouveau_screen_init(struct nouveau_scre
        pscreen->fence_signalled = nouveau_screen_fence_signalled;
        pscreen->fence_finish = nouveau_screen_fence_finish;
  
 +      util_format_s3tc_init();
 +
        return 0;
  }
  
index 757f13b640a6d429d29024fcc1e7cde479bab8d5,a8cb1e25d81bfaa231ac28874144dbef8a29d74f..2c0caada3664c81cbf234ee831ad4bd4469ceaa7
@@@ -20,7 -20,6 +20,7 @@@
   * SOFTWARE.
   */
  
 +#include "util/u_format_s3tc.h"
  #include "pipe/p_screen.h"
  
  #include "nv50_context.h"
@@@ -33,8 -32,12 +33,12 @@@ static boolea
  nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                                enum pipe_format format,
                                enum pipe_texture_target target,
+                               unsigned sample_count,
                                unsigned tex_usage, unsigned geom_flags)
  {
+       if (sample_count > 1)
+               return FALSE;
        if (tex_usage & PIPE_BIND_RENDER_TARGET) {
                switch (format) {
                case PIPE_FORMAT_B8G8R8X8_UNORM:
                        break;
                }
        } else {
 +              if (tex_usage & PIPE_BIND_SAMPLER_VIEW) {
 +                      switch (format) {
 +                      case PIPE_FORMAT_DXT1_RGB:
 +                      case PIPE_FORMAT_DXT1_RGBA:
 +                      case PIPE_FORMAT_DXT3_RGBA:
 +                      case PIPE_FORMAT_DXT5_RGBA:
 +                              return util_format_s3tc_enabled;
 +                      default:
 +                              break;
 +                      }
 +              }
                switch (format) {
                case PIPE_FORMAT_B8G8R8A8_UNORM:
                case PIPE_FORMAT_B8G8R8X8_UNORM:
                case PIPE_FORMAT_A8_UNORM:
                case PIPE_FORMAT_I8_UNORM:
                case PIPE_FORMAT_L8A8_UNORM:
 -              case PIPE_FORMAT_DXT1_RGB:
 -              case PIPE_FORMAT_DXT1_RGBA:
 -              case PIPE_FORMAT_DXT3_RGBA:
 -              case PIPE_FORMAT_DXT5_RGBA:
                case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
                case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
                case PIPE_FORMAT_Z32_FLOAT:
  }
  
  static int
 -nv50_screen_get_param(struct pipe_screen *pscreen, int param)
 +nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
  {
        switch (param) {
        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
                return 8;
        case PIPE_CAP_OCCLUSION_QUERY:
                return 1;
 +        case PIPE_CAP_TIMER_QUERY:
 +              return 0;
        case PIPE_CAP_TEXTURE_SHADOW_MAP:
                return 1;
        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
                return 0;
 +      case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +      case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: /* arbitrary limit */
 +              return 16384;
 +      case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +      case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: /* need stack bo */
 +              return 4;
 +      case PIPE_CAP_MAX_VS_INPUTS:
 +              return 16;
 +      case PIPE_CAP_MAX_FS_INPUTS: /* 128 / 4 with GP */
 +              return 64 / 4;
 +      case PIPE_CAP_MAX_VS_CONSTS:
 +      case PIPE_CAP_MAX_FS_CONSTS:
 +              return 65536 / 16;
 +      case PIPE_CAP_MAX_VS_ADDRS:
 +      case PIPE_CAP_MAX_FS_ADDRS: /* no spilling atm */
 +              return 1;
 +      case PIPE_CAP_MAX_VS_PREDS:
 +      case PIPE_CAP_MAX_FS_PREDS: /* not yet handled */
 +              return 0;
 +      case PIPE_CAP_MAX_VS_TEMPS:
 +      case PIPE_CAP_MAX_FS_TEMPS: /* no spilling atm */
 +              return 128 / 4;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
  }
  
  static float
 -nv50_screen_get_paramf(struct pipe_screen *pscreen, int param)
 +nv50_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_cap param)
  {
        switch (param) {
        case PIPE_CAP_MAX_LINE_WIDTH:
index b20781fa1fbdd6808f86c43c34ce80072cf7a1e9,cf4105bcb77a44a488125b6a3f789e702c352fb8..f8bff764f27ab2ac626b5c5ff9a5e93fc8cc2d81
@@@ -345,7 -345,7 +345,7 @@@ nv50_rasterizer_state_create(struct pip
                CALLOC_STRUCT(nv50_rasterizer_stateobj);
  
        /*XXX: ignored
 -       *      - light_twosize
 +       *      - light_twoside
         *      - point_smooth
         *      - multisample
         *      - point_sprite / sprite_coord_mode
        so_data  (so, cso->point_quad_rasterization ? 1 : 0);
  
        so_method(so, tesla, NV50TCL_POLYGON_MODE_FRONT, 3);
 -      if (cso->front_winding == PIPE_WINDING_CCW) {
 -              so_data(so, nvgl_polygon_mode(cso->fill_ccw));
 -              so_data(so, nvgl_polygon_mode(cso->fill_cw));
 -      } else {
 -              so_data(so, nvgl_polygon_mode(cso->fill_cw));
 -              so_data(so, nvgl_polygon_mode(cso->fill_ccw));
 -      }
 +        so_data(so, nvgl_polygon_mode(cso->fill_front));
 +        so_data(so, nvgl_polygon_mode(cso->fill_back));
        so_data(so, cso->poly_smooth ? 1 : 0);
  
        so_method(so, tesla, NV50TCL_CULL_FACE_ENABLE, 3);
 -      so_data  (so, cso->cull_mode != PIPE_WINDING_NONE);
 -      if (cso->front_winding == PIPE_WINDING_CCW) {
 +      so_data  (so, cso->cull_face != PIPE_FACE_NONE);
 +      if (cso->front_ccw) {
                so_data(so, NV50TCL_FRONT_FACE_CCW);
 -              switch (cso->cull_mode) {
 -              case PIPE_WINDING_CCW:
 -                      so_data(so, NV50TCL_CULL_FACE_FRONT);
 -                      break;
 -              case PIPE_WINDING_CW:
 -                      so_data(so, NV50TCL_CULL_FACE_BACK);
 -                      break;
 -              case PIPE_WINDING_BOTH:
 -                      so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK);
 -                      break;
 -              default:
 -                      so_data(so, NV50TCL_CULL_FACE_BACK);
 -                      break;
 -              }
 -      } else {
 +        }
 +        else {
                so_data(so, NV50TCL_FRONT_FACE_CW);
 -              switch (cso->cull_mode) {
 -              case PIPE_WINDING_CCW:
 -                      so_data(so, NV50TCL_CULL_FACE_BACK);
 -                      break;
 -              case PIPE_WINDING_CW:
 -                      so_data(so, NV50TCL_CULL_FACE_FRONT);
 -                      break;
 -              case PIPE_WINDING_BOTH:
 -                      so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK);
 -                      break;
 -              default:
 -                      so_data(so, NV50TCL_CULL_FACE_BACK);
 -                      break;
 -              }
 +        }
 +      switch (cso->cull_face) {
 +      case PIPE_FACE_FRONT:
 +              so_data(so, NV50TCL_CULL_FACE_FRONT);
 +              break;
 +      case PIPE_FACE_BACK:
 +              so_data(so, NV50TCL_CULL_FACE_BACK);
 +              break;
 +      case PIPE_FACE_FRONT_AND_BACK:
 +              so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK);
 +              break;
 +      default:
 +              so_data(so, NV50TCL_CULL_FACE_BACK);
 +              break;
        }
  
        so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_ENABLE, 1);
        so_data  (so, cso->poly_stipple_enable ? 1 : 0);
  
        so_method(so, tesla, NV50TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
 -              so_data(so, 1);
 -      else
 -              so_data(so, 0);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
 -              so_data(so, 1);
 -      else
 -              so_data(so, 0);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
 -              so_data(so, 1);
 -      else
 -              so_data(so, 0);
 +        so_data(so, cso->offset_point);
 +        so_data(so, cso->offset_line);
 +        so_data(so, cso->offset_tri);
  
 -      if (cso->offset_cw || cso->offset_ccw) {
 +      if (cso->offset_point ||
 +            cso->offset_line ||
 +            cso->offset_tri) {
                so_method(so, tesla, NV50TCL_POLYGON_OFFSET_FACTOR, 1);
                so_data  (so, fui(cso->offset_scale));
                so_method(so, tesla, NV50TCL_POLYGON_OFFSET_UNITS, 1);
@@@ -660,6 -688,12 +660,12 @@@ nv50_set_clip_state(struct pipe_contex
  {
  }
  
+ static void
+ nv50_set_sample_mask(struct pipe_context *pipe,
+                    unsigned sample_mask)
+ {
+ }
  static void
  nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         struct pipe_resource *buf )
@@@ -805,6 -839,7 +811,7 @@@ nv50_init_state_functions(struct nv50_c
        nv50->pipe.set_blend_color = nv50_set_blend_color;
          nv50->pipe.set_stencil_ref = nv50_set_stencil_ref;
        nv50->pipe.set_clip_state = nv50_set_clip_state;
+       nv50->pipe.set_sample_mask = nv50_set_sample_mask;
        nv50->pipe.set_constant_buffer = nv50_set_constant_buffer;
        nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state;
        nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple;
index 6cb8428e4b618856be802dadd4a21c39e9d76763,1786af776aaa40443d2be511fd859b1f7ce94dac..7e534a0c738bd048cc0067bbba062f70dc457732
@@@ -1,6 -1,5 +1,6 @@@
  #include "pipe/p_screen.h"
  #include "pipe/p_state.h"
 +#include "util/u_format_s3tc.h"
  #include "util/u_simple_screen.h"
  
  #include "nouveau/nouveau_screen.h"
@@@ -30,7 -29,7 +30,7 @@@ struct nouveau_winsys 
  #define NV6X_GRCLASS4497_CHIPSETS 0x00000088
  
  static int
 -nvfx_screen_get_param(struct pipe_screen *pscreen, int param)
 +nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
  {
        struct nvfx_screen *screen = nvfx_screen(pscreen);
  
@@@ -52,8 -51,6 +52,8 @@@
                return screen->is_nv4x ? 4 : 2;
        case PIPE_CAP_OCCLUSION_QUERY:
                return 1;
 +        case PIPE_CAP_TIMER_QUERY:
 +              return 0;
        case PIPE_CAP_TEXTURE_SHADOW_MAP:
                return 1;
        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
                return 0;
 +      case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 +              return 4096;
 +      case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
 +              /* FIXME: is it the dynamic (nv30:0/nv40:24) or the static
 +                 value (nv30:0/nv40:4) ? */
 +              return screen->is_nv4x ? 4 : 0;
 +      case PIPE_CAP_MAX_FS_INPUTS:
 +              return 10;
 +      case PIPE_CAP_MAX_FS_CONSTS:
 +              return screen->is_nv4x ? 224 : 32;
 +      case PIPE_CAP_MAX_FS_TEMPS:
 +              return 32;
 +      case PIPE_CAP_MAX_FS_ADDRS:
 +              return screen->is_nv4x ? 1 : 0;
 +      case PIPE_CAP_MAX_FS_PREDS:
 +              return screen->is_nv4x ? 1 : 0;
 +      case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +              return screen->is_nv4x ? 512 : 256;
 +      case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +      case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +              return screen->is_nv4x ? 512 : 0;
 +      case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +              /* FIXME: is it the dynamic (nv30:24/nv40:24) or the static
 +                 value (nv30:1/nv40:4) ? */
 +              return screen->is_nv4x ? 4 : 1;
 +      case PIPE_CAP_MAX_VS_INPUTS:
 +              return 16;
 +      case PIPE_CAP_MAX_VS_CONSTS:
 +              return 256;
 +      case PIPE_CAP_MAX_VS_TEMPS:
 +              return screen->is_nv4x ? 32 : 13;
 +      case PIPE_CAP_MAX_VS_ADDRS:
 +              return 2;
 +      case PIPE_CAP_MAX_VS_PREDS:
 +              return screen->is_nv4x ? 1 : 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
  }
  
  static float
 -nvfx_screen_get_paramf(struct pipe_screen *pscreen, int param)
 +nvfx_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_cap param)
  {
        struct nvfx_screen *screen = nvfx_screen(pscreen);
  
@@@ -157,11 -115,15 +157,15 @@@ static boolea
  nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
                                     enum pipe_format format,
                                     enum pipe_texture_target target,
+                                    unsigned sample_count,
                                     unsigned tex_usage, unsigned geom_flags)
  {
        struct nvfx_screen *screen = nvfx_screen(pscreen);
        struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
  
+        if (sample_count > 1)
+               return FALSE;
        if (tex_usage & PIPE_BIND_RENDER_TARGET) {
                switch (format) {
                case PIPE_FORMAT_B8G8R8A8_UNORM:
                }
        } else {
                switch (format) {
 +              if (tex_usage & PIPE_BIND_SAMPLER_VIEW) {
 +                      switch (format) {
 +                      case PIPE_FORMAT_DXT1_RGB:
 +                      case PIPE_FORMAT_DXT1_RGBA:
 +                      case PIPE_FORMAT_DXT3_RGBA:
 +                      case PIPE_FORMAT_DXT5_RGBA:
 +                              return util_format_s3tc_enabled;
 +                      default:
 +                              break;
 +                      }
 +              }
                case PIPE_FORMAT_B8G8R8A8_UNORM:
                case PIPE_FORMAT_B8G8R8X8_UNORM:
                case PIPE_FORMAT_B5G5R5A1_UNORM:
                case PIPE_FORMAT_L8A8_UNORM:
                case PIPE_FORMAT_Z16_UNORM:
                case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
 -              case PIPE_FORMAT_DXT1_RGB:
 -              case PIPE_FORMAT_DXT1_RGBA:
 -              case PIPE_FORMAT_DXT3_RGBA:
 -              case PIPE_FORMAT_DXT5_RGBA:
                        return TRUE;
                /* TODO: does nv30 support this? */
                case PIPE_FORMAT_R16_SNORM:
index 17f3f701406ea3360081e6986f262a160bd80fc5,3c566808d03ae6badccd8d604db407983e1d0398..30322d46d934df0a1e8867f41408aaac2f4ce265
@@@ -216,39 -216,66 +216,39 @@@ nvfx_rasterizer_state_create(struct pip
        sb_data(sb, fui(cso->point_size));
  
        sb_method(sb, NV34TCL_POLYGON_MODE_FRONT, 6);
 -      if (cso->front_winding == PIPE_WINDING_CCW) {
 -              sb_data(sb, nvgl_polygon_mode(cso->fill_ccw));
 -              sb_data(sb, nvgl_polygon_mode(cso->fill_cw));
 -              switch (cso->cull_mode) {
 -              case PIPE_WINDING_CCW:
 -                      sb_data(sb, NV34TCL_CULL_FACE_FRONT);
 -                      break;
 -              case PIPE_WINDING_CW:
 -                      sb_data(sb, NV34TCL_CULL_FACE_BACK);
 -                      break;
 -              case PIPE_WINDING_BOTH:
 -                      sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK);
 -                      break;
 -              default:
 -                      sb_data(sb, NV34TCL_CULL_FACE_BACK);
 -                      break;
 -              }
 +        sb_data(sb, nvgl_polygon_mode(cso->fill_front));
 +        sb_data(sb, nvgl_polygon_mode(cso->fill_back));
 +      switch (cso->cull_face) {
 +      case PIPE_FACE_FRONT:
 +              sb_data(sb, NV34TCL_CULL_FACE_FRONT);
 +              break;
 +      case PIPE_FACE_BACK:
 +              sb_data(sb, NV34TCL_CULL_FACE_BACK);
 +              break;
 +      case PIPE_FACE_FRONT_AND_BACK:
 +              sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK);
 +              break;
 +      default:
 +              sb_data(sb, NV34TCL_CULL_FACE_BACK);
 +              break;
 +      }
 +      if (cso->front_ccw) {
                sb_data(sb, NV34TCL_FRONT_FACE_CCW);
        } else {
 -              sb_data(sb, nvgl_polygon_mode(cso->fill_cw));
 -              sb_data(sb, nvgl_polygon_mode(cso->fill_ccw));
 -              switch (cso->cull_mode) {
 -              case PIPE_WINDING_CCW:
 -                      sb_data(sb, NV34TCL_CULL_FACE_BACK);
 -                      break;
 -              case PIPE_WINDING_CW:
 -                      sb_data(sb, NV34TCL_CULL_FACE_FRONT);
 -                      break;
 -              case PIPE_WINDING_BOTH:
 -                      sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK);
 -                      break;
 -              default:
 -                      sb_data(sb, NV34TCL_CULL_FACE_BACK);
 -                      break;
 -              }
                sb_data(sb, NV34TCL_FRONT_FACE_CW);
        }
        sb_data(sb, cso->poly_smooth ? 1 : 0);
 -      sb_data(sb, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
 +      sb_data(sb, (cso->cull_face != PIPE_FACE_NONE) ? 1 : 0);
  
        sb_method(sb, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
        sb_data(sb, cso->poly_stipple_enable ? 1 : 0);
  
        sb_method(sb, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
 -              sb_data(sb, 1);
 -      else
 -              sb_data(sb, 0);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
 -              sb_data(sb, 1);
 -      else
 -              sb_data(sb, 0);
 -      if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
 -          (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
 -              sb_data(sb, 1);
 -      else
 -              sb_data(sb, 0);
 -      if (cso->offset_cw || cso->offset_ccw) {
 +        sb_data(sb, cso->offset_point);
 +        sb_data(sb, cso->offset_line);
 +        sb_data(sb, cso->offset_tri);
 +
 +      if (cso->offset_point || cso->offset_line || cso->offset_tri) {
                sb_method(sb, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
                sb_data(sb, fui(cso->offset_scale));
                sb_data(sb, fui(cso->offset_units * 2));
@@@ -478,6 -505,12 +478,12 @@@ nvfx_set_clip_state(struct pipe_contex
        nvfx->draw_dirty |= NVFX_NEW_UCP;
  }
  
+ static void
+ nvfx_set_sample_mask(struct pipe_context *pipe,
+                    unsigned sample_mask)
+ {
+ }
  static void
  nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         struct pipe_resource *buf )
@@@ -617,6 -650,7 +623,7 @@@ nvfx_init_state_functions(struct nvfx_c
        nvfx->pipe.set_blend_color = nvfx_set_blend_color;
          nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref;
        nvfx->pipe.set_clip_state = nvfx_set_clip_state;
+       nvfx->pipe.set_sample_mask = nvfx_set_sample_mask;
        nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer;
        nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state;
        nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple;
index 9837deaa5e31b6a3a134403516b4b5b82ef651a8,b3ef97fa52b2f93bf6ec9986919dab84a2936bb0..f771e10c64ee6c5fb27400f7a70c26df074ccd54
@@@ -80,9 -80,6 +80,9 @@@ static void r300_destroy_context(struc
      FREE(r300->ztop_state.state);
      FREE(r300->fs_constants.state);
      FREE(r300->vs_constants.state);
 +    if (!r300->screen->caps.has_tcl) {
 +        FREE(r300->vertex_stream_state.state);
 +    }
      FREE(r300);
  }
  
@@@ -154,16 -151,6 +154,16 @@@ static void r300_setup_atoms(struct r30
      r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
      r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
      r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
 +    if (!r300->screen->caps.has_tcl) {
 +        r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state);
 +    }
 +
 +    /* Some non-CSO atoms don't use the state pointer. */
 +    r300->invariant_state.allow_null_state = TRUE;
 +    r300->fs_rc_constant_state.allow_null_state = TRUE;
 +    r300->pvs_flush.allow_null_state = TRUE;
 +    r300->query_start.allow_null_state = TRUE;
 +    r300->texture_cache_inval.allow_null_state = TRUE;
  }
  
  struct pipe_context* r300_create_context(struct pipe_screen* screen,
      r300->context.destroy = r300_destroy_context;
  
      r300->context.clear = r300_clear;
-     r300->context.surface_copy = r300_surface_copy;
-     r300->context.surface_fill = r300_surface_fill;
+     r300->context.resource_copy_region = r300_surface_copy;
+     r300->context.resource_fill_region = r300_surface_fill;
  
      if (r300screen->caps.has_tcl) {
          r300->context.draw_arrays = r300_draw_arrays;
          draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
          /* Enable Draw's clipping. */
          draw_set_driver_clipping(r300->draw, FALSE);
 -        /* Force Draw to never do viewport transform, since we can do
 -         * transform in hardware, always. */
 -        draw_set_viewport_state(r300->draw, &r300_viewport_identity);
 +        /* Disable converting points/lines to triangles. */
 +        draw_wide_line_threshold(r300->draw, 10000000.f);
 +        draw_wide_point_threshold(r300->draw, 10000000.f);
      }
  
      r300_setup_atoms(r300);
index 640b3d346887fbd6f70d5d69cb87e46b025ca74c,b7f1c617f0390d63f732c2d725331295a1aa96b6..ef0255066b798061a30f74924c5c2557e5ba3d1a
@@@ -76,19 -76,20 +76,19 @@@ static const char* r300_get_name(struc
      return chip_families[r300screen->caps.family];
  }
  
 -static int r300_get_param(struct pipe_screen* pscreen, int param)
 +static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
  {
      struct r300_screen* r300screen = r300_screen(pscreen);
 +    boolean is_r400 = r300screen->caps.is_r400;
 +    boolean is_r500 = r300screen->caps.is_r500;
 +
 +    /* XXX extended shader capabilities of r400 unimplemented */
 +    is_r400 = FALSE;
  
      switch (param) {
 -        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
 -        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
 -            return r300screen->caps.num_tex_units;
 +        /* Supported features (boolean caps). */
          case PIPE_CAP_NPOT_TEXTURES:
 -            /* XXX enable now to get GL2.1 API,
 -             * figure out later how to emulate this */
 -            return 1;
          case PIPE_CAP_TWO_SIDED_STENCIL:
 -            return 1;
          case PIPE_CAP_GLSL:
              /* I'll be frank. This is a lie.
               *
               *
               * ~ C.
               */
 -            return 1;
 -        case PIPE_CAP_DUAL_SOURCE_BLEND:
 -            return 0;
          case PIPE_CAP_ANISOTROPIC_FILTER:
 -            return 1;
          case PIPE_CAP_POINT_SPRITE:
 -            return 1;
 -        case PIPE_CAP_MAX_RENDER_TARGETS:
 -            return 4;
          case PIPE_CAP_OCCLUSION_QUERY:
 -            return 1;
          case PIPE_CAP_TEXTURE_SHADOW_MAP:
 -            return 1;
 -        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
 -        case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
 -        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
 -            if (r300screen->caps.is_r500) {
 -                /* 13 == 4096 */
 -                return 13;
 -            } else {
 -                /* 12 == 2048 */
 -                return 12;
 -            }
          case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
 -            return 1;
          case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
 +        case PIPE_CAP_BLEND_EQUATION_SEPARATE:
              return 1;
 -        case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
 -            return 0;
 +
 +        /* Unsupported features (boolean caps). */
 +        case PIPE_CAP_TIMER_QUERY:
 +        case PIPE_CAP_DUAL_SOURCE_BLEND:
          case PIPE_CAP_TGSI_CONT_SUPPORTED:
 +        case PIPE_CAP_INDEP_BLEND_ENABLE:
 +        case PIPE_CAP_INDEP_BLEND_FUNC:
              return 0;
 -        case PIPE_CAP_BLEND_EQUATION_SEPARATE:
 -            return 1;
 +
 +        /* Texturing. */
 +        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
 +        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
 +            return r300screen->caps.num_tex_units;
 +        case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
 +            return 0;
 +        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
 +        case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
 +        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
 +            /* 13 == 4096, 12 == 2048 */
 +            return is_r500 ? 13 : 12;
 +
 +        /* Render targets. */
 +        case PIPE_CAP_MAX_RENDER_TARGETS:
 +            return 4;
 +
 +        /* General shader limits and features. */
          case PIPE_CAP_SM3:
 -            if (r300screen->caps.is_r500) {
 -                return 1;
 -            } else {
 -                return 0;
 -            }
 +            return is_r500 ? 1 : 0;
          case PIPE_CAP_MAX_CONST_BUFFERS:
              return 1;
          case PIPE_CAP_MAX_CONST_BUFFER_SIZE:
              return 256;
 -        case PIPE_CAP_INDEP_BLEND_ENABLE:
 -            return 0;
 -        case PIPE_CAP_INDEP_BLEND_FUNC:
 -            return 0;
 +
 +        /* Fragment coordinate conventions. */
          case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
          case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
            return 1;
          case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
          case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
              return 0;
 +
 +        /* Fragment shader limits. */
 +        case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +            return is_r500 || is_r400 ? 512 : 96;
 +        case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +            return is_r500 || is_r400 ? 512 : 64;
 +        case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +            return is_r500 || is_r400 ? 512 : 32;
 +        case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 +            return is_r500 ? 511 : 4;
 +        case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
 +            return is_r500 ? 64 : 0; /* Actually unlimited on r500. */
 +        case PIPE_CAP_MAX_FS_INPUTS:
 +            /* 2 colors + 8 texcoords are always supported
 +             * (minus fog and wpos).
 +             *
 +             * R500 has the ability to turn 3rd and 4th color into
 +             * additional texcoords but there is no two-sided color
 +             * selection then. However the facing bit can be used instead. */
 +            return 10;
 +        case PIPE_CAP_MAX_FS_CONSTS:
 +            return is_r500 ? 256 : 32;
 +        case PIPE_CAP_MAX_FS_TEMPS:
 +            return is_r500 ? 128 : is_r400 ? 64 : 32;
 +        case PIPE_CAP_MAX_FS_ADDRS:
 +            return 0;
 +        case PIPE_CAP_MAX_FS_PREDS:
 +            return is_r500 ? 1 : 0;
 +
 +        /* Vertex shader limits. */
 +        case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +        case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +            return is_r500 ? 1024 : 256;
 +        case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +        case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +            return 0;
 +        case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +            return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. */
 +        case PIPE_CAP_MAX_VS_INPUTS:
 +            return 16;
 +        case PIPE_CAP_MAX_VS_CONSTS:
 +            return 256;
 +        case PIPE_CAP_MAX_VS_TEMPS:
 +            return 32;
 +        case PIPE_CAP_MAX_VS_ADDRS:
 +            return 1; /* XXX guessed */
 +        case PIPE_CAP_MAX_VS_PREDS:
 +            return is_r500 ? 4 : 0; /* XXX guessed. */
 +
          default:
              fprintf(stderr, "r300: Implementation error: Bad param %d\n",
                  param);
      }
  }
  
 -static float r300_get_paramf(struct pipe_screen* pscreen, int param)
 +static float r300_get_paramf(struct pipe_screen* pscreen, enum pipe_cap param)
  {
      struct r300_screen* r300screen = r300_screen(pscreen);
  
  static boolean r300_is_format_supported(struct pipe_screen* screen,
                                          enum pipe_format format,
                                          enum pipe_texture_target target,
+                                         unsigned sample_count,
                                          unsigned usage,
                                          unsigned geom_flags)
  {
          return FALSE;
      }
  
+    if (sample_count > 1)
+       return FALSE;
      /* Check sampler format support. */
      if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
          /* Z24 cannot be sampled from on non-r5xx. */
index 11c10e2f2a85e360835334c7f46827e3910a3785,4f41530c16a648464a3014dd2c420431645dd685..67e09362d8e38fbef6ef8ce270c42f8d40d289b6
@@@ -395,15 -395,22 +395,22 @@@ static void r300_set_clip_state(struct 
      if (r300->screen->caps.has_tcl) {
          memcpy(r300->clip_state.state, state, sizeof(struct pipe_clip_state));
          r300->clip_state.size = 29;
 +
 +        r300->clip_state.dirty = TRUE;
      } else {
          draw_flush(r300->draw);
          draw_set_clip_state(r300->draw, state);
          r300->clip_state.size = 2;
      }
 -
 -    r300->clip_state.dirty = TRUE;
  }
  
+ static void
+ r300_set_sample_mask(struct pipe_context *pipe,
+                      unsigned sample_mask)
+ {
+ }
  /* Create a new depth, stencil, and alpha state based on the CSO dsa state.
   *
   * This contains the depth buffer, stencil buffer, alpha test, and such.
@@@ -566,35 -573,13 +573,35 @@@ static void r300_fb_set_tiling_flags(st
      }
  }
  
 +static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index,
 +                                    const char *binding)
 +{
 +    struct pipe_resource *tex = surf->texture;
 +    struct r300_texture *rtex = r300_texture(tex);
 +
 +    fprintf(stderr,
 +            "r300:   %s[%i] Dim: %ix%i, Offset: %i, ZSlice: %i, "
 +            "Face: %i, Level: %i, Format: %s\n"
 +
 +            "r300:     TEX: Macro: %s, Micro: %s, Pitch: %i, "
 +            "Dim: %ix%ix%i, LastLevel: %i, Format: %s\n",
 +
 +            binding, index, surf->width, surf->height, surf->offset,
 +            surf->zslice, surf->face, surf->level,
 +            util_format_short_name(surf->format),
 +
 +            rtex->macrotile ? "YES" : " NO", rtex->microtile ? "YES" : " NO",
 +            rtex->hwpitch[0], tex->width0, tex->height0, tex->depth0,
 +            tex->last_level, util_format_short_name(tex->format));
 +}
 +
  static void
      r300_set_framebuffer_state(struct pipe_context* pipe,
                                 const struct pipe_framebuffer_state* state)
  {
      struct r300_context* r300 = r300_context(pipe);
      struct pipe_framebuffer_state *old_state = r300->fb_state.state;
 -    unsigned max_width, max_height;
 +    unsigned max_width, max_height, i;
      uint32_t zbuffer_bpp = 0;
  
      if (state->nr_cbufs > 4) {
      memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state));
  
      r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) +
 -                          (state->zsbuf ? 10 : 0) + 11;
 +                          (state->zsbuf ? 10 : 0) + 9;
  
      /* Polygon offset depends on the zbuffer bit depth. */
      if (state->zsbuf && r300->polygon_offset_enabled) {
              r300->rs_state.dirty = TRUE;
          }
      }
 +
 +    if (DBG_ON(r300, DBG_FB)) {
 +        fprintf(stderr, "r300: set_framebuffer_state:\n");
 +        for (i = 0; i < state->nr_cbufs; i++) {
 +            r300_print_fb_surf_info(state->cbufs[i], i, "CB");
 +        }
 +        if (state->zsbuf) {
 +            r300_print_fb_surf_info(state->zsbuf, 0, "ZB");
 +        }
 +    }
  }
  
  /* Create fragment shader state. */
@@@ -754,14 -729,9 +761,14 @@@ static void* r300_create_rs_state(struc
  {
      struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state);
      int i;
 +    float psiz;
  
 -    /* Copy rasterizer state for Draw. */
 +    /* Copy rasterizer state. */
      rs->rs = *state;
 +    rs->rs_draw = *state;
 +
 +    /* Override some states for Draw. */
 +    rs->rs_draw.sprite_coord_enable = 0; /* We can do this in HW. */
  
  #ifdef PIPE_ARCH_LITTLE_ENDIAN
      rs->vap_control_status = R300_VC_NO_SWAP;
          rs->vap_control_status |= R300_VAP_TCL_BYPASS;
      }
  
 -    rs->point_size = pack_float_16_6x(state->point_size) |
 +    /* Point size width and height. */
 +    rs->point_size =
 +        pack_float_16_6x(state->point_size) |
          (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT);
  
 +    /* Point size clamping. */
 +    if (state->point_size_per_vertex) {
 +        /* Per-vertex point size.
 +         * Clamp to [0, max FB size] */
 +        psiz = pipe->screen->get_paramf(pipe->screen,
 +                                        PIPE_CAP_MAX_POINT_WIDTH);
 +        rs->point_minmax =
 +            pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MAX_SHIFT;
 +    } else {
 +        /* We cannot disable the point-size vertex output,
 +         * so clamp it. */
 +        psiz = state->point_size;
 +        rs->point_minmax =
 +            (pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MIN_SHIFT) |
 +            (pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MAX_SHIFT);
 +    }
 +
 +    /* Line control. */
      rs->line_control = pack_float_16_6x(state->line_width) |
          R300_GA_LINE_CNTL_END_TYPE_COMP;
  
      /* Enable polygon mode */
 -    if (state->fill_cw != PIPE_POLYGON_MODE_FILL ||
 -        state->fill_ccw != PIPE_POLYGON_MODE_FILL) {
 +    if (state->fill_front != PIPE_POLYGON_MODE_FILL ||
 +        state->fill_back != PIPE_POLYGON_MODE_FILL) {
          rs->polygon_mode = R300_GA_POLY_MODE_DUAL;
      }
  
 -    /* Radeons don't think in "CW/CCW", they think in "front/back". */
 -    if (state->front_winding == PIPE_WINDING_CW) {
 -        rs->cull_mode = R300_FRONT_FACE_CW;
 -
 -        /* Polygon offset */
 -        if (state->offset_cw) {
 -            rs->polygon_offset_enable |= R300_FRONT_ENABLE;
 -        }
 -        if (state->offset_ccw) {
 -            rs->polygon_offset_enable |= R300_BACK_ENABLE;
 -        }
 -
 -        /* Polygon mode */
 -        if (rs->polygon_mode) {
 -            rs->polygon_mode |=
 -                r300_translate_polygon_mode_front(state->fill_cw);
 -            rs->polygon_mode |=
 -                r300_translate_polygon_mode_back(state->fill_ccw);
 -        }
 -    } else {
 +    /* Front face */
 +    if (state->front_ccw) 
          rs->cull_mode = R300_FRONT_FACE_CCW;
 +    else
 +        rs->cull_mode = R300_FRONT_FACE_CW;
  
 -        /* Polygon offset */
 -        if (state->offset_ccw) {
 -            rs->polygon_offset_enable |= R300_FRONT_ENABLE;
 -        }
 -        if (state->offset_cw) {
 -            rs->polygon_offset_enable |= R300_BACK_ENABLE;
 -        }
 +    /* Polygon offset */
 +    if (util_get_offset(state, state->fill_front)) {
 +       rs->polygon_offset_enable |= R300_FRONT_ENABLE;
 +    }
 +    if (util_get_offset(state, state->fill_back)) {
 +       rs->polygon_offset_enable |= R300_BACK_ENABLE;
 +    }
  
 -        /* Polygon mode */
 -        if (rs->polygon_mode) {
 -            rs->polygon_mode |=
 -                r300_translate_polygon_mode_front(state->fill_ccw);
 -            rs->polygon_mode |=
 -                r300_translate_polygon_mode_back(state->fill_cw);
 -        }
 +    /* Polygon mode */
 +    if (rs->polygon_mode) {
 +       rs->polygon_mode |=
 +          r300_translate_polygon_mode_front(state->fill_front);
 +       rs->polygon_mode |=
 +          r300_translate_polygon_mode_back(state->fill_back);
      }
 -    if (state->front_winding & state->cull_mode) {
 +
 +    if (state->cull_face & PIPE_FACE_FRONT) {
          rs->cull_mode |= R300_CULL_FRONT;
      }
 -    if (~(state->front_winding) & state->cull_mode) {
 +    if (state->cull_face & PIPE_FACE_BACK) {
          rs->cull_mode |= R300_CULL_BACK;
      }
  
@@@ -890,30 -856,24 +897,30 @@@ static void r300_bind_rs_state(struct p
      struct r300_context* r300 = r300_context(pipe);
      struct r300_rs_state* rs = (struct r300_rs_state*)state;
      int last_sprite_coord_enable = r300->sprite_coord_enable;
 +    boolean last_two_sided_color = r300->two_sided_color;
  
 -    if (r300->draw) {
 +    if (r300->draw && rs) {
          draw_flush(r300->draw);
 -        draw_set_rasterizer_state(r300->draw, &rs->rs, state);
 +        draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state);
      }
  
      if (rs) {
 -        r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw;
 +        r300->polygon_offset_enabled = (rs->rs.offset_point ||
 +                                        rs->rs.offset_line ||
 +                                        rs->rs.offset_tri);
          r300->sprite_coord_enable = rs->rs.sprite_coord_enable;
 +        r300->two_sided_color = rs->rs.light_twoside;
      } else {
          r300->polygon_offset_enabled = FALSE;
          r300->sprite_coord_enable = 0;
 +        r300->two_sided_color = FALSE;
      }
  
      UPDATE_STATE(state, r300->rs_state);
 -    r300->rs_state.size = 26 + (r300->polygon_offset_enabled ? 5 : 0);
 +    r300->rs_state.size = 27 + (r300->polygon_offset_enabled ? 5 : 0);
  
 -    if (last_sprite_coord_enable != r300->sprite_coord_enable) {
 +    if (last_sprite_coord_enable != r300->sprite_coord_enable ||
 +        last_two_sided_color != r300->two_sided_color) {
          r300->rs_block_state.dirty = TRUE;
      }
  }
@@@ -953,7 -913,7 +960,7 @@@ static void
      sampler->min_lod = MAX2((unsigned)state->min_lod, 0);
      sampler->max_lod = MAX2((unsigned)ceilf(state->max_lod), 0);
  
 -    lod_bias = CLAMP((int)(state->lod_bias * 32), -(1 << 9), (1 << 9) - 1);
 +    lod_bias = CLAMP((int)(state->lod_bias * 32 + 1), -(1 << 9), (1 << 9) - 1);
  
      sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT;
  
@@@ -1068,6 -1028,7 +1075,6 @@@ r300_create_sampler_view(struct pipe_co
  {
      struct r300_sampler_view *view = CALLOC_STRUCT(r300_sampler_view);
      struct r300_texture *tex = r300_texture(texture);
 -    unsigned char swizzle[4];
  
      if (view) {
          view->base = *templ;
          view->base.texture = NULL;
          pipe_resource_reference(&view->base.texture, texture);
  
 -        swizzle[0] = templ->swizzle_r;
 -        swizzle[1] = templ->swizzle_g;
 -        swizzle[2] = templ->swizzle_b;
 -        swizzle[3] = templ->swizzle_a;
 +        view->swizzle[0] = templ->swizzle_r;
 +        view->swizzle[1] = templ->swizzle_g;
 +        view->swizzle[2] = templ->swizzle_b;
 +        view->swizzle[3] = templ->swizzle_a;
  
          view->format = tex->tx_format;
          view->format.format1 |= r300_translate_texformat(templ->format,
 -                                                         swizzle);
 +                                                         view->swizzle);
          if (r300_screen(pipe->screen)->caps.is_r500) {
              view->format.format2 |= r500_tx_format_msb_bit(templ->format);
          }
@@@ -1120,13 -1081,6 +1127,13 @@@ static void r300_set_viewport_state(str
  
      r300->viewport = *state;
  
 +    if (r300->draw) {
 +        draw_flush(r300->draw);
 +        draw_set_viewport_state(r300->draw, state);
 +        viewport->vte_control = R300_VTX_XY_FMT | R300_VTX_Z_FMT;
 +        return;
 +    }
 +
      /* Do the transform in HW. */
      viewport->vte_control = R300_VTX_W0_FMT;
  
@@@ -1236,7 -1190,7 +1243,7 @@@ static void r300_set_vertex_buffers(str
      }
  }
  
 -/* Update the PSC tables. */
 +/* Initialize the PSC tables. */
  static void r300_vertex_psc(struct r300_vertex_element_state *velems)
  {
      struct r300_vertex_stream_state *vstream = &velems->vertex_stream;
@@@ -1375,6 -1329,7 +1382,6 @@@ static void* r300_create_vertex_element
                      abort();
                  }
              }
 -
          }
      }
      return velems;
@@@ -1395,7 -1350,6 +1402,7 @@@ static void r300_bind_vertex_elements_s
      if (r300->draw) {
          draw_flush(r300->draw);
          draw_set_vertex_elements(r300->draw, velems->count, velems->velem);
 +        return;
      }
  
      UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state);
@@@ -1418,10 -1372,8 +1425,10 @@@ static void* r300_create_vs_state(struc
      vs->state = *shader;
      vs->state.tokens = tgsi_dup_tokens(shader->tokens);
  
 +    r300_init_vs_outputs(vs);
 +
      if (r300->screen->caps.has_tcl) {
 -        r300_translate_vertex_shader(r300, vs, vs->state.tokens);
 +        r300_translate_vertex_shader(r300, vs);
      } else {
          vs->draw_vs = draw_create_vertex_shader(r300->draw, shader);
      }
@@@ -1491,7 -1443,7 +1498,7 @@@ static void r300_set_constant_buffer(st
      struct r300_constant_buffer *cbuf;
      struct pipe_transfer *tr;
      void *mapped;
 -    int max_size = 0;
 +    int max_size = 0, max_size_bytes = 0, clamped_size = 0;
  
      switch (shader) {
          case PIPE_SHADER_VERTEX:
              assert(0);
              return;
      }
 +    max_size_bytes = max_size * 4 * sizeof(float);
  
      if (buf == NULL || buf->width0 == 0 ||
          (mapped = pipe_buffer_map(pipe, buf, PIPE_TRANSFER_READ, &tr)) == NULL)
          return;
      }
  
 -    assert((buf->width0 % 4 * sizeof(float)) == 0);
 +    if (shader == PIPE_SHADER_FRAGMENT ||
 +        (shader == PIPE_SHADER_VERTEX && r300->screen->caps.has_tcl)) {
 +        assert((buf->width0 % (4 * sizeof(float))) == 0);
  
 -    /* Check the size of the constant buffer. */
 -    /* XXX Subtract immediates and RC_STATE_* variables. */
 -    if (buf->width0 > (sizeof(float) * 4 * max_size)) {
 -        fprintf(stderr, "r300: Max size of the constant buffer is "
 -                      "%i*4 floats.\n", max_size);
 -        abort();
 -    }
 +        /* Check the size of the constant buffer. */
 +        /* XXX Subtract immediates and RC_STATE_* variables. */
 +        if (buf->width0 > max_size_bytes) {
 +            fprintf(stderr, "r300: Max size of the constant buffer is "
 +                          "%i*4 floats.\n", max_size);
 +        }
 +        clamped_size = MIN2(buf->width0, max_size_bytes);
  
 -    memcpy(cbuf->constants, mapped, buf->width0);
 -    cbuf->count = buf->width0 / (4 * sizeof(float));
 -    pipe_buffer_unmap(pipe, buf, tr);
 +        memcpy(cbuf->constants, mapped, clamped_size);
 +        cbuf->count = clamped_size / (4 * sizeof(float));
 +    }
  
      if (shader == PIPE_SHADER_VERTEX) {
          if (r300->screen->caps.has_tcl) {
              r300->pvs_flush.dirty = TRUE;
          } else if (r300->draw) {
              draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX,
 -                0, cbuf->constants,
 -                buf->width0);
 +                0, mapped, buf->width0);
          }
      } else if (shader == PIPE_SHADER_FRAGMENT) {
          r300->fs_constants.dirty = TRUE;
      }
 +
 +    pipe_buffer_unmap(pipe, buf, tr);
  }
  
  void r300_init_state_functions(struct r300_context* r300)
      r300->context.set_blend_color = r300_set_blend_color;
  
      r300->context.set_clip_state = r300_set_clip_state;
+     r300->context.set_sample_mask = r300_set_sample_mask;
  
      r300->context.set_constant_buffer = r300_set_constant_buffer;
  
index 14a9bfd86501f0e52abb4023fa8e64cf55fa38f2,f0f87c5e2bcfc57bb77f81131e3f4b6bb3e74b67..beb321cb2380a683d7986cc6871da80b4d1d9032
@@@ -56,63 -56,44 +56,44 @@@ r300_transfer(struct pipe_transfer* tra
  static void r300_copy_from_tiled_texture(struct pipe_context *ctx,
                                           struct r300_transfer *r300transfer)
  {
-     struct pipe_screen *screen = ctx->screen;
      struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
      struct pipe_resource *tex = transfer->resource;
-     struct pipe_surface *src, *dst;
+     struct pipe_subresource subdst;
  
-     src = screen->get_tex_surface(screen, tex,
-                                 transfer->sr.face,
-                                   transfer->sr.level,
-                                 transfer->box.z,
-                                 PIPE_BIND_BLIT_SOURCE);
+     subdst.face = 0;
+     subdst.level = 0;
  
-     dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
-                                   0, 0, 0,
-                                   PIPE_BIND_BLIT_DESTINATION);
-     ctx->surface_copy(ctx, dst, 0, 0, src, 
-                     transfer->box.x, transfer->box.y,
-                       transfer->box.width, transfer->box.height);
-     pipe_surface_reference(&src, NULL);
-     pipe_surface_reference(&dst, NULL);
+     ctx->resource_copy_region(ctx, &r300transfer->detiled_texture->b.b, subdst,
+                             0, 0, 0,
+                             tex, transfer->sr,
+                             transfer->box.x, transfer->box.y, transfer->box.z,
+                             transfer->box.width, transfer->box.height);
  }
  
  /* Copy a detiled texture to a tiled one. */
  static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
                                           struct r300_transfer *r300transfer)
  {
-     struct pipe_screen *screen = ctx->screen;
      struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
      struct pipe_resource *tex = transfer->resource;
-     struct pipe_surface *src, *dst;
+     struct pipe_subresource subsrc;
  
-     src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
-                                   0, 0, 0,
-                                   PIPE_BIND_BLIT_SOURCE);
-     dst = screen->get_tex_surface(screen, tex,
-                                 transfer->sr.face,
-                                   transfer->sr.level,
-                                 transfer->box.z,
-                                   PIPE_BIND_BLIT_DESTINATION);
+     subsrc.face = 0;
+     subsrc.level = 0;
  
      /* XXX this flush prevents the following DRM error from occuring:
       * [drm:radeon_cs_ioctl] *ERROR* Failed to parse relocation !
       * Reproducible with perf/copytex. */
      ctx->flush(ctx, 0, NULL);
  
-     ctx->surface_copy(ctx, dst,
-                     transfer->box.x, transfer->box.y,
-                     src, 0, 0,
-                       transfer->box.width, transfer->box.height);
+     ctx->resource_copy_region(ctx, tex, transfer->sr,
+                             transfer->box.x, transfer->box.y, transfer->box.z,
+                             &r300transfer->detiled_texture->b.b, subsrc,
+                             0, 0, 0,
+                             transfer->box.width, transfer->box.height);
  
      /* XXX this flush fixes a few piglit tests (e.g. glean/pixelFormats). */
      ctx->flush(ctx, 0, NULL);
-     pipe_surface_reference(&src, NULL);
-     pipe_surface_reference(&dst, NULL);
  }
  
  struct pipe_transfer*
@@@ -127,12 -108,6 +108,12 @@@ r300_texture_get_transfer(struct pipe_c
      struct r300_transfer *trans;
      struct pipe_resource base;
  
 +    /* XXX Why aren't flushes taken care of by winsys automatically?
 +     * Winsys seems to sometimes return a cached buffer instead of
 +     * a mapped hardware buffer if this flush is commented out. */
 +    if (ctx->is_resource_referenced(ctx, texture, sr.face, sr.level))
 +        ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 +
      trans = CALLOC_STRUCT(r300_transfer);
      if (trans) {
          /* Initialize the transfer object. */
index fea3520fa56a1b82921654d4aabb9a061f685536,0f1bcc21bd66e7ce133f64bf15b02b0c7134820f..2f10b46e9898e3c916646a894aa4f044f2f7e964
@@@ -36,7 -36,6 +36,7 @@@
  #include "util/u_math.h"
  #include "util/u_memory.h"
  #include "util/u_inlines.h"
 +#include "tgsi/tgsi_exec.h"
  #include "sp_clear.h"
  #include "sp_context.h"
  #include "sp_flush.h"
@@@ -124,8 -123,6 +124,8 @@@ softpipe_destroy( struct pipe_context *
        }
     }
  
 +   tgsi_exec_machine_destroy(softpipe->fs_machine);
 +
     FREE( softpipe );
  }
  
@@@ -254,6 -251,7 +254,7 @@@ softpipe_create_context( struct pipe_sc
     softpipe->pipe.set_blend_color = softpipe_set_blend_color;
     softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref;
     softpipe->pipe.set_clip_state = softpipe_set_clip_state;
+    softpipe->pipe.set_sample_mask = softpipe_set_sample_mask;
     softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
     softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
     softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
        softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe );
     }
  
 +   softpipe->fs_machine = tgsi_exec_machine_create();
 +
     /* setup quad rendering stages */
     softpipe->quad.shade = sp_quad_shade_stage(softpipe);
     softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
index 8c33efa1987104bad3c69d9f7723f68bca0b2000,ad59ee909365b327afbee426549fc507f1fd1959..73987c913e5d4367a0170d8622afa694afce795b
@@@ -33,7 -33,6 +33,7 @@@
  #include "pipe/p_screen.h"
  
  #include "state_tracker/sw_winsys.h"
 +#include "tgsi/tgsi_exec.h"
  
  #include "sp_texture.h"
  #include "sp_screen.h"
@@@ -57,7 -56,7 +57,7 @@@ softpipe_get_name(struct pipe_screen *s
  
  
  static int
 -softpipe_get_param(struct pipe_screen *screen, int param)
 +softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
@@@ -82,8 -81,6 +82,8 @@@
        return PIPE_MAX_COLOR_BUFS;
     case PIPE_CAP_OCCLUSION_QUERY:
        return 1;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 1;
     case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
        return 1;
     case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
     case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
     case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
        return 1;
 +
 +   case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 +      /* There is no limit in number of instructions beyond available memory */
 +      return 32768;
 +   case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +   case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
 +      return TGSI_EXEC_MAX_NESTING;
 +   case PIPE_CAP_MAX_VS_INPUTS:
 +   case PIPE_CAP_MAX_FS_INPUTS:
 +      return TGSI_EXEC_MAX_INPUT_ATTRIBS;
 +   case PIPE_CAP_MAX_FS_CONSTS:
 +   case PIPE_CAP_MAX_VS_CONSTS:
 +      return TGSI_EXEC_MAX_CONST_BUFFER;
 +   case PIPE_CAP_MAX_VS_TEMPS:
 +   case PIPE_CAP_MAX_FS_TEMPS:
 +      return TGSI_EXEC_NUM_TEMPS;
 +   case PIPE_CAP_MAX_VS_ADDRS:
 +   case PIPE_CAP_MAX_FS_ADDRS:
 +      return TGSI_EXEC_NUM_ADDRS;
 +   case PIPE_CAP_MAX_VS_PREDS:
 +   case PIPE_CAP_MAX_FS_PREDS:
 +      return TGSI_EXEC_NUM_PREDS;
 +
     default:
        return 0;
     }
  
  
  static float
 -softpipe_get_paramf(struct pipe_screen *screen, int param)
 +softpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     switch (param) {
     case PIPE_CAP_MAX_LINE_WIDTH:
   */
  static boolean
  softpipe_is_format_supported( struct pipe_screen *screen,
-                               enum pipe_format format, 
+                               enum pipe_format format,
                                enum pipe_texture_target target,
+                               unsigned sample_count,
                                unsigned bind,
                                unsigned geom_flags )
  {
     if (!format_desc)
        return FALSE;
  
+    if (sample_count > 1)
+       return FALSE;
     if (bind & (PIPE_BIND_DISPLAY_TARGET |
                 PIPE_BIND_SCANOUT |
                 PIPE_BIND_SHARED)) {
index bef22f41ae5d2bdf5d44014c3c93bbec28bf3938,b24af3292184d0a8b73482c05d605c0ac59c99ac..99b419178b0b3db2fc6631ca2fd5bb9ad5851b69
@@@ -84,7 -84,7 +84,7 @@@ svga_get_name( struct pipe_screen *pscr
  
  
  static float
 -svga_get_paramf(struct pipe_screen *screen, int param)
 +svga_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
  {
     struct svga_screen *svgascreen = svga_screen(screen);
     struct svga_winsys_screen *sws = svgascreen->sws;
        return MIN2(result.u, PIPE_MAX_COLOR_BUFS);
     case PIPE_CAP_OCCLUSION_QUERY:
        return 1;
 +   case PIPE_CAP_TIMER_QUERY:
 +      return 0;
     case PIPE_CAP_TEXTURE_SHADOW_MAP:
        return 1;
  
     case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
        return 0;
  
 +   /*
 +    * Fragment shader limits
 +    */
 +
 +   case PIPE_CAP_MAX_FS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS:
 +      return svgascreen->use_ps30 ? 512 : 96;
 +   case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH:
 +      return SVGA3D_MAX_NESTING_LEVEL;
 +   case PIPE_CAP_MAX_FS_INPUTS:
 +      return 10;
 +   case PIPE_CAP_MAX_FS_CONSTS:
 +      return svgascreen->use_vs30 ? 224 : 16;
 +   case PIPE_CAP_MAX_FS_TEMPS:
 +      if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS, &result))
 +         return svgascreen->use_ps30 ? 32 : 12;
 +      return result.u;
 +   case PIPE_CAP_MAX_FS_ADDRS:
 +      return svgascreen->use_ps30 ? 1 : 0;
 +   case PIPE_CAP_MAX_FS_PREDS:
 +      return svgascreen->use_ps30 ? 1 : 0;
 +
 +   /*
 +    * Vertex shader limits
 +    */
 +   case PIPE_CAP_MAX_VS_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS:
 +      if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS, &result))
 +         return svgascreen->use_vs30 ? 512 : 256;
 +      return result.u;
 +   case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS:
 +   case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS:
 +      /* XXX: until we have vertex texture support */
 +      return 0;
 +   case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH:
 +      return SVGA3D_MAX_NESTING_LEVEL;
 +   case PIPE_CAP_MAX_VS_INPUTS:
 +      return 16;
 +   case PIPE_CAP_MAX_VS_CONSTS:
 +      return 256;
 +   case PIPE_CAP_MAX_VS_TEMPS:
 +      if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS, &result))
 +         return svgascreen->use_vs30 ? 32 : 12;
 +      return result.u;
 +   case PIPE_CAP_MAX_VS_ADDRS:
 +      return svgascreen->use_vs30 ? 1 : 0;
 +   case PIPE_CAP_MAX_VS_PREDS:
 +      return svgascreen->use_vs30 ? 1 : 0;
 +
     default:
        return 0;
     }
  /* This is a fairly pointless interface
   */
  static int
 -svga_get_param(struct pipe_screen *screen, int param)
 +svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
  {
     return (int) svga_get_paramf( screen, param );
  }
@@@ -290,17 -237,21 +290,21 @@@ svga_translate_format_cap(enum pipe_for
  
  static boolean
  svga_is_format_supported( struct pipe_screen *screen,
-                           enum pipe_format format, 
+                           enum pipe_format format,
                            enum pipe_texture_target target,
-                           unsigned tex_usage, 
+                           unsigned sample_count,
+                           unsigned tex_usage,
                            unsigned geom_flags )
  {
     struct svga_winsys_screen *sws = svga_screen(screen)->sws;
     SVGA3dDevCapIndex index;
     SVGA3dDevCapResult result;
-    
     assert(tex_usage);
  
+    if (sample_count > 1)
+       return FALSE;
     /* Override host capabilities */
     if (tex_usage & PIPE_BIND_RENDER_TARGET) {
        switch(format) { 
index 066fa6b9ac9cc21c159f7c9ed027eaa3e906a627,64a4316984b3a7e1d919ce1b2684582a50ce926c..5cc244d4b779ea0bd73cad4b40660b567cbe4767
  #include "util/u_inlines.h"
  #include "util/u_memory.h"
  #include "util/u_simple_list.h"
 -#include "util/u_format.h"
  
  #include "pipe/p_format.h"
  #include "pipe/p_screen.h"
  
  #include "tr_dump.h"
  #include "tr_dump_state.h"
 -#include "tr_state.h"
 +#include "tr_public.h"
  #include "tr_screen.h"
  #include "tr_texture.h"
 +#include "tr_context.h"
  
  
  
@@@ -82,6 -82,71 +82,6 @@@ trace_surface_unwrap(struct trace_conte
  }
  
  
 -static INLINE void
 -trace_context_draw_block(struct trace_context *tr_ctx, int flag)
 -{
 -   int k;
 -
 -   pipe_mutex_lock(tr_ctx->draw_mutex);
 -
 -   if (tr_ctx->draw_blocker & flag) {
 -      tr_ctx->draw_blocked |= flag;
 -   } else if ((tr_ctx->draw_rule.blocker & flag) &&
 -              (tr_ctx->draw_blocker & 4)) {
 -      boolean block = FALSE;
 -      debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__,
 -                   (void *) tr_ctx->draw_rule.fs, (void *) tr_ctx->curr.fs,
 -                   (void *) tr_ctx->draw_rule.vs, (void *) tr_ctx->curr.vs,
 -                   (void *) tr_ctx->draw_rule.surf, 0,
 -                   (void *) tr_ctx->draw_rule.sampler_view, 0);
 -      if (tr_ctx->draw_rule.fs &&
 -          tr_ctx->draw_rule.fs == tr_ctx->curr.fs)
 -         block = TRUE;
 -      if (tr_ctx->draw_rule.vs &&
 -          tr_ctx->draw_rule.vs == tr_ctx->curr.vs)
 -         block = TRUE;
 -      if (tr_ctx->draw_rule.surf &&
 -          tr_ctx->draw_rule.surf == tr_ctx->curr.zsbuf)
 -            block = TRUE;
 -      if (tr_ctx->draw_rule.surf)
 -         for (k = 0; k < tr_ctx->curr.nr_cbufs; k++)
 -            if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k])
 -               block = TRUE;
 -      if (tr_ctx->draw_rule.sampler_view) {
 -         for (k = 0; k < tr_ctx->curr.num_sampler_views; k++)
 -            if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.sampler_views[k])
 -               block = TRUE;
 -         for (k = 0; k < tr_ctx->curr.num_vert_sampler_views; k++) {
 -            if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.vert_sampler_views[k]) {
 -               block = TRUE;
 -            }
 -         }
 -      }
 -
 -      if (block)
 -         tr_ctx->draw_blocked |= (flag | 4);
 -   }
 -
 -   if (tr_ctx->draw_blocked)
 -      trace_rbug_notify_draw_blocked(tr_ctx);
 -
 -   /* wait for rbug to clear the blocked flag */
 -   while (tr_ctx->draw_blocked & flag) {
 -      tr_ctx->draw_blocked |= flag;
 -#ifdef PIPE_THREAD_HAVE_CONDVAR
 -      pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex);
 -#else
 -      pipe_mutex_unlock(tr_ctx->draw_mutex);
 -#ifdef PIPE_SUBSYSTEM_WINDOWS_USER
 -      Sleep(1);
 -#endif
 -      pipe_mutex_lock(tr_ctx->draw_mutex);
 -#endif
 -   }
 -
 -   pipe_mutex_unlock(tr_ctx->draw_mutex);
 -}
 -
  static INLINE void
  trace_context_draw_arrays(struct pipe_context *_pipe,
                            unsigned mode, unsigned start, unsigned count)
     struct trace_context *tr_ctx = trace_context(_pipe);
     struct pipe_context *pipe = tr_ctx->pipe;
  
 -   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
 -      return;
 -
 -   trace_context_draw_block(tr_ctx, 1);
 -
     trace_dump_call_begin("pipe_context", "draw_arrays");
  
     trace_dump_arg(ptr, pipe);
     pipe->draw_arrays(pipe, mode, start, count);
  
     trace_dump_call_end();
 -
 -   trace_context_draw_block(tr_ctx, 2);
  }
  
  
@@@ -113,6 -185,11 +113,6 @@@ trace_context_draw_elements(struct pipe
     struct pipe_context *pipe = tr_ctx->pipe;
     struct pipe_resource *indexBuffer = tr_buf->resource;
  
 -   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
 -      return;
 -
 -   trace_context_draw_block(tr_ctx, 1);
 -
     trace_dump_call_begin("pipe_context", "draw_elements");
  
     trace_dump_arg(ptr, pipe);
                         mode, start, count);
  
     trace_dump_call_end();
 -
 -   trace_context_draw_block(tr_ctx, 2);
  }
  
  
@@@ -146,6 -225,11 +146,6 @@@ trace_context_draw_range_elements(struc
     struct pipe_context *pipe = tr_ctx->pipe;
     struct pipe_resource *indexBuffer = tr_buf->resource;
  
 -   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
 -      return;
 -
 -   trace_context_draw_block(tr_ctx, 1);
 -
     trace_dump_call_begin("pipe_context", "draw_range_elements");
  
     trace_dump_arg(ptr, pipe);
                               mode, start, count);
  
     trace_dump_call_end();
 -
 -   trace_context_draw_block(tr_ctx, 2);
  }
  
  
@@@ -548,22 -634,31 +548,22 @@@ trace_context_create_fs_state(struct pi
  
     trace_dump_call_end();
  
 -   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_FRAGMENT);
 -
     return result;
  }
  
  
  static INLINE void
  trace_context_bind_fs_state(struct pipe_context *_pipe,
 -                            void *_state)
 +                            void *state)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
 -   struct trace_shader *tr_shdr = trace_shader(_state);
     struct pipe_context *pipe = tr_ctx->pipe;
 -   void *state = tr_shdr ? tr_shdr->state : NULL;
  
     trace_dump_call_begin("pipe_context", "bind_fs_state");
  
     trace_dump_arg(ptr, pipe);
     trace_dump_arg(ptr, state);
  
 -   tr_ctx->curr.fs = tr_shdr;
 -
 -   if (tr_shdr && tr_shdr->replaced)
 -      state = tr_shdr->replaced;
 -
     pipe->bind_fs_state(pipe, state);
  
     trace_dump_call_end();
  
  static INLINE void
  trace_context_delete_fs_state(struct pipe_context *_pipe,
 -                              void *_state)
 +                              void *state)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
 -   struct trace_shader *tr_shdr = trace_shader(_state);
     struct pipe_context *pipe = tr_ctx->pipe;
 -   void *state = tr_shdr->state;
  
     trace_dump_call_begin("pipe_context", "delete_fs_state");
  
     pipe->delete_fs_state(pipe, state);
  
     trace_dump_call_end();
 -
 -   trace_shader_destroy(tr_ctx, tr_shdr);
  }
  
  
@@@ -607,22 -706,31 +607,22 @@@ trace_context_create_vs_state(struct pi
  
     trace_dump_call_end();
  
 -   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_VERTEX);
 -
     return result;
  }
  
  
  static INLINE void
  trace_context_bind_vs_state(struct pipe_context *_pipe,
 -                            void *_state)
 +                            void *state)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
 -   struct trace_shader *tr_shdr = trace_shader(_state);
     struct pipe_context *pipe = tr_ctx->pipe;
 -   void *state = tr_shdr ? tr_shdr->state : NULL;
  
     trace_dump_call_begin("pipe_context", "bind_vs_state");
  
     trace_dump_arg(ptr, pipe);
     trace_dump_arg(ptr, state);
  
 -   tr_ctx->curr.vs = tr_shdr;
 -
 -   if (tr_shdr && tr_shdr->replaced)
 -      state = tr_shdr->replaced;
 -
     pipe->bind_vs_state(pipe, state);
  
     trace_dump_call_end();
  
  static INLINE void
  trace_context_delete_vs_state(struct pipe_context *_pipe,
 -                              void *_state)
 +                              void *state)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
 -   struct trace_shader *tr_shdr = trace_shader(_state);
     struct pipe_context *pipe = tr_ctx->pipe;
 -   void *state = tr_shdr->state;
  
     trace_dump_call_begin("pipe_context", "delete_vs_state");
  
     pipe->delete_vs_state(pipe, state);
  
     trace_dump_call_end();
 -
 -   trace_shader_destroy(tr_ctx, tr_shdr);
  }
  
  
@@@ -764,6 -876,22 +764,22 @@@ trace_context_set_clip_state(struct pip
     trace_dump_call_end();
  }
  
+ static INLINE void
+ trace_context_set_sample_mask(struct pipe_context *_pipe,
+                               unsigned sample_mask)
+ {
+    struct trace_context *tr_ctx = trace_context(_pipe);
+    struct pipe_context *pipe = tr_ctx->pipe;
+    trace_dump_call_begin("pipe_context", "set_sample_mask");
+    trace_dump_arg(ptr, pipe);
+    trace_dump_arg(uint, sample_mask);
+    pipe->set_sample_mask(pipe, sample_mask);
+    trace_dump_call_end();
+ }
  
  static INLINE void
  trace_context_set_constant_buffer(struct pipe_context *_pipe,
@@@ -799,6 -927,18 +815,6 @@@ trace_context_set_framebuffer_state(str
     struct pipe_framebuffer_state unwrapped_state;
     unsigned i;
  
 -   {
 -      tr_ctx->curr.nr_cbufs = state->nr_cbufs;
 -      for (i = 0; i < state->nr_cbufs; i++)
 -         if (state->cbufs[i])
 -            tr_ctx->curr.cbufs[i] = trace_resource(state->cbufs[i]->texture);
 -         else
 -            tr_ctx->curr.cbufs[i] = NULL;
 -      if (state->zsbuf)
 -         tr_ctx->curr.zsbuf = trace_resource(state->zsbuf->texture);
 -      else
 -         tr_ctx->curr.zsbuf = NULL;
 -   }
  
     /* Unwrap the input state */
     memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
@@@ -948,8 -1088,10 +964,8 @@@ trace_context_set_fragment_sampler_view
     struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
     unsigned i;
  
 -   tr_ctx->curr.num_sampler_views = num;
     for(i = 0; i < num; ++i) {
        tr_view = trace_sampler_view(views[i]);
 -      tr_ctx->curr.sampler_views[i] = tr_view;
        unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
     }
     views = unwrapped_views;
@@@ -977,8 -1119,10 +993,8 @@@ trace_context_set_vertex_sampler_views(
     struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
     unsigned i;
  
 -   tr_ctx->curr.num_vert_sampler_views = num;
     for(i = 0; i < num; ++i) {
        tr_view = trace_sampler_view(views[i]);
 -      tr_ctx->curr.vert_sampler_views[i] = tr_view;
        unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
     }
     views = unwrapped_views;
@@@ -1029,61 -1173,72 +1045,72 @@@ trace_context_set_vertex_buffers(struc
  
  
  static INLINE void
- trace_context_surface_copy(struct pipe_context *_pipe,
-                            struct pipe_surface *dest,
-                            unsigned destx, unsigned desty,
-                            struct pipe_surface *src,
-                            unsigned srcx, unsigned srcy,
-                            unsigned width, unsigned height)
+ trace_context_resource_copy_region(struct pipe_context *_pipe,
+                                    struct pipe_resource *dst,
+                                    struct pipe_subresource subdst,
+                                    unsigned dstx, unsigned dsty, unsigned dstz,
+                                    struct pipe_resource *src,
+                                    struct pipe_subresource subsrc,
+                                    unsigned srcx, unsigned srcy, unsigned srcz,
+                                    unsigned width, unsigned height)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
     struct pipe_context *pipe = tr_ctx->pipe;
  
-    dest = trace_surface_unwrap(tr_ctx, dest);
-    src = trace_surface_unwrap(tr_ctx, src);
+    dst = trace_resource_unwrap(tr_ctx, dst);
+    src = trace_resource_unwrap(tr_ctx, src);
  
-    trace_dump_call_begin("pipe_context", "surface_copy");
+    trace_dump_call_begin("pipe_context", "resource_copy_region");
  
     trace_dump_arg(ptr, pipe);
-    trace_dump_arg(ptr, dest);
-    trace_dump_arg(uint, destx);
-    trace_dump_arg(uint, desty);
+    trace_dump_arg(ptr, dst);
+    trace_dump_arg_struct(subresource, subdst);
+    trace_dump_arg(uint, dstx);
+    trace_dump_arg(uint, dsty);
+    trace_dump_arg(uint, dstz);
     trace_dump_arg(ptr, src);
+    trace_dump_arg_struct(subresource, subsrc);
     trace_dump_arg(uint, srcx);
     trace_dump_arg(uint, srcy);
+    trace_dump_arg(uint, srcz);
     trace_dump_arg(uint, width);
     trace_dump_arg(uint, height);
  
-    pipe->surface_copy(pipe,
-                       dest, destx, desty,
-                       src, srcx, srcy, width, height);
+    pipe->resource_copy_region(pipe,
+                               dst, subdst, dstx, dsty, dstz,
+                               src, subsrc, srcx, srcy, srcz, width, height);
  
     trace_dump_call_end();
  }
  
  
  static INLINE void
- trace_context_surface_fill(struct pipe_context *_pipe,
-                            struct pipe_surface *dst,
-                            unsigned dstx, unsigned dsty,
-                            unsigned width, unsigned height,
-                            unsigned value)
+ trace_context_resource_fill_region(struct pipe_context *_pipe,
+                                    struct pipe_resource *dst,
+                                    struct pipe_subresource subdst,
+                                    unsigned dstx, unsigned dsty, unsigned dstz,
+                                    unsigned width, unsigned height,
+                                    unsigned value)
  {
     struct trace_context *tr_ctx = trace_context(_pipe);
     struct pipe_context *pipe = tr_ctx->pipe;
  
-    dst = trace_surface_unwrap(tr_ctx, dst);
+    dst = trace_resource_unwrap(tr_ctx, dst);
  
-    trace_dump_call_begin("pipe_context", "surface_fill");
+    trace_dump_call_begin("pipe_context", "resource_fill_region");
  
     trace_dump_arg(ptr, pipe);
     trace_dump_arg(ptr, dst);
+    trace_dump_arg_struct(subresource, subdst);
     trace_dump_arg(uint, dstx);
     trace_dump_arg(uint, dsty);
+    trace_dump_arg(uint, dstz);
     trace_dump_arg(uint, width);
     trace_dump_arg(uint, height);
+    trace_dump_arg(uint, value);
  
-    pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);
+    pipe->resource_fill_region(pipe, dst, subdst, dstx, dsty, dstz,
+                               width, height, value);
  
     trace_dump_call_end();
  }
@@@ -1138,6 -1293,7 +1165,6 @@@ trace_context_flush(struct pipe_contex
  static INLINE void
  trace_context_destroy(struct pipe_context *_pipe)
  {
 -   struct trace_screen *tr_scr = trace_screen(_pipe->screen);
     struct trace_context *tr_ctx = trace_context(_pipe);
     struct pipe_context *pipe = tr_ctx->pipe;
  
     trace_dump_arg(ptr, pipe);
     trace_dump_call_end();
  
 -   trace_screen_remove_from_list(tr_scr, contexts, tr_ctx);
 -
     pipe->destroy(pipe);
  
     FREE(tr_ctx);
@@@ -1377,6 -1535,13 +1404,6 @@@ trace_context_create(struct trace_scree
     tr_ctx->base.winsys = NULL;
     tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
     tr_ctx->base.screen = &tr_scr->base;
 -   tr_ctx->draw_blocker = debug_get_flags_option("RBUG_BLOCK",
 -                                                 rbug_blocker_flags,
 -                                                 0);
 -   pipe_mutex_init(tr_ctx->draw_mutex);
 -   pipe_condvar_init(tr_ctx->draw_cond);
 -   pipe_mutex_init(tr_ctx->list_mutex);
 -   make_empty_list(&tr_ctx->shaders);
  
     tr_ctx->base.destroy = trace_context_destroy;
     tr_ctx->base.draw_arrays = trace_context_draw_arrays;
     tr_ctx->base.set_blend_color = trace_context_set_blend_color;
     tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref;
     tr_ctx->base.set_clip_state = trace_context_set_clip_state;
+    tr_ctx->base.set_sample_mask = trace_context_set_sample_mask;
     tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer;
     tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state;
     tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
     tr_ctx->base.create_sampler_view = trace_create_sampler_view;
     tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy;
     tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
-    if (pipe->surface_copy)
-       tr_ctx->base.surface_copy = trace_context_surface_copy;
-    if (pipe->surface_fill)
-       tr_ctx->base.surface_fill = trace_context_surface_fill;
+    tr_ctx->base.resource_copy_region = trace_context_resource_copy_region;
+    tr_ctx->base.resource_fill_region = trace_context_resource_fill_region;
     tr_ctx->base.clear = trace_context_clear;
     tr_ctx->base.flush = trace_context_flush;
     tr_ctx->base.is_resource_referenced = trace_is_resource_referenced;
  
     tr_ctx->pipe = pipe;
  
 -   trace_screen_add_to_list(tr_scr, contexts, tr_ctx);
 -
     return &tr_ctx->base;
  
  error1:
index ac0b906000137ba095365936cf77632ce4de4a9f,ffae6e94d11ee544dbbeb72c80edcb069521dc23..32e519a68a094e0263ef50aa145f74d4605ac94a
@@@ -40,6 -40,7 +40,6 @@@
  
  
  static boolean trace = FALSE;
 -static boolean rbug = FALSE;
  
  static const char *
  trace_screen_get_name(struct pipe_screen *_screen)
@@@ -85,7 -86,7 +85,7 @@@ trace_screen_get_vendor(struct pipe_scr
  
  static int
  trace_screen_get_param(struct pipe_screen *_screen,
 -                       int param)
 +                       enum pipe_cap param)
  {
     struct trace_screen *tr_scr = trace_screen(_screen);
     struct pipe_screen *screen = tr_scr->screen;
  
  static float
  trace_screen_get_paramf(struct pipe_screen *_screen,
 -                        int param)
 +                        enum pipe_cap param)
  {
     struct trace_screen *tr_scr = trace_screen(_screen);
     struct pipe_screen *screen = tr_scr->screen;
@@@ -133,6 -134,7 +133,7 @@@ static boolea
  trace_screen_is_format_supported(struct pipe_screen *_screen,
                                   enum pipe_format format,
                                   enum pipe_texture_target target,
+                                  unsigned sample_count,
                                   unsigned tex_usage,
                                   unsigned geom_flags)
  {
     trace_dump_arg(ptr, screen);
     trace_dump_arg(format, format);
     trace_dump_arg(int, target);
+    trace_dump_arg(uint, sample_count);
     trace_dump_arg(uint, tex_usage);
     trace_dump_arg(uint, geom_flags);
  
-    result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
+    result = screen->is_format_supported(screen, format, target, sample_count,
+                                         tex_usage, geom_flags);
  
     trace_dump_ret(bool, result);
  
@@@ -490,6 -494,9 +493,6 @@@ trace_screen_destroy(struct pipe_scree
     trace_dump_call_end();
     trace_dump_trace_end();
  
 -   if (tr_scr->rbug)
 -      trace_rbug_stop(tr_scr->rbug);
 -
     screen->destroy(screen);
  
     FREE(tr_scr);
@@@ -511,6 -518,11 +514,6 @@@ trace_enabled(void
        trace = TRUE;
     }
  
 -   if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) {
 -      trace = TRUE;
 -      rbug = TRUE;
 -   }
 -
     return trace;
  }
  
@@@ -539,6 -551,13 +542,6 @@@ trace_screen_create(struct pipe_screen 
  #else
     winsys = screen->winsys;
  #endif
 -   pipe_mutex_init(tr_scr->list_mutex);
 -   make_empty_list(&tr_scr->buffers);
 -   make_empty_list(&tr_scr->contexts);
 -   make_empty_list(&tr_scr->textures);
 -   make_empty_list(&tr_scr->surfaces);
 -   make_empty_list(&tr_scr->transfers);
 -
     tr_scr->base.winsys = winsys;
     tr_scr->base.destroy = trace_screen_destroy;
     tr_scr->base.get_name = trace_screen_get_name;
     tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer;
  
     tr_scr->screen = screen;
 -   tr_scr->private_context = screen->context_create(screen, NULL);
 -   if (tr_scr->private_context == NULL)
 -      goto error3;
  
     trace_dump_ret(ptr, screen);
     trace_dump_call_end();
  
 -   if (rbug)
 -      tr_scr->rbug = trace_rbug_start(tr_scr);
 -
     return &tr_scr->base;
  
 -error3:
 -   FREE(tr_scr);
  error2:
     trace_dump_ret(ptr, screen);
     trace_dump_call_end();
index 8201c29ac7622a312251b708d02d823101fbbc2a,a852ad97cab2875e4dc1fb7c4d0250d115787e79..b54a6ef8247d8f0308c4aa6bf2a1dfd3224fe4bb
@@@ -119,11 -119,11 +119,11 @@@ enum pipe_error 
  #define PIPE_POLYGON_MODE_LINE  1
  #define PIPE_POLYGON_MODE_POINT 2
  
 -/** Polygon front/back window, also for culling */
 -#define PIPE_WINDING_NONE 0
 -#define PIPE_WINDING_CW   1
 -#define PIPE_WINDING_CCW  2
 -#define PIPE_WINDING_BOTH (PIPE_WINDING_CW | PIPE_WINDING_CCW)
 +/** Polygon face specification, eg for culling */
 +#define PIPE_FACE_NONE           0
 +#define PIPE_FACE_FRONT          1
 +#define PIPE_FACE_BACK           2
 +#define PIPE_FACE_FRONT_AND_BACK (PIPE_FACE_FRONT | PIPE_FACE_BACK)
  
  /** Stencil ops */
  #define PIPE_STENCIL_OP_KEEP       0
@@@ -284,8 -284,6 +284,6 @@@ enum pipe_transfer_usage 
  #define PIPE_BIND_VERTEX_BUFFER        (1 << 3) /* set_vertex_buffers */
  #define PIPE_BIND_INDEX_BUFFER         (1 << 4) /* draw_elements */
  #define PIPE_BIND_CONSTANT_BUFFER      (1 << 5) /* set_constant_buffer */
- #define PIPE_BIND_BLIT_SOURCE          (1 << 6) /* surface_copy */
- #define PIPE_BIND_BLIT_DESTINATION     (1 << 7) /* surface_copy, fill */
  #define PIPE_BIND_DISPLAY_TARGET       (1 << 8) /* flush_front_buffer */
  #define PIPE_BIND_TRANSFER_WRITE       (1 << 9) /* get_transfer */
  #define PIPE_BIND_TRANSFER_READ        (1 << 10) /* get_transfer */
  #define PIPE_QUERY_OCCLUSION_COUNTER     0
  #define PIPE_QUERY_PRIMITIVES_GENERATED  1
  #define PIPE_QUERY_PRIMITIVES_EMITTED    2
 -#define PIPE_QUERY_TYPES                 3
 +#define PIPE_QUERY_TIME_ELAPSED          3
 +#define PIPE_QUERY_TYPES                 4
  
  
  /**
   * Implementation capabilities/limits which are queried through
   * pipe_screen::get_param() and pipe_screen::get_paramf().
   */
 -#define PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS 1
 -#define PIPE_CAP_NPOT_TEXTURES           2
 -#define PIPE_CAP_TWO_SIDED_STENCIL       3
 -#define PIPE_CAP_GLSL                    4  /* XXX need something better */
 -#define PIPE_CAP_DUAL_SOURCE_BLEND       5  
 -#define PIPE_CAP_ANISOTROPIC_FILTER      6
 -#define PIPE_CAP_POINT_SPRITE            7
 -#define PIPE_CAP_MAX_RENDER_TARGETS      8
 -#define PIPE_CAP_OCCLUSION_QUERY         9
 -#define PIPE_CAP_TEXTURE_SHADOW_MAP      10
 -#define PIPE_CAP_MAX_TEXTURE_2D_LEVELS   11
 -#define PIPE_CAP_MAX_TEXTURE_3D_LEVELS   12
 -#define PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS 13
 -#define PIPE_CAP_MAX_LINE_WIDTH          14
 -#define PIPE_CAP_MAX_LINE_WIDTH_AA       15
 -#define PIPE_CAP_MAX_POINT_WIDTH         16
 -#define PIPE_CAP_MAX_POINT_WIDTH_AA      17
 -#define PIPE_CAP_MAX_TEXTURE_ANISOTROPY  18
 -#define PIPE_CAP_MAX_TEXTURE_LOD_BIAS    19
 -#define PIPE_CAP_GUARD_BAND_LEFT         20  /*< float */
 -#define PIPE_CAP_GUARD_BAND_TOP          21  /*< float */
 -#define PIPE_CAP_GUARD_BAND_RIGHT        22  /*< float */
 -#define PIPE_CAP_GUARD_BAND_BOTTOM       23  /*< float */
 -#define PIPE_CAP_TEXTURE_MIRROR_CLAMP    24
 -#define PIPE_CAP_TEXTURE_MIRROR_REPEAT   25
 -#define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26
 -#define PIPE_CAP_TGSI_CONT_SUPPORTED     27
 -#define PIPE_CAP_BLEND_EQUATION_SEPARATE 28
 -#define PIPE_CAP_SM3                     29  /*< Shader Model 3 supported */
 -#define PIPE_CAP_MAX_PREDICATE_REGISTERS 30
 -#define PIPE_CAP_MAX_COMBINED_SAMPLERS   31  /*< Maximum texture image units accessible from vertex
 -                                                 and fragment shaders combined */
 -#define PIPE_CAP_MAX_CONST_BUFFERS       32
 -#define PIPE_CAP_MAX_CONST_BUFFER_SIZE   33  /*< In bytes */
 -#define PIPE_CAP_INDEP_BLEND_ENABLE      34  /*< blend enables and write masks per rendertarget */
 -#define PIPE_CAP_INDEP_BLEND_FUNC        35  /*< different blend funcs per rendertarget */
 -#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT 36
 -#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT 37
 -#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 38
 -#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER 39
 +enum pipe_cap {
 +   PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS,
 +   PIPE_CAP_NPOT_TEXTURES,
 +   PIPE_CAP_TWO_SIDED_STENCIL,
 +   PIPE_CAP_GLSL,  /* XXX need something better */
 +   PIPE_CAP_DUAL_SOURCE_BLEND,
 +   PIPE_CAP_ANISOTROPIC_FILTER,
 +   PIPE_CAP_POINT_SPRITE,
 +   PIPE_CAP_MAX_RENDER_TARGETS,
 +   PIPE_CAP_OCCLUSION_QUERY,
 +   PIPE_CAP_TIMER_QUERY,
 +   PIPE_CAP_TEXTURE_SHADOW_MAP,
 +   PIPE_CAP_MAX_TEXTURE_2D_LEVELS,
 +   PIPE_CAP_MAX_TEXTURE_3D_LEVELS,
 +   PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS,
 +   PIPE_CAP_MAX_LINE_WIDTH,
 +   PIPE_CAP_MAX_LINE_WIDTH_AA,
 +   PIPE_CAP_MAX_POINT_WIDTH,
 +   PIPE_CAP_MAX_POINT_WIDTH_AA,
 +   PIPE_CAP_MAX_TEXTURE_ANISOTROPY,
 +   PIPE_CAP_MAX_TEXTURE_LOD_BIAS,
 +   PIPE_CAP_GUARD_BAND_LEFT,  /*< float */
 +   PIPE_CAP_GUARD_BAND_TOP,  /*< float */
 +   PIPE_CAP_GUARD_BAND_RIGHT,  /*< float */
 +   PIPE_CAP_GUARD_BAND_BOTTOM,  /*< float */
 +   PIPE_CAP_TEXTURE_MIRROR_CLAMP,
 +   PIPE_CAP_TEXTURE_MIRROR_REPEAT,
 +   PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS,
 +   PIPE_CAP_TGSI_CONT_SUPPORTED,
 +   PIPE_CAP_BLEND_EQUATION_SEPARATE,
 +   PIPE_CAP_SM3,  /*< Shader Model, supported */
 +   PIPE_CAP_MAX_PREDICATE_REGISTERS,
 +   /** Maximum texture image units accessible from vertex and fragment shaders
 +    * combined */
 +   PIPE_CAP_MAX_COMBINED_SAMPLERS,
 +   PIPE_CAP_MAX_CONST_BUFFERS,
 +   PIPE_CAP_MAX_CONST_BUFFER_SIZE,  /*< In bytes */
 +   /** blend enables and write masks per rendertarget */
 +   PIPE_CAP_INDEP_BLEND_ENABLE,
 +   /** different blend funcs per rendertarget */
 +   PIPE_CAP_INDEP_BLEND_FUNC,
 +   PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT,
 +   PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT,
 +   PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER,
 +   PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER,
 +
 +   /*
 +    * Shader limits.
 +    */
 +   PIPE_CAP_MAX_FS_INSTRUCTIONS,
 +   PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS,
 +   PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS,
 +   PIPE_CAP_MAX_FS_TEX_INDIRECTIONS,
 +   PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH,
 +   PIPE_CAP_MAX_FS_INPUTS,
 +   PIPE_CAP_MAX_FS_CONSTS,
 +   PIPE_CAP_MAX_FS_TEMPS,
 +   PIPE_CAP_MAX_FS_ADDRS,
 +   PIPE_CAP_MAX_FS_PREDS,
 +   PIPE_CAP_MAX_VS_INSTRUCTIONS,
 +   PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS,
 +   PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS,
 +   PIPE_CAP_MAX_VS_TEX_INDIRECTIONS,
 +   PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH,
 +   PIPE_CAP_MAX_VS_INPUTS,
 +   PIPE_CAP_MAX_VS_CONSTS,
 +   PIPE_CAP_MAX_VS_TEMPS,
 +   PIPE_CAP_MAX_VS_ADDRS,
 +   PIPE_CAP_MAX_VS_PREDS
 +};
  
  
  /**
index 0d9de48c9094a9fbd2ad0241cd6d3dd031905ea0,9cb949a4465bd30661d9de6cf0ce0e6a16dd1b32..21f428ed4af0862b1e1e0bd050188de68d5fc326
@@@ -54,6 -54,7 +54,6 @@@ struct winsys_handle
  /** Opaque type */
  struct pipe_fence_handle;
  struct pipe_winsys;
 -struct pipe_texture;
  struct pipe_resource;
  struct pipe_surface;
  struct pipe_transfer;
@@@ -78,17 -79,17 +78,17 @@@ struct pipe_screen 
      * Query an integer-valued capability/parameter/limit
      * \param param  one of PIPE_CAP_x
      */
 -   int (*get_param)( struct pipe_screen *, int param );
 +   int (*get_param)( struct pipe_screen *, enum pipe_cap param );
  
     /**
      * Query a float-valued capability/parameter/limit
      * \param param  one of PIPE_CAP_x
      */
 -   float (*get_paramf)( struct pipe_screen *, int param );
 +   float (*get_paramf)( struct pipe_screen *, enum pipe_cap param );
  
     struct pipe_context * (*context_create)( struct pipe_screen *,
                                            void *priv );
-    
     /**
      * Check if the given pipe_format is supported as a texture or
      * drawing surface.
@@@ -98,7 -99,8 +98,8 @@@
     boolean (*is_format_supported)( struct pipe_screen *,
                                     enum pipe_format format,
                                     enum pipe_texture_target target,
-                                    unsigned bindings, 
+                                    unsigned sample_count,
+                                    unsigned bindings,
                                     unsigned geom_flags );
  
     /**
index a01698d7674c47da78835df6b45fc8c49471fe5b,f9ad07d8f87edca4b6fc4f99c54bd5a4fd68ffd5..5255b2003f8d5b0d823af80bcffb31467058b65d
@@@ -79,13 -79,12 +79,13 @@@ struct pipe_rasterizer_stat
  {
     unsigned flatshade:1;
     unsigned light_twoside:1;
 -   unsigned front_winding:2;  /**< PIPE_WINDING_x */
 -   unsigned cull_mode:2;      /**< PIPE_WINDING_x */
 -   unsigned fill_cw:2;        /**< PIPE_POLYGON_MODE_x */
 -   unsigned fill_ccw:2;       /**< PIPE_POLYGON_MODE_x */
 -   unsigned offset_cw:1;
 -   unsigned offset_ccw:1;
 +   unsigned front_ccw:1;
 +   unsigned cull_face:2;      /**< PIPE_FACE_x */
 +   unsigned fill_front:2;     /**< PIPE_POLYGON_MODE_x */
 +   unsigned fill_back:2;      /**< PIPE_POLYGON_MODE_x */
 +   unsigned offset_point:1;
 +   unsigned offset_line:1;
 +   unsigned offset_tri:1;
     unsigned scissor:1;
     unsigned poly_smooth:1;
     unsigned poly_stipple_enable:1;
@@@ -219,6 -218,8 +219,8 @@@ struct pipe_blend_stat
     unsigned logicop_enable:1;
     unsigned logicop_func:4;      /**< PIPE_LOGICOP_x */
     unsigned dither:1;
+    unsigned alpha_to_coverage:1;
+    unsigned alpha_to_one:1;
     struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
  };
  
index 5c6fe97922a7bf0944b29121f2eb07a71cddb7ad,871c33267ae37a86920636bedc76c81a0d8c268e..d63b81a1c59b868a55a9cbf8416b8b4129bbe00c
@@@ -50,8 -50,8 +50,8 @@@ egl_g3d_init_st(_EGLDriver *drv
     if (gdrv->api_mask)
        return;
  
 +   egl_g3d_init_st_apis(gdrv->stapis);
     for (i = 0; i < ST_API_COUNT; i++) {
 -      gdrv->stapis[i] = egl_g3d_create_st_api(i);
        if (gdrv->stapis[i])
           gdrv->api_mask |= egl_g3d_st_api_bit(i);
     }
@@@ -351,7 -351,7 +351,7 @@@ egl_g3d_fill_depth_stencil_formats(_EGL
        /* pick the first supported format */
        for (i = 0; i < n; i++) {
           if (screen->is_format_supported(screen, fmt[i],
-                   PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL, 0)) {
+                   PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0)) {
              formats[count++] = fmt[i];
              break;
           }
@@@ -581,8 -581,13 +581,8 @@@ static voi
  egl_g3d_unload(_EGLDriver *drv)
  {
     struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
 -   EGLint i;
 -
 -   for (i = 0; i < ST_API_COUNT; i++) {
 -      if (gdrv->stapis[i])
 -         gdrv->stapis[i]->destroy(gdrv->stapis[i]);
 -   }
  
 +   egl_g3d_destroy_st_apis();
     egl_g3d_destroy_probe(drv, NULL);
     FREE(gdrv);
  }
index f6b07f2109f92d1a5fed941bf105085d38db4a45,b55a2b57bed8411c58ca6c4ec95e9f79c9d3d6b7..f02db8949df3884307fac872545a98ab83200485
@@@ -33,7 -33,6 +33,7 @@@
  #include "asm_util.h"
  #include "st_inlines.h"
  #include "vg_manager.h"
 +#include "api.h"
  
  #include "pipe/p_context.h"
  #include "util/u_inlines.h"
@@@ -68,7 -67,6 +68,7 @@@ static void init_clear(struct vg_contex
  void vg_set_current_context(struct vg_context *ctx)
  {
     _vg_context = ctx;
 +   api_make_dispatch_current((ctx) ? ctx->dispatch : NULL);
  }
  
  struct vg_context * vg_create_context(struct pipe_context *pipe,
@@@ -82,8 -80,6 +82,8 @@@
  
     ctx->pipe = pipe;
  
 +   ctx->dispatch = api_create_dispatch();
 +
     vg_init_state(&ctx->state.vg);
     ctx->state.dirty = ALL_DIRTY;
  
@@@ -189,8 -185,6 +189,8 @@@ void vg_destroy_context(struct vg_conte
     cso_hash_delete(ctx->owned_objects[VG_OBJECT_FONT]);
     cso_hash_delete(ctx->owned_objects[VG_OBJECT_PATH]);
  
 +   api_destroy_dispatch(ctx->dispatch);
 +
     free(ctx);
  }
  
@@@ -457,8 -451,7 +457,7 @@@ void vg_prepare_blend_surface(struct vg
     dest_surface = pipe->screen->get_tex_surface(pipe->screen,
                                                  stfb->blend_texture_view->texture,
                                                  0, 0, 0,
-                                                 PIPE_BIND_BLIT_DESTINATION |
-                                               PIPE_BIND_RENDER_TARGET);
+                                                 PIPE_BIND_RENDER_TARGET);
     /* flip it, because we want to use it as a sampler */
     util_blit_pixels_tex(ctx->blit,
                          view,
@@@ -494,8 -487,7 +493,7 @@@ void vg_prepare_blend_surface_from_mask
     dest_surface = pipe->screen->get_tex_surface(pipe->screen,
                                                  stfb->blend_texture_view->texture,
                                                  0, 0, 0,
-                                                 PIPE_BIND_BLIT_DESTINATION |
-                                               PIPE_BIND_RENDER_TARGET);
+                                                 PIPE_BIND_RENDER_TARGET);
  
     /* flip it, because we want to use it as a sampler */
     util_blit_pixels_tex(ctx->blit,
index f1bc57878557b22f7cd3eeb489af7dfbdabfc62e,8a62a191207280eadb0183fb70360e12ffbdd8ae..3b04816df04dfc8533040b92aa88e5356307e799
  #include "util/u_format.h"
  #include "util/u_sampler.h"
  
 +#include "vg_api.h"
  #include "vg_manager.h"
  #include "vg_context.h"
  #include "image.h"
  #include "mask.h"
 +#include "api.h"
  
  static struct pipe_resource *
  create_texture(struct pipe_context *pipe, enum pipe_format format,
@@@ -124,28 -122,22 +124,22 @@@ setup_new_alpha_mask(struct vg_context 
  
     /* if we had an old surface copy it over */
     if (old_sampler_view) {
-       struct pipe_surface *surface = pipe->screen->get_tex_surface(
-          pipe->screen,
-          stfb->alpha_mask_view->texture,
-          0, 0, 0,
-          PIPE_BIND_RENDER_TARGET |
-          PIPE_BIND_BLIT_DESTINATION);
-       struct pipe_surface *old_surface = pipe->screen->get_tex_surface(
-          pipe->screen,
-          old_sampler_view->texture,
-          0, 0, 0,
-          PIPE_BIND_BLIT_SOURCE);
-       pipe->surface_copy(pipe,
-                          surface,
-                          0, 0,
-                          old_surface,
-                          0, 0,
-                          MIN2(old_surface->width, surface->width),
-                          MIN2(old_surface->height, surface->height));
-       if (surface)
-          pipe_surface_reference(&surface, NULL);
-       if (old_surface)
-          pipe_surface_reference(&old_surface, NULL);
+       struct pipe_subresource subsurf, subold_surf;
+       subsurf.face = 0;
+       subsurf.level = 0;
+       subold_surf.face = 0;
+       subold_surf.level = 0;
+       pipe->resource_copy_region(pipe,
+                                  stfb->alpha_mask_view->texture,
+                                  subsurf,
+                                  0, 0, 0,
+                                  old_sampler_view->texture,
+                                  subold_surf,
+                                  0, 0, 0,
+                                  MIN2(old_sampler_view->texture->width0,
+                                       stfb->alpha_mask_view->texture->width0),
+                                  MIN2(old_sampler_view->texture->height0,
+                                       stfb->alpha_mask_view->texture->height0));
     }
  
     /* Free the old texture
@@@ -172,9 -164,7 +166,7 @@@ vg_context_update_depth_stencil_rb(stru
  
     /* Probably need dedicated flags for surface usage too:
      */
-    surface_usage = (PIPE_BIND_RENDER_TARGET |
-                     PIPE_BIND_BLIT_SOURCE |
-                     PIPE_BIND_BLIT_DESTINATION);
+    surface_usage = PIPE_BIND_DEPTH_STENCIL; /* XXX: was: RENDER_TARGET */
  
     dsrb->texture = create_texture(pipe, dsrb->format, width, height);
     if (!dsrb->texture)
@@@ -216,9 -206,7 +208,7 @@@ vg_context_update_color_rb(struct vg_co
  
     strb->texture = pt;
     strb->surface = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
-          PIPE_BIND_RENDER_TARGET |
-          PIPE_BIND_BLIT_SOURCE |
-          PIPE_BIND_BLIT_DESTINATION);
+                                            PIPE_BIND_RENDER_TARGET);
     if (!strb->surface) {
        pipe_resource_reference(&strb->texture, NULL);
        return TRUE;
@@@ -538,15 -526,17 +528,15 @@@ vg_api_is_visual_supported(struct st_ap
  static st_proc_t
  vg_api_get_proc_address(struct st_api *stapi, const char *procname)
  {
 -   /* TODO */
 -   return (st_proc_t) NULL;
 +   return api_get_proc_address(procname);
  }
  
  static void
  vg_api_destroy(struct st_api *stapi)
  {
 -   free(stapi);
  }
  
 -struct st_api st_vg_api = {
 +static const struct st_api vg_api = {
     vg_api_destroy,
     vg_api_get_proc_address,
     vg_api_is_visual_supported,
     vg_api_get_current,
  };
  
 -struct st_api *
 -st_api_create_OpenVG(void)
 +const struct st_api *
 +vg_api_get(void)
  {
 -   return &st_vg_api;
 +   return &vg_api;
  }
index 921b6900fcd7cbdfb9c12a6677b2a0e7dd087725,35741f8684280b344aa38e9f32553ddbf609502c..e719644d340c5ab3ff226b172789f8df176d3f7e
@@@ -403,7 -403,7 +403,7 @@@ xorg_dri2_init(ScreenPtr pScreen
      }
  #endif
  
 -    dri2info.version = DRI2INFOREC_VERSION;
 +    dri2info.version = min(DRI2INFOREC_VERSION, 3);
      dri2info.fd = ms->fd;
  
      dri2info.driverName = pScrn->driverName;
      ms->d_depth_bits_last =
         ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM,
                                         PIPE_TEXTURE_2D,
+                                        0,
                                         PIPE_BIND_DEPTH_STENCIL, 0);
      ms->ds_depth_bits_last =
         ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
                                         PIPE_TEXTURE_2D,
+                                        0,
                                         PIPE_BIND_DEPTH_STENCIL, 0);
  
      return DRI2ScreenInit(pScreen, &dri2info);
index 31140f13bb4d2a389f32aca5098d28054c64d72d,6657f7391b276a918a967f9e89f3b327d060cdad..ee40bc8ccbd363faa35fff7f809ca13e5cba1bfd
@@@ -347,7 -347,7 +347,7 @@@ ExaPrepareSolid(PixmapPtr pPixmap, int 
        XORG_FALLBACK("not GXcopy");
  
      if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
-                                         priv->tex->target,
+                                         priv->tex->target, 0,
                                          PIPE_BIND_RENDER_TARGET, 0)) {
        XORG_FALLBACK("format %s", util_format_name(priv->tex->format));
      }
@@@ -428,39 -428,26 +428,26 @@@ ExaPrepareCopy(PixmapPtr pSrcPixmap, Pi
        XORG_FALLBACK("alu not GXcopy");
  
      if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
-                                         priv->tex->target,
+                                         priv->tex->target, 0,
                                          PIPE_BIND_RENDER_TARGET, 0))
        XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format));
  
      if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format,
-                                         src_priv->tex->target,
+                                         src_priv->tex->target, 0,
                                          PIPE_BIND_SAMPLER_VIEW, 0))
        XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format));
  
      exa->copy.src = src_priv;
      exa->copy.dst = priv;
  
-     /* For same-surface copies, the pipe->surface_copy path is clearly
-      * superior, providing it is implemented.  In other cases it's not
-      * clear what the better path would be, and eventually we'd
-      * probably want to gather timings and choose dynamically.
+     /* XXX this used to use resource_copy_region for same-surface copies,
+      * but they were redefined to not allow overlaps (some of the util code
+      * always assumed this anyway).
+      * Drivers should implement accelerated resource_copy_region or it will
+      * be slow - disable for now.
       */
-     if (exa->pipe->surface_copy &&
-         exa->copy.src == exa->copy.dst) {
+     if (0 && exa->copy.src != exa->copy.dst) {
         exa->copy.use_surface_copy = TRUE;
-        
-        exa->copy.src_surface =
-           exa->scrn->get_tex_surface( exa->scrn,
-                                       exa->copy.src->tex,
-                                       0, 0, 0,
-                                       PIPE_BIND_BLIT_SOURCE);
-        exa->copy.dst_surface =
-           exa->scrn->get_tex_surface( exa->scrn, 
-                                       exa->copy.dst->tex,
-                                       0, 0, 0, 
-                                       PIPE_BIND_BLIT_DESTINATION );
      }
      else {
         exa->copy.use_surface_copy = FALSE;
            exa->scrn->get_tex_surface(exa->scrn,
                                       exa->copy.dst->tex,
                                       0, 0, 0,
-                                      PIPE_BIND_BLIT_DESTINATION);
+                                      PIPE_BIND_RENDER_TARGET);
  
  
         renderer_copy_prepare(exa->renderer, 
@@@ -506,14 -493,19 +493,19 @@@ ExaCopy(PixmapPtr pDstPixmap, int srcX
     (void) priv;
  
     if (exa->copy.use_surface_copy) {
-       /* XXX: consider exposing >1 box in surface_copy interface.
-        */
-       exa->pipe->surface_copy( exa->pipe,
-                              exa->copy.dst_surface,
-                              dstX, dstY,
-                              exa->copy.src_surface,
-                              srcX, srcY,
-                              width, height );
+       struct pipe_subresource subdst, subsrc;
+       subdst.face = 0;
+       subdst.level = 0;
+       subsrc.face = 0;
+       subsrc.level = 0;
+       exa->pipe->resource_copy_region( exa->pipe,
+                                        exa->copy.dst->tex,
+                                        subdst,
+                                        dstX, dstY, 0,
+                                        exa->copy.src->tex,
+                                        subsrc,
+                                        srcX, srcY, 0,
+                                        width, height );
     }
     else {
        renderer_copy_pixmap(exa->renderer, 
@@@ -540,7 -532,6 +532,6 @@@ ExaDoneCopy(PixmapPtr pPixmap
  
     exa->copy.src = NULL;
     exa->copy.dst = NULL;
-    pipe_surface_reference(&exa->copy.src_surface, NULL);
     pipe_surface_reference(&exa->copy.dst_surface, NULL);
     pipe_resource_reference(&exa->copy.src_texture, NULL);
  }
@@@ -639,7 -630,7 +630,7 @@@ ExaPrepareComposite(int op, PicturePtr 
        XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex");
  
     if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
-                                        priv->tex->target,
+                                        priv->tex->target, 0,
                                         PIPE_BIND_RENDER_TARGET, 0))
        XORG_FALLBACK("pDst format: %s", util_format_name(priv->tex->format));
  
           XORG_FALLBACK("pSrc %s", !priv ? "!priv" : "!priv->tex");
  
        if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
-                                           priv->tex->target,
+                                           priv->tex->target, 0,
                                            PIPE_BIND_SAMPLER_VIEW, 0))
           XORG_FALLBACK("pSrc format: %s", util_format_name(priv->tex->format));
  
           XORG_FALLBACK("pMask %s", !priv ? "!priv" : "!priv->tex");
  
        if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
-                                           priv->tex->target,
+                                           priv->tex->target, 0,
                                            PIPE_BIND_SAMPLER_VIEW, 0))
           XORG_FALLBACK("pMask format: %s", util_format_name(priv->tex->format));
  
@@@ -890,23 -881,19 +881,19 @@@ ExaModifyPixmapHeader(PixmapPtr pPixmap
        texture = exa->scrn->resource_create(exa->scrn, &template);
  
        if (priv->tex) {
-           struct pipe_surface *dst_surf;
+           struct pipe_subresource subdst, subsrc;
            struct pipe_surface *src_surf;
  
-           dst_surf = exa->scrn->get_tex_surface(
-               exa->scrn, texture, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION);
-           src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
-             if (exa->pipe->surface_copy) {
-                exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
-                                        0, 0, min(width, texture->width0),
-                                        min(height, texture->height0));
-             } else {
-                util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
-                                  0, 0, min(width, texture->width0),
-                                  min(height, texture->height0));
-             }
-           exa->scrn->tex_surface_destroy(dst_surf);
-           exa->scrn->tex_surface_destroy(src_surf);
+           subdst.face = 0;
+           subdst.level = 0;
+           subsrc.face = 0;
+           subsrc.level = 0;
+             exa->pipe->resource_copy_region(exa->pipe, texture,
+                                             subdst, 0, 0, 0,
+                                             priv->tex,
+                                             subsrc, 0, 0, 0,
+                                             min(width, texture->width0),
+                                             min(height, texture->height0));
        }
  
        pipe_resource_reference(&priv->tex, texture);
@@@ -981,8 -968,6 +968,8 @@@ xorg_exa_close(ScrnInfoPtr pScrn
  
     renderer_destroy(exa->renderer);
  
 +   xorg_exa_finish(exa);
 +
     if (exa->pipe)
        exa->pipe->destroy(exa->pipe);
     exa->pipe = NULL;
@@@ -1076,11 -1061,7 +1063,7 @@@ out_err
  struct pipe_surface *
  xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv)
  {
-    
-    /* seems to get called both for blits and render target usage */
     return scrn->get_tex_surface(scrn, priv->tex, 0, 0, 0,
-                                 PIPE_BIND_BLIT_SOURCE |
-                                 PIPE_BIND_BLIT_DESTINATION |
                                  PIPE_BIND_RENDER_TARGET);
  
  }
index a9610a8678079c5e79517c5cae3f8806db97b8af,1576e5ea01bb50ab8b5da8c38982c36f12ac557a..e5def3e2edd5a5b7e2b12d850674e6a00eafe2d7
@@@ -7,6 -7,7 +7,6 @@@
  #include "util/u_draw_quad.h"
  #include "util/u_math.h"
  #include "util/u_memory.h"
 -#include "util/u_rect.h"
  #include "util/u_sampler.h"
  #include "util/u_surface.h"
  
@@@ -448,7 -449,7 +448,7 @@@ void renderer_copy_prepare(struct xorg_
     struct xorg_shader shader;
  
     assert(screen->is_format_supported(screen, dst_surface->format,
-                                       PIPE_TEXTURE_2D,
+                                       PIPE_TEXTURE_2D, 0,
                                        PIPE_BIND_RENDER_TARGET,
                                        0));
     (void) screen;
@@@ -524,7 -525,7 +524,7 @@@ renderer_clone_texture(struct xorg_rend
  
     /* the coming in texture should already have that invariance */
     debug_assert(screen->is_format_supported(screen, src->format,
-                                             PIPE_TEXTURE_2D,
+                                             PIPE_TEXTURE_2D, 0,
                                              PIPE_BIND_SAMPLER_VIEW, 0));
  
     format = src->format;
  
     {
        /* copy source framebuffer surface into texture */
-       struct pipe_surface *ps_read = screen->get_tex_surface(
-          screen, src, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
-       struct pipe_surface *ps_tex = screen->get_tex_surface(
-          screen, pt, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION );
-       if (pipe->surface_copy) {
-          pipe->surface_copy(pipe,
-                 ps_tex, /* dest */
-                 0, 0, /* destx/y */
-                 ps_read,
-                 0, 0, src->width0, src->height0);
-       } else {
-           util_surface_copy(pipe, FALSE,
-                 ps_tex, /* dest */
-                 0, 0, /* destx/y */
-                 ps_read,
-                 0, 0, src->width0, src->height0);
-       }
-       pipe_surface_reference(&ps_read, NULL);
-       pipe_surface_reference(&ps_tex, NULL);
+       struct pipe_subresource subsrc, subdst;
+       subsrc.face = 0;
+       subsrc.level = 0;
+       subdst.face = 0;
+       subdst.level = 0;
+       pipe->resource_copy_region(pipe,
+                                  pt, /* dest */
+                                  subdst,
+                                  0, 0, 0, /* destx/y/z */
+                                  src,
+                                  subsrc,
+                                  0, 0, 0,
+                                  src->width0, src->height0);
     }
  
     return pt;
diff --combined src/mesa/SConscript
index 9408e2d2f69f8e1ef13b931bf41c0eb19a549ee2,a7572af45d4189d9ceaff88911b3b2879f517fff..b553804fcdc838cf07432d3c6d82b72c76e32d24
@@@ -9,7 -9,6 +9,7 @@@ if env['platform'] != 'winddk'
        env = env.Clone()
        
        env.Append(CPPPATH = [
 +              '#/src/mapi',
                '#/src/mesa',
        ])
        
@@@ -79,6 -78,7 +79,6 @@@
                'main/polygon.c',
                'main/queryobj.c',
                'main/rastpos.c',
 -              'main/rbadaptors.c',
                'main/readpix.c',
                'main/remap.c',
                'main/renderbuffer.c',
                'state_tracker/st_atom_constbuf.c',
                'state_tracker/st_atom_depth.c',
                'state_tracker/st_atom_framebuffer.c',
+               'state_tracker/st_atom_msaa.c',
                'state_tracker/st_atom_pixeltransfer.c',
                'state_tracker/st_atom_sampler.c',
                'state_tracker/st_atom_scissor.c',
                'state_tracker/st_cb_readpixels.c',
                'state_tracker/st_cb_strings.c',
                'state_tracker/st_cb_texture.c',
 +              'state_tracker/st_cb_xformfb.c',
                'state_tracker/st_context.c',
                'state_tracker/st_debug.c',
                'state_tracker/st_draw.c',
                slang_sources
        )
  
 -      glapi_sources = [
 -              'glapi/glapi.c',
 -              'glapi/glapi_dispatch.c',
 -              'glapi/glapi_entrypoint.c',
 -              'glapi/glapi_execmem.c',
 -              'glapi/glapi_getproc.c',
 -              'glapi/glapi_nop.c',
 -              'glapi/glthread.c',
 -      ]
 -      
        #
        # Assembly sources
        #
                        'x86/sse_normal.S',
                        'x86/read_rgba_span_x86.S',
                ]
 -              glapi_sources += [
 -                      'x86/glapi_x86.S',
 -              ]
        elif gcc and env['machine'] == 'x86_64':
                env.Append(CPPDEFINES = [
                        'USE_X86_64_ASM', 
                        'x86-64/x86-64.c',
                        'x86-64/xform4.S',
                ]
 -              glapi_sources += [
 -                      'x86-64/glapi_x86-64.S'
 -              ]
        elif gcc and env['machine'] == 'ppc':
                env.Append(CPPDEFINES = [
                        'USE_PPC_ASM', 
                mesa_sources += [
                        'ppc/common_ppc.c',
                ]
 -              glapi_sources += [
 -              ]
        elif gcc and env['machine'] == 'sparc':
                mesa_sources += [
                        'sparc/sparc.c',
                        'sparc/norm.S',
                        'sparc/xform.S',
                ]
 -              glapi_sources += [
 -                      'sparc/glapi_sparc.S'
 -              ]
        else:
                pass
        
                source = mesa_sources,
        )
        Export('mesa')
 -      
 -      glapi = env.ConvenienceLibrary(
 -              target = 'glapi',
 -              source = glapi_sources,
 -      )
 -      Export('glapi')
 -
diff --combined src/mesa/sources.mak
index af125d79aa0b711ab3f65870dace6341f279f6ea,b69e7eeae51fed7d2231532c8749f4cc35e0b0b4..74563bcf96e683c9e487b6c70ad4397f3b7f1c87
@@@ -1,9 -1,12 +1,9 @@@
  ### Lists of source files, included by Makefiles
  
 -ES1_SOURCES = \
 +# this is part of MAIN_SOURCES
 +MAIN_ES_SOURCES = \
        main/api_exec_es1.c \
 -      main/get_es1.c
 -
 -ES2_SOURCES = \
 -      main/api_exec_es2.c \
 -      main/get_es2.c
 +      main/api_exec_es2.c
  
  MAIN_SOURCES = \
        main/api_arrayelt.c \
@@@ -62,6 -65,7 +62,6 @@@
        main/queryobj.c \
        main/querymatrix.c \
        main/rastpos.c \
 -      main/rbadaptors.c \
        main/readpix.c \
        main/remap.c \
        main/renderbuffer.c \
        main/version.c \
        main/viewport.c \
        main/vtxfmt.c \
 -      $(ES_SOURCES)
 -
 -GLAPI_SOURCES = \
 -      glapi/glapi.c \
 -      glapi/glapi_dispatch.c \
 -      glapi/glapi_entrypoint.c \
 -      glapi/glapi_execmem.c \
 -      glapi/glapi_getproc.c \
 -      glapi/glapi_nop.c \
 -      glapi/glthread.c
 +      $(MAIN_ES_SOURCES)
  
  MATH_SOURCES = \
        math/m_debug_clip.c \
@@@ -182,6 -195,7 +182,7 @@@ STATETRACKER_SOURCES = 
        state_tracker/st_atom_constbuf.c \
        state_tracker/st_atom_depth.c \
        state_tracker/st_atom_framebuffer.c \
+       state_tracker/st_atom_msaa.c \
        state_tracker/st_atom_pixeltransfer.c \
        state_tracker/st_atom_sampler.c \
        state_tracker/st_atom_scissor.c \
        state_tracker/st_cb_readpixels.c \
        state_tracker/st_cb_strings.c \
        state_tracker/st_cb_texture.c \
 +      state_tracker/st_cb_xformfb.c \
        state_tracker/st_context.c \
        state_tracker/st_debug.c \
        state_tracker/st_draw.c \
@@@ -297,14 -310,23 +298,14 @@@ X86_SOURCES =                   
        x86/sse_normal.S        \
        x86/read_rgba_span_x86.S
  
 -X86_API =                     \
 -      x86/glapi_x86.S
 -
  X86-64_SOURCES =              \
        x86-64/xform4.S
  
 -X86-64_API =                  \
 -      x86-64/glapi_x86-64.S
 -
  SPARC_SOURCES =                       \
        sparc/clip.S            \
        sparc/norm.S            \
        sparc/xform.S
  
 -SPARC_API =                   \
 -      sparc/glapi_sparc.S
 -
  COMMON_DRIVER_SOURCES =                       \
        drivers/common/driverfuncs.c    \
        drivers/common/meta.c
@@@ -338,6 -360,7 +339,6 @@@ MESA_GALLIUM_SOURCES = 
  # All the core C sources, for dependency checking
  ALL_SOURCES = \
        $(MESA_SOURCES)         \
 -      $(GLAPI_SOURCES)        \
        $(MESA_ASM_SOURCES)     \
        $(STATETRACKER_SOURCES)
  
@@@ -352,6 -375,10 +353,6 @@@ MESA_GALLIUM_OBJECTS = 
        $(MESA_GALLIUM_SOURCES:.c=.o) \
        $(MESA_ASM_SOURCES:.S=.o)
  
 -GLAPI_OBJECTS = \
 -      $(GLAPI_SOURCES:.c=.o) \
 -      $(GLAPI_ASM_SOURCES:.S=.o)
 -
  
  COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
  
@@@ -368,6 -395,5 +369,6 @@@ GLSL_LIBS = 
  INCLUDE_DIRS = \
        -I$(TOP)/include \
        -I$(TOP)/src/mesa \
 +      -I$(TOP)/src/mapi \
        -I$(TOP)/src/gallium/include \
        -I$(TOP)/src/gallium/auxiliary
index 14865e601a07451700de3187cb1d6d99c8aafaf6,323de8a8bd3c80110f30d613df4550ff6bc65cf9..b8644faaf8375ebeee0f707fcd1a1570ad7bf8ab
  #include "st_context.h"
  #include "st_format.h"
  #include "st_texture.h"
 -#include "st_inlines.h"
  
  #include "pipe/p_screen.h"
  #include "pipe/p_context.h"
 +#include "util/u_inlines.h"
  #include "util/u_pack_color.h"
  
  
@@@ -123,7 -123,7 +123,7 @@@ create_color_map_texture(GLcontext *ctx
  
     /* find an RGBA texture format */
     format = st_choose_format(pipe->screen, GL_RGBA,
-                              PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+                              PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
  
     /* create texture for color map/table */
     pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
@@@ -149,7 -149,7 +149,7 @@@ load_color_map_texture(GLcontext *ctx, 
     uint *dest;
     uint i, j;
  
 -   transfer = st_cond_flush_get_tex_transfer(st_context(ctx),
 +   transfer = pipe_get_transfer(st_context(ctx)->pipe,
                                             pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
                                             0, 0, texSize, texSize);
     dest = (uint *) pipe_transfer_map(pipe, transfer);
index 3e3076f721977ead0b3ae47e97bc63ffaa37d750,1b3787828e17cba749ba3e86bdddc06d742962bd..5aca1105eeb7a26c05cf6b9791112d1d9d1e5540
@@@ -43,6 -43,7 +43,6 @@@
  #include "st_program.h"
  #include "st_cb_bitmap.h"
  #include "st_texture.h"
 -#include "st_inlines.h"
  
  #include "pipe/p_context.h"
  #include "pipe/p_defines.h"
@@@ -53,7 -54,6 +53,7 @@@
  #include "cso_cache/cso_context.h"
  
  
 +#if FEATURE_drawpix
  
  /**
   * glBitmaps are drawn as textured quads.  The user's bitmap pattern
@@@ -282,7 -282,7 +282,7 @@@ make_bitmap_texture(GLcontext *ctx, GLs
        return NULL;
     }
  
 -   transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0,
 +   transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0,
                                           PIPE_TRANSFER_WRITE,
                                           0, 0, width, height);
  
@@@ -382,7 -382,7 +382,7 @@@ setup_bitmap_vertex_data(struct st_cont
     }
  
     /* put vertex data into vbuf */
 -   st_no_flush_pipe_buffer_write_nooverlap(st,
 +   pipe_buffer_write_nooverlap(st->pipe,
                                             st->bitmap.vbuf,
                                             st->bitmap.vbuf_slot * sizeof st->bitmap.vertices,
                                             sizeof st->bitmap.vertices,
@@@ -579,7 -579,7 +579,7 @@@ create_cache_trans(struct st_context *s
     /* Map the texture transfer.
      * Subsequent glBitmap calls will write into the texture image.
      */
 -   cache->trans = st_no_flush_get_tex_transfer(st, cache->texture, 0, 0, 0,
 +   cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, 0,
                                               PIPE_TRANSFER_WRITE, 0, 0,
                                               BITMAP_CACHE_WIDTH,
                                               BITMAP_CACHE_HEIGHT);
@@@ -807,15 -807,15 +807,15 @@@ st_init_bitmap(struct st_context *st
     st->bitmap.rasterizer.gl_rasterization_rules = 1;
  
     /* find a usable texture format */
-    if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, 
+    if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
        st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
     }
-    else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, 
+    else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, 0,
                                          PIPE_BIND_SAMPLER_VIEW, 0)) {
        st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
     }
-    else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, 
+    else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, 0,
                                          PIPE_BIND_SAMPLER_VIEW, 0)) {
        st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
     }
@@@ -860,5 -860,3 +860,5 @@@ st_destroy_bitmap(struct st_context *st
        st->bitmap.cache = NULL;
     }
  }
 +
 +#endif /* FEATURE_drawpix */
index 97b19b20c3535149002127be9d30102f11894ce0,3a34bdfe9a4837448da8d790e3e6c95889f8748f..fb7b48a7bf642423b0717ec66ed0e43448e761f0
@@@ -60,7 -60,6 +60,7 @@@ st_destroy_blit(struct st_context *st
  
  
  #if FEATURE_EXT_framebuffer_blit
 +
  static void
  st_BlitFramebuffer(GLcontext *ctx,
                     GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
           &readFB->Attachment[readFB->_ColorReadBufferIndex];
  
        if(srcAtt->Type == GL_TEXTURE) {
-          struct pipe_screen *screen = pipe->screen;
           struct st_texture_object *srcObj =
              st_texture_object(srcAtt->Texture);
           struct st_renderbuffer *dstRb =
              st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
-          struct pipe_surface *srcSurf;
+          struct pipe_subresource srcSub;
           struct pipe_surface *dstSurf = dstRb->surface;
  
           if (!srcObj->pt)
              return;
  
-          srcSurf = screen->get_tex_surface(screen,
-                                            srcObj->pt,
-                                            srcAtt->CubeMapFace,
-                                            srcAtt->TextureLevel,
-                                            srcAtt->Zoffset,
-                                            PIPE_BIND_BLIT_SOURCE);
-          if(!srcSurf)
-             return;
+          srcSub.face = srcAtt->CubeMapFace;
+          srcSub.level = srcAtt->TextureLevel;
  
-          util_blit_pixels(st->blit,
-                           srcSurf, st_get_texture_sampler_view(srcObj, pipe),
-                           srcX0, srcY0, srcX1, srcY1,
+          util_blit_pixels(st->blit, srcObj->pt, srcSub,
+                           srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset,
                            dstSurf, dstX0, dstY0, dstX1, dstY1,
                            0.0, pFilter);
-          pipe_surface_reference(&srcSurf, NULL);
        }
        else {
           struct st_renderbuffer *srcRb =
           struct st_renderbuffer *dstRb =
              st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
           struct pipe_surface *srcSurf = srcRb->surface;
-          struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcRb, pipe);
           struct pipe_surface *dstSurf = dstRb->surface;
+          struct pipe_subresource srcSub;
+          srcSub.face = srcSurf->face;
+          srcSub.level = srcSurf->level;
  
           util_blit_pixels(st->blit,
-                           srcSurf, srcView, srcX0, srcY0, srcX1, srcY1,
+                           srcRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
+                           srcSurf->zslice,
                            dstSurf, dstX0, dstY0, dstX1, dstY1,
                            0.0, pFilter);
        }
        if ((mask & depthStencil) == depthStencil &&
            srcDepthSurf == srcStencilSurf &&
            dstDepthSurf == dstStencilSurf) {
-          struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcDepthRb, pipe);
+          struct pipe_subresource srcSub;
+          srcSub.face = srcDepthRb->surface->face;
+          srcSub.level = srcDepthRb->surface->level;
  
           /* Blitting depth and stencil values between combined
            * depth/stencil buffers.  This is the ideal case for such buffers.
            */
           util_blit_pixels(st->blit,
-                           srcDepthSurf, srcView, srcX0, srcY0, srcX1, srcY1,
+                           srcDepthRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
+                           srcDepthRb->surface->zslice,
                            dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
                            0.0, pFilter);
        }
        }
     }
  }
 -#endif /* FEATURE_EXT_framebuffer_blit */
 -
  
  
  void
  st_init_blit_functions(struct dd_function_table *functions)
  {
 -#if FEATURE_EXT_framebuffer_blit
     functions->BlitFramebuffer = st_BlitFramebuffer;
 -#endif
  }
 +
 +#endif /* FEATURE_EXT_framebuffer_blit */
index 900deaf46ded682abe817cd3ffec357d2d73bf34,b883c071f7e25eb412406475f6bb9ba4ed281d3c..7991a93a1e6b04383a7b01edc403fc3aab1d6160
@@@ -36,6 -36,7 +36,6 @@@
  #include "main/arrayobj.h"
  #include "main/bufferobj.h"
  
 -#include "st_inlines.h"
  #include "st_context.h"
  #include "st_cb_bufferobjects.h"
  
@@@ -179,9 -180,7 +179,7 @@@ st_bufferobj_data(GLcontext *ctx
     switch(target) {
     case GL_PIXEL_PACK_BUFFER_ARB:
     case GL_PIXEL_UNPACK_BUFFER_ARB:
-       buffer_usage = (PIPE_BIND_RENDER_TARGET |
-                     PIPE_BIND_BLIT_SOURCE |
-                     PIPE_BIND_BLIT_DESTINATION);
+       buffer_usage = PIPE_BIND_RENDER_TARGET;
        break;
     case GL_ARRAY_BUFFER_ARB:
        buffer_usage = PIPE_BIND_VERTEX_BUFFER;
        }
  
        if (data)
 -         st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0,
 +         pipe_buffer_write(st_context(ctx)->pipe, st_obj->buffer, 0,
                                       size, data);
        return GL_TRUE;
     }
index 932e8edb2504a855ebfe47e97e84b247ee453468,ad20004d369b91307139d1599925bf0c8a662527..f74d8cd42d046cb98e832efae13208171f4b5e00
@@@ -49,6 -49,7 +49,6 @@@
  #include "st_cb_fbo.h"
  #include "st_format.h"
  #include "st_texture.h"
 -#include "st_inlines.h"
  
  #include "pipe/p_context.h"
  #include "pipe/p_defines.h"
@@@ -62,8 -63,6 +62,8 @@@
  #include "cso_cache/cso_context.h"
  
  
 +#if FEATURE_drawpix
 +
  /**
   * Check if the given program is:
   * 0: MOVE result.color, fragment.color;
@@@ -385,7 -384,7 +385,7 @@@ make_texture(struct st_context *st
        /* we'll do pixel transfer in a fragment shader */
        ctx->_ImageTransferState = 0x0;
  
 -      transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0,
 +      transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0,
                                              PIPE_TRANSFER_WRITE, 0, 0,
                                              width, height);
  
@@@ -509,7 -508,7 +509,7 @@@ draw_quad(GLcontext *ctx, GLfloat x0, G
        buf = pipe_buffer_create(pipe->screen,
                               PIPE_BIND_VERTEX_BUFFER,
                                 sizeof(verts));
 -      st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts);
 +      pipe_buffer_write(st->pipe, buf, 0, sizeof(verts), verts);
  
        util_draw_vertex_buffer(pipe, buf, 0,
                                PIPE_PRIM_QUADS,
@@@ -686,7 -685,7 +686,7 @@@ draw_stencil_pixels(GLcontext *ctx, GLi
     else
        usage = PIPE_TRANSFER_WRITE;
  
 -   pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, 0, 0, 0,
 +   pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0,
                                       usage, x, y,
                                       width, height);
  
@@@ -886,7 -885,7 +886,7 @@@ copy_stencil_pixels(GLcontext *ctx, GLi
        dsty = rbDraw->Base.Height - dsty - height;
     }
  
 -   ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx),
 +   ptDraw = pipe_get_transfer(st_context(ctx)->pipe,
                                           rbDraw->texture, 0, 0, 0,
                                           usage, dstx, dsty,
                                           width, height);
@@@ -969,8 -968,11 +969,9 @@@ st_CopyPixels(GLcontext *ctx, GLint src
     enum pipe_format srcFormat, texFormat;
     GLboolean invertTex = GL_FALSE;
     GLint readX, readY, readW, readH;
+    GLuint sample_count;
     struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
  
 -   pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 -
     st_validate_state(st);
  
     if (type == GL_STENCIL) {
        driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
     }
  
+    sample_count = rbRead->texture->nr_samples;
+    /* I believe this would be legal, presumably would need to do a resolve
+       for color, and for depth/stencil spec says to just use one of the
+       depth/stencil samples per pixel? Need some transfer clarifications. */
+    assert(sample_count < 2);
     srcFormat = rbRead->texture->format;
  
-    if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, 
+    if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, sample_count,
                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
        texFormat = srcFormat;
     }
        /* srcFormat can't be used as a texture format */
        if (type == GL_DEPTH) {
           texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
-                                       PIPE_TEXTURE_2D, 
+                                       PIPE_TEXTURE_2D, sample_count,
                                        PIPE_BIND_DEPTH_STENCIL);
           assert(texFormat != PIPE_FORMAT_NONE);
        }
        else {
           /* default color format */
           texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D, 
-                                       PIPE_BIND_SAMPLER_VIEW);
+                                       sample_count, PIPE_BIND_SAMPLER_VIEW);
           assert(texFormat != PIPE_FORMAT_NONE);
        }
     }
     /* Make temporary texture which is a copy of the src region.
      */
     if (srcFormat == texFormat) {
+       struct pipe_subresource srcsub, dstsub;
+       srcsub.face = 0;
+       srcsub.level = 0;
+       dstsub.face = 0;
+       dstsub.level = 0;
        /* copy source framebuffer surface into mipmap/texture */
-       struct pipe_surface *psRead = screen->get_tex_surface(screen,
-                                        rbRead->texture, 0, 0, 0,
-                                        PIPE_BIND_BLIT_SOURCE);
-       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
-                                        PIPE_BIND_RENDER_TARGET |
-                                        PIPE_BIND_BLIT_DESTINATION);
-       pipe->surface_copy(pipe,
-                          psTex,                               /* dest surf */
-                          pack.SkipPixels, pack.SkipRows,      /* dest pos */
-                          psRead,                              /* src surf */
-                          readX, readY, readW, readH);         /* src region */
-       if (0) {
-          /* debug */
-          debug_dump_surface(pipe, "copypixsrcsurf", psRead);
-          debug_dump_surface(pipe, "copypixtemptex", psTex);
-       }
+       pipe->resource_copy_region(pipe,
+                                  pt,                                /* dest tex */
+                                  dstsub,
+                                  pack.SkipPixels, pack.SkipRows, 0, /* dest pos */
+                                  rbRead->texture,                   /* src tex */
+                                  srcsub,
+                                  readX, readY, 0, readW, readH);    /* src region */
  
-       pipe_surface_reference(&psRead, NULL); 
-       pipe_surface_reference(&psTex, NULL);
     }
     else {
        /* CPU-based fallback/conversion */
        struct pipe_transfer *ptRead =
 -         st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0,
 +         pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, 0,
                                          PIPE_TRANSFER_READ,
                                          readX, readY, readW, readH);
        struct pipe_transfer *ptTex;
        else
           transfer_usage = PIPE_TRANSFER_WRITE;
  
 -      ptTex = st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, transfer_usage,
 +      ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, 0, transfer_usage,
                                               0, 0, width, height);
  
        /* copy image from ptRead surface to ptTex surface */
@@@ -1142,9 -1143,7 +1142,9 @@@ st_destroy_drawpix(struct st_context *s
     st_reference_fragprog(st, &st->drawpix.z_shader, NULL);
     st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
     if (st->drawpix.vert_shaders[0])
 -      free(st->drawpix.vert_shaders[0]);
 +      ureg_free_tokens(st->drawpix.vert_shaders[0]);
     if (st->drawpix.vert_shaders[1])
 -      free(st->drawpix.vert_shaders[1]);
 +      ureg_free_tokens(st->drawpix.vert_shaders[1]);
  }
 +
 +#endif /* FEATURE_drawpix */
index 00861a6ff36834dfa7961892070e8b4afdba0ff4,91a42fafd19f0bea7b59136b8b0bebb27564c43c..4aaf91d5a19dd6188a7ed5524f98a0b10c130696
@@@ -79,7 -79,7 +79,7 @@@ st_egl_image_target_renderbuffer_storag
     struct pipe_surface *ps;
     unsigned usage;
  
-    usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION;
+    usage = PIPE_BIND_RENDER_TARGET;
     ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
     if (ps) {
        strb->Base.Width = ps->width;
@@@ -129,10 -129,6 +129,10 @@@ st_bind_surface(GLcontext *ctx, GLenum 
     /* FIXME create a non-default sampler view from the pipe_surface? */
     pipe_resource_reference(&stImage->pt, ps->texture);
  
 +   stObj->width0 = ps->width;
 +   stObj->height0 = ps->height;
 +   stObj->depth0 = 1;
 +
     _mesa_dirty_texobj(ctx, texObj, GL_TRUE);
  }
  
@@@ -146,7 -142,7 +146,7 @@@ st_egl_image_target_texture_2d(GLcontex
     struct pipe_surface *ps;
     unsigned usage;
  
-    usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE;
+    usage = PIPE_BIND_SAMPLER_VIEW;
     ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
     if (ps) {
        st_bind_surface(ctx, target, texObj, texImage, ps);
index e34fd09dcb753f468310695d74e11f2668d30e6d,92342167d9226e7f8817b82f3b92246b75f72782..647898ef7c9a1c840f914799f35ecf6fe944197a
  #include "state_tracker/st_debug.h"
  #include "state_tracker/st_context.h"
  #include "state_tracker/st_cb_fbo.h"
 +#include "state_tracker/st_cb_flush.h"
  #include "state_tracker/st_cb_texture.h"
  #include "state_tracker/st_format.h"
  #include "state_tracker/st_texture.h"
  #include "state_tracker/st_gen_mipmap.h"
 -#include "state_tracker/st_inlines.h"
  #include "state_tracker/st_atom.h"
  
  #include "pipe/p_context.h"
@@@ -221,7 -221,7 +221,7 @@@ default_bindings(struct st_context *st
     else
        bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
  
-    if (screen->is_format_supported(screen, format, target, bindings, geom))
+    if (screen->is_format_supported(screen, format, target, 0, bindings, geom))
        return bindings;
     else
        return PIPE_BIND_SAMPLER_VIEW;
@@@ -255,10 -255,8 +255,10 @@@ get_texture_dims(GLenum target
   *
   * We use the given st_texture_image as a clue to determine the size of the
   * mipmap image at level=0.
 + *
 + * \return GL_TRUE for success, GL_FALSE if out of memory.
   */
 -static void
 +static GLboolean
  guess_and_alloc_texture(struct st_context *st,
                        struct st_texture_object *stObj,
                        const struct st_texture_image *stImage)
             (dims >= 3 && depth == 1) ) {
           /* we can't determine the image size at level=0 */
           stObj->width0 = stObj->height0 = stObj->depth0 = 0;
 -         return;
 +         /* this is not an out of memory error */
 +         return GL_TRUE;
        }
     }
  
                                   depth,
                                   bindings);
  
 -   DBG("%s - success\n", __FUNCTION__);
 +   DBG("%s returning %d\n", __FUNCTION__, (stObj->pt != NULL));
 +
 +   return stObj->pt != NULL;
  }
  
  
@@@ -433,7 -428,7 +433,7 @@@ compress_with_blit(GLcontext * ctx
     /* get destination surface (in the compressed texture) */
     dst_surface = screen->get_tex_surface(screen, stImage->pt,
                                           stImage->face, stImage->level, 0,
-                                          PIPE_BIND_BLIT_DESTINATION);
+                                          0 /* flags */);
     if (!dst_surface) {
        /* can't render into this format (or other problem) */
        return GL_FALSE;
  
     /* Put user's tex data into the temporary texture
      */
 -   tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx), src_tex,
 +   tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, src_tex,
                                             0, 0, 0, /* face, level are zero */
                                             PIPE_TRANSFER_WRITE,
                                             0, 0, width, height); /* x, y, w, h */
@@@ -602,12 -597,14 +602,12 @@@ st_TexImage(GLcontext * ctx
     }
  
     if (!stObj->pt) {
 -      guess_and_alloc_texture(st, stObj, stImage);
 -      if (!stObj->pt) {
 +      if (!guess_and_alloc_texture(st, stObj, stImage)) {
           /* Probably out of memory.
            * Try flushing any pending rendering, then retry.
            */
           st_finish(st);
 -         guess_and_alloc_texture(st, stObj, stImage);
 -         if (!stObj->pt) {
 +         if (!guess_and_alloc_texture(st, stObj, stImage)) {
              _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
              return;
           }
         _mesa_is_format_compressed(texImage->TexFormat) &&
         screen->is_format_supported(screen,
                                     stImage->pt->format,
-                                    stImage->pt->target,
+                                    stImage->pt->target, 0,
                                     PIPE_BIND_RENDER_TARGET, 0)) {
        if (!pixels)
           goto done;
@@@ -851,8 -848,7 +851,7 @@@ decompress_with_blit(GLcontext * ctx, G
     struct pipe_surface *dst_surface;
     struct pipe_resource *dst_texture;
     struct pipe_transfer *tex_xfer;
-    unsigned bind = (PIPE_BIND_BLIT_DESTINATION |
-                   PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
+    unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
                    PIPE_BIND_TRANSFER_READ);
  
     /* create temp / dest surface */
                          PIPE_TEX_MIPFILTER_NEAREST);
  
     /* map the dst_surface so we can read from it */
 -   tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx),
 +   tex_xfer = pipe_get_transfer(st_context(ctx)->pipe,
                                             dst_texture, 0, 0, 0,
                                             PIPE_TRANSFER_READ,
                                             0, 0, width, height);
@@@ -961,6 -957,11 +960,6 @@@ st_get_tex_image(GLcontext * ctx, GLenu
        /* Image is stored in hardware format in a buffer managed by the
         * kernel.  Need to explicitly map and unmap it.
         */
 -      unsigned face = _mesa_tex_target_to_face(target);
 -
 -      st_teximage_flush_before_map(st, stImage->pt, face, level,
 -                                 PIPE_TRANSFER_READ);
 -
        texImage->Data = st_texture_image_map(st, stImage, 0,
                                              PIPE_TRANSFER_READ, 0, 0,
                                              stImage->base.Width,
@@@ -1078,7 -1079,7 +1077,7 @@@ st_TexSubimage(GLcontext *ctx, GLint di
         _mesa_is_format_compressed(texImage->TexFormat) &&
         screen->is_format_supported(screen,
                                     stImage->pt->format,
-                                    stImage->pt->target,
+                                    stImage->pt->target, 0,
                                     PIPE_BIND_RENDER_TARGET, 0)) {
        if (compress_with_blit(ctx, target, level,
                               xoffset, yoffset, zoffset,
      * from uploading the buffer under us.
      */
     if (stImage->pt) {
 -      unsigned face = _mesa_tex_target_to_face(target);
 -
        if (format == GL_DEPTH_COMPONENT &&
            util_format_is_depth_and_stencil(stImage->pt->format))
           transfer_usage = PIPE_TRANSFER_READ_WRITE;
        else
           transfer_usage = PIPE_TRANSFER_WRITE;
  
 -      st_teximage_flush_before_map(st, stImage->pt, face, level,
 -                                 transfer_usage);
        texImage->Data = st_texture_image_map(st, stImage, zoffset, 
                                              transfer_usage,
                                              xoffset, yoffset,
@@@ -1220,8 -1225,11 +1219,8 @@@ st_CompressedTexSubImage2D(GLcontext *c
     enum pipe_format pformat;
  
     if (stImage->pt) {
 -      unsigned face = _mesa_tex_target_to_face(target);
        pformat = stImage->pt->format;
  
 -      st_teximage_flush_before_map(st, stImage->pt, face, level,
 -                                 PIPE_TRANSFER_WRITE);
        texImage->Data = st_texture_image_map(st, stImage, 0, 
                                              PIPE_TRANSFER_WRITE,
                                              xoffset, yoffset,
@@@ -1305,7 -1313,7 +1304,7 @@@ fallback_copy_texsubimage(GLcontext *ct
        srcY = strb->Base.Height - srcY - height;
     }
  
 -   src_trans = st_cond_flush_get_tex_transfer( st_context(ctx),
 +   src_trans = pipe_get_transfer(st_context(ctx)->pipe,
                                               strb->texture,
                                               0, 0, 0,
                                               PIPE_TRANSFER_READ,
     else
        transfer_usage = PIPE_TRANSFER_WRITE;
  
 -   st_teximage_flush_before_map(st, stImage->pt, 0, 0,
 -                              transfer_usage);
 -
     texDest = st_texture_image_map(st, stImage, 0, transfer_usage,
                                    destX, destY, width, height);
  
@@@ -1496,10 -1507,13 +1495,10 @@@ st_copy_texsubimage(GLcontext *ctx
     enum pipe_format dest_format, src_format;
     GLboolean use_fallback = GL_TRUE;
     GLboolean matching_base_formats;
-    GLuint format_writemask;
+    GLuint format_writemask, sample_count;
     struct pipe_surface *dest_surface = NULL;
     GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
  
 -   /* any rendering in progress must flushed before we grab the fb image */
 -   st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
 -
     /* make sure finalize_textures has been called? 
      */
     if (0) st_validate_state(st);
        return;
     }
  
+    sample_count = strb->surface->texture->nr_samples;
+    /* I believe this would be legal, presumably would need to do a resolve
+       for color, and for depth/stencil spec says to just use one of the
+       depth/stencil samples per pixel? Need some transfer clarifications. */
+    assert(sample_count < 2);
     if (srcX < 0) {
        width -= -srcX;
        destX += -srcX;
            !do_flip) 
        {
           /* use surface_copy() / blit */
-          dest_surface = screen->get_tex_surface(screen, stImage->pt,
-                                                 stImage->face, stImage->level,
-                                                 destZ,
-                                                 PIPE_BIND_BLIT_DESTINATION);
-          /* for surface_copy(), y=0=top, always */
-          pipe->surface_copy(pipe,
-                             /* dest */
-                             dest_surface,
-                             destX, destY,
-                             /* src */
-                             strb->surface,
-                             srcX, srcY,
-                             /* size */
-                             width, height);
+          struct pipe_subresource subdst, subsrc;
+          subdst.face = stImage->face;
+          subdst.level = stImage->level;
+          subsrc.face = strb->surface->face;
+          subsrc.level = strb->surface->level;
+          /* for resource_copy_region(), y=0=top, always */
+          pipe->resource_copy_region(pipe,
+                                     /* dest */
+                                     stImage->pt,
+                                     subdst,
+                                     destX, destY, destZ,
+                                     /* src */
+                                     strb->texture,
+                                     subsrc,
+                                     srcX, srcY, strb->surface->zslice,
+                                     /* size */
+                                     width, height);
           use_fallback = GL_FALSE;
        }
        else if (format_writemask &&
                 texBaseFormat != GL_DEPTH_COMPONENT &&
                 texBaseFormat != GL_DEPTH_STENCIL &&
                 screen->is_format_supported(screen, src_format,
-                                            PIPE_TEXTURE_2D, 
+                                            PIPE_TEXTURE_2D, sample_count,
                                             PIPE_BIND_SAMPLER_VIEW,
                                             0) &&
                 screen->is_format_supported(screen, dest_format,
-                                            PIPE_TEXTURE_2D, 
+                                            PIPE_TEXTURE_2D, 0,
                                             PIPE_BIND_RENDER_TARGET,
                                             0)) {
           /* draw textured quad to do the copy */
           GLint srcY0, srcY1;
+          struct pipe_subresource subsrc;
  
           dest_surface = screen->get_tex_surface(screen, stImage->pt,
                                                  stImage->face, stImage->level,
                                                  destZ,
-                                                 PIPE_BIND_BLIT_DESTINATION);
+                                                 PIPE_BIND_RENDER_TARGET);
  
           if (do_flip) {
              srcY1 = strb->Base.Height - srcY - height;
              srcY0 = srcY;
              srcY1 = srcY0 + height;
           }
+          subsrc.face = strb->surface->face;
+          subsrc.level = strb->surface->level;
           util_blit_pixels_writemask(st->blit,
-                                     strb->surface,
-                                     st_get_renderbuffer_sampler_view(strb, pipe),
+                                     strb->texture,
+                                     subsrc,
                                      srcX, srcY0,
                                      srcX + width, srcY1,
+                                     strb->surface->zslice,
                                      dest_surface,
                                      destX, destY,
                                      destX + width, destY + height,
@@@ -1760,12 -1787,17 +1772,12 @@@ copy_image_data_to_texture(struct st_co
         */
        st_texture_image_copy(st->pipe,
                              stObj->pt, dstLevel,  /* dest texture, level */
 -                            stImage->pt, /* src texture */
 +                            stImage->pt, stImage->level, /* src texture, level */
                              stImage->face);
  
        pipe_resource_reference(&stImage->pt, NULL);
     }
     else if (stImage->base.Data) {
 -      /* More straightforward upload.  
 -       */
 -      st_teximage_flush_before_map(st, stObj->pt, stImage->face, dstLevel,
 -                                 PIPE_TRANSFER_WRITE);
 -
        st_texture_image_data(st,
                              stObj->pt,
                              stImage->face,
@@@ -1877,7 -1909,7 +1889,7 @@@ st_finalize_texture(GLcontext *ctx
      */
     for (face = 0; face < nr_faces; face++) {
        GLuint level;
 -      for (level = 0; level <= stObj->lastLevel; level++) {
 +      for (level = stObj->base.BaseLevel; level <= stObj->lastLevel; level++) {
           struct st_texture_image *stImage =
              st_texture_image(stObj->base.Image[face][level]);
  
index 21d0fa96e1698c21083f388af9cc563d2d02d856,d4ea593e3f7dbf07b41169b0520bfc0031b83869..2070f14a5a64893ccad18ff78ca70b4b35f4e9e2
  #include "st_cb_bufferobjects.h"
  #include "st_cb_clear.h"
  #include "st_cb_condrender.h"
 -#if FEATURE_drawpix
  #include "st_cb_drawpixels.h"
  #include "st_cb_rasterpos.h"
 -#endif
 -#if FEATURE_OES_draw_texture
  #include "st_cb_drawtex.h"
 -#endif
  #include "st_cb_eglimage.h"
  #include "st_cb_fbo.h"
 -#if FEATURE_feedback
  #include "st_cb_feedback.h"
 -#endif
  #include "st_cb_program.h"
  #include "st_cb_queryobj.h"
  #include "st_cb_readpixels.h"
  #include "st_cb_texture.h"
 +#include "st_cb_xformfb.h"
  #include "st_cb_flush.h"
  #include "st_cb_strings.h"
  #include "st_atom.h"
@@@ -60,6 -65,7 +60,6 @@@
  #include "util/u_inlines.h"
  #include "util/u_rect.h"
  #include "util/u_surface.h"
 -#include "draw/draw_context.h"
  #include "cso_cache/cso_context.h"
  
  
@@@ -93,19 -99,6 +93,6 @@@ st_get_msaa(void
  }
  
  
- /** Default method for pipe_context::surface_copy() */
- static void
- st_surface_copy(struct pipe_context *pipe,
-                 struct pipe_surface *dst,
-                 unsigned dst_x, unsigned dst_y,
-                 struct pipe_surface *src,
-                 unsigned src_x, unsigned src_y, 
-                 unsigned w, unsigned h)
- {
-    util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h);
- }
  static struct st_context *
  st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
  {
     /* state tracker needs the VBO module */
     _vbo_CreateContext(ctx);
  
 -#if FEATURE_feedback || FEATURE_drawpix
 -   st->draw = draw_create(pipe); /* for selection/feedback */
 -
 -   /* Disable draw options that might convert points/lines to tris, etc.
 -    * as that would foul-up feedback/selection mode.
 -    */
 -   draw_wide_line_threshold(st->draw, 1000.0f);
 -   draw_wide_point_threshold(st->draw, 1000.0f);
 -   draw_enable_line_stipple(st->draw, FALSE);
 -   draw_enable_point_sprites(st->draw, FALSE);
 -#endif
 -
     st->dirty.mesa = ~0;
     st->dirty.st = ~0;
  
     st_init_limits(st);
     st_init_extensions(st);
  
-    /* plug in helper driver functions if needed */
-    if (!pipe->surface_copy)
-       pipe->surface_copy = st_surface_copy;
     return st;
  }
  
@@@ -207,14 -208,23 +190,14 @@@ static void st_destroy_context_priv( st
  {
     uint i;
  
 -#if FEATURE_feedback || FEATURE_drawpix
 -   draw_destroy(st->draw);
 -#endif
     st_destroy_atoms( st );
     st_destroy_draw( st );
     st_destroy_generate_mipmap(st);
 -#if FEATURE_EXT_framebuffer_blit
     st_destroy_blit(st);
 -#endif
     st_destroy_clear(st);
 -#if FEATURE_drawpix
     st_destroy_bitmap(st);
     st_destroy_drawpix(st);
 -#endif
 -#if FEATURE_OES_draw_texture
     st_destroy_drawtex(st);
 -#endif
  
     for (i = 0; i < Elements(st->state.sampler_views); i++) {
        pipe_sampler_view_reference(&st->state.sampler_views[i], NULL);
@@@ -274,29 -284,39 +257,29 @@@ void st_init_driver_functions(struct dd
  {
     _mesa_init_glsl_driver_functions(functions);
  
 -#if FEATURE_accum
     st_init_accum_functions(functions);
 -#endif
 -#if FEATURE_EXT_framebuffer_blit
     st_init_blit_functions(functions);
 -#endif
     st_init_bufferobject_functions(functions);
     st_init_clear_functions(functions);
 -#if FEATURE_drawpix
     st_init_bitmap_functions(functions);
     st_init_drawpixels_functions(functions);
     st_init_rasterpos_functions(functions);
 -#endif
  
 -#if FEATURE_OES_draw_texture
     st_init_drawtex_functions(functions);
 -#endif
  
     st_init_eglimage_functions(functions);
  
     st_init_fbo_functions(functions);
 -#if FEATURE_feedback
     st_init_feedback_functions(functions);
 -#endif
     st_init_program_functions(functions);
 -#if FEATURE_queryobj
     st_init_query_functions(functions);
 -#endif
     st_init_cond_render_functions(functions);
     st_init_readpixels_functions(functions);
     st_init_texture_functions(functions);
     st_init_flush_functions(functions);
     st_init_string_functions(functions);
  
 +   st_init_xformfb_functions(functions);
 +
     functions->UpdateState = st_invalidate_state;
  }
index 459e924cca39ddd919a52c4b9c004a6c78dc1082,9ada38aa483b1683cc03228a72aa1d06b4047311..810a0635b50842484e1c52e22e7b0452efb735fb
@@@ -67,7 -67,6 +67,7 @@@ void st_init_limits(struct st_context *
  {
     struct pipe_screen *screen = st->pipe->screen;
     struct gl_constants *c = &st->ctx->Const;
 +   struct gl_program_constants *pc;
  
     c->MaxTextureLevels
        = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
  
     /* Quads always follow GL provoking rules. */
     c->QuadsFollowProvokingVertexConvention = GL_FALSE;
 +
 +   pc = &c->FragmentProgram;
 +   pc->MaxNativeInstructions    = screen->get_param(screen, PIPE_CAP_MAX_FS_INSTRUCTIONS);
 +   pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS);
 +   pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS);
 +   pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INDIRECTIONS);
 +   pc->MaxNativeAttribs         = screen->get_param(screen, PIPE_CAP_MAX_FS_INPUTS);
 +   pc->MaxNativeTemps           = screen->get_param(screen, PIPE_CAP_MAX_FS_TEMPS);
 +   pc->MaxNativeAddressRegs     = screen->get_param(screen, PIPE_CAP_MAX_FS_ADDRS);
 +   pc->MaxNativeParameters      = screen->get_param(screen, PIPE_CAP_MAX_FS_CONSTS);
 +
 +   pc = &c->VertexProgram;
 +   pc->MaxNativeInstructions    = screen->get_param(screen, PIPE_CAP_MAX_VS_INSTRUCTIONS);
 +   pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS);
 +   pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS);
 +   pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INDIRECTIONS);
 +   pc->MaxNativeAttribs         = screen->get_param(screen, PIPE_CAP_MAX_VS_INPUTS);
 +   pc->MaxNativeTemps           = screen->get_param(screen, PIPE_CAP_MAX_VS_TEMPS);
 +   pc->MaxNativeAddressRegs     = screen->get_param(screen, PIPE_CAP_MAX_VS_ADDRS);
 +   pc->MaxNativeParameters      = screen->get_param(screen, PIPE_CAP_MAX_VS_CONSTS);
  }
  
  
@@@ -296,9 -275,6 +296,9 @@@ void st_init_extensions(struct st_conte
     if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
        ctx->Extensions.ARB_occlusion_query = GL_TRUE;
     }
 +   if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
 +     ctx->Extensions.EXT_timer_query = GL_TRUE;
 +   }
  
     if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
        ctx->Extensions.ARB_depth_texture = GL_TRUE;
      * a depth/stencil buffer and texture from depth/stencil source.
      */
     if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_DEPTH_STENCIL, 0) &&
         screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
        ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
     }
     else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
-                                         PIPE_TEXTURE_2D, 
+                                         PIPE_TEXTURE_2D, 0,
                                          PIPE_BIND_DEPTH_STENCIL, 0) &&
              screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
-                                         PIPE_TEXTURE_2D, 
+                                         PIPE_TEXTURE_2D, 0,
                                          PIPE_BIND_SAMPLER_VIEW, 0)) {
        ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
     }
  
     /* sRGB support */
     if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0) ||
        screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
        ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
     }
  
     /* s3tc support */
     if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
-                                    PIPE_TEXTURE_2D,
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0) &&
         (ctx->Mesa_DXTn ||
          screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
-                                     PIPE_TEXTURE_2D,
+                                     PIPE_TEXTURE_2D, 0,
                                      PIPE_BIND_RENDER_TARGET, 0))) {
        ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
        ctx->Extensions.S3_s3tc = GL_TRUE;
  
     /* ycbcr support */
     if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, 
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0) ||
         screen->is_format_supported(screen, PIPE_FORMAT_YUYV, 
-                                    PIPE_TEXTURE_2D, 
+                                    PIPE_TEXTURE_2D, 0,
                                     PIPE_BIND_SAMPLER_VIEW, 0)) {
        ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
     }
index e656908bedec0cb6a2cd47cdf29d974cc88339b0,5cf8b4a881bed4bfed505c641bd2d4351444fe4f..2d587df6055a1c37414567b187551e8f41f43d43
@@@ -39,9 -39,9 +39,9 @@@
  
  #include "st_debug.h"
  #include "st_context.h"
 +#include "st_texture.h"
  #include "st_gen_mipmap.h"
  #include "st_cb_texture.h"
 -#include "st_inlines.h"
  
  
  /**
@@@ -79,11 -79,10 +79,11 @@@ st_render_mipmap(struct st_context *st
     struct pipe_sampler_view *psv = st_get_texture_sampler_view(stObj, pipe);
     const uint face = _mesa_tex_target_to_face(target);
  
 +   assert(psv->texture == stObj->pt);
     assert(target != GL_TEXTURE_3D); /* not done yet */
  
     /* check if we can render in the texture's format */
-    if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
+    if (!screen->is_format_supported(screen, psv->format, psv->texture->target, 0,
                                      PIPE_BIND_RENDER_TARGET, 0)) {
        return FALSE;
     }
@@@ -105,32 -104,10 +105,32 @@@ decompress_image(enum pipe_format forma
                   unsigned width, unsigned height)
  {
     const struct util_format_description *desc = util_format_description(format);
 -   const uint dst_stride = 4 * width;
 +   const uint bw = util_format_get_blockwidth(format);
 +   const uint bh = util_format_get_blockheight(format);
 +   const uint dst_stride = 4 * MAX2(width, bw);
     const uint src_stride = util_format_get_stride(format, width);
  
     desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height);
 +
 +   if (width < bw || height < bh) {
 +      /* We're decompressing an image smaller than the compression
 +       * block size.  We don't want garbage pixel values in the region
 +       * outside (width x height) so replicate pixels from the (width
 +       * x height) region to fill out the (bw x bh) block size.
 +       */
 +      uint x, y;
 +      for (y = 0; y < bh; y++) {
 +         for (x = 0; x < bw; x++) {
 +            if (x >= width || y >= height) {
 +               uint p = (y * bw + x) * 4;
 +               dst[p + 0] = dst[0];
 +               dst[p + 1] = dst[1];
 +               dst[p + 2] = dst[2];
 +               dst[p + 3] = dst[3];
 +            }
 +         }
 +      }
 +   }
  }
  
  
@@@ -199,13 -176,13 +199,13 @@@ fallback_generate_mipmap(GLcontext *ctx
        ubyte *dstData;
        int srcStride, dstStride;
  
 -      srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
 +      srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face,
                                                srcLevel, zslice,
                                                PIPE_TRANSFER_READ, 0, 0,
                                                  srcWidth, srcHeight);
                                                
  
 -      dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,
 +      dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face,
                                                dstLevel, zslice,
                                                PIPE_TRANSFER_WRITE, 0, 0,
                                                dstWidth, dstHeight);
                                       dstWidth2); /* stride in texels */
  
           /* compress the new image: dstTemp -> dstData */
 -         compress_image(format, dstTemp, dstData, dstWidth2, dstHeight2);
 +         compress_image(format, dstTemp, dstData, dstWidth, dstHeight);
  
           free(srcTemp);
           free(dstTemp);
@@@ -284,6 -261,7 +284,6 @@@ compute_num_levels(GLcontext *ctx
        return 1;
     }
     else {
 -      const GLuint maxLevels = texObj->MaxLevel - texObj->BaseLevel + 1;
        const struct gl_texture_image *baseImage = 
           _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
        GLuint size, numLevels;
        size = MAX2(baseImage->Width2, baseImage->Height2);
        size = MAX2(size, baseImage->Depth2);
  
 -      numLevels = 0;
 +      numLevels = texObj->BaseLevel;
  
        while (size > 0) {
           numLevels++;
           size >>= 1;
        }
  
 -      numLevels = MIN2(numLevels, maxLevels);
 +      numLevels = MIN2(numLevels, texObj->MaxLevel + 1);
 +
 +      assert(numLevels >= 1);
  
        return numLevels;
     }
@@@ -324,7 -300,11 +324,11 @@@ st_generate_mipmap(GLcontext *ctx, GLen
     if (!pt)
        return;
  
-    /* find expected last mipmap level to generate */
+    /* not sure if this ultimately actually should work,
+       but we're not supporting multisampled textures yet. */
+    assert(pt->nr_samples < 2);
 -   /* find expected last mipmap level */
++   /* find expected last mipmap level to generate*/
     lastLevel = compute_num_levels(ctx, texObj, target) - 1;
  
     if (lastLevel == 0)
        pt = stObj->pt;
     }
  
 -   assert(lastLevel <= pt->last_level);
 +   assert(pt->last_level >= lastLevel);
  
     /* Try to generate the mipmap by rendering/texturing.  If that fails,
      * use the software fallback.
index 2d364737cb0eace58369ac1803266a365a5407d1,d0d1c5c3156117157631a2a6d40fee2b1535edb3..dbdf1ea1ad0420037b4e48bfeede0f4fceaabef0
@@@ -29,6 -29,7 +29,6 @@@
  #include "st_format.h"
  #include "st_texture.h"
  #include "st_cb_fbo.h"
 -#include "st_inlines.h"
  #include "main/enums.h"
  
  #undef Elements  /* fix re-defined macro warning */
@@@ -65,16 -66,13 +65,16 @@@ st_texture_create(struct st_context *st
     struct pipe_screen *screen = st->pipe->screen;
  
     assert(target <= PIPE_TEXTURE_CUBE);
 +   assert(width0 > 0);
 +   assert(height0 > 0);
 +   assert(depth0 > 0);
  
     DBG("%s target %s format %s last_level %d\n", __FUNCTION__,
         _mesa_lookup_enum_by_nr(target),
         _mesa_lookup_enum_by_nr(format), last_level);
  
     assert(format);
-    assert(screen->is_format_supported(screen, format, target, 
+    assert(screen->is_format_supported(screen, format, target, 0,
                                        PIPE_BIND_SAMPLER_VIEW, 0));
  
     memset(&pt, 0, sizeof(pt));
@@@ -144,7 -142,7 +144,7 @@@ st_texture_image_map(struct st_context 
  
     DBG("%s \n", __FUNCTION__);
  
 -   stImage->transfer = st_no_flush_get_tex_transfer(st, pt, stImage->face,
 +   stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face,
                                                    stImage->level, zoffset,
                                                    usage, x, y, w, h);
  
@@@ -219,7 -217,7 +219,7 @@@ st_texture_image_data(struct st_contex
     DBG("%s\n", __FUNCTION__);
  
     for (i = 0; i < depth; i++) {
 -      dst_transfer = st_no_flush_get_tex_transfer(st, dst, face, level, i,
 +      dst_transfer = pipe_get_transfer(st->pipe, dst, face, level, i,
                                                  PIPE_TRANSFER_WRITE, 0, 0,
                                                  u_minify(dst->width0, level),
                                                    u_minify(dst->height0, level));
  }
  
  
 -/* Copy mipmap image between textures
 +/**
 + * For debug only: get/print center pixel in the src resource.
 + */
 +static void
 +print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src)
 +{
 +   struct pipe_subresource rect;
 +   struct pipe_transfer *xfer;
 +   struct pipe_box region;
 +   ubyte *map;
 +
 +   rect.face = 0;
 +   rect.level = 0;
 +
 +   region.x = src->width0 / 2;
 +   region.y = src->height0 / 2;
 +   region.z = 0;
 +   region.width = 1;
 +   region.height = 1;
 +   region.depth = 1;
 +
 +   xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, &region);
 +   map = pipe->transfer_map(pipe, xfer);
 +
 +   printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]);
 +
 +   pipe->transfer_unmap(pipe, xfer);
 +   pipe->transfer_destroy(pipe, xfer);
 +}
 +
 +
 +/**
 + * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'.
 + * This is used to copy mipmap images from one texture buffer to another.
 + * This typically happens when our initial guess at the total texture size
 + * is incorrect (see the guess_and_alloc_texture() function).
   */
  void
  st_texture_image_copy(struct pipe_context *pipe,
                        struct pipe_resource *dst, GLuint dstLevel,
 -                      struct pipe_resource *src,
 +                      struct pipe_resource *src, GLuint srcLevel,
                        GLuint face)
  {
-    struct pipe_screen *screen = pipe->screen;
     GLuint width = u_minify(dst->width0, dstLevel); 
     GLuint height = u_minify(dst->height0, dstLevel); 
     GLuint depth = u_minify(dst->depth0, dstLevel); 
-    struct pipe_surface *src_surface;
-    struct pipe_surface *dst_surface;
+    struct pipe_subresource dstsub, srcsub;
     GLuint i;
  
 -   assert(src->width0 == dst->width0);
 -   assert(src->height0 == dst->height0);
 +   assert(u_minify(src->width0, srcLevel) == width);
 +   assert(u_minify(src->height0, srcLevel) == height);
 +   assert(u_minify(src->depth0, srcLevel) == depth);
  
 -
+    dstsub.face = face;
+    dstsub.level = dstLevel;
+    srcsub.face = face;
++   srcsub.level = srcLevel;
 +   /* Loop over 3D image slices */
     for (i = 0; i < depth; i++) {
 -      GLuint srcLevel;
 -
 -      /* find src texture level of needed size */
 -      for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) {
 -         if (u_minify(src->width0, srcLevel) == width &&
 -             u_minify(src->height0, srcLevel) == height) {
 -            break;
 -         }
 -      }
 -      assert(u_minify(src->width0, srcLevel) == width);
 -      assert(u_minify(src->height0, srcLevel) == height);
 -
 -#if 0
 -      {
 -         struct pipe_screen *screen = pipe->screen;
 -         src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
 -                                               PIPE_BUFFER_USAGE_CPU_READ);
 -         ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ);
 -         map += src_surface->width * src_surface->height * 4 / 2;
 -         printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n",
 -                __FUNCTION__,
 -                map[0], map[1], map[2], map[3],
 -                src, srcLevel, dst, dstLevel);
 -
 -         screen->surface_unmap(screen, src_surface);
 -         pipe_surface_reference(&src_surface, NULL);
 +
 +      if (0)  {
 +         print_center_pixel(pipe, src);
        }
 -#endif
 -      srcsub.level = srcLevel;
  
-       dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
-                                             PIPE_BIND_BLIT_DESTINATION);
-       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
-                                             PIPE_BIND_BLIT_SOURCE);
-       pipe->surface_copy(pipe,
-                          dst_surface,
-                          0, 0, /* destX, Y */
-                          src_surface,
-                          0, 0, /* srcX, Y */
-                          width, height);
-       pipe_surface_reference(&src_surface, NULL);
-       pipe_surface_reference(&dst_surface, NULL);
+       pipe->resource_copy_region(pipe,
+                                  dst,
+                                  dstsub,
+                                  0, 0, i,/* destX, Y, Z */
+                                  src,
+                                  srcsub,
+                                  0, 0, i,/* srcX, Y, Z */
+                                  width, height);
     }
  }
  
 -
 -void
 -st_teximage_flush_before_map(struct st_context *st,
 -                           struct pipe_resource *pt,
 -                           unsigned int face,
 -                           unsigned int level,
 -                           enum pipe_transfer_usage usage)
 -{
 -   struct pipe_context *pipe = st->pipe;
 -   unsigned referenced =
 -      pipe->is_resource_referenced(pipe, pt, face, level);
 -
 -   if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
 -                    (usage & PIPE_TRANSFER_WRITE)))
 -      st->pipe->flush(st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 -}