Mesa (gallium-buffer-usage-cleanup): gallium: start a cleanup of buffer_usage

Keith Whitwell keithw at kemper.freedesktop.org
Sun Mar 14 16:55:25 PDT 2010


Module: Mesa
Branch: gallium-buffer-usage-cleanup
Commit: dd7ba1378fc50710667724d30d6d4cf1125ad61e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd7ba1378fc50710667724d30d6d4cf1125ad61e

Author: Keith Whitwell <keithw at vmware.com>
Date:   Sun Mar 14 23:54:36 2010 +0000

gallium: start a cleanup of buffer_usage

Remove fairly meaningless CPU/GPU READ/WRITE flags and
replace with proper usages.

---

 src/gallium/auxiliary/util/u_blit.c                |    2 +-
 src/gallium/auxiliary/util/u_blitter.c             |    4 +-
 src/gallium/auxiliary/util/u_gen_mipmap.c          |    2 +-
 src/gallium/auxiliary/util/u_surface.c             |    7 +++-
 src/gallium/auxiliary/util/u_upload_mgr.c          |    2 +-
 src/gallium/drivers/i915/i915_resource_buffer.c    |    2 +-
 src/gallium/drivers/i965/brw_resource_buffer.c     |    7 +---
 src/gallium/drivers/llvmpipe/lp_scene.c            |   18 +++++++---
 src/gallium/drivers/llvmpipe/lp_setup.c            |    2 +-
 src/gallium/drivers/llvmpipe/lp_texture.c          |   32 +++---------------
 src/gallium/drivers/llvmpipe/lp_texture.h          |    7 ++--
 src/gallium/drivers/softpipe/sp_texture.c          |   22 +------------
 src/gallium/drivers/svga/svga_cmd.c                |   34 ++++++++++----------
 src/gallium/drivers/svga/svga_draw.c               |    4 +-
 src/gallium/drivers/svga/svga_draw_arrays.c        |    6 +--
 src/gallium/drivers/svga/svga_draw_elements.c      |    8 ++---
 src/gallium/drivers/svga/svga_pipe_query.c         |    2 +-
 src/gallium/drivers/svga/svga_resource_buffer.c    |    2 +-
 .../drivers/svga/svga_resource_buffer_upload.c     |   10 +++---
 src/gallium/drivers/svga/svga_resource_texture.c   |    4 +-
 src/gallium/drivers/svga/svga_state_constants.c    |    2 +-
 src/gallium/drivers/svga/svga_state_tss.c          |    2 +-
 src/gallium/drivers/svga/svga_state_vs.c           |    2 +-
 src/gallium/drivers/svga/svga_surface.c            |    5 +--
 src/gallium/drivers/svga/svga_swtnl_draw.c         |    6 ++--
 src/gallium/drivers/svga/svga_winsys.h             |    5 +++
 src/gallium/include/pipe/p_defines.h               |   23 +++++++------
 src/gallium/state_trackers/vega/api_filters.c      |    2 +-
 src/gallium/state_trackers/vega/image.c            |    6 ++--
 src/gallium/state_trackers/vega/mask.c             |    4 +-
 src/gallium/state_trackers/vega/renderer.c         |    4 +-
 src/gallium/state_trackers/vega/vg_context.c       |    6 ++-
 src/gallium/state_trackers/vega/vg_tracker.c       |   10 +++--
 src/mesa/state_tracker/st_atom_framebuffer.c       |    5 ++-
 src/mesa/state_tracker/st_cb_blit.c                |    2 +-
 src/mesa/state_tracker/st_cb_bufferobjects.c       |   11 +++---
 src/mesa/state_tracker/st_cb_drawpixels.c          |    5 ++-
 src/mesa/state_tracker/st_cb_fbo.c                 |   10 +-----
 src/mesa/state_tracker/st_cb_texture.c             |    6 ++--
 src/mesa/state_tracker/st_draw_feedback.c          |    6 ++--
 src/mesa/state_tracker/st_texture.c                |    9 +++--
 41 files changed, 140 insertions(+), 168 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 12a4ff6..da27637 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -377,7 +377,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
          return;
 
       texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, 
-                                        PIPE_BUFFER_USAGE_GPU_WRITE);
+                                        PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
       /* load temp texture */
       if (pipe->surface_copy) {
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index b4a49b7..c4ad492 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -734,8 +734,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
       return;
 
    tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
-				      PIPE_BUFFER_USAGE_GPU_READ | 
-				      PIPE_BUFFER_USAGE_GPU_WRITE);
+				      PIPE_BUFFER_USAGE_BLIT_SOURCE | 
+				      PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
    /* blit from the src to the temp */
    util_blitter_do_copy(blitter, tex_surf, 0, 0,
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index a2c5f77..5673ff5 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1539,7 +1539,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
 
       struct pipe_surface *surf = 
          screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
-                                 PIPE_BUFFER_USAGE_GPU_WRITE);
+                                 PIPE_BUFFER_USAGE_RENDER_TARGET);
 
       /*
        * Setup framebuffer / dest surface
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index e21e81d..67c8565 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -91,7 +91,12 @@ util_create_rgba_surface(struct pipe_screen *screen,
       return FALSE;
 
    /* create surface / view into texture */
-   *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+   *surfaceOut = screen->get_tex_surface(screen, 
+					 *textureOut,
+					 0, 0, 0,
+					 (PIPE_BUFFER_USAGE_RENDER_TARGET |
+					  PIPE_BUFFER_USAGE_BLIT_SOURCE |
+					  PIPE_BUFFER_USAGE_BLIT_DESTINATION));
    if (!*surfaceOut) {
       pipe_resource_reference(textureOut, NULL);
       return FALSE;
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index ea17b74..5628080 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -150,7 +150,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
 
    upload->buffer = pipe_buffer_create( upload->pipe->screen,
                                         upload->alignment,
-                                        upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE,
+                                        upload->usage,
                                         size );
    if (upload->buffer == NULL) 
       goto fail;
diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
index 9dcd50c..ecf948f 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -148,7 +148,7 @@ i915_user_buffer_create(struct pipe_screen *screen,
    buf->b.vtbl = &i915_buffer_vtbl;
    buf->b.b.screen = screen;
    buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
-   buf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
+   buf->b.b.usage = usage;
    buf->b.b.width0 = bytes;
    buf->b.b.height0 = 1;
    buf->b.b.depth0 = 1;
diff --git a/src/gallium/drivers/i965/brw_resource_buffer.c b/src/gallium/drivers/i965/brw_resource_buffer.c
index db5883e..2f4a40d 100644
--- a/src/gallium/drivers/i965/brw_resource_buffer.c
+++ b/src/gallium/drivers/i965/brw_resource_buffer.c
@@ -145,7 +145,6 @@ brw_buffer_create(struct pipe_screen *screen,
 
    switch (template->usage & (PIPE_BUFFER_USAGE_VERTEX |
 			      PIPE_BUFFER_USAGE_INDEX |
-			      PIPE_BUFFER_USAGE_PIXEL |
 			      PIPE_BUFFER_USAGE_CONSTANT))
    {
    case PIPE_BUFFER_USAGE_VERTEX:
@@ -154,10 +153,6 @@ brw_buffer_create(struct pipe_screen *screen,
       buffer_type = BRW_BUFFER_TYPE_VERTEX;
       break;
       
-   case PIPE_BUFFER_USAGE_PIXEL:
-      buffer_type = BRW_BUFFER_TYPE_PIXEL;
-      break;
-
    case PIPE_BUFFER_USAGE_CONSTANT:
       buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
       break;
@@ -194,7 +189,7 @@ brw_user_buffer_create(struct pipe_screen *screen,
    buf->b.vtbl = &brw_buffer_vtbl;
    buf->b.b.screen = screen;
    buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
-   buf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
+   buf->b.b.usage = usage;
    buf->b.b.width0 = bytes;
    buf->b.b.height0 = 1;
    buf->b.b.depth0 = 1;
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index a8aab15..36b5613 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -398,10 +398,14 @@ static boolean
 lp_scene_map_buffers( struct lp_scene *scene )
 {
    struct pipe_surface *cbuf, *zsbuf;
+   unsigned usage;
    int i;
 
    LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
 
+   /* XXX: try to improve on this:
+    */
+   usage = PIPE_TRANSFER_READ_WRITE;
 
    /* Map all color buffers 
     */
@@ -409,9 +413,10 @@ lp_scene_map_buffers( struct lp_scene *scene )
       cbuf = scene->fb.cbufs[i];
       if (cbuf) {
 	 scene->cbuf_map[i] = llvmpipe_resource_map(cbuf->texture,
-	                                           cbuf->face,
-                                                   cbuf->level,
-                                                   cbuf->zslice);
+						    usage,
+						    cbuf->face,
+						    cbuf->level,
+						    cbuf->zslice);
 	 if (!scene->cbuf_map[i])
 	    goto fail;
       }
@@ -422,9 +427,10 @@ lp_scene_map_buffers( struct lp_scene *scene )
    zsbuf = scene->fb.zsbuf;
    if (zsbuf) {
       scene->zsbuf_map = llvmpipe_resource_map(zsbuf->texture,
-                                              zsbuf->face,
-                                              zsbuf->level,
-                                              zsbuf->zslice);
+					       usage,
+					       zsbuf->face,
+					       zsbuf->level,
+					       zsbuf->zslice);
       if (!scene->zsbuf_map)
 	 goto fail;
    }
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 7080a0a..1231a31 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -492,7 +492,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
             struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen);
             struct sw_winsys *winsys = screen->winsys;
             jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt,
-                                                      PIPE_BUFFER_USAGE_CPU_READ);
+							 PIPE_TRANSFER_READ);
             jit_tex->row_stride[0] = lp_tex->stride[0];
             assert(jit_tex->data[0]);
          }
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 9c1651d..eaf1f90 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -172,9 +172,10 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
  */
 void *
 llvmpipe_resource_map(struct pipe_resource *texture,
-                     unsigned face,
-                     unsigned level,
-                     unsigned zslice)
+		      unsigned usage,
+		      unsigned face,
+		      unsigned level,
+		      unsigned zslice)
 {
    struct llvmpipe_resource *lpt = llvmpipe_resource(texture);
    uint8_t *map;
@@ -183,7 +184,6 @@ llvmpipe_resource_map(struct pipe_resource *texture,
       /* display target */
       struct llvmpipe_screen *screen = llvmpipe_screen(texture->screen);
       struct sw_winsys *winsys = screen->winsys;
-      const unsigned usage = PIPE_BUFFER_USAGE_CPU_READ_WRITE;
 
       assert(face == 0);
       assert(level == 0);
@@ -259,7 +259,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
                          unsigned face, unsigned level, unsigned zslice,
                          unsigned usage)
 {
-   struct llvmpipe_resource *lpt = llvmpipe_resource(pt);
    struct pipe_surface *ps;
 
    assert(level <= pt->last_level);
@@ -273,26 +272,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
       ps->height = u_minify(pt->height0, level);
       ps->usage = usage;
 
-      /* Because we are llvmpipe, anything that the state tracker
-       * thought was going to be done with the GPU will actually get
-       * done with the CPU.  Let's adjust the flags to take that into
-       * account.
-       */
-      if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
-         /* GPU_WRITE means "render" and that can involve reads (blending) */
-         ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ;
-      }
-
-      if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
-         ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
-
-      if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
-                       PIPE_BUFFER_USAGE_GPU_WRITE)) {
-         /* Mark the surface as dirty. */
-         lpt->timestamp++;
-         llvmpipe_screen(screen)->timestamp++;
-      }
-
       ps->face = face;
       ps->level = level;
       ps->zslice = zslice;
@@ -382,6 +361,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
                           FALSE); /* do_not_flush */
 
    map = llvmpipe_resource_map(transfer->resource,
+			       transfer->usage,
 			       transfer->sr.face,
 			       transfer->sr.level,
 			       transfer->box.z);
@@ -448,7 +428,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen,
    pipe_reference_init(&buffer->base.reference, 1);
    buffer->base.screen = screen;
    buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
-   buffer->base.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
+   buffer->base.usage = usage;
    buffer->base.width0 = bytes;
    buffer->base.height0 = 1;
    buffer->base.depth0 = 1;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h
index ca67b5b..54c9377 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.h
+++ b/src/gallium/drivers/llvmpipe/lp_texture.h
@@ -111,9 +111,10 @@ llvmpipe_resource_stride(struct pipe_resource *texture,
 
 void *
 llvmpipe_resource_map(struct pipe_resource *texture,
-                     unsigned face,
-                     unsigned level,
-                     unsigned zslice);
+		      unsigned usage,
+		      unsigned face,
+		      unsigned level,
+		      unsigned zslice);
 
 void
 llvmpipe_resource_unmap(struct pipe_resource *texture,
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index e24c46b..a2250cc 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -189,26 +189,6 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
       ps->offset = spt->level_offset[level];
       ps->usage = usage;
 
-      /* Because we are softpipe, anything that the state tracker
-       * thought was going to be done with the GPU will actually get
-       * done with the CPU.  Let's adjust the flags to take that into
-       * account.
-       */
-      if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
-         /* GPU_WRITE means "render" and that can involve reads (blending) */
-         ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ;
-      }
-
-      if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
-         ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
-
-      if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
-                       PIPE_BUFFER_USAGE_GPU_WRITE)) {
-         /* Mark the surface as dirty.  The tile cache will look for this. */
-         spt->timestamp++;
-         softpipe_screen(screen)->timestamp++;
-      }
-
       ps->face = face;
       ps->level = level;
       ps->zslice = zslice;
@@ -397,7 +377,7 @@ softpipe_user_buffer_create(struct pipe_screen *screen,
    pipe_reference_init(&buffer->base.reference, 1);
    buffer->base.screen = screen;
    buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
-   buffer->base.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
+   buffer->base.usage = usage;
    buffer->base.width0 = bytes;
    buffer->base.height0 = 1;
    buffer->base.depth0 = 1;
diff --git a/src/gallium/drivers/svga/svga_cmd.c b/src/gallium/drivers/svga/svga_cmd.c
index d58082c..7b2dfe2 100644
--- a/src/gallium/drivers/svga/svga_cmd.c
+++ b/src/gallium/drivers/svga/svga_cmd.c
@@ -280,7 +280,7 @@ SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
    if(!cmd)
       return PIPE_ERROR_OUT_OF_MEMORY;
 
-   swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_WRITE);
+   swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_WRITE);
    cmd->surfaceFlags = flags;
    cmd->format = format;
 
@@ -366,7 +366,7 @@ SVGA3D_DestroySurface(struct svga_winsys_context *swc,
    if(!cmd)
       return PIPE_ERROR_OUT_OF_MEMORY;
    
-   swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_READ);
+   swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_READ);
    swc->commit(swc);;
    
    return PIPE_OK;
@@ -432,12 +432,12 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
    unsigned surface_flags;
    
    if(transfer == SVGA3D_WRITE_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      region_flags = SVGA_RELOC_READ;
+      surface_flags = SVGA_RELOC_WRITE;
    }
    else if(transfer == SVGA3D_READ_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      region_flags = SVGA_RELOC_WRITE;
+      surface_flags = SVGA_RELOC_READ;
    }
    else {
       assert(0);
@@ -490,12 +490,12 @@ SVGA3D_BufferDMA(struct svga_winsys_context *swc,
    unsigned surface_flags;
    
    if(transfer == SVGA3D_WRITE_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      region_flags = SVGA_RELOC_READ;
+      surface_flags = SVGA_RELOC_WRITE;
    }
    else if(transfer == SVGA3D_READ_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      region_flags = SVGA_RELOC_WRITE;
+      surface_flags = SVGA_RELOC_READ;
    }
    else {
       assert(0);
@@ -585,7 +585,7 @@ SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
 
    cmd->type = type;
 
-   surface_to_surfaceid(swc, surface, &cmd->target, PIPE_BUFFER_USAGE_GPU_WRITE);
+   surface_to_surfaceid(swc, surface, &cmd->target, SVGA_RELOC_WRITE);
 
    swc->commit(swc);
 
@@ -1001,8 +1001,8 @@ SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
    if(!cmd)
       return PIPE_ERROR_OUT_OF_MEMORY;
 
-   surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
-   surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+   surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ);
+   surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE);
    *boxes = (SVGA3dCopyBox*) &cmd[1];
 
    memset(*boxes, 0, boxesSize);
@@ -1044,8 +1044,8 @@ SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
    if(!cmd)
       return PIPE_ERROR_OUT_OF_MEMORY;
 
-   surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
-   surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+   surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ);
+   surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE);
    cmd->boxSrc = *boxSrc;
    cmd->boxDest = *boxDest;
    cmd->mode = mode;
@@ -1374,7 +1374,7 @@ SVGA3D_EndQuery(struct svga_winsys_context *swc,
    cmd->type = type;
 
    swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
-                          PIPE_BUFFER_USAGE_GPU_WRITE);
+                          SVGA_RELOC_WRITE);
 
    swc->commit(swc);
    
@@ -1421,7 +1421,7 @@ SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
    cmd->type = type;
    
    swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
-                          PIPE_BUFFER_USAGE_GPU_WRITE);
+                          SVGA_RELOC_WRITE);
 
    swc->commit(swc);
    
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
index efc84d5..81dd477 100644
--- a/src/gallium/drivers/svga/svga_draw.c
+++ b/src/gallium/drivers/svga/svga_draw.c
@@ -198,7 +198,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
          swc->surface_relocation(swc,
                                  &vdecl[i].array.surfaceId,
                                  vb_handle[i],
-                                 PIPE_BUFFER_USAGE_GPU_READ);
+                                 SVGA_RELOC_READ);
       }
 
       memcpy( prim,
@@ -209,7 +209,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
          swc->surface_relocation(swc,
                                  &prim[i].indexArray.surfaceId,
                                  ib_handle[i],
-                                 PIPE_BUFFER_USAGE_GPU_READ);
+                                 SVGA_RELOC_READ);
          pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL);
       }
       
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index dc01a8c..1e4fbdf 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -52,14 +52,12 @@ static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl,
    void *dst_map = NULL;
 
    dst = pipe_buffer_create( pipe->screen, 32, 
-			     PIPE_BUFFER_USAGE_INDEX |
-			     PIPE_BUFFER_USAGE_CPU_WRITE |
-			     PIPE_BUFFER_USAGE_GPU_READ, 
+			     PIPE_BUFFER_USAGE_INDEX, 
 			     size );
    if (dst == NULL)
       goto fail;
 
-   dst_map = pipe_buffer_map( pipe, dst, PIPE_BUFFER_USAGE_CPU_WRITE,
+   dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE,
 			      &transfer);
    if (dst_map == NULL)
       goto fail;
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index e131686..78c20a8 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -55,18 +55,16 @@ translate_indices( struct svga_hwtnl *hwtnl,
    void *dst_map = NULL;
 
    dst = pipe_buffer_create( pipe->screen, 32, 
-			     PIPE_BUFFER_USAGE_INDEX |
-			     PIPE_BUFFER_USAGE_CPU_WRITE |
-			     PIPE_BUFFER_USAGE_GPU_READ, 
+			     PIPE_BUFFER_USAGE_INDEX, 
 			     size );
    if (dst == NULL)
       goto fail;
 
-   src_map = pipe_buffer_map( pipe, src, PIPE_BUFFER_USAGE_CPU_READ, &src_transfer );
+   src_map = pipe_buffer_map( pipe, src, PIPE_TRANSFER_READ, &src_transfer );
    if (src_map == NULL)
       goto fail;
 
-   dst_map = pipe_buffer_map( pipe, dst, PIPE_BUFFER_USAGE_CPU_WRITE, &dst_transfer );
+   dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer );
    if (dst_map == NULL)
       goto fail;
 
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
index 0439779..9c6f585 100644
--- a/src/gallium/drivers/svga/svga_pipe_query.c
+++ b/src/gallium/drivers/svga/svga_pipe_query.c
@@ -89,7 +89,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe,
     
    sq->queryResult = (SVGA3dQueryResult *)sws->buffer_map(sws, 
                                                           sq->hwbuf, 
-                                                          PIPE_BUFFER_USAGE_CPU_WRITE);
+                                                          PIPE_TRANSFER_WRITE);
    if(!sq->queryResult)
       goto no_query_result;
 
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index b35abc0..445358b 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -336,7 +336,7 @@ svga_user_buffer_create(struct pipe_screen *screen,
    sbuf->b.vtbl = &svga_buffer_vtbl;
    sbuf->b.b.screen = screen;
    sbuf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
-   sbuf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
+   sbuf->b.b.usage = usage;
    sbuf->b.b.width0 = bytes;
    sbuf->b.b.height0 = 1;
    sbuf->b.b.depth0 = 1;
diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c
index 78fda66..31c014e 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c
@@ -182,12 +182,12 @@ svga_buffer_upload_command(struct svga_context *svga,
    struct pipe_resource *dummy;
 
    if(transfer == SVGA3D_WRITE_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_READ;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+      region_flags = SVGA_RELOC_READ;
+      surface_flags = SVGA_RELOC_WRITE;
    }
    else if(transfer == SVGA3D_READ_HOST_VRAM) {
-      region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
-      surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+      region_flags = SVGA_RELOC_WRITE;
+      surface_flags = SVGA_RELOC_READ;
    }
    else {
       assert(0);
@@ -415,7 +415,7 @@ svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf)
          return ret;
 
       pipe_mutex_lock(ss->swc_mutex);
-      map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+      map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_TRANSFER_WRITE);
       assert(map);
       if(!map) {
 	 pipe_mutex_unlock(ss->swc_mutex);
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index a288aa5..5fc8875 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -263,7 +263,7 @@ svga_transfer_dma(struct svga_transfer *st,
                sws->fence_reference(sws, &fence, NULL);
             }
 
-            hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+            hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_WRITE);
             assert(hw);
             if(hw) {
                memcpy(hw, sw, length);
@@ -277,7 +277,7 @@ svga_transfer_dma(struct svga_transfer *st,
             svga_screen_flush(screen, &fence);
             sws->fence_finish(sws, fence, 0);
 
-            hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_READ);
+            hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ);
             assert(hw);
             if(hw) {
                memcpy(sw, hw, length);
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index 5580315..97c818c 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -95,7 +95,7 @@ static int emit_consts( struct svga_context *svga,
 
    data = (const float (*)[4])pipe_buffer_map(&svga->pipe,
                                               svga->curr.cb[unit],
-                                              PIPE_BUFFER_USAGE_CPU_READ,
+                                              PIPE_TRANSFER_READ,
 					      &transfer);
    if (data == NULL) {
       ret = PIPE_ERROR_OUT_OF_MEMORY;
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
index a8d9f6d..76a2dae 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -135,7 +135,7 @@ update_tss_binding(struct svga_context *svga,
             svga->swc->surface_relocation(svga->swc,
                                           &ts[i].value,
                                           queue.bind[i].view->v->handle,
-                                          PIPE_BUFFER_USAGE_GPU_READ);
+                                          SVGA_RELOC_READ);
          }
          else {
             ts[i].value = SVGA3D_INVALID_ID;
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index e9ed0f9..a6215c6 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -224,7 +224,7 @@ static int update_zero_stride( struct svga_context *svga,
                                                vbuffer->buffer,
                                                vel->src_offset,
                                                util_format_get_blocksize(vel->src_format),
-                                               PIPE_BUFFER_USAGE_CPU_READ,
+                                               PIPE_TRANSFER_READ,
 					       &transfer);
 
          translate->set_buffer(translate, vel->vertex_buffer_index,
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index 6051eb4..2547406 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -210,7 +210,8 @@ svga_get_tex_surface(struct pipe_screen *screen,
 {
    struct svga_texture *tex = svga_texture(pt);
    struct svga_surface *s;
-   boolean render = flags & PIPE_BUFFER_USAGE_GPU_WRITE ? TRUE : FALSE;
+   boolean render = (flags & (PIPE_BUFFER_USAGE_RENDER_TARGET |
+			      PIPE_BUFFER_USAGE_DEPTH_STENCIL)) ? TRUE : FALSE;
    boolean view = FALSE;
    SVGA3dSurfaceFormat format;
 
@@ -234,8 +235,6 @@ svga_get_tex_surface(struct pipe_screen *screen,
       format = svga_translate_format_render(pt->format);
 
    assert(format != SVGA3D_FORMAT_INVALID);
-   assert(!(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
-
 
    if (svga_screen(screen)->debug.force_surface_view)
       view = TRUE;
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index ee12c9a..0037bbd 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -69,7 +69,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
    for (i = 0; i < svga->curr.num_vertex_buffers; i++) {
       map = pipe_buffer_map(&svga->pipe,
                             svga->curr.vb[i].buffer,
-                            PIPE_BUFFER_USAGE_CPU_READ,
+                            PIPE_TRANSFER_READ,
 			    &vb_transfer[i]);
 
       draw_set_mapped_vertex_buffer(draw, i, map);
@@ -78,7 +78,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
    /* Map index buffer, if present */
    if (indexBuffer) {
       map = pipe_buffer_map(&svga->pipe, indexBuffer,
-                            PIPE_BUFFER_USAGE_CPU_READ,
+                            PIPE_TRANSFER_READ,
 			    &ib_transfer);
 
       draw_set_mapped_element_buffer_range(draw, 
@@ -91,7 +91,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
    if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
       map = pipe_buffer_map(&svga->pipe,
                             svga->curr.cb[PIPE_SHADER_VERTEX],
-                            PIPE_BUFFER_USAGE_CPU_READ,
+                            PIPE_TRANSFER_READ,
 			    &cb_transfer);
       assert(map);
       draw_set_mapped_constant_buffer(
diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h
index 225c2ba..dc4888b 100644
--- a/src/gallium/drivers/svga/svga_winsys.h
+++ b/src/gallium/drivers/svga/svga_winsys.h
@@ -58,6 +58,11 @@ struct winsys_handle;
 #define SVGA_BUFFER_USAGE_WRAPPED (PIPE_BUFFER_USAGE_CUSTOM << 1)
 
 
+#define SVGA_RELOC_WRITE 0x1
+#define SVGA_RELOC_READ  0x2
+
+
+
 /** Opaque surface handle */
 struct svga_winsys_surface;
 
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 62e1401..e315409 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -287,19 +287,22 @@ enum pipe_transfer_usage {
 
 
 /*
- * Buffer usage flags
+ * Resource usage flags -- state tracker must specify in advance all
+ * the ways a resource might be used.  
+ *
+ * XXX: add a method to extend the flags?
  */
 
-#define PIPE_BUFFER_USAGE_CPU_READ  (1 << 0)
-#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1)
-#define PIPE_BUFFER_USAGE_GPU_READ  (1 << 2)
-#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3)
-#define PIPE_BUFFER_USAGE_PIXEL     (1 << 4)
-#define PIPE_BUFFER_USAGE_VERTEX    (1 << 5)
-#define PIPE_BUFFER_USAGE_INDEX     (1 << 6)
-#define PIPE_BUFFER_USAGE_CONSTANT  (1 << 7)
+#define PIPE_BUFFER_USAGE_DEPTH_STENCIL (1 << 0)
+#define PIPE_BUFFER_USAGE_RENDER_TARGET (1 << 1)
+#define PIPE_BUFFER_USAGE_SAMPLER       (1 << 2)
+#define PIPE_BUFFER_USAGE_VERTEX        (1 << 3)
+#define PIPE_BUFFER_USAGE_INDEX         (1 << 4)
+#define PIPE_BUFFER_USAGE_CONSTANT      (1 << 5)
+#define PIPE_BUFFER_USAGE_BLIT_SOURCE    (1 << 6) /* will go away */
+#define PIPE_BUFFER_USAGE_BLIT_DESTINATION (1 << 7) /* will go away */
 
-#define PIPE_BUFFER_USAGE_CUSTOM    (1 << 16)
+#define PIPE_BUFFER_USAGE_CUSTOM        (1 << 16)
 
 /* Convenient shortcuts */
 #define PIPE_BUFFER_USAGE_CPU_READ_WRITE \
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index 01c9896..6400f1f 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -98,7 +98,7 @@ static INLINE struct pipe_surface * setup_framebuffer(struct vg_image *dst)
    struct pipe_framebuffer_state fb;
    struct pipe_surface *dst_surf = pipe->screen->get_tex_surface(
       pipe->screen, dst->texture, 0, 0, 0,
-      PIPE_BUFFER_USAGE_GPU_WRITE);
+      PIPE_BUFFER_USAGE_RENDER_TARGET);
 
    /* drawing dest */
    memset(&fb, 0, sizeof(fb));
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c
index 2f55d80..ba3397f 100644
--- a/src/gallium/state_trackers/vega/image.c
+++ b/src/gallium/state_trackers/vega/image.c
@@ -567,7 +567,7 @@ void image_set_pixels(VGint dx, VGint dy,
    pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 
    surf = screen->get_tex_surface(screen, image_texture(src),  0, 0, 0,
-                                  PIPE_BUFFER_USAGE_GPU_READ);
+                                  PIPE_BUFFER_USAGE_BLIT_SOURCE);
 
    vg_copy_surface(ctx, strb->surface, dx, dy,
                    surf, sx+src->x, sy+src->y, width, height);
@@ -592,8 +592,8 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy,
    pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 
    surf = screen->get_tex_surface(screen, image_texture(dst),  0, 0, 0,
-                                  PIPE_BUFFER_USAGE_GPU_WRITE |
-                                  PIPE_BUFFER_USAGE_GPU_READ);
+                                  PIPE_BUFFER_USAGE_BLIT_SOURCE);
+
    vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy,
                    strb->surface, sx, sy, width, height);
 
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index 379e46b..5f097e7 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -418,7 +418,7 @@ static void mask_using_texture(struct pipe_resource *texture,
 {
    struct vg_context *ctx = vg_current_context();
    struct pipe_surface *surface =
-      alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_GPU_WRITE);
+      alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_RENDER_TARGET);
    VGint offsets[4], loc[4];
 
    if (!surface)
@@ -654,7 +654,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height,
    struct vg_context *ctx = vg_current_context();
    VGfloat alpha_color[4] = {.0f, .0f, .0f, value};
    struct pipe_surface *surf = alpha_mask_surface(
-      ctx, PIPE_BUFFER_USAGE_GPU_WRITE);
+      ctx, PIPE_BUFFER_USAGE_RENDER_TARGET);
 
 #if DEBUG_MASKS
    debug_printf("mask_fill(%d, %d, %d, %d) with  rgba(%f, %f, %f, %f)\n",
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index 415dd5e..05897c0 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -278,7 +278,7 @@ void renderer_copy_texture(struct renderer *ctx,
    struct pipe_resource *buf;
    struct pipe_surface *dst_surf = screen->get_tex_surface(
       screen, dst, 0, 0, 0,
-      PIPE_BUFFER_USAGE_GPU_WRITE);
+      PIPE_BUFFER_USAGE_RENDER_TARGET);
    struct pipe_framebuffer_state fb;
    float s0, t0, s1, t1;
 
@@ -461,7 +461,7 @@ void renderer_copy_surface(struct renderer *ctx,
       return;
 
    texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
-                                     PIPE_BUFFER_USAGE_GPU_WRITE);
+                                     PIPE_BUFFER_USAGE_RENDER_TARGET);
 
    /* load temp texture */
    if (pipe->surface_copy) {
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 49ddb34..887fd35 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -442,7 +442,8 @@ void vg_prepare_blend_surface(struct vg_context *ctx)
    dest_surface = pipe->screen->get_tex_surface(pipe->screen,
                                                 stfb->blend_texture,
                                                 0, 0, 0,
-                                                PIPE_BUFFER_USAGE_GPU_WRITE);
+                                                PIPE_BUFFER_USAGE_BLIT_DESTINATION |
+						PIPE_BUFFER_USAGE_RENDER_TARGET);
    /* flip it, because we want to use it as a sampler */
    util_blit_pixels_tex(ctx->blit,
                         strb->texture,
@@ -476,7 +477,8 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx)
    dest_surface = pipe->screen->get_tex_surface(pipe->screen,
                                                 stfb->blend_texture,
                                                 0, 0, 0,
-                                                PIPE_BUFFER_USAGE_GPU_WRITE);
+                                                PIPE_BUFFER_USAGE_BLIT_DESTINATION |
+						PIPE_BUFFER_USAGE_RENDER_TARGET);
 
    /* flip it, because we want to use it as a sampler */
    util_blit_pixels_tex(ctx->blit,
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index 4e59216..658ef03 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -112,8 +112,9 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx,
 
    /* Probably need dedicated flags for surface usage too:
     */
-   surface_usage = (PIPE_BUFFER_USAGE_GPU_READ  |
-                    PIPE_BUFFER_USAGE_GPU_WRITE);
+   surface_usage = (PIPE_BUFFER_USAGE_RENDER_TARGET  |
+                    PIPE_BUFFER_USAGE_BLIT_SOURCE |
+		    PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
    strb->texture = create_texture(pipe, strb->format,
                                   width, height);
@@ -233,12 +234,13 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
          pipe->screen,
          stfb->alpha_mask,
          0, 0, 0,
-         PIPE_BUFFER_USAGE_GPU_WRITE);
+         PIPE_BUFFER_USAGE_RENDER_TARGET |
+	 PIPE_BUFFER_USAGE_BLIT_DESTINATION);
       struct pipe_surface *old_surface = pipe->screen->get_tex_surface(
          pipe->screen,
          old_texture,
          0, 0, 0,
-         PIPE_BUFFER_USAGE_GPU_READ);
+         PIPE_BUFFER_USAGE_BLIT_SOURCE);
       if (pipe->surface_copy) {
          pipe->surface_copy(pipe,
                             surface,
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 764ccc8..ff71547 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -75,8 +75,9 @@ update_renderbuffer_surface(struct st_context *st,
 						    strb->rtt_face,
 						    level,
 						    strb->rtt_slice,
-						    PIPE_BUFFER_USAGE_GPU_READ |
-						    PIPE_BUFFER_USAGE_GPU_WRITE);
+						    PIPE_BUFFER_USAGE_RENDER_TARGET |
+						    PIPE_BUFFER_USAGE_BLIT_SOURCE |
+						    PIPE_BUFFER_USAGE_BLIT_DESTINATION );
 #if 0
             printf("-- alloc new surface %d x %d into tex %p\n",
                    strb->surface->width, strb->surface->height,
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 36e0301..55821fb 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -127,7 +127,7 @@ st_BlitFramebuffer(GLcontext *ctx,
                                            srcAtt->CubeMapFace,
                                            srcAtt->TextureLevel,
                                            srcAtt->Zoffset,
-                                           PIPE_BUFFER_USAGE_GPU_READ);
+                                           PIPE_BUFFER_USAGE_BLIT_SOURCE);
          if(!srcSurf)
             return;
 
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 554b756..d90ddf0 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -194,7 +194,9 @@ st_bufferobj_data(GLcontext *ctx,
    switch(target) {
    case GL_PIXEL_PACK_BUFFER_ARB:
    case GL_PIXEL_UNPACK_BUFFER_ARB:
-      buffer_usage = PIPE_BUFFER_USAGE_PIXEL;
+      buffer_usage = (PIPE_BUFFER_USAGE_RENDER_TARGET |
+		      PIPE_BUFFER_USAGE_BLIT_SOURCE |
+		      PIPE_BUFFER_USAGE_BLIT_DESTINATION);
       break;
    case GL_ARRAY_BUFFER_ARB:
       buffer_usage = PIPE_BUFFER_USAGE_VERTEX;
@@ -239,15 +241,14 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
 
    switch (access) {
    case GL_WRITE_ONLY:
-      flags = PIPE_BUFFER_USAGE_CPU_WRITE;
+      flags = PIPE_TRANSFER_WRITE;
       break;
    case GL_READ_ONLY:
-      flags = PIPE_BUFFER_USAGE_CPU_READ;
+      flags = PIPE_TRANSFER_READ;
       break;
    case GL_READ_WRITE:
-      /* fall-through */
    default:
-      flags = PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
+      flags = PIPE_TRANSFER_READ_WRITE;
       break;      
    }
 
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 5b168e9..8e59fca 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1075,9 +1075,10 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       /* copy source framebuffer surface into mipmap/texture */
       struct pipe_surface *psRead = screen->get_tex_surface(screen,
                                        rbRead->texture, 0, 0, 0,
-                                       PIPE_BUFFER_USAGE_GPU_READ);
+                                       PIPE_BUFFER_USAGE_BLIT_SOURCE);
       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
-                                      PIPE_BUFFER_USAGE_GPU_WRITE );
+				       PIPE_BUFFER_USAGE_RENDER_TARGET |
+				       PIPE_BUFFER_USAGE_BLIT_DESTINATION);
       if (pipe->surface_copy) {
          pipe->surface_copy(pipe,
                             psTex, /* dest */
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index f15ff3c..b27c663 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -124,12 +124,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
       /* Probably need dedicated flags for surface usage too: 
        */
-      surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
-                       PIPE_BUFFER_USAGE_GPU_WRITE);
-#if 0
-                       PIPE_BUFFER_USAGE_CPU_READ |
-                       PIPE_BUFFER_USAGE_CPU_WRITE);
-#endif
+      surface_usage = template.tex_usage;
 
       strb->texture = screen->resource_create(screen, &template);
 
@@ -376,8 +371,7 @@ st_render_texture(GLcontext *ctx,
                                            strb->rtt_face,
                                            strb->rtt_level,
                                            strb->rtt_slice,
-                                           PIPE_BUFFER_USAGE_GPU_READ |
-                                           PIPE_BUFFER_USAGE_GPU_WRITE);
+                                           PIPE_BUFFER_USAGE_RENDER_TARGET);
 
    strb->format = pt->format;
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 7b44d3f..b9d3229 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -392,7 +392,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_BUFFER_USAGE_GPU_WRITE);
+                                         PIPE_BUFFER_USAGE_BLIT_DESTINATION);
    if (!dst_surface) {
       /* can't render into this format (or other problem) */
       return GL_FALSE;
@@ -1554,7 +1554,7 @@ st_copy_texsubimage(GLcontext *ctx,
          dest_surface = screen->get_tex_surface(screen, stImage->pt,
                                                 stImage->face, stImage->level,
                                                 destZ,
-                                                PIPE_BUFFER_USAGE_GPU_WRITE);
+                                                PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
          /* for surface_copy(), y=0=top, always */
          pipe->surface_copy(pipe,
@@ -1585,7 +1585,7 @@ st_copy_texsubimage(GLcontext *ctx,
          dest_surface = screen->get_tex_surface(screen, stImage->pt,
                                                 stImage->face, stImage->level,
                                                 destZ,
-                                                PIPE_BUFFER_USAGE_GPU_WRITE);
+                                                PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
          if (do_flip) {
             srcY1 = strb->Base.Height - srcY - height;
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index b590073..3335e26 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -196,7 +196,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
 
       /* map the attrib buffer */
       map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
-                            PIPE_BUFFER_USAGE_CPU_READ,
+                            PIPE_TRANSFER_READ,
 			    &vb_transfer[attr]);
       draw_set_mapped_vertex_buffer(draw, attr, map);
    }
@@ -227,7 +227,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
          index_buffer_handle = stobj->buffer;
 
          map = pipe_buffer_map(pipe, index_buffer_handle,
-                               PIPE_BUFFER_USAGE_CPU_READ, &ib_transfer);
+                               PIPE_TRANSFER_READ, &ib_transfer);
 
          draw_set_mapped_element_buffer(draw, indexSize, map);
       }
@@ -245,7 +245,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
    /* map constant buffers */
    mapped_constants = pipe_buffer_map(pipe,
                                       st->state.constants[PIPE_SHADER_VERTEX],
-                                      PIPE_BUFFER_USAGE_CPU_READ,
+                                      PIPE_TRANSFER_READ,
 				      &cb_transfer);
    draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0,
                                    mapped_constants,
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 9933e05..fea815d 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -337,10 +337,10 @@ st_texture_image_copy(struct pipe_context *pipe,
 #endif
 
       dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
-                                            PIPE_BUFFER_USAGE_GPU_WRITE);
+                                            PIPE_BUFFER_USAGE_BLIT_DESTINATION);
 
       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
-                                            PIPE_BUFFER_USAGE_GPU_READ);
+                                            PIPE_BUFFER_USAGE_BLIT_SOURCE);
 
       if (pipe->surface_copy) {
          pipe->surface_copy(pipe,
@@ -533,8 +533,9 @@ st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
    pipe_resource_reference(&strb->texture, stImage->pt);
    strb->surface = screen->get_tex_surface(screen, strb->texture,
                                            face, level, slice,
-                                           (PIPE_BUFFER_USAGE_GPU_READ |
-                                            PIPE_BUFFER_USAGE_GPU_WRITE));
+                                           (PIPE_BUFFER_USAGE_RENDER_TARGET |
+                                            PIPE_BUFFER_USAGE_BLIT_SOURCE |
+					    PIPE_BUFFER_USAGE_BLIT_DESTINATION));
 
    st->dirty.st |= ST_NEW_FRAMEBUFFER;
 



More information about the mesa-commit mailing list