gallium: unify transfer functions
authorMarek Olšák <maraeo@gmail.com>
Mon, 8 Oct 2012 02:06:42 +0000 (04:06 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 11 Oct 2012 19:12:16 +0000 (21:12 +0200)
"get_transfer + transfer_map" becomes "transfer_map".
"transfer_unmap + transfer_destroy" becomes "transfer_unmap".

transfer_map must create and return the transfer object and transfer_unmap
must destroy it.

transfer_map is successful if the returned buffer pointer is not NULL.
If transfer_map fails, the pointer to the transfer object remains unchanged
(i.e. doesn't have to be NULL).

Acked-by: Brian Paul <brianp@vmware.com>
103 files changed:
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/util/u_debug.c
src/gallium/auxiliary/util/u_debug.h
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/util/u_pstipple.c
src/gallium/auxiliary/util/u_resource.c
src/gallium/auxiliary/util/u_slab.h
src/gallium/auxiliary/util/u_surface.c
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h
src/gallium/auxiliary/util/u_transfer.c
src/gallium/auxiliary/util/u_transfer.h
src/gallium/auxiliary/util/u_upload_mgr.c
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_zscan.c
src/gallium/docs/source/context.rst
src/gallium/drivers/galahad/glhd_context.c
src/gallium/drivers/galahad/glhd_objects.c
src/gallium/drivers/i915/i915_resource.c
src/gallium/drivers/i915/i915_resource_buffer.c
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/identity/id_objects.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/noop/noop_pipe.c
src/gallium/drivers/nouveau/nouveau_buffer.c
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_resource.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_resource.c
src/gallium/drivers/nv50/nv50_resource.h
src/gallium/drivers/nv50/nv50_transfer.c
src/gallium/drivers/nvc0/nvc0_miptree.c
src/gallium/drivers/nvc0/nvc0_resource.c
src/gallium/drivers/nvc0/nvc0_resource.h
src/gallium/drivers/nvc0/nvc0_transfer.c
src/gallium/drivers/r300/r300_resource.c
src/gallium/drivers/r300/r300_screen_buffer.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_transfer.c
src/gallium/drivers/r300/r300_transfer.h
src/gallium/drivers/r600/compute_memory_pool.c
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/r600/evergreen_compute.h
src/gallium/drivers/r600/r600_buffer.c
src/gallium/drivers/r600/r600_resource.c
src/gallium/drivers/r600/r600_resource.h
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeonsi/r600_buffer.c
src/gallium/drivers/radeonsi/r600_resource.c
src/gallium/drivers/radeonsi/r600_texture.c
src/gallium/drivers/rbug/rbug_context.c
src/gallium/drivers/rbug/rbug_core.c
src/gallium/drivers/rbug/rbug_objects.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_flush.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_tile_cache.c
src/gallium/drivers/softpipe/sp_tile_cache.h
src/gallium/drivers/svga/svga_resource.c
src/gallium/drivers/svga/svga_resource_buffer.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_swtnl_backend.c
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_texture.c
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/clover/core/resource.cpp
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
src/gallium/state_trackers/dri/sw/drisw.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/vdpau/output.c
src/gallium/state_trackers/vdpau/surface.c
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/api_images.c
src/gallium/state_trackers/vega/image.c
src/gallium/state_trackers/vega/paint.c
src/gallium/state_trackers/xa/xa_context.c
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_xv.c
src/gallium/state_trackers/xvmc/subpicture.c
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/graw_util.h
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/quad-sample.c
src/gallium/tests/graw/vs-test.c
src/gallium/tests/trivial/quad-tex.c
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.c

index d6b981195b220f02884fa8511e3e96522861922a..b6c328b2db91dd9c8cda15042251ddc5b01029af 100644 (file)
@@ -451,13 +451,12 @@ aaline_create_texture(struct aaline_stage *aaline)
 
       /* This texture is new, no need to flush. 
        */
-      transfer = pipe->get_transfer(pipe,
-                                    aaline->texture,
-                                    level,
-                                    PIPE_TRANSFER_WRITE,
-                                    &box);
+      data = pipe->transfer_map(pipe,
+                                aaline->texture,
+                                level,
+                                PIPE_TRANSFER_WRITE,
+                                &box, &transfer);
 
-      data = pipe->transfer_map(pipe, transfer);
       if (data == NULL)
          return FALSE;
 
@@ -482,7 +481,6 @@ aaline_create_texture(struct aaline_stage *aaline)
 
       /* unmap */
       pipe->transfer_unmap(pipe, transfer);
-      pipe->transfer_destroy(pipe, transfer);
    }
    return TRUE;
 }
index 842f6eeba22435ddadf9391d4bb8c2b2d5aa10a2..e4c5e733768ac02eb3128b19cd9996906181e02e 100644 (file)
@@ -396,9 +396,8 @@ pstip_update_texture(struct pstip_stage *pstip)
    uint i, j;
    ubyte *data;
 
-   transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0,
-                                PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
-   data = pipe->transfer_map(pipe, transfer);
+   data = pipe_transfer_map(pipe, pstip->texture, 0, 0,
+                                PIPE_TRANSFER_WRITE, 0, 0, 32, 32, &transfer);
 
    /*
     * Load alpha texture.
@@ -421,7 +420,6 @@ pstip_update_texture(struct pstip_stage *pstip)
 
    /* unmap */
    pipe->transfer_unmap(pipe, transfer);
-   pipe->transfer_destroy(pipe, transfer);
 }
 
 
index bf98f222ec092b445a0389c6e378473832bb9832..fd9e28ac0265c5562f6026eb5f0429fd8a07fabf 100644 (file)
@@ -516,14 +516,12 @@ void debug_dump_surface(struct pipe_context *pipe,
     */
    texture = surface->texture;
 
-   transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level,
-                                surface->u.tex.first_layer,
-                                PIPE_TRANSFER_READ,
-                                0, 0, surface->width, surface->height);
-
-   data = pipe->transfer_map(pipe, transfer);
+   data = pipe_transfer_map(pipe, texture, surface->u.tex.level,
+                            surface->u.tex.first_layer,
+                            PIPE_TRANSFER_READ,
+                            0, 0, surface->width, surface->height, &transfer);
    if(!data)
-      goto error;
+      return;
 
    debug_dump_image(prefix,
                     texture->format,
@@ -534,8 +532,6 @@ void debug_dump_surface(struct pipe_context *pipe,
                     data);
 
    pipe->transfer_unmap(pipe, transfer);
-error:
-   pipe->transfer_destroy(pipe, transfer);
 }
 
 
@@ -597,20 +593,21 @@ debug_dump_surface_bmp(struct pipe_context *pipe,
 {
    struct pipe_transfer *transfer;
    struct pipe_resource *texture = surface->texture;
+   void *ptr;
 
-   transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level,
-                                surface->u.tex.first_layer, PIPE_TRANSFER_READ,
-                                0, 0, surface->width, surface->height);
+   ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level,
+                           surface->u.tex.first_layer, PIPE_TRANSFER_READ,
+                           0, 0, surface->width, surface->height, &transfer);
 
-   debug_dump_transfer_bmp(pipe, filename, transfer);
+   debug_dump_transfer_bmp(pipe, filename, transfer, ptr);
 
-   pipe->transfer_destroy(pipe, transfer);
+   pipe->transfer_unmap(pipe, transfer);
 }
 
 void
 debug_dump_transfer_bmp(struct pipe_context *pipe,
                         const char *filename,
-                        struct pipe_transfer *transfer)
+                        struct pipe_transfer *transfer, void *ptr)
 {
    float *rgba;
 
@@ -624,7 +621,7 @@ debug_dump_transfer_bmp(struct pipe_context *pipe,
    if(!rgba)
       goto error1;
 
-   pipe_get_tile_rgba(pipe, transfer, 0, 0,
+   pipe_get_tile_rgba(pipe, transfer, ptr, 0, 0,
                       transfer->box.width, transfer->box.height,
                       rgba);
 
index 06470f66af15e847251dbe7d13c17835fa49e8a0..ec7d4a07a8c803af6efce1b63772d1545c4f804c 100644 (file)
@@ -433,7 +433,7 @@ void debug_dump_surface_bmp(struct pipe_context *pipe,
                             struct pipe_surface *surface);
 void debug_dump_transfer_bmp(struct pipe_context *pipe,
                              const char *filename,
-                             struct pipe_transfer *transfer);
+                             struct pipe_transfer *transfer, void *ptr);
 void debug_dump_float_rgba_bmp(const char *filename,
                                unsigned width, unsigned height,
                                float *rgba, unsigned stride);
@@ -441,7 +441,7 @@ void debug_dump_float_rgba_bmp(const char *filename,
 #define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
 #define debug_dump_surface(pipe, prefix, surface) ((void)0)
 #define debug_dump_surface_bmp(pipe, filename, surface) ((void)0)
-#define debug_dump_transfer_bmp(filename, transfer) ((void)0)
+#define debug_dump_transfer_bmp(filename, transfer, ptr) ((void)0)
 #define debug_dump_float_rgba_bmp(filename, width, height, rgba, stride) ((void)0)
 #endif
 
index c82c52c840ef7af5db69d88ce62d83102e583685..4d8adb9f3551726868d207a6089c8e9d39a12312 100644 (file)
@@ -1111,17 +1111,14 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
       struct pipe_transfer *srcTrans, *dstTrans;
       void *srcMap, *dstMap;
 
-      srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer,
-                                   PIPE_TRANSFER_READ, 0, 0,
-                                   u_minify(pt->width0, srcLevel),
-                                   u_minify(pt->height0, srcLevel));
-      dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer,
-                                   PIPE_TRANSFER_WRITE, 0, 0,
-                                   u_minify(pt->width0, dstLevel),
-                                   u_minify(pt->height0, dstLevel));
-
-      srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
-      dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+      srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer,
+                                 PIPE_TRANSFER_READ, 0, 0,
+                                 u_minify(pt->width0, srcLevel),
+                                 u_minify(pt->height0, srcLevel), &srcTrans);
+      dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer,
+                                 PIPE_TRANSFER_WRITE, 0, 0,
+                                 u_minify(pt->width0, dstLevel),
+                                 u_minify(pt->height0, dstLevel), &dstTrans);
 
       reduce_1d(pt->format,
                 srcTrans->box.width, srcMap,
@@ -1129,9 +1126,6 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
 
       pipe->transfer_unmap(pipe, srcTrans);
       pipe->transfer_unmap(pipe, dstTrans);
-
-      pipe->transfer_destroy(pipe, srcTrans);
-      pipe->transfer_destroy(pipe, dstTrans);
    }
 }
 
@@ -1152,17 +1146,14 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
       struct pipe_transfer *srcTrans, *dstTrans;
       ubyte *srcMap, *dstMap;
 
-      srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer,
-                                   PIPE_TRANSFER_READ, 0, 0,
-                                   u_minify(pt->width0, srcLevel),
-                                   u_minify(pt->height0, srcLevel));
-      dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer,
-                                   PIPE_TRANSFER_WRITE, 0, 0,
-                                   u_minify(pt->width0, dstLevel),
-                                   u_minify(pt->height0, dstLevel));
-
-      srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
-      dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+      srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer,
+                                 PIPE_TRANSFER_READ, 0, 0,
+                                 u_minify(pt->width0, srcLevel),
+                                 u_minify(pt->height0, srcLevel), &srcTrans);
+      dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer,
+                                 PIPE_TRANSFER_WRITE, 0, 0,
+                                 u_minify(pt->width0, dstLevel),
+                                 u_minify(pt->height0, dstLevel), &dstTrans);
 
       reduce_2d(pt->format,
                 srcTrans->box.width, srcTrans->box.height,
@@ -1172,9 +1163,6 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
 
       pipe->transfer_unmap(pipe, srcTrans);
       pipe->transfer_unmap(pipe, dstTrans);
-
-      pipe->transfer_destroy(pipe, srcTrans);
-      pipe->transfer_destroy(pipe, dstTrans);
    }
 }
 
@@ -1207,15 +1195,12 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
       dst_box.height = u_minify(pt->height0, dstLevel);
       dst_box.depth = u_minify(pt->depth0, dstLevel);
 
-      srcTrans = pipe->get_transfer(pipe, pt, srcLevel,
-                                    PIPE_TRANSFER_READ,
-                                    &src_box);
-      dstTrans = pipe->get_transfer(pipe, pt, dstLevel,
-                                    PIPE_TRANSFER_WRITE,
-                                    &dst_box);
-
-      srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
-      dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+      srcMap = pipe->transfer_map(pipe, pt, srcLevel,
+                                  PIPE_TRANSFER_READ,
+                                  &src_box, &srcTrans);
+      dstMap = pipe->transfer_map(pipe, pt, dstLevel,
+                                  PIPE_TRANSFER_WRITE,
+                                  &dst_box, &dstTrans);
 
       reduce_3d(pt->format,
                 srcTrans->box.width, srcTrans->box.height, srcTrans->box.depth,
@@ -1225,9 +1210,6 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
 
       pipe->transfer_unmap(pipe, srcTrans);
       pipe->transfer_unmap(pipe, dstTrans);
-
-      pipe->transfer_destroy(pipe, srcTrans);
-      pipe->transfer_destroy(pipe, dstTrans);
    }
 }
 
index 033c100edffd0936baf9e91e03a9e4cf8612f15a..5c6e7eb3234a2bae31142d65215c8c05282b30e8 100644 (file)
@@ -251,19 +251,8 @@ pipe_buffer_map_range(struct pipe_context *pipe,
 
    u_box_1d(offset, length, &box);
 
-   *transfer = pipe->get_transfer( pipe,
-                                   buffer,
-                                   0,
-                                   usage,
-                                   &box);
-
-   if (*transfer == NULL)
-      return NULL;
-
-   map = pipe->transfer_map( pipe, *transfer );
+   map = pipe->transfer_map(pipe, buffer, 0, usage, &box, transfer);
    if (map == NULL) {
-      pipe->transfer_destroy( pipe, *transfer );
-      *transfer = NULL;
       return NULL;
    }
 
@@ -285,10 +274,7 @@ static INLINE void
 pipe_buffer_unmap(struct pipe_context *pipe,
                   struct pipe_transfer *transfer)
 {
-   if (transfer) {
-      pipe->transfer_unmap(pipe, transfer);
-      pipe->transfer_destroy(pipe, transfer);
-   }
+   pipe->transfer_unmap(pipe, transfer);
 }
 
 static INLINE void
@@ -397,35 +383,29 @@ pipe_buffer_read(struct pipe_context *pipe,
                                         offset, size,
                                         PIPE_TRANSFER_READ,
                                         &src_transfer);
+   if (!map)
+      return;
 
-   if (map)
-      memcpy(data, map, size);
-
+   memcpy(data, map, size);
    pipe_buffer_unmap(pipe, src_transfer);
 }
 
-static INLINE struct pipe_transfer *
-pipe_get_transfer( struct pipe_context *context,
-                   struct pipe_resource *resource,
-                   unsigned level, unsigned layer,
-                   enum pipe_transfer_usage usage,
-                   unsigned x, unsigned y,
-                   unsigned w, unsigned h)
-{
-   struct pipe_box box;
-   u_box_2d_zslice( x, y, layer, w, h, &box );
-   return context->get_transfer( context,
-                                 resource,
-                                 level,
-                                 usage,
-                                 &box );
-}
-
 static INLINE void *
-pipe_transfer_map( struct pipe_context *context,
-                   struct pipe_transfer *transfer )
+pipe_transfer_map(struct pipe_context *context,
+                  struct pipe_resource *resource,
+                  unsigned level, unsigned layer,
+                  enum pipe_transfer_usage usage,
+                  unsigned x, unsigned y,
+                  unsigned w, unsigned h,
+                  struct pipe_transfer **transfer)
 {
-   return context->transfer_map( context, transfer );
+   struct pipe_box box;
+   u_box_2d_zslice(x, y, layer, w, h, &box);
+   return context->transfer_map(context,
+                                resource,
+                                level,
+                                usage,
+                                &box, transfer);
 }
 
 static INLINE void
@@ -435,14 +415,6 @@ pipe_transfer_unmap( struct pipe_context *context,
    context->transfer_unmap( context, transfer );
 }
 
-
-static INLINE void
-pipe_transfer_destroy( struct pipe_context *context, 
-                       struct pipe_transfer *transfer )
-{
-   context->transfer_destroy(context, transfer);
-}
-
 static INLINE void
 pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                          struct pipe_resource *buf)
index 3a91b1da138fb75afdd2996be1ebd7a1060e7ece..68804ae98c6b932a3b3caf32ad70bf45551b914b 100644 (file)
@@ -69,9 +69,8 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe,
    int i, j;
 
    /* map texture memory */
-   transfer = pipe_get_transfer(pipe, tex, 0, 0,
-                                PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
-   data = pipe->transfer_map(pipe, transfer);
+   data = pipe_transfer_map(pipe, tex, 0, 0,
+                            PIPE_TRANSFER_WRITE, 0, 0, 32, 32, &transfer);
 
    /*
     * Load alpha texture.
@@ -94,7 +93,6 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe,
 
    /* unmap */
    pipe->transfer_unmap(pipe, transfer);
-   pipe->transfer_destroy(pipe, transfer);
 }
 
 
index 50a7cd4d55b0b9356c99cfdf8ebd4d73ad7121e3..a32c4f6dfa897d92be68a4ec9c689e47a34f6eb7 100644 (file)
@@ -24,28 +24,16 @@ void u_resource_destroy_vtbl(struct pipe_screen *screen,
    ur->vtbl->resource_destroy(screen, resource);
 }
 
-struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
-                                          struct pipe_resource *resource,
-                                          unsigned level,
-                                          unsigned usage,
-                                          const struct pipe_box *box)
+void *u_transfer_map_vtbl(struct pipe_context *context,
+                          struct pipe_resource *resource,
+                          unsigned level,
+                          unsigned usage,
+                          const struct pipe_box *box,
+                          struct pipe_transfer **transfer)
 {
    struct u_resource *ur = u_resource(resource);
-   return ur->vtbl->get_transfer(context, resource, level, usage, box);
-}
-
-void u_transfer_destroy_vtbl(struct pipe_context *pipe,
-                             struct pipe_transfer *transfer)
-{
-   struct u_resource *ur = u_resource(transfer->resource);
-   ur->vtbl->transfer_destroy(pipe, transfer);
-}
-
-void *u_transfer_map_vtbl( struct pipe_context *pipe,
-                           struct pipe_transfer *transfer )
-{
-   struct u_resource *ur = u_resource(transfer->resource);
-   return ur->vtbl->transfer_map(pipe, transfer);
+   return ur->vtbl->transfer_map(context, resource, level, usage, box,
+                                 transfer);
 }
 
 void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
index 3ed8b12d35716afd273c54f0c365ad7a2fde054f..29d0252ba1bbd1f2281224facbea28320aeaad4e 100644 (file)
@@ -28,7 +28,7 @@
  * Good for allocations which have very low lifetime and are allocated
  * and freed very often. Use a profiler first to know if it's worth using it!
  *
- * Candidates: get_transfer
+ * Candidates: transfer_map
  *
  * @author Marek Olšák
  */
index 7fd6b36753b54452d1f5abdf62e72d9b1eef7640..304da9070b5ff915d3ec495c6f559bcbd0b5c74c 100644 (file)
@@ -145,27 +145,23 @@ util_resource_copy_region(struct pipe_context *pipe,
    src_format = src->format;
    dst_format = dst->format;
 
-   src_trans = pipe_get_transfer(pipe,
-                                 src,
-                                 src_level,
-                                 src_box->z,
-                                 PIPE_TRANSFER_READ,
-                                 src_box->x, src_box->y, w, h);
-
-   dst_trans = pipe_get_transfer(pipe,
-                                 dst,
-                                 dst_level,
-                                 dst_z,
-                                 PIPE_TRANSFER_WRITE,
-                                 dst_x, dst_y, w, h);
+   src_map = pipe_transfer_map(pipe,
+                               src,
+                               src_level,
+                               src_box->z,
+                               PIPE_TRANSFER_READ,
+                               src_box->x, src_box->y, w, h, &src_trans);
+
+   dst_map = pipe_transfer_map(pipe,
+                               dst,
+                               dst_level,
+                               dst_z,
+                               PIPE_TRANSFER_WRITE,
+                               dst_x, dst_y, w, h, &dst_trans);
 
    assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
    assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
    assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
-
-   src_map = pipe->transfer_map(pipe, src_trans);
-   dst_map = pipe->transfer_map(pipe, dst_trans);
-
    assert(src_map);
    assert(dst_map);
 
@@ -187,9 +183,6 @@ util_resource_copy_region(struct pipe_context *pipe,
 
    pipe->transfer_unmap(pipe, src_trans);
    pipe->transfer_unmap(pipe, dst_trans);
-
-   pipe->transfer_destroy(pipe, src_trans);
-   pipe->transfer_destroy(pipe, dst_trans);
 }
 
 
@@ -219,14 +212,12 @@ util_clear_render_target(struct pipe_context *pipe,
    if (!dst->texture)
       return;
    /* XXX: should handle multiple layers */
-   dst_trans = pipe_get_transfer(pipe,
-                                 dst->texture,
-                                 dst->u.tex.level,
-                                 dst->u.tex.first_layer,
-                                 PIPE_TRANSFER_WRITE,
-                                 dstx, dsty, width, height);
-
-   dst_map = pipe->transfer_map(pipe, dst_trans);
+   dst_map = pipe_transfer_map(pipe,
+                               dst->texture,
+                               dst->u.tex.level,
+                               dst->u.tex.first_layer,
+                               PIPE_TRANSFER_WRITE,
+                               dstx, dsty, width, height, &dst_trans);
 
    assert(dst_map);
 
@@ -237,10 +228,9 @@ util_clear_render_target(struct pipe_context *pipe,
       util_fill_rect(dst_map, dst->texture->format,
                      dst_trans->stride,
                      0, 0, width, height, &uc);
-   }
 
-   pipe->transfer_unmap(pipe, dst_trans);
-   pipe->transfer_destroy(pipe, dst_trans);
+      pipe->transfer_unmap(pipe, dst_trans);
+   }
 }
 
 /**
@@ -270,16 +260,13 @@ util_clear_depth_stencil(struct pipe_context *pipe,
    assert(dst->texture);
    if (!dst->texture)
       return;
-   dst_trans = pipe_get_transfer(pipe,
-                                 dst->texture,
-                                 dst->u.tex.level,
-                                 dst->u.tex.first_layer,
-                                 (need_rmw ? PIPE_TRANSFER_READ_WRITE :
-                                     PIPE_TRANSFER_WRITE),
-                                 dstx, dsty, width, height);
-
-   dst_map = pipe->transfer_map(pipe, dst_trans);
-
+   dst_map = pipe_transfer_map(pipe,
+                               dst->texture,
+                               dst->u.tex.level,
+                               dst->u.tex.first_layer,
+                               (need_rmw ? PIPE_TRANSFER_READ_WRITE :
+                                           PIPE_TRANSFER_WRITE),
+                               dstx, dsty, width, height, &dst_trans);
    assert(dst_map);
 
    if (dst_map) {
@@ -376,8 +363,7 @@ util_clear_depth_stencil(struct pipe_context *pipe,
          assert(0);
          break;
       }
-   }
 
-   pipe->transfer_unmap(pipe, dst_trans);
-   pipe->transfer_destroy(pipe, dst_trans);
+      pipe->transfer_unmap(pipe, dst_trans);
+   }
 }
index 48e73c40ba7c70cb7e678e42f258d4c8fd9a0401..f4b5cad0e6171cc34fc91be75a3370ed12211737 100644 (file)
  * Move raw block of pixels from transfer object to user memory.
  */
 void
-pipe_get_tile_raw(struct pipe_context *pipe,
-                  struct pipe_transfer *pt,
+pipe_get_tile_raw(struct pipe_transfer *pt,
+                  const void *src,
                   uint x, uint y, uint w, uint h,
                   void *dst, int dst_stride)
 {
-   const void *src;
-
    if (dst_stride == 0)
       dst_stride = util_format_get_stride(pt->resource->format, w);
 
    if (u_clip_tile(x, y, &w, &h, &pt->box))
       return;
 
-   src = pipe->transfer_map(pipe, pt);
-   assert(src);
-   if(!src)
-      return;
-
    util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
-
-   pipe->transfer_unmap(pipe, pt);
 }
 
 
@@ -73,12 +64,11 @@ pipe_get_tile_raw(struct pipe_context *pipe,
  * Move raw block of pixels from user memory to transfer object.
  */
 void
-pipe_put_tile_raw(struct pipe_context *pipe,
-                  struct pipe_transfer *pt,
+pipe_put_tile_raw(struct pipe_transfer *pt,
+                  void *dst,
                   uint x, uint y, uint w, uint h,
                   const void *src, int src_stride)
 {
-   void *dst;
    enum pipe_format format = pt->resource->format;
 
    if (src_stride == 0)
@@ -87,14 +77,7 @@ pipe_put_tile_raw(struct pipe_context *pipe,
    if (u_clip_tile(x, y, &w, &h, &pt->box))
       return;
 
-   dst = pipe->transfer_map(pipe, pt);
-   assert(dst);
-   if(!dst)
-      return;
-
    util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0);
-
-   pipe->transfer_unmap(pipe, pt);
 }
 
 
@@ -372,7 +355,7 @@ x32_s8_get_tile_rgba(const unsigned *src,
 
 void
 pipe_tile_raw_to_rgba(enum pipe_format format,
-                      void *src,
+                      const void *src,
                       uint w, uint h,
                       float *dst, unsigned dst_stride)
 {
@@ -419,7 +402,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
 
 void
 pipe_tile_raw_to_unsigned(enum pipe_format format,
-                          void *src,
+                          const void *src,
                           uint w, uint h,
                           unsigned *dst, unsigned dst_stride)
 {
@@ -442,18 +425,18 @@ pipe_tile_raw_to_signed(enum pipe_format format,
 }
 
 void
-pipe_get_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_transfer *pt,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
+                   const void *src,
                    uint x, uint y, uint w, uint h,
                    float *p)
 {
-   pipe_get_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p);
+   pipe_get_tile_rgba_format(pt, src, x, y, w, h, pt->resource->format, p);
 }
 
 
 void
-pipe_get_tile_rgba_format(struct pipe_context *pipe,
-                          struct pipe_transfer *pt,
+pipe_get_tile_rgba_format(struct pipe_transfer *pt,
+                          const void *src,
                           uint x, uint y, uint w, uint h,
                           enum pipe_format format,
                           float *p)
@@ -474,7 +457,7 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe,
       assert((x & 1) == 0);
    }
 
-   pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
 
    pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
 
@@ -483,18 +466,18 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe,
 
 
 void
-pipe_put_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_transfer *pt,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
+                   void *dst,
                    uint x, uint y, uint w, uint h,
                    const float *p)
 {
-   pipe_put_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p);
+   pipe_put_tile_rgba_format(pt, dst, x, y, w, h, pt->resource->format, p);
 }
 
 
 void
-pipe_put_tile_rgba_format(struct pipe_context *pipe,
-                          struct pipe_transfer *pt,
+pipe_put_tile_rgba_format(struct pipe_transfer *pt,
+                          void *dst,
                           uint x, uint y, uint w, uint h,
                           enum pipe_format format,
                           const float *p)
@@ -538,14 +521,14 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe,
                            0, 0, w, h);
    }
 
-   pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
 
    FREE(packed);
 }
 
 void
-pipe_put_tile_i_format(struct pipe_context *pipe,
-                       struct pipe_transfer *pt,
+pipe_put_tile_i_format(struct pipe_transfer *pt,
+                       void *dst,
                        uint x, uint y, uint w, uint h,
                        enum pipe_format format,
                        const int *p)
@@ -566,14 +549,14 @@ pipe_put_tile_i_format(struct pipe_context *pipe,
                         packed, util_format_get_stride(format, w),
                         0, 0, w, h);
 
-   pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
 
    FREE(packed);
 }
 
 void
-pipe_put_tile_ui_format(struct pipe_context *pipe,
-                        struct pipe_transfer *pt,
+pipe_put_tile_ui_format(struct pipe_transfer *pt,
+                        void *dst,
                         uint x, uint y, uint w, uint h,
                         enum pipe_format format,
                         const unsigned int *p)
@@ -594,7 +577,7 @@ pipe_put_tile_ui_format(struct pipe_context *pipe,
                          packed, util_format_get_stride(format, w),
                          0, 0, w, h);
 
-   pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
 
    FREE(packed);
 }
@@ -603,13 +586,13 @@ pipe_put_tile_ui_format(struct pipe_context *pipe,
  * Get a block of Z values, converted to 32-bit range.
  */
 void
-pipe_get_tile_z(struct pipe_context *pipe,
-                struct pipe_transfer *pt,
+pipe_get_tile_z(struct pipe_transfer *pt,
+                const void *src,
                 uint x, uint y, uint w, uint h,
                 uint *z)
 {
    const uint dstStride = w;
-   ubyte *map;
+   const ubyte *map = src;
    uint *pDest = z;
    uint i, j;
    enum pipe_format format = pt->resource->format;
@@ -617,12 +600,6 @@ pipe_get_tile_z(struct pipe_context *pipe,
    if (u_clip_tile(x, y, &w, &h, &pt->box))
       return;
 
-   map = (ubyte *)pipe->transfer_map(pipe, pt);
-   if (!map) {
-      assert(0);
-      return;
-   }
-
    switch (format) {
    case PIPE_FORMAT_Z32_UNORM:
       {
@@ -704,32 +681,24 @@ pipe_get_tile_z(struct pipe_context *pipe,
    default:
       assert(0);
    }
-
-   pipe->transfer_unmap(pipe, pt);
 }
 
 
 void
-pipe_put_tile_z(struct pipe_context *pipe,
-                struct pipe_transfer *pt,
+pipe_put_tile_z(struct pipe_transfer *pt,
+                void *dst,
                 uint x, uint y, uint w, uint h,
                 const uint *zSrc)
 {
    const uint srcStride = w;
    const uint *ptrc = zSrc;
-   ubyte *map;
+   ubyte *map = dst;
    uint i, j;
    enum pipe_format format = pt->resource->format;
 
    if (u_clip_tile(x, y, &w, &h, &pt->box))
       return;
 
-   map = (ubyte *)pipe->transfer_map(pipe, pt);
-   if (!map) {
-      assert(0);
-      return;
-   }
-
    switch (format) {
    case PIPE_FORMAT_Z32_UNORM:
       {
@@ -825,14 +794,12 @@ pipe_put_tile_z(struct pipe_context *pipe,
    default:
       assert(0);
    }
-
-   pipe->transfer_unmap(pipe, pt);
 }
 
 
 void
-pipe_get_tile_ui_format(struct pipe_context *pipe,
-                        struct pipe_transfer *pt,
+pipe_get_tile_ui_format(struct pipe_transfer *pt,
+                        const void *src,
                         uint x, uint y, uint w, uint h,
                         enum pipe_format format,
                         unsigned int *p)
@@ -853,7 +820,7 @@ pipe_get_tile_ui_format(struct pipe_context *pipe,
       assert((x & 1) == 0);
    }
 
-   pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
 
    pipe_tile_raw_to_unsigned(format, packed, w, h, p, dst_stride);
 
@@ -862,8 +829,8 @@ pipe_get_tile_ui_format(struct pipe_context *pipe,
 
 
 void
-pipe_get_tile_i_format(struct pipe_context *pipe,
-                       struct pipe_transfer *pt,
+pipe_get_tile_i_format(struct pipe_transfer *pt,
+                       const void *src,
                        uint x, uint y, uint w, uint h,
                        enum pipe_format format,
                        int *p)
@@ -884,7 +851,7 @@ pipe_get_tile_i_format(struct pipe_context *pipe,
       assert((x & 1) == 0);
    }
 
-   pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+   pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
 
    pipe_tile_raw_to_signed(format, packed, w, h, p, dst_stride);
 
index 926f1695feb190acf203a58f022eb5db09881953..abcd402c8c4d0b7cd460c2a4897b7e1e93471ef4 100644 (file)
@@ -61,66 +61,66 @@ extern "C" {
 #endif
 
 void
-pipe_get_tile_raw(struct pipe_context *pipe,
-                  struct pipe_transfer *pt,
+pipe_get_tile_raw(struct pipe_transfer *pt,
+                  const void *src,
                   uint x, uint y, uint w, uint h,
                   void *p, int dst_stride);
 
 void
-pipe_put_tile_raw(struct pipe_context *pipe,
-                  struct pipe_transfer *pt,
+pipe_put_tile_raw(struct pipe_transfer *pt,
+                  void *dst,
                   uint x, uint y, uint w, uint h,
                   const void *p, int src_stride);
 
 
 void
-pipe_get_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_transfer *pt,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
+                   const void *src,
                    uint x, uint y, uint w, uint h,
                    float *p);
 
 void
-pipe_get_tile_rgba_format(struct pipe_context *pipe,
-                          struct pipe_transfer *pt,
+pipe_get_tile_rgba_format(struct pipe_transfer *pt,
+                          const void *src,
                           uint x, uint y, uint w, uint h,
                           enum pipe_format format,
                           float *p);
 
 void
-pipe_put_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_transfer *pt,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
+                   void *dst,
                    uint x, uint y, uint w, uint h,
                    const float *p);
 
 void
-pipe_put_tile_rgba_format(struct pipe_context *pipe,
-                          struct pipe_transfer *pt,
+pipe_put_tile_rgba_format(struct pipe_transfer *pt,
+                          void *dst,
                           uint x, uint y, uint w, uint h,
                           enum pipe_format format,
                           const float *p);
 
 
 void
-pipe_get_tile_z(struct pipe_context *pipe,
-                struct pipe_transfer *pt,
+pipe_get_tile_z(struct pipe_transfer *pt,
+                const void *src,
                 uint x, uint y, uint w, uint h,
                 uint *z);
 
 void
-pipe_put_tile_z(struct pipe_context *pipe,
-                struct pipe_transfer *pt,
+pipe_put_tile_z(struct pipe_transfer *pt,
+                void *dst,
                 uint x, uint y, uint w, uint h,
                 const uint *z);
 
 void
 pipe_tile_raw_to_rgba(enum pipe_format format,
-                      void *src,
+                      const void *src,
                       uint w, uint h,
                       float *dst, unsigned dst_stride);
 
 void
 pipe_tile_raw_to_unsigned(enum pipe_format format,
-                          void *src,
+                          const void *src,
                           uint w, uint h,
                           unsigned *dst, unsigned dst_stride);
 
@@ -131,29 +131,29 @@ pipe_tile_raw_to_signed(enum pipe_format format,
                         int *dst, unsigned dst_stride);
 
 void
-pipe_get_tile_ui_format(struct pipe_context *pipe,
-                        struct pipe_transfer *pt,
+pipe_get_tile_ui_format(struct pipe_transfer *pt,
+                        const void *src,
                         uint x, uint y, uint w, uint h,
                         enum pipe_format format,
                         unsigned int *p);
 
 void
-pipe_get_tile_i_format(struct pipe_context *pipe,
-                       struct pipe_transfer *pt,
+pipe_get_tile_i_format(struct pipe_transfer *pt,
+                       const void *src,
                        uint x, uint y, uint w, uint h,
                        enum pipe_format format,
                        int *p);
 
 void
-pipe_put_tile_ui_format(struct pipe_context *pipe,
-                        struct pipe_transfer *pt,
+pipe_put_tile_ui_format(struct pipe_transfer *pt,
+                        void *dst,
                         uint x, uint y, uint w, uint h,
                         enum pipe_format format,
                         const unsigned *p);
 
 void
-pipe_put_tile_i_format(struct pipe_context *pipe,
-                       struct pipe_transfer *pt,
+pipe_put_tile_i_format(struct pipe_transfer *pt,
+                       void *dst,
                        uint x, uint y, uint w, uint h,
                        enum pipe_format format,
                        const int *p);
index 0b2679ffdb4c0f10aeaf2be8fbbab3be4b99c0f1..8b4c3659253681917c5a0fb6d9685993d514158e 100644 (file)
@@ -31,17 +31,13 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
       usage |= PIPE_TRANSFER_DISCARD_RANGE;
    }
 
-   transfer = pipe->get_transfer(pipe,
-                                 resource,
-                                 level,
-                                 usage,
-                                 box );
-   if (transfer == NULL)
-      goto out;
-
-   map = pipe_transfer_map(pipe, transfer);
+   map = pipe->transfer_map(pipe,
+                            resource,
+                            level,
+                            usage,
+                            box, &transfer);
    if (map == NULL)
-      goto out;
+      return;
 
    if (resource->target == PIPE_BUFFER) {
       assert(box->height == 1);
@@ -68,12 +64,7 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
       }
    }
 
-out:
-   if (map)
-      pipe_transfer_unmap(pipe, transfer);
-
-   if (transfer)
-      pipe_transfer_destroy(pipe, transfer);
+   pipe_transfer_unmap(pipe, transfer);
 }
 
 
@@ -94,34 +85,7 @@ void u_default_transfer_flush_region( struct pipe_context *pipe,
     */
 }
 
-struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
-                                              struct pipe_resource *resource,
-                                              unsigned level,
-                                              unsigned usage,
-                                              const struct pipe_box *box)
-{
-   struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
-   if (transfer == NULL)
-      return NULL;
-
-   transfer->resource = resource;
-   transfer->level = level;
-   transfer->usage = usage;
-   transfer->box = *box;
-
-   /* Note strides are zero, this is ok for buffers, but not for
-    * textures 2d & higher at least. 
-    */
-   return transfer;
-}
-
 void u_default_transfer_unmap( struct pipe_context *pipe,
                                struct pipe_transfer *transfer )
 {
 }
-
-void u_default_transfer_destroy(struct pipe_context *pipe,
-                                struct pipe_transfer *transfer)
-{
-   FREE(transfer);
-}
index f4fdf9a48408aa60277e8edb9ebe2cff5244360e..6c25ee0f024e08b82431a55214f554c97266e9fd 100644 (file)
@@ -27,18 +27,9 @@ void u_default_transfer_flush_region( struct pipe_context *pipe,
                                       struct pipe_transfer *transfer,
                                       const struct pipe_box *box);
 
-struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
-                                              struct pipe_resource *resource,
-                                              unsigned level,
-                                              unsigned usage,
-                                              const struct pipe_box *box);
-
 void u_default_transfer_unmap( struct pipe_context *pipe,
                                struct pipe_transfer *transfer );
 
-void u_default_transfer_destroy(struct pipe_context *pipe,
-                                struct pipe_transfer *transfer);
-
 
 
 /* Useful helper to allow >1 implementation of resource functionality
@@ -53,24 +44,20 @@ struct u_resource_vtbl {
    void (*resource_destroy)(struct pipe_screen *,
                             struct pipe_resource *pt);
 
-   struct pipe_transfer *(*get_transfer)(struct pipe_context *,
-                                         struct pipe_resource *resource,
-                                         unsigned level,
-                                         unsigned usage,
-                                         const struct pipe_box *);
+   void *(*transfer_map)(struct pipe_context *,
+                         struct pipe_resource *resource,
+                         unsigned level,
+                         unsigned usage,
+                         const struct pipe_box *,
+                         struct pipe_transfer **);
 
-   void (*transfer_destroy)(struct pipe_context *,
-                            struct pipe_transfer *);
-
-   void *(*transfer_map)( struct pipe_context *,
-                          struct pipe_transfer *transfer );
 
    void (*transfer_flush_region)( struct pipe_context *,
                                   struct pipe_transfer *transfer,
                                   const struct pipe_box *);
 
    void (*transfer_unmap)( struct pipe_context *,
-   struct pipe_transfer *transfer );
+                           struct pipe_transfer *transfer );
 
    void (*transfer_inline_write)( struct pipe_context *pipe,
                                   struct pipe_resource *resource,
@@ -96,17 +83,12 @@ boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
 void u_resource_destroy_vtbl(struct pipe_screen *screen,
                              struct pipe_resource *resource);
 
-struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
-                                          struct pipe_resource *resource,
-                                          unsigned level,
-                                          unsigned usage,
-                                          const struct pipe_box *box);
-
-void u_transfer_destroy_vtbl(struct pipe_context *pipe,
-                             struct pipe_transfer *transfer);
-
-void *u_transfer_map_vtbl( struct pipe_context *pipe,
-                           struct pipe_transfer *transfer );
+void *u_transfer_map_vtbl(struct pipe_context *context,
+                          struct pipe_resource *resource,
+                          unsigned level,
+                          unsigned usage,
+                          const struct pipe_box *box,
+                          struct pipe_transfer **transfer);
 
 void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
                                    struct pipe_transfer *transfer,
index b4b4c91f1ec632a42491e33ff092654d41d977c5..b62973de6cbce80d3256d0f92abcb3f59f309403 100644 (file)
@@ -82,7 +82,6 @@ void u_upload_unmap( struct u_upload_mgr *upload )
                                         box->x, upload->offset - box->x);
       }
       pipe_transfer_unmap(upload->pipe, upload->transfer);
-      pipe_transfer_destroy(upload->pipe, upload->transfer);
       upload->transfer = NULL;
       upload->map = NULL;
    }
@@ -142,13 +141,13 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
                                        PIPE_TRANSFER_FLUSH_EXPLICIT,
                                        &upload->transfer);
    if (upload->map == NULL) {
+      upload->transfer = NULL;
       upload->size = 0;
       pipe_resource_reference(&upload->buffer, NULL);
       return PIPE_ERROR_OUT_OF_MEMORY;
    }
 
    upload->size = size;
-
    upload->offset = 0;
    return PIPE_OK;
 }
@@ -185,6 +184,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
       if (!upload->map) {
          pipe_resource_reference(outbuf, NULL);
          *ptr = NULL;
+         upload->transfer = NULL;
          return PIPE_ERROR_OUT_OF_MEMORY;
       }
 
index f848a78d18ab1cc41bde7aa0a3218ea0ceab4cf2..5adc72f7db6601c805df92114eaf06a36071a08b 100644 (file)
@@ -713,28 +713,21 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
    if (!matrix)
       goto error_matrix;
 
-   buf_transfer = pipe->get_transfer
-   (
-      pipe, matrix,
-      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
-      &rect
-   );
-   if (!buf_transfer)
-      goto error_transfer;
-
-   pitch = buf_transfer->stride / sizeof(float);
-
-   f = pipe->transfer_map(pipe, buf_transfer);
+   f = pipe->transfer_map(pipe, matrix, 0,
+                                     PIPE_TRANSFER_WRITE |
+                                     PIPE_TRANSFER_DISCARD_RANGE,
+                                     &rect, &buf_transfer);
    if (!f)
       goto error_map;
 
+   pitch = buf_transfer->stride / sizeof(float);
+
    for(i = 0; i < VL_BLOCK_HEIGHT; ++i)
       for(j = 0; j < VL_BLOCK_WIDTH; ++j)
          // transpose and scale
          f[i * pitch + j] = ((const float (*)[8])const_matrix)[j][i] * scale;
 
    pipe->transfer_unmap(pipe, buf_transfer);
-   pipe->transfer_destroy(pipe, buf_transfer);
 
    memset(&sv_templ, 0, sizeof(sv_templ));
    u_sampler_view_default_template(&sv_templ, matrix, matrix->format);
@@ -746,9 +739,6 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
    return sv;
 
 error_map:
-   pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
    pipe_resource_reference(&matrix, NULL);
 
 error_matrix:
index 31d96fd316c8d92d8379a3e01bcc754ae5a581b0..4614c8abd37e9cef84bc8a63e54c24e191d41f51 100644 (file)
@@ -545,15 +545,13 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder,
    rect.width = tex->width0;
    rect.height = tex->height0;
 
-   buf->tex_transfer = dec->base.context->get_transfer
-   (
-      dec->base.context, tex,
-      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
-      &rect
-   );
+   buf->texels =
+      dec->base.context->transfer_map(dec->base.context, tex, 0,
+                                      PIPE_TRANSFER_WRITE |
+                                      PIPE_TRANSFER_DISCARD_RANGE,
+                                      &rect, &buf->tex_transfer);
 
    buf->block_num = 0;
-   buf->texels = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer);
 
    for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
       buf->ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
@@ -690,7 +688,6 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder,
    vl_vb_unmap(&buf->vertex_stream, dec->base.context);
 
    dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer);
-   dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer);
 
    vb[0] = dec->quads;
    vb[1] = dec->pos;
index 1f0939b1dc3560c671fc11e8d8d2b8451a8ebbbe..53c2e801c2d81acd4c5a47a809b3c17eb65644a1 100644 (file)
@@ -381,21 +381,14 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
    if (!res)
       goto error_resource;
 
-   buf_transfer = pipe->get_transfer
-   (
-      pipe, res,
-      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
-      &rect
-   );
-   if (!buf_transfer)
-      goto error_transfer;
-
-   pitch = buf_transfer->stride / sizeof(float);
-
-   f = pipe->transfer_map(pipe, buf_transfer);
+   f = pipe->transfer_map(pipe, res,
+                          0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
+                          &rect, &buf_transfer);
    if (!f)
       goto error_map;
 
+   pitch = buf_transfer->stride / sizeof(float);
+
    for (i = 0; i < blocks_per_line; ++i)
       for (y = 0; y < VL_BLOCK_HEIGHT; ++y)
          for (x = 0; x < VL_BLOCK_WIDTH; ++x) {
@@ -408,7 +401,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
          }
 
    pipe->transfer_unmap(pipe, buf_transfer);
-   pipe->transfer_destroy(pipe, buf_transfer);
 
    memset(&sv_tmpl, 0, sizeof(sv_tmpl));
    u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -420,9 +412,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
    return sv;
 
 error_map:
-   pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
    pipe_resource_reference(&res, NULL);
 
 error_resource:
@@ -560,33 +549,21 @@ vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
 
    rect.width *= zscan->blocks_per_line;
 
-   buf_transfer = pipe->get_transfer
-   (
-      pipe, buffer->quant->texture,
-      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
-      &rect
-   );
-   if (!buf_transfer)
-      goto error_transfer;
+   data = pipe->transfer_map(pipe, buffer->quant->texture,
+                             0, PIPE_TRANSFER_WRITE |
+                             PIPE_TRANSFER_DISCARD_RANGE,
+                             &rect, &buf_transfer);
+   if (!data)
+      return;
 
    pitch = buf_transfer->stride;
 
-   data = pipe->transfer_map(pipe, buf_transfer);
-   if (!data)
-      goto error_map;
-
    for (i = 0; i < zscan->blocks_per_line; ++i)
       for (y = 0; y < VL_BLOCK_HEIGHT; ++y)
          for (x = 0; x < VL_BLOCK_WIDTH; ++x)
             data[i * VL_BLOCK_WIDTH + y * pitch + x] = matrix[x + y * VL_BLOCK_WIDTH];
 
    pipe->transfer_unmap(pipe, buf_transfer);
-
-error_map:
-   pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
-   return;
 }
 
 void
index 28096f804b17ca1877fcd7ba80d4e51c02a30663..af84a2d91f811a0c6601bc28842d2b776b727b02 100644 (file)
@@ -450,21 +450,19 @@ Transfers
 
 These methods are used to get data to/from a resource.
 
-``get_transfer`` creates a transfer object.
+``transfer_map`` creates a memory mapping and the transfer object
+associated with it.
+The returned pointer points to the start of the mapped range according to
+the box region, not the beginning of the resource. If transfer_map fails,
+the returned pointer to the buffer memory is NULL, and the pointer
+to the transfer object remains unchanged (i.e. it can be non-NULL).
 
-``transfer_destroy`` destroys the transfer object. May cause
-data to be written to the resource at this point.
-
-``transfer_map`` creates a memory mapping for the transfer object.
-The returned map points to the start of the mapped range according to
-the box region, 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.
+``transfer_unmap`` remove the memory mapping for and destroy
+the transfer object. The pointer into the resource should be considered
+invalid and discarded.
 
 ``transfer_inline_write`` performs a simplified transfer for simple writes.
-Basically get_transfer, transfer_map, data write, transfer_unmap, and
-transfer_destroy all in one.
+Basically transfer_map, data write, and transfer_unmap all in one.
 
 
 The box parameter to some of these functions defines a 1D, 2D or 3D
@@ -515,7 +513,7 @@ These flags control the behavior of a transfer object.
   Resource contents read back (or accessed directly) at transfer create time.
 
 ``PIPE_TRANSFER_WRITE``
-  Resource contents will be written back at transfer_destroy time (or modified
+  Resource contents will be written back at transfer_unmap time (or modified
   as a result of being accessed directly).
 
 ``PIPE_TRANSFER_MAP_DIRECTLY``
index 354f20a3ad7caee68fc5bbcb83e0a47c0b084fec..92ca4a63da911d88a1ed385cdb7578311520f114 100644 (file)
@@ -877,58 +877,35 @@ galahad_context_surface_destroy(struct pipe_context *_pipe,
 }
 
 
-
-static struct pipe_transfer *
-galahad_context_get_transfer(struct pipe_context *_context,
-                              struct pipe_resource *_resource,
-                              unsigned level,
-                              unsigned usage,
-                              const struct pipe_box *box)
+static void *
+galahad_context_transfer_map(struct pipe_context *_context,
+                             struct pipe_resource *_resource,
+                             unsigned level,
+                             unsigned usage,
+                             const struct pipe_box *box,
+                             struct pipe_transfer **transfer)
 {
    struct galahad_context *glhd_context = galahad_context(_context);
    struct galahad_resource *glhd_resource = galahad_resource(_resource);
    struct pipe_context *context = glhd_context->pipe;
    struct pipe_resource *resource = glhd_resource->resource;
    struct pipe_transfer *result;
-
-   result = context->get_transfer(context,
-                                  resource,
-                                  level,
-                                  usage,
-                                  box);
-
-   if (result)
-      return galahad_transfer_create(glhd_context, glhd_resource, result);
-   return NULL;
-}
-
-static void
-galahad_context_transfer_destroy(struct pipe_context *_pipe,
-                                  struct pipe_transfer *_transfer)
-{
-   galahad_transfer_destroy(galahad_context(_pipe),
-                             galahad_transfer(_transfer));
-}
-
-static void *
-galahad_context_transfer_map(struct pipe_context *_context,
-                              struct pipe_transfer *_transfer)
-{
-   struct galahad_context *glhd_context = galahad_context(_context);
-   struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
-   struct pipe_context *context = glhd_context->pipe;
-   struct pipe_transfer *transfer = glhd_transfer->transfer;
-
-   struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
+   void *map;
+
+   map = context->transfer_map(context,
+                               resource,
+                               level,
+                               usage,
+                               box, &result);
+   if (!map)
+      return NULL;
 
    glhd_resource->map_count++;
 
-   return context->transfer_map(context,
-                                transfer);
+   *transfer = galahad_transfer_create(glhd_context, glhd_resource, result);
+   return *transfer ? map : NULL;
 }
 
-
-
 static void
 galahad_context_transfer_flush_region(struct pipe_context *_context,
                                        struct pipe_transfer *_transfer,
@@ -944,7 +921,6 @@ galahad_context_transfer_flush_region(struct pipe_context *_context,
                                   box);
 }
 
-
 static void
 galahad_context_transfer_unmap(struct pipe_context *_context,
                                 struct pipe_transfer *_transfer)
@@ -964,6 +940,9 @@ galahad_context_transfer_unmap(struct pipe_context *_context,
 
    context->transfer_unmap(context,
                            transfer);
+
+   galahad_transfer_destroy(galahad_context(_context),
+                             galahad_transfer(_transfer));
 }
 
 
@@ -1088,8 +1067,6 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    GLHD_PIPE_INIT(sampler_view_destroy);
    GLHD_PIPE_INIT(create_surface);
    GLHD_PIPE_INIT(surface_destroy);
-   GLHD_PIPE_INIT(get_transfer);
-   GLHD_PIPE_INIT(transfer_destroy);
    GLHD_PIPE_INIT(transfer_map);
    GLHD_PIPE_INIT(transfer_flush_region);
    GLHD_PIPE_INIT(transfer_unmap);
index b44adff20c737e87e9257eb7feb768054a8bc766..e4a8f28f352fb147a2378307d165ea2daf8a0197 100644 (file)
@@ -173,7 +173,7 @@ galahad_transfer_create(struct galahad_context *glhd_context,
    return &glhd_transfer->base;
 
 error:
-   glhd_context->pipe->transfer_destroy(glhd_context->pipe, transfer);
+   glhd_context->pipe->transfer_unmap(glhd_context->pipe, transfer);
    return NULL;
 }
 
@@ -182,7 +182,5 @@ galahad_transfer_destroy(struct galahad_context *glhd_context,
                           struct galahad_transfer *glhd_transfer)
 {
    pipe_resource_reference(&glhd_transfer->base.resource, NULL);
-   glhd_context->pipe->transfer_destroy(glhd_context->pipe,
-                                        glhd_transfer->transfer);
    FREE(glhd_transfer);
 }
index 253c7d062338e26b910ac351ac5714acbbe3b2f9..314ebe9551e080b46f2d581689053ce205b0db30 100644 (file)
@@ -31,11 +31,9 @@ i915_resource_from_handle(struct pipe_screen * screen,
 void
 i915_init_resource_functions(struct i915_context *i915 )
 {
-   i915->base.get_transfer = u_get_transfer_vtbl;
    i915->base.transfer_map = u_transfer_map_vtbl;
    i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
    i915->base.transfer_unmap = u_transfer_unmap_vtbl;
-   i915->base.transfer_destroy = u_transfer_destroy_vtbl;
    i915->base.transfer_inline_write = u_transfer_inline_write_vtbl;
 }
 
index 77c03450b3a24b81449838c82d2cca95a8e1bdcf..80ec43a41eba55b36c49f1f73185747e07fa5691 100644 (file)
@@ -60,14 +60,16 @@ i915_buffer_destroy(struct pipe_screen *screen,
 }
 
 
-static struct pipe_transfer *
-i915_get_transfer(struct pipe_context *pipe,
-                  struct pipe_resource *resource,
-                  unsigned level,
-                  unsigned usage,
-                  const struct pipe_box *box)
+static void *
+i915_buffer_transfer_map(struct pipe_context *pipe,
+                         struct pipe_resource *resource,
+                         unsigned level,
+                         unsigned usage,
+                         const struct pipe_box *box,
+                         struct pipe_transfer **ptransfer)
 {
    struct i915_context *i915 = i915_context(pipe);
+   struct i915_buffer *buffer = i915_buffer(resource);
    struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
 
    if (transfer == NULL)
@@ -77,30 +79,19 @@ i915_get_transfer(struct pipe_context *pipe,
    transfer->level = level;
    transfer->usage = usage;
    transfer->box = *box;
+   *ptransfer = transfer;
 
-   /* Note strides are zero, this is ok for buffers, but not for
-    * textures 2d & higher at least. 
-    */
-   return transfer;
+   return buffer->data + transfer->box.x;
 }
 
 static void
-i915_transfer_destroy(struct pipe_context *pipe,
-                      struct pipe_transfer *transfer)
+i915_buffer_transfer_unmap(struct pipe_context *pipe,
+                           struct pipe_transfer *transfer)
 {
    struct i915_context *i915 = i915_context(pipe);
    util_slab_free(&i915->transfer_pool, transfer);
 }
 
-static void *
-i915_buffer_transfer_map( struct pipe_context *pipe,
-                          struct pipe_transfer *transfer )
-{
-   struct i915_buffer *buffer = i915_buffer(transfer->resource);
-   return buffer->data + transfer->box.x;
-}
-
-
 static void
 i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx,
                                    struct pipe_resource *resource,
@@ -123,11 +114,9 @@ struct u_resource_vtbl i915_buffer_vtbl =
 {
    i915_buffer_get_handle,          /* get_handle */
    i915_buffer_destroy,                     /* resource_destroy */
-   i915_get_transfer,               /* get_transfer */
-   i915_transfer_destroy,           /* transfer_destroy */
    i915_buffer_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,  /* transfer_flush_region */
-   u_default_transfer_unmap,        /* transfer_unmap */
+   i915_buffer_transfer_unmap,      /* transfer_unmap */
    i915_buffer_transfer_inline_write /* transfer_inline_write */
 };
 
index 83437af371a955984de5a0a6fb112eb1f04e3ca8..52ef776b3cee1cfff816a15a54af6d05b86b2842 100644 (file)
@@ -705,17 +705,22 @@ i915_texture_destroy(struct pipe_screen *screen,
    FREE(tex);
 }
 
-static struct pipe_transfer *
-i915_texture_get_transfer(struct pipe_context *pipe,
+static void *
+i915_texture_transfer_map(struct pipe_context *pipe,
                           struct pipe_resource *resource,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer)
 {
    struct i915_context *i915 = i915_context(pipe);
    struct i915_texture *tex = i915_texture(resource);
    struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool);
    boolean use_staging_texture = FALSE;
+   struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
+   enum pipe_format format = resource->format;
+   unsigned offset;
+   char *map;
 
    if (transfer == NULL)
       return NULL;
@@ -749,67 +754,32 @@ i915_texture_get_transfer(struct pipe_context *pipe,
       transfer->staging_texture = i915_texture_create(pipe->screen, resource, TRUE);
    }
 
-   return (struct pipe_transfer*)transfer;
-}
-
-static void
-i915_transfer_destroy(struct pipe_context *pipe,
-                      struct pipe_transfer *transfer)
-{
-   struct i915_context *i915 = i915_context(pipe);
-   struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
-
-   if ((itransfer->staging_texture) &&
-       (transfer->usage & PIPE_TRANSFER_WRITE)) {
-      struct pipe_box sbox;
-
-      u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
-      pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
-                                   itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
-                                   itransfer->staging_texture,
-                                   0, &sbox);
-      pipe->flush(pipe, NULL);
-      pipe_resource_reference(&itransfer->staging_texture, NULL);
-   }
-
-   util_slab_free(&i915->texture_transfer_pool, itransfer);
-}
-
-static void *
-i915_texture_transfer_map(struct pipe_context *pipe,
-                          struct pipe_transfer *transfer)
-{
-   struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
-   struct pipe_resource *resource = itransfer->b.resource;
-   struct i915_texture *tex = NULL;
-   struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
-   struct pipe_box *box = &itransfer->b.box;
-   enum pipe_format format = resource->format;
-   unsigned offset;
-   char *map;
-
    if (resource->target != PIPE_TEXTURE_3D &&
        resource->target != PIPE_TEXTURE_CUBE)
       assert(box->z == 0);
 
-   if (itransfer->staging_texture) {
-      tex = i915_texture(itransfer->staging_texture);
+   if (transfer->staging_texture) {
+      tex = i915_texture(transfer->staging_texture);
    } else {
       /* TODO this is a sledgehammer */
       tex = i915_texture(resource);
       pipe->flush(pipe, NULL);
    }
 
-   offset = i915_texture_offset(tex, itransfer->b.level, box->z);
+   offset = i915_texture_offset(tex, transfer->b.level, box->z);
 
    map = iws->buffer_map(iws, tex->buffer,
-                         (itransfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
+                         (transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
    if (map == NULL) {
+      pipe_resource_reference(&transfer->staging_texture, NULL);
+      FREE(transfer);
       return NULL;
    }
 
+   *ptransfer = &transfer->b;
+
    return map + offset +
-      box->y / util_format_get_blockheight(format) * itransfer->b.stride +
+      box->y / util_format_get_blockheight(format) * transfer->b.stride +
       box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 }
 
@@ -817,6 +787,7 @@ static void
 i915_texture_transfer_unmap(struct pipe_context *pipe,
                            struct pipe_transfer *transfer)
 {
+   struct i915_context *i915 = i915_context(pipe);
    struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
    struct i915_texture *tex = i915_texture(itransfer->b.resource);
    struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
@@ -825,8 +796,24 @@ i915_texture_transfer_unmap(struct pipe_context *pipe,
       tex = i915_texture(itransfer->staging_texture);
 
    iws->buffer_unmap(iws, tex->buffer);
+
+   if ((itransfer->staging_texture) &&
+       (transfer->usage & PIPE_TRANSFER_WRITE)) {
+      struct pipe_box sbox;
+
+      u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
+      pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
+                                   itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
+                                   itransfer->staging_texture,
+                                   0, &sbox);
+      pipe->flush(pipe, NULL);
+      pipe_resource_reference(&itransfer->staging_texture, NULL);
+   }
+
+   util_slab_free(&i915->texture_transfer_pool, itransfer);
 }
 
+#if 0
 static void i915_transfer_inline_write( struct pipe_context *pipe,
                                  struct pipe_resource *resource,
                                  unsigned level,
@@ -841,7 +828,7 @@ static void i915_transfer_inline_write( struct pipe_context *pipe,
    const uint8_t *src_data = data;
    unsigned i;
 
-   transfer = pipe->get_transfer(pipe,
+   transfer = pipe->transfer_get(pipe,
                                  resource,
                                  level,
                                  usage,
@@ -913,24 +900,19 @@ out:
    if (itransfer)
       pipe_transfer_destroy(pipe, &itransfer->b);
 }
-
-
+#endif
 
 struct u_resource_vtbl i915_texture_vtbl =
 {
    i915_texture_get_handle,          /* get_handle */
    i915_texture_destroy,             /* resource_destroy */
-   i915_texture_get_transfer,        /* get_transfer */
-   i915_transfer_destroy,            /* transfer_destroy */
    i915_texture_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,   /* transfer_flush_region */
    i915_texture_transfer_unmap,              /* transfer_unmap */
-   i915_transfer_inline_write         /* transfer_inline_write */
+   u_default_transfer_inline_write    /* transfer_inline_write */
 };
 
 
-
-
 struct pipe_resource *
 i915_texture_create(struct pipe_screen *screen,
                     const struct pipe_resource *template,
index cf0a3f9aa409e632dc3c7f2deb4397a4e86d363a..fb2f78764a44cc721ecfe54ea6065d607d605bb7 100644 (file)
@@ -776,53 +776,34 @@ identity_context_surface_destroy(struct pipe_context *_pipe,
                             identity_surface(_surf));
 }
 
-static struct pipe_transfer *
-identity_context_get_transfer(struct pipe_context *_context,
+static void *
+identity_context_transfer_map(struct pipe_context *_context,
                               struct pipe_resource *_resource,
                               unsigned level,
                               unsigned usage,
-                              const struct pipe_box *box)
+                              const struct pipe_box *box,
+                              struct pipe_transfer **transfer)
 {
    struct identity_context *id_context = identity_context(_context);
    struct identity_resource *id_resource = identity_resource(_resource);
    struct pipe_context *context = id_context->pipe;
    struct pipe_resource *resource = id_resource->resource;
    struct pipe_transfer *result;
+   void *map;
 
-   result = context->get_transfer(context,
-                                  resource,
-                                  level,
-                                  usage,
-                                  box);
-
-   if (result)
-      return identity_transfer_create(id_context, id_resource, result);
-   return NULL;
-}
+   map = context->transfer_map(context,
+                               resource,
+                               level,
+                               usage,
+                               box, &result);
 
-static void
-identity_context_transfer_destroy(struct pipe_context *_pipe,
-                                  struct pipe_transfer *_transfer)
-{
-   identity_transfer_destroy(identity_context(_pipe),
-                             identity_transfer(_transfer));
-}
-
-static void *
-identity_context_transfer_map(struct pipe_context *_context,
-                              struct pipe_transfer *_transfer)
-{
-   struct identity_context *id_context = identity_context(_context);
-   struct identity_transfer *id_transfer = identity_transfer(_transfer);
-   struct pipe_context *context = id_context->pipe;
-   struct pipe_transfer *transfer = id_transfer->transfer;
+   if (!map)
+      return NULL;
 
-   return context->transfer_map(context,
-                                transfer);
+   *transfer = identity_transfer_map(id_context, id_resource, result);
+   return *transfer ? map : NULL;
 }
 
-
-
 static void
 identity_context_transfer_flush_region(struct pipe_context *_context,
                                        struct pipe_transfer *_transfer,
@@ -850,6 +831,9 @@ identity_context_transfer_unmap(struct pipe_context *_context,
 
    context->transfer_unmap(context,
                            transfer);
+
+   identity_transfer_destroy(identity_context(_context),
+                             identity_transfer(_transfer));
 }
 
 
@@ -945,8 +929,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.surface_destroy = identity_context_surface_destroy;
    id_pipe->base.create_sampler_view = identity_context_create_sampler_view;
    id_pipe->base.sampler_view_destroy = identity_context_sampler_view_destroy;
-   id_pipe->base.get_transfer = identity_context_get_transfer;
-   id_pipe->base.transfer_destroy = identity_context_transfer_destroy;
    id_pipe->base.transfer_map = identity_context_transfer_map;
    id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
    id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region;
index 63454410525ee4e8639d794e8bb637962ffb6f83..a26d9874870b9bc0b0f3f3f8953003ca6ee7c0a0 100644 (file)
@@ -149,9 +149,9 @@ identity_sampler_view_destroy(struct identity_context *id_context,
 
 
 struct pipe_transfer *
-identity_transfer_create(struct identity_context *id_context,
-                         struct identity_resource *id_resource,
-                         struct pipe_transfer *transfer)
+identity_transfer_map(struct identity_context *id_context,
+                      struct identity_resource *id_resource,
+                      struct pipe_transfer *transfer)
 {
    struct identity_transfer *id_transfer;
 
@@ -175,7 +175,7 @@ identity_transfer_create(struct identity_context *id_context,
    return &id_transfer->base;
 
 error:
-   id_context->pipe->transfer_destroy(id_context->pipe, transfer);
+   id_context->pipe->transfer_unmap(id_context->pipe, transfer);
    return NULL;
 }
 
@@ -184,8 +184,6 @@ identity_transfer_destroy(struct identity_context *id_context,
                           struct identity_transfer *id_transfer)
 {
    pipe_resource_reference(&id_transfer->base.resource, NULL);
-   id_context->pipe->transfer_destroy(id_context->pipe,
-                                      id_transfer->transfer);
    FREE(id_transfer);
 }
 
index 181f2d6623e9dc635522a4f6a10bf84e879a4ffb..67049436247db8469392a28669f95eb5b42fda12 100644 (file)
@@ -165,7 +165,7 @@ identity_sampler_view_destroy(struct identity_context *id_context,
                               struct identity_sampler_view *id_sampler_view);
 
 struct pipe_transfer *
-identity_transfer_create(struct identity_context *id_context,
+identity_transfer_map(struct identity_context *id_context,
                          struct identity_resource *id_resource,
                          struct pipe_transfer *transfer);
 
index 841df004d14bad0842226fc715afb8866348af03..b4ea94ca1ae9b33a5bb6528af6eec0530a2068d9 100644 (file)
@@ -622,16 +622,23 @@ llvmpipe_surface_destroy(struct pipe_context *pipe,
 }
 
 
-static struct pipe_transfer *
-llvmpipe_get_transfer(struct pipe_context *pipe,
-                      struct pipe_resource *resource,
-                      unsigned level,
-                      unsigned usage,
-                      const struct pipe_box *box)
+static void *
+llvmpipe_transfer_map( struct pipe_context *pipe,
+                       struct pipe_resource *resource,
+                       unsigned level,
+                       unsigned usage,
+                       const struct pipe_box *box,
+                       struct pipe_transfer **transfer )
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
-   struct llvmpipe_resource *lprex = llvmpipe_resource(resource);
-   struct llvmpipe_transfer *lpr;
+   struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
+   struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
+   struct llvmpipe_transfer *lpt;
+   struct pipe_transfer *pt;
+   ubyte *map;
+   enum pipe_format format;
+   enum lp_texture_usage tex_usage;
+   const char *mode;
 
    assert(resource);
    assert(level <= resource->last_level);
@@ -661,48 +668,19 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
    if (resource == llvmpipe->constants[PIPE_SHADER_FRAGMENT][0])
       llvmpipe->dirty |= LP_NEW_CONSTANTS;
 
-   lpr = CALLOC_STRUCT(llvmpipe_transfer);
-   if (lpr) {
-      struct pipe_transfer *pt = &lpr->base;
-      pipe_resource_reference(&pt->resource, resource);
-      pt->box = *box;
-      pt->level = level;
-      pt->stride = lprex->row_stride[level];
-      pt->layer_stride = lprex->img_stride[level];
-      pt->usage = usage;
-
-      return pt;
-   }
-   return NULL;
-}
-
-
-static void 
-llvmpipe_transfer_destroy(struct pipe_context *pipe,
-                              struct pipe_transfer *transfer)
-{
-   /* Effectively do the texture_update work here - if texture images
-    * needed post-processing to put them into hardware layout, this is
-    * where it would happen.  For llvmpipe, nothing to do.
-    */
-   assert (transfer->resource);
-   pipe_resource_reference(&transfer->resource, NULL);
-   FREE(transfer);
-}
-
-
-static void *
-llvmpipe_transfer_map( struct pipe_context *pipe,
-                       struct pipe_transfer *transfer )
-{
-   struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
-   ubyte *map;
-   struct llvmpipe_resource *lpr;
-   enum pipe_format format;
-   enum lp_texture_usage tex_usage;
-   const char *mode;
+   lpt = CALLOC_STRUCT(llvmpipe_transfer);
+   if (!lpt)
+      return NULL;
+   pt = &lpt->base;
+   pipe_resource_reference(&pt->resource, resource);
+   pt->box = *box;
+   pt->level = level;
+   pt->stride = lpr->row_stride[level];
+   pt->layer_stride = lpr->img_stride[level];
+   pt->usage = usage;
+   *transfer = pt;
 
-   assert(transfer->level < LP_MAX_TEXTURE_LEVELS);
+   assert(level < LP_MAX_TEXTURE_LEVELS);
 
    /*
    printf("tex_transfer_map(%d, %d  %d x %d of %d x %d,  usage %d )\n",
@@ -712,7 +690,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
           transfer->usage);
    */
 
-   if (transfer->usage == PIPE_TRANSFER_READ) {
+   if (usage == PIPE_TRANSFER_READ) {
       tex_usage = LP_TEX_USAGE_READ;
       mode = "read";
    }
@@ -722,33 +700,29 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
    }
 
    if (0) {
-      struct llvmpipe_resource *lpr = llvmpipe_resource(transfer->resource);
       printf("transfer map tex %u  mode %s\n", lpr->id, mode);
    }
 
-
-   assert(transfer->resource);
-   lpr = llvmpipe_resource(transfer->resource);
    format = lpr->base.format;
 
-   map = llvmpipe_resource_map(transfer->resource,
-                               transfer->level,
-                               transfer->box.z,
+   map = llvmpipe_resource_map(resource,
+                               level,
+                               box->z,
                                tex_usage, LP_TEX_LAYOUT_LINEAR);
 
 
    /* May want to do different things here depending on read/write nature
     * of the map:
     */
-   if (transfer->usage & PIPE_TRANSFER_WRITE) {
+   if (usage & PIPE_TRANSFER_WRITE) {
       /* Do something to notify sharing contexts of a texture change.
        */
       screen->timestamp++;
    }
 
    map +=
-      transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
-      transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+      box->y / util_format_get_blockheight(format) * pt->stride +
+      box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 
    return map;
 }
@@ -763,6 +737,14 @@ llvmpipe_transfer_unmap(struct pipe_context *pipe,
    llvmpipe_resource_unmap(transfer->resource,
                            transfer->level,
                            transfer->box.z);
+
+   /* Effectively do the texture_update work here - if texture images
+    * needed post-processing to put them into hardware layout, this is
+    * where it would happen.  For llvmpipe, nothing to do.
+    */
+   assert (transfer->resource);
+   pipe_resource_reference(&transfer->resource, NULL);
+   FREE(transfer);
 }
 
 unsigned int
@@ -1474,8 +1456,6 @@ llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
 void
 llvmpipe_init_context_resource_funcs(struct pipe_context *pipe)
 {
-   pipe->get_transfer = llvmpipe_get_transfer;
-   pipe->transfer_destroy = llvmpipe_transfer_destroy;
    pipe->transfer_map = llvmpipe_transfer_map;
    pipe->transfer_unmap = llvmpipe_transfer_unmap;
  
index 6411418c3fe69bc2916fa0c0e2cd010a59350b99..b7c73cf084da6af500792a5e8ebeea78cbfa2d88 100644 (file)
@@ -146,32 +146,28 @@ static void noop_resource_destroy(struct pipe_screen *screen,
 /*
  * transfer
  */
-static struct pipe_transfer *noop_get_transfer(struct pipe_context *context,
-                                               struct pipe_resource *resource,
-                                               unsigned level,
-                                               enum pipe_transfer_usage usage,
-                                               const struct pipe_box *box)
-{
-       struct pipe_transfer *transfer;
-
-       transfer = CALLOC_STRUCT(pipe_transfer);
-       if (transfer == NULL)
-               return NULL;
-       pipe_resource_reference(&transfer->resource, resource);
-       transfer->level = level;
-       transfer->usage = usage;
-       transfer->box = *box;
-       transfer->stride = 1;
-       transfer->layer_stride = 1;
-       return transfer;
-}
-
 static void *noop_transfer_map(struct pipe_context *pipe,
-                               struct pipe_transfer *transfer)
+                               struct pipe_resource *resource,
+                               unsigned level,
+                               enum pipe_transfer_usage usage,
+                               const struct pipe_box *box,
+                               struct pipe_transfer **ptransfer)
 {
-       struct noop_resource *nresource = (struct noop_resource *)transfer->resource;
+   struct pipe_transfer *transfer;
+   struct noop_resource *nresource = (struct noop_resource *)resource;
+
+   transfer = CALLOC_STRUCT(pipe_transfer);
+   if (transfer == NULL)
+           return NULL;
+   pipe_resource_reference(&transfer->resource, resource);
+   transfer->level = level;
+   transfer->usage = usage;
+   transfer->box = *box;
+   transfer->stride = 1;
+   transfer->layer_stride = 1;
+   *ptransfer = transfer;
 
-       return nresource->data;
+   return nresource->data;
 }
 
 static void noop_transfer_flush_region(struct pipe_context *pipe,
@@ -183,13 +179,8 @@ static void noop_transfer_flush_region(struct pipe_context *pipe,
 static void noop_transfer_unmap(struct pipe_context *pipe,
                                struct pipe_transfer *transfer)
 {
-}
-
-static void noop_transfer_destroy(struct pipe_context *pipe,
-                                       struct pipe_transfer *transfer)
-{
-       pipe_resource_reference(&transfer->resource, NULL);
-       FREE(transfer);
+   pipe_resource_reference(&transfer->resource, NULL);
+   FREE(transfer);
 }
 
 static void noop_transfer_inline_write(struct pipe_context *pipe,
@@ -280,11 +271,9 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen, void
        ctx->begin_query = noop_begin_query;
        ctx->end_query = noop_end_query;
        ctx->get_query_result = noop_get_query_result;
-       ctx->get_transfer = noop_get_transfer;
        ctx->transfer_map = noop_transfer_map;
        ctx->transfer_flush_region = noop_transfer_flush_region;
        ctx->transfer_unmap = noop_transfer_unmap;
-       ctx->transfer_destroy = noop_transfer_destroy;
        ctx->transfer_inline_write = noop_transfer_inline_write;
        noop_init_state_functions(ctx);
 
index e83aae0bba545381ed331a0c71266c7843b820a4..f16345d540e96693a3dfad08754a9c50d6489846 100644 (file)
@@ -167,54 +167,6 @@ nouveau_buffer_upload(struct nouveau_context *nv, struct nv04_resource *buf,
    return TRUE;
 }
 
-static struct pipe_transfer *
-nouveau_buffer_transfer_get(struct pipe_context *pipe,
-                            struct pipe_resource *resource,
-                            unsigned level, unsigned usage,
-                            const struct pipe_box *box)
-{
-   struct nv04_resource *buf = nv04_resource(resource);
-   struct nouveau_context *nv = nouveau_context(pipe);
-   struct nouveau_transfer *xfr = CALLOC_STRUCT(nouveau_transfer);
-   if (!xfr)
-      return NULL;
-
-   xfr->base.resource = resource;
-   xfr->base.box.x = box->x;
-   xfr->base.box.width = box->width;
-   xfr->base.usage = usage;
-
-   if (buf->domain == NOUVEAU_BO_VRAM) {
-      if (usage & PIPE_TRANSFER_READ) {
-         if (buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING)
-            nouveau_buffer_download(nv, buf, 0, buf->base.width0);
-      }
-   }
-
-   return &xfr->base;
-}
-
-static void
-nouveau_buffer_transfer_destroy(struct pipe_context *pipe,
-                                struct pipe_transfer *transfer)
-{
-   struct nv04_resource *buf = nv04_resource(transfer->resource);
-   struct nouveau_transfer *xfr = nouveau_transfer(transfer);
-   struct nouveau_context *nv = nouveau_context(pipe);
-
-   if (xfr->base.usage & PIPE_TRANSFER_WRITE) {
-      if (buf->domain == NOUVEAU_BO_VRAM) {
-         nouveau_buffer_upload(nv, buf, transfer->box.x, transfer->box.width);
-      }
-
-      if (buf->domain != 0 && (buf->base.bind & (PIPE_BIND_VERTEX_BUFFER |
-                                                 PIPE_BIND_INDEX_BUFFER)))
-         nouveau_context(pipe)->vbo_dirty = TRUE;
-   }
-
-   FREE(xfr);
-}
-
 static INLINE boolean
 nouveau_buffer_sync(struct nv04_resource *buf, unsigned rw)
 {
@@ -247,19 +199,39 @@ nouveau_buffer_busy(struct nv04_resource *buf, unsigned rw)
 
 static void *
 nouveau_buffer_transfer_map(struct pipe_context *pipe,
-                            struct pipe_transfer *transfer)
+                            struct pipe_resource *resource,
+                            unsigned level, unsigned usage,
+                            const struct pipe_box *box,
+                            struct pipe_transfer **ptransfer)
 {
+   struct nv04_resource *buf = nv04_resource(resource);
    struct nouveau_context *nv = nouveau_context(pipe);
-   struct nouveau_transfer *xfr = nouveau_transfer(transfer);
-   struct nv04_resource *buf = nv04_resource(transfer->resource);
+   struct nouveau_transfer *xfr = CALLOC_STRUCT(nouveau_transfer);
    struct nouveau_bo *bo = buf->bo;
    uint8_t *map;
    int ret;
    uint32_t offset = xfr->base.box.x;
    uint32_t flags = 0;
 
-   if (buf->domain != NOUVEAU_BO_GART)
+   if (!xfr)
+      return NULL;
+
+   xfr->base.resource = resource;
+   xfr->base.box.x = box->x;
+   xfr->base.box.width = box->width;
+   xfr->base.usage = usage;
+
+   if (buf->domain == NOUVEAU_BO_VRAM) {
+      if (usage & PIPE_TRANSFER_READ) {
+         if (buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING)
+            nouveau_buffer_download(nv, buf, 0, buf->base.width0);
+      }
+   }
+
+   if (buf->domain != NOUVEAU_BO_GART) {
+      *ptransfer = &xfr->base;
       return buf->data + offset;
+   }
 
    if (!buf->mm)
       flags = nouveau_screen_transfer_flags(xfr->base.usage);
@@ -267,19 +239,24 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
    offset += buf->offset;
 
    ret = nouveau_bo_map(buf->bo, flags, nv->screen->client);
-   if (ret)
+   if (ret) {
+      FREE(xfr);
       return NULL;
+   }
    map = (uint8_t *)bo->map + offset;
 
    if (buf->mm) {
       if (xfr->base.usage & PIPE_TRANSFER_DONTBLOCK) {
-         if (nouveau_buffer_busy(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE))
+         if (nouveau_buffer_busy(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE)) {
+            FREE(xfr);
             return NULL;
+         }
       } else
       if (!(xfr->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
          nouveau_buffer_sync(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE);
       }
    }
+   *ptransfer = &xfr->base;
    return map;
 }
 
@@ -307,6 +284,21 @@ static void
 nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
                               struct pipe_transfer *transfer)
 {
+   struct nv04_resource *buf = nv04_resource(transfer->resource);
+   struct nouveau_transfer *xfr = nouveau_transfer(transfer);
+   struct nouveau_context *nv = nouveau_context(pipe);
+
+   if (xfr->base.usage & PIPE_TRANSFER_WRITE) {
+      if (buf->domain == NOUVEAU_BO_VRAM) {
+         nouveau_buffer_upload(nv, buf, transfer->box.x, transfer->box.width);
+      }
+
+      if (buf->domain != 0 && (buf->base.bind & (PIPE_BIND_VERTEX_BUFFER |
+                                                 PIPE_BIND_INDEX_BUFFER)))
+         nouveau_context(pipe)->vbo_dirty = TRUE;
+   }
+
+   FREE(xfr);
 }
 
 
@@ -341,8 +333,6 @@ const struct u_resource_vtbl nouveau_buffer_vtbl =
 {
    u_default_resource_get_handle,     /* get_handle */
    nouveau_buffer_destroy,               /* resource_destroy */
-   nouveau_buffer_transfer_get,          /* get_transfer */
-   nouveau_buffer_transfer_destroy,      /* transfer_destroy */
    nouveau_buffer_transfer_map,          /* transfer_map */
    nouveau_buffer_transfer_flush_region, /* transfer_flush_region */
    nouveau_buffer_transfer_unmap,        /* transfer_unmap */
index 9700fa8cb4b0cc3e8b8b29824c1a05201fb2e6ba..e89725feb2f04ef4c916f7a57c5a34bcfe7e45af 100644 (file)
@@ -218,14 +218,16 @@ nv30_blit(struct pipe_context *pipe,
    util_blitter_blit(nv30->blitter, &info);
 }
 
-static struct pipe_transfer *
-nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
+static void *
+nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
                           unsigned level, unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer)
 {
    struct nv30_context *nv30 = nv30_context(pipe);
    struct nouveau_device *dev = nv30->screen->base.device;
    struct nv30_transfer *tx;
+   unsigned access = 0;
    int ret;
 
    tx = CALLOC_STRUCT(nv30_transfer);
@@ -270,42 +272,24 @@ nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
    if (usage & PIPE_TRANSFER_READ)
       nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp);
 
-   return &tx->base;
-}
-
-static void
-nv30_miptree_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
-   struct nv30_context *nv30 = nv30_context(pipe);
-   struct nv30_transfer *tx = nv30_transfer(ptx);
-
-   if (ptx->usage & PIPE_TRANSFER_WRITE)
-      nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
-
-   nouveau_bo_ref(NULL, &tx->tmp.bo);
-   pipe_resource_reference(&ptx->resource, NULL);
-   FREE(tx);
-}
-
-static void *
-nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
-   struct nv30_context *nv30 = nv30_context(pipe);
-   struct nv30_transfer *tx = nv30_transfer(ptx);
-   unsigned access = 0;
-   int ret;
-
-   if (tx->tmp.bo->map)
+   if (tx->tmp.bo->map) {
+      *ptransfer = &tx->base;
       return tx->tmp.bo->map;
+   }
 
-   if (ptx->usage & PIPE_TRANSFER_READ)
+   if (usage & PIPE_TRANSFER_READ)
       access |= NOUVEAU_BO_RD;
-   if (ptx->usage & PIPE_TRANSFER_WRITE)
+   if (usage & PIPE_TRANSFER_WRITE)
       access |= NOUVEAU_BO_WR;
 
    ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
-   if (ret)
+   if (ret) {
+      pipe_resource_reference(&tx->base.resource, NULL);
+      FREE(tx);
       return NULL;
+   }
+
+   *ptransfer = &tx->base;
    return tx->tmp.bo->map;
 }
 
@@ -313,13 +297,20 @@ static void
 nv30_miptree_transfer_unmap(struct pipe_context *pipe,
                             struct pipe_transfer *ptx)
 {
+   struct nv30_context *nv30 = nv30_context(pipe);
+   struct nv30_transfer *tx = nv30_transfer(ptx);
+
+   if (ptx->usage & PIPE_TRANSFER_WRITE)
+      nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
+
+   nouveau_bo_ref(NULL, &tx->tmp.bo);
+   pipe_resource_reference(&ptx->resource, NULL);
+   FREE(tx);
 }
 
 const struct u_resource_vtbl nv30_miptree_vtbl = {
    nv30_miptree_get_handle,
    nv30_miptree_destroy,
-   nv30_miptree_transfer_new,
-   nv30_miptree_transfer_del,
    nv30_miptree_transfer_map,
    u_default_transfer_flush_region,
    nv30_miptree_transfer_unmap,
index 4d2a2284a75a4e9754f4720e512b5aa7606208fa..f3bc8f1ee1b17a0b40701bd773758bbc31c6bbc5 100644 (file)
@@ -66,11 +66,9 @@ nv30_resource_screen_init(struct pipe_screen *pscreen)
 void
 nv30_resource_init(struct pipe_context *pipe)
 {
-   pipe->get_transfer = u_get_transfer_vtbl;
    pipe->transfer_map = u_transfer_map_vtbl;
    pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
    pipe->transfer_unmap = u_transfer_unmap_vtbl;
-   pipe->transfer_destroy = u_transfer_destroy_vtbl;
    pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
    pipe->create_surface = nv30_miptree_surface_new;
    pipe->surface_destroy = nv30_miptree_surface_del;
index 70e8c7788ea8be16d7aaf1e1463b1e0c0fc21c9a..568526c5933f830ec10405e11cd5cfe84218ef3b 100644 (file)
@@ -145,8 +145,6 @@ const struct u_resource_vtbl nv50_miptree_vtbl =
 {
    nv50_miptree_get_handle,         /* get_handle */
    nv50_miptree_destroy,            /* resource_destroy */
-   nv50_miptree_transfer_new,       /* get_transfer */
-   nv50_miptree_transfer_del,       /* transfer_destroy */
    nv50_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nv50_miptree_transfer_unmap,     /* transfer_unmap */
index 9fe18a6d09dac98784d2bf73c4051e106a0e8f53..42fefa61efcdc387e3addcffd05b27b2e511fc23 100644 (file)
@@ -86,11 +86,9 @@ nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps)
 void
 nv50_init_resource_functions(struct pipe_context *pcontext)
 {
-   pcontext->get_transfer = u_get_transfer_vtbl;
    pcontext->transfer_map = u_transfer_map_vtbl;
    pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
    pcontext->transfer_unmap = u_transfer_unmap_vtbl;
-   pcontext->transfer_destroy = u_transfer_destroy_vtbl;
    pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
    pcontext->create_surface = nv50_surface_create;
    pcontext->surface_destroy = nv50_surface_destroy;
index c1b159e1244646da8687a9f3034ac7c5281f42bc..480895570827b055e3ae35527e5286c6b422f95e 100644 (file)
@@ -123,18 +123,13 @@ nv50_miptree_surface_new(struct pipe_context *,
                          struct pipe_resource *,
                          const struct pipe_surface *templ);
 
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pcontext,
-                          struct pipe_resource *pt,
+void *
+nv50_miptree_transfer_map(struct pipe_context *pctx,
+                          struct pipe_resource *res,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box);
-void
-nv50_miptree_transfer_del(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void *
-nv50_miptree_transfer_map(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer);
 void
 nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
                             struct pipe_transfer *ptx);
index b960dc0d191fc72fa9065b8cff7ccc9feaa05977..25319d785e447b70250f5675c2b4e309f3e9c30e 100644 (file)
@@ -246,19 +246,22 @@ nv50_m2mf_copy_linear(struct nouveau_context *nv,
    nouveau_bufctx_reset(bctx, 0);
 }
 
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pctx,
+void *
+nv50_miptree_transfer_map(struct pipe_context *pctx,
                           struct pipe_resource *res,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer)
 {
+   struct nv50_screen *screen = nv50_screen(pctx->screen);
    struct nv50_context *nv50 = nv50_context(pctx);
    struct nouveau_device *dev = nv50->screen->base.device;
    const struct nv50_miptree *mt = nv50_miptree(res);
    struct nv50_transfer *tx;
    uint32_t size;
    int ret;
+   unsigned flags = 0;
 
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
       return NULL;
@@ -320,12 +323,30 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
       tx->rect[1].base = 0;
    }
 
-   return &tx->base;
+   if (tx->rect[1].bo->map) {
+      *ptransfer = &tx->base;
+      return tx->rect[1].bo->map;
+   }
+
+   if (usage & PIPE_TRANSFER_READ)
+      flags = NOUVEAU_BO_RD;
+   if (usage & PIPE_TRANSFER_WRITE)
+      flags |= NOUVEAU_BO_WR;
+
+   ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client);
+   if (ret) {
+      nouveau_bo_ref(NULL, &tx->rect[1].bo);
+      FREE(tx);
+      return NULL;
+   }
+
+   *ptransfer = &tx->base;
+   return tx->rect[1].bo->map;
 }
 
 void
-nv50_miptree_transfer_del(struct pipe_context *pctx,
-                          struct pipe_transfer *transfer)
+nv50_miptree_transfer_unmap(struct pipe_context *pctx,
+                            struct pipe_transfer *transfer)
 {
    struct nv50_context *nv50 = nv50_context(pctx);
    struct nv50_transfer *tx = (struct nv50_transfer *)transfer;
@@ -350,36 +371,6 @@ nv50_miptree_transfer_del(struct pipe_context *pctx,
    FREE(tx);
 }
 
-void *
-nv50_miptree_transfer_map(struct pipe_context *pctx,
-                          struct pipe_transfer *transfer)
-{
-   struct nv50_screen *screen = nv50_screen(pctx->screen);
-   struct nv50_transfer *tx = (struct nv50_transfer *)transfer;
-   int ret;
-   unsigned flags = 0;
-
-   if (tx->rect[1].bo->map)
-      return tx->rect[1].bo->map;
-
-   if (transfer->usage & PIPE_TRANSFER_READ)
-      flags = NOUVEAU_BO_RD;
-   if (transfer->usage & PIPE_TRANSFER_WRITE)
-      flags |= NOUVEAU_BO_WR;
-
-   ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client);
-   if (ret)
-      return NULL;
-   return tx->rect[1].bo->map;
-}
-
-void
-nv50_miptree_transfer_unmap(struct pipe_context *pctx,
-                            struct pipe_transfer *transfer)
-{
-   /* nothing to do */
-}
-
 void
 nv50_cb_push(struct nouveau_context *nv,
              struct nouveau_bo *bo, unsigned domain,
index 591ac4402db92f0c9de4922afc52bf95ee70fa5b..b63f196eecdc4b9f317fc719b0358c59adc4b203 100644 (file)
@@ -259,8 +259,6 @@ const struct u_resource_vtbl nvc0_miptree_vtbl =
 {
    nv50_miptree_get_handle,         /* get_handle */
    nv50_miptree_destroy,            /* resource_destroy */
-   nvc0_miptree_transfer_new,       /* get_transfer */
-   nvc0_miptree_transfer_del,       /* transfer_destroy */
    nvc0_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nvc0_miptree_transfer_unmap,     /* transfer_unmap */
index daf5c907a05b579a7c5ee6c242d7858248712fec..162399f2e4865fc7e0697fe7b22b256838fdeafa 100644 (file)
@@ -44,11 +44,9 @@ nvc0_surface_create(struct pipe_context *pipe,
 void
 nvc0_init_resource_functions(struct pipe_context *pcontext)
 {
-   pcontext->get_transfer = u_get_transfer_vtbl;
    pcontext->transfer_map = u_transfer_map_vtbl;
    pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
    pcontext->transfer_unmap = u_transfer_unmap_vtbl;
-   pcontext->transfer_destroy = u_transfer_destroy_vtbl;
    pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
    pcontext->create_surface = nvc0_surface_create;
    pcontext->surface_destroy = nv50_surface_destroy;
index 41b1667b2e4067c69f7411ecad2ded055a4032a0..0d5f026d6e1c12767b0921180e162f4c587fe3d3 100644 (file)
@@ -44,18 +44,13 @@ nvc0_miptree_surface_new(struct pipe_context *,
 unsigned
 nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z);
 
-struct pipe_transfer *
-nvc0_miptree_transfer_new(struct pipe_context *pcontext,
-                          struct pipe_resource *pt,
+void *
+nvc0_miptree_transfer_map(struct pipe_context *pctx,
+                          struct pipe_resource *res,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box);
-void
-nvc0_miptree_transfer_del(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void *
-nvc0_miptree_transfer_map(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer);
 void
 nvc0_miptree_transfer_unmap(struct pipe_context *pcontext,
                             struct pipe_transfer *ptx);
index 58dcd862c991d8269d40391529228fd600667a69..66753c9135ba45cd9da68d75ff72ef9056cc3044 100644 (file)
@@ -326,12 +326,13 @@ nve4_m2mf_copy_linear(struct nouveau_context *nv,
    nouveau_bufctx_reset(bctx, 0);
 }
 
-struct pipe_transfer *
-nvc0_miptree_transfer_new(struct pipe_context *pctx,
+void *
+nvc0_miptree_transfer_map(struct pipe_context *pctx,
                           struct pipe_resource *res,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer)
 {
    struct nvc0_context *nvc0 = nvc0_context(pctx);
    struct nouveau_device *dev = nvc0->screen->base.device;
@@ -339,6 +340,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    struct nvc0_transfer *tx;
    uint32_t size;
    int ret;
+   unsigned flags = 0;
 
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
       return NULL;
@@ -372,6 +374,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
                         size * tx->nlayers, NULL, &tx->rect[1].bo);
    if (ret) {
+      pipe_resource_reference(&tx->base.resource, NULL);
       FREE(tx);
       return NULL;
    }
@@ -401,12 +404,31 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
       tx->rect[1].base = 0;
    }
 
-   return &tx->base;
+   if (tx->rect[1].bo->map) {
+      *ptransfer = &tx->base;
+      return tx->rect[1].bo->map;
+   }
+
+   if (usage & PIPE_TRANSFER_READ)
+      flags = NOUVEAU_BO_RD;
+   if (usage & PIPE_TRANSFER_WRITE)
+      flags |= NOUVEAU_BO_WR;
+
+   ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client);
+   if (ret) {
+      pipe_resource_reference(&tx->base.resource, NULL);
+      nouveau_bo_ref(NULL, &tx->rect[1].bo);
+      FREE(tx);
+      return NULL;
+   }
+
+   *ptransfer = &tx->base;
+   return tx->rect[1].bo->map;
 }
 
 void
-nvc0_miptree_transfer_del(struct pipe_context *pctx,
-                          struct pipe_transfer *transfer)
+nvc0_miptree_transfer_unmap(struct pipe_context *pctx,
+                            struct pipe_transfer *transfer)
 {
    struct nvc0_context *nvc0 = nvc0_context(pctx);
    struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer;
@@ -431,35 +453,6 @@ nvc0_miptree_transfer_del(struct pipe_context *pctx,
    FREE(tx);
 }
 
-void *
-nvc0_miptree_transfer_map(struct pipe_context *pctx,
-                          struct pipe_transfer *transfer)
-{
-   struct nvc0_context *nvc0 = nvc0_context(pctx);
-   struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer;
-   int ret;
-   unsigned flags = 0;
-
-   if (tx->rect[1].bo->map)
-      return tx->rect[1].bo->map;
-
-   if (transfer->usage & PIPE_TRANSFER_READ)
-      flags = NOUVEAU_BO_RD;
-   if (transfer->usage & PIPE_TRANSFER_WRITE)
-      flags |= NOUVEAU_BO_WR;
-
-   ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client);
-   if (ret)
-      return NULL;
-   return tx->rect[1].bo->map;
-}
-
-void
-nvc0_miptree_transfer_unmap(struct pipe_context *pctx,
-                            struct pipe_transfer *transfer)
-{
-}
-
 void
 nvc0_cb_push(struct nouveau_context *nv,
              struct nouveau_bo *bo, unsigned domain,
index 46399fb2397f99e6f3d24ff4bc37b1a605491d06..701fd249d307ee9b7ccbebfc5732be8df26b6b4c 100644 (file)
@@ -40,11 +40,9 @@ r300_resource_create(struct pipe_screen *screen,
 
 void r300_init_resource_functions(struct r300_context *r300)
 {
-   r300->context.get_transfer = u_get_transfer_vtbl;
    r300->context.transfer_map = u_transfer_map_vtbl;
    r300->context.transfer_flush_region = u_default_transfer_flush_region;
    r300->context.transfer_unmap = u_transfer_unmap_vtbl;
-   r300->context.transfer_destroy = u_transfer_destroy_vtbl;
    r300->context.transfer_inline_write = u_default_transfer_inline_write;
    r300->context.create_surface = r300_create_surface;
    r300->context.surface_destroy = r300_surface_destroy;
index f652bf72b0c2568b28a60157db805077ecf99dcc..37a7c77010ab9bea703f31c4f917390a0d9d0639 100644 (file)
@@ -63,79 +63,63 @@ static void r300_buffer_destroy(struct pipe_screen *screen,
     FREE(rbuf);
 }
 
-static struct pipe_transfer*
-r300_buffer_get_transfer(struct pipe_context *context,
-                         struct pipe_resource *resource,
-                         unsigned level,
-                         unsigned usage,
-                         const struct pipe_box *box)
-{
-   struct r300_context *r300 = r300_context(context);
-   struct pipe_transfer *transfer =
-         util_slab_alloc(&r300->pool_transfers);
-
-   transfer->resource = resource;
-   transfer->level = level;
-   transfer->usage = usage;
-   transfer->box = *box;
-   transfer->stride = 0;
-   transfer->layer_stride = 0;
-   transfer->data = NULL;
-
-   /* Note strides are zero, this is ok for buffers, but not for
-    * textures 2d & higher at least.
-    */
-   return transfer;
-}
-
-static void r300_buffer_transfer_destroy(struct pipe_context *pipe,
-                                         struct pipe_transfer *transfer)
-{
-   struct r300_context *r300 = r300_context(pipe);
-   util_slab_free(&r300->pool_transfers, transfer);
-}
-
 static void *
-r300_buffer_transfer_map( struct pipe_context *pipe,
-                         struct pipe_transfer *transfer )
+r300_buffer_transfer_map( struct pipe_context *context,
+                          struct pipe_resource *resource,
+                          unsigned level,
+                          unsigned usage,
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer )
 {
-    struct r300_context *r300 = r300_context(pipe);
-    struct r300_screen *r300screen = r300_screen(pipe->screen);
-    struct radeon_winsys *rws = r300screen->rws;
-    struct r300_resource *rbuf = r300_resource(transfer->resource);
+    struct r300_context *r300 = r300_context(context);
+    struct radeon_winsys *rws = r300->screen->rws;
+    struct r300_resource *rbuf = r300_resource(resource);
+    struct pipe_transfer *transfer;
     uint8_t *map;
-    enum pipe_transfer_usage usage;
 
-    if (rbuf->malloced_buffer)
-        return (uint8_t *) rbuf->malloced_buffer + transfer->box.x;
+    transfer = util_slab_alloc(&r300->pool_transfers);
+    transfer->resource = resource;
+    transfer->level = level;
+    transfer->usage = usage;
+    transfer->box = *box;
+    transfer->stride = 0;
+    transfer->layer_stride = 0;
+    transfer->data = NULL;
+
+    if (rbuf->malloced_buffer) {
+        *ptransfer = transfer;
+        return (uint8_t *) rbuf->malloced_buffer + box->x;
+    }
 
     /* Buffers are never used for write, therefore mapping for read can be
      * unsynchronized. */
-    usage = transfer->usage;
     if (!(usage & PIPE_TRANSFER_WRITE)) {
        usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
     }
 
     map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
 
-    if (map == NULL)
+    if (map == NULL) {
+        util_slab_free(&r300->pool_transfers, transfer);
         return NULL;
+    }
 
-    return map + transfer->box.x;
+    *ptransfer = transfer;
+    return map + box->x;
 }
 
 static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
-                           struct pipe_transfer *transfer )
+                                        struct pipe_transfer *transfer )
 {
-    /* no-op */
+    struct r300_context *r300 = r300_context(pipe);
+
+    util_slab_free(&r300->pool_transfers, transfer);
 }
 
 static const struct u_resource_vtbl r300_buffer_vtbl =
 {
    NULL,                               /* get_handle */
    r300_buffer_destroy,                /* resource_destroy */
-   r300_buffer_get_transfer,           /* get_transfer */
-   r300_buffer_transfer_destroy,       /* transfer_destroy */
    r300_buffer_transfer_map,           /* transfer_map */
    NULL,                               /* transfer_flush_region */
    r300_buffer_transfer_unmap,         /* transfer_unmap */
index 39cca78ebce39ec5685e2a2e2242bf1945e875a9..7f74538deeaa5475ce158bb51bd9a914844e25a2 100644 (file)
@@ -937,8 +937,6 @@ static const struct u_resource_vtbl r300_texture_vtbl =
 {
     NULL,                           /* get_handle */
     r300_texture_destroy,           /* resource_destroy */
-    r300_texture_get_transfer,      /* get_transfer */
-    r300_texture_transfer_destroy,  /* transfer_destroy */
     r300_texture_transfer_map,      /* transfer_map */
     NULL,                           /* transfer_flush_region */
     r300_texture_transfer_unmap,    /* transfer_unmap */
index 9140bb191cfe6443f1c98cc03e54da7685c2cf44..fbae2df52b9be8017971858b6fa027e5743d24f4 100644 (file)
@@ -76,18 +76,21 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
     r300_flush(ctx, 0, NULL);
 }
 
-struct pipe_transfer*
-r300_texture_get_transfer(struct pipe_context *ctx,
+void *
+r300_texture_transfer_map(struct pipe_context *ctx,
                           struct pipe_resource *texture,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **transfer)
 {
     struct r300_context *r300 = r300_context(ctx);
     struct r300_resource *tex = r300_resource(texture);
     struct r300_transfer *trans;
     struct pipe_resource base;
     boolean referenced_cs, referenced_hw;
+    enum pipe_format format = tex->b.b.format;
+    char *map;
 
     referenced_cs =
         r300->rws->cs_is_buffer_referenced(r300->cs, tex->cs_buf, RADEON_USAGE_READWRITE);
@@ -101,7 +104,7 @@ r300_texture_get_transfer(struct pipe_context *ctx,
     trans = CALLOC_STRUCT(r300_transfer);
     if (trans) {
         /* Initialize the transfer object. */
-        pipe_resource_reference(&trans->transfer.resource, texture);
+        trans->transfer.resource = texture;
         trans->transfer.level = level;
         trans->transfer.usage = usage;
         trans->transfer.box = *box;
@@ -161,15 +164,8 @@ r300_texture_get_transfer(struct pipe_context *ctx,
                                                 &base));
 
                 if (!trans->linear_texture) {
-                    /* For linear textures, it's safe to fallback to
-                     * an unpipelined transfer. */
-                    if (!tex->tex.microtile && !tex->tex.macrotile[level]) {
-                        goto unpipelined;
-                    }
-
-                    /* Otherwise, go to hell. */
                     fprintf(stderr,
-                        "r300: Failed to create a transfer object, praise.\n");
+                            "r300: Failed to create a transfer object.\n");
                     FREE(trans);
                     return NULL;
                 }
@@ -190,64 +186,43 @@ r300_texture_get_transfer(struct pipe_context *ctx,
                 /* Always referenced in the blit. */
                 r300_flush(ctx, 0, NULL);
             }
-            return &trans->transfer;
-        }
-
-    unpipelined:
-        /* Unpipelined transfer. */
-        trans->transfer.stride = tex->tex.stride_in_bytes[level];
-        trans->offset = r300_texture_get_offset(tex, level, box->z);
-
-        if (referenced_cs &&
-            !(usage & PIPE_TRANSFER_UNSYNCHRONIZED))
-            r300_flush(ctx, 0, NULL);
-        return &trans->transfer;
-    }
-    return NULL;
-}
+        } else {
+            /* Unpipelined transfer. */
+            trans->transfer.stride = tex->tex.stride_in_bytes[level];
+            trans->offset = r300_texture_get_offset(tex, level, box->z);
 
-void r300_texture_transfer_destroy(struct pipe_context *ctx,
-                                  struct pipe_transfer *trans)
-{
-    struct r300_transfer *r300transfer = r300_transfer(trans);
-
-    if (r300transfer->linear_texture) {
-        if (trans->usage & PIPE_TRANSFER_WRITE) {
-            r300_copy_into_tiled_texture(ctx, r300transfer);
+            if (referenced_cs &&
+                !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+                r300_flush(ctx, 0, NULL);
+            }
         }
-
-        pipe_resource_reference(
-            (struct pipe_resource**)&r300transfer->linear_texture, NULL);
     }
-    pipe_resource_reference(&trans->resource, NULL);
-    FREE(trans);
-}
 
-void* r300_texture_transfer_map(struct pipe_context *ctx,
-                               struct pipe_transfer *transfer)
-{
-    struct r300_context *r300 = r300_context(ctx);
-    struct r300_transfer *r300transfer = r300_transfer(transfer);
-    struct r300_resource *tex = r300_resource(transfer->resource);
-    char *map;
-    enum pipe_format format = tex->b.b.format;
-
-    if (r300transfer->linear_texture) {
+    if (trans->linear_texture) {
         /* The detiled texture is of the same size as the region being mapped
          * (no offset needed). */
-        return r300->rws->buffer_map(r300transfer->linear_texture->cs_buf,
-                                    r300->cs, transfer->usage);
+        map = r300->rws->buffer_map(trans->linear_texture->cs_buf,
+                                    r300->cs, usage);
+        if (!map) {
+            pipe_resource_reference(
+                (struct pipe_resource**)&trans->linear_texture, NULL);
+            FREE(trans);
+            return NULL;
+        }
+       *transfer = &trans->transfer;
+        return map;
     } else {
         /* Tiling is disabled. */
-        map = r300->rws->buffer_map(tex->cs_buf, r300->cs, transfer->usage);
-
+        map = r300->rws->buffer_map(tex->cs_buf, r300->cs, usage);
         if (!map) {
+            FREE(trans);
             return NULL;
         }
 
-        return map + r300_transfer(transfer)->offset +
-            transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
-            transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+       *transfer = &trans->transfer;
+        return map + trans->offset +
+            box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+            box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
     }
 }
 
@@ -255,12 +230,20 @@ void r300_texture_transfer_unmap(struct pipe_context *ctx,
                                 struct pipe_transfer *transfer)
 {
     struct radeon_winsys *rws = r300_context(ctx)->rws;
-    struct r300_transfer *r300transfer = r300_transfer(transfer);
+    struct r300_transfer *trans = r300_transfer(transfer);
     struct r300_resource *tex = r300_resource(transfer->resource);
 
-    if (r300transfer->linear_texture) {
-        rws->buffer_unmap(r300transfer->linear_texture->cs_buf);
+    if (trans->linear_texture) {
+        rws->buffer_unmap(trans->linear_texture->cs_buf);
+
+        if (transfer->usage & PIPE_TRANSFER_WRITE) {
+            r300_copy_into_tiled_texture(ctx, trans);
+        }
+
+        pipe_resource_reference(
+            (struct pipe_resource**)&trans->linear_texture, NULL);
     } else {
         rws->buffer_unmap(tex->cs_buf);
     }
+    FREE(transfer);
 }
index 7977ef516f2181b380ca9d938428ad0d787e340c..45477ae6d0d71f399f735eff35e5e9aed433688a 100644 (file)
 
 struct r300_context;
 
-struct pipe_transfer*
-r300_texture_get_transfer(struct pipe_context *ctx,
+void *
+r300_texture_transfer_map(struct pipe_context *ctx,
                           struct pipe_resource *texture,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box);
-
-void
-r300_texture_transfer_destroy(struct pipe_context *ctx,
-                              struct pipe_transfer *trans);
-
-void*
-r300_texture_transfer_map(struct pipe_context *ctx,
-                          struct pipe_transfer *transfer);
+                          const struct pipe_box *box,
+                          struct pipe_transfer **transfer);
 
 void
 r300_texture_transfer_unmap(struct pipe_context *ctx,
index 19fbe0cddc4a80c1de63140d6fc40c3d090b5e3b..46bff3221d9ff8c63fffb829497bb30a4913cc13 100644 (file)
@@ -453,27 +453,22 @@ void compute_memory_transfer(
                "offset_in_chunk = %d, size = %d\n", device_to_host,
                offset_in_chunk, size);
 
-       if (device_to_host)
-       {
-               xfer = pipe->get_transfer(pipe, gart, 0, PIPE_TRANSFER_READ,
+       if (device_to_host) {
+               map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_READ,
                        &(struct pipe_box) { .width = aligned_size,
-                       .height = 1, .depth = 1 });
-               assert(xfer);
-               map = pipe->transfer_map(pipe, xfer);
+                       .height = 1, .depth = 1 }, &xfer);
+                assert(xfer);
                assert(map);
                memcpy(data, map + internal_offset, size);
                pipe->transfer_unmap(pipe, xfer);
-               pipe->transfer_destroy(pipe, xfer);
        } else {
-               xfer = pipe->get_transfer(pipe, gart, 0, PIPE_TRANSFER_WRITE,
+               map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_WRITE,
                        &(struct pipe_box) { .width = aligned_size,
-                       .height = 1, .depth = 1 });
+                       .height = 1, .depth = 1 }, &xfer);
                assert(xfer);
-               map = pipe->transfer_map(pipe, xfer);
                assert(map);
                memcpy(map + internal_offset, data, size);
                pipe->transfer_unmap(pipe, xfer);
-               pipe->transfer_destroy(pipe, xfer);
        }
 }
 
index 8f055bd5f389d842c6f5295563adf07410d2878c..655cf756186e90896d9796b1a9550d7f8a535d13 100644 (file)
@@ -104,12 +104,10 @@ static void evergreen_cs_set_vertex_buffer(
        state->atom.dirty = true;
 }
 
-const struct u_resource_vtbl r600_global_buffer_vtbl =
+static const struct u_resource_vtbl r600_global_buffer_vtbl =
 {
        u_default_resource_get_handle, /* get_handle */
        r600_compute_global_buffer_destroy, /* resource_destroy */
-       r600_compute_global_get_transfer, /* get_transfer */
-       r600_compute_global_transfer_destroy, /* transfer_destroy */
        r600_compute_global_transfer_map, /* transfer_map */
        r600_compute_global_transfer_flush_region,/* transfer_flush_region */
        r600_compute_global_transfer_unmap, /* transfer_unmap */
@@ -841,30 +839,57 @@ void r600_compute_global_buffer_destroy(
        free(res);
 }
 
-voidr600_compute_global_transfer_map(
+void *r600_compute_global_transfer_map(
        struct pipe_context *ctx_,
-       struct pipe_transfer* transfer)
+       struct pipe_resource *resource,
+       unsigned level,
+       unsigned usage,
+       const struct pipe_box *box,
+       struct pipe_transfer **ptransfer)
 {
+       struct r600_context *rctx = (struct r600_context*)ctx_;
+       struct compute_memory_pool *pool = rctx->screen->global_pool;
+       struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+       struct r600_resource_global* buffer =
+               (struct r600_resource_global*)transfer->resource;
+       uint32_t* map;
+
+       compute_memory_finalize_pending(pool, ctx_);
+
+       assert(resource->target == PIPE_BUFFER);
+
+       COMPUTE_DBG("* r600_compute_global_get_transfer()\n"
+                       "level = %u, usage = %u, box(x = %u, y = %u, z = %u "
+                       "width = %u, height = %u, depth = %u)\n", level, usage,
+                       box->x, box->y, box->z, box->width, box->height,
+                       box->depth);
+
+       transfer->resource = resource;
+       transfer->level = level;
+       transfer->usage = usage;
+       transfer->box = *box;
+       transfer->stride = 0;
+       transfer->layer_stride = 0;
+       transfer->data = NULL;
+
        assert(transfer->resource->target == PIPE_BUFFER);
        assert(transfer->resource->bind & PIPE_BIND_GLOBAL);
        assert(transfer->box.x >= 0);
        assert(transfer->box.y == 0);
        assert(transfer->box.z == 0);
 
-       struct r600_context *ctx = (struct r600_context *)ctx_;
-       struct r600_resource_global* buffer =
-               (struct r600_resource_global*)transfer->resource;
-
-       uint32_t* map;
        ///TODO: do it better, mapping is not possible if the pool is too big
 
        COMPUTE_DBG("* r600_compute_global_transfer_map()\n");
 
-       if (!(map = ctx->ws->buffer_map(buffer->chunk->pool->bo->cs_buf,
-                                               ctx->cs, transfer->usage))) {
+       if (!(map = rctx->ws->buffer_map(buffer->chunk->pool->bo->cs_buf,
+                                               rctx->cs, transfer->usage))) {
+               util_slab_free(&rctx->pool_transfers, transfer);
                return NULL;
        }
 
+       *ptransfer = transfer;
+
        COMPUTE_DBG("Buffer: %p + %u (buffer offset in global memory) "
                "+ %u (box.x)\n", map, buffer->chunk->start_in_dw, transfer->box.x);
        return ((char*)(map + buffer->chunk->start_in_dw)) + transfer->box.x;
@@ -884,50 +909,7 @@ void r600_compute_global_transfer_unmap(
        COMPUTE_DBG("* r600_compute_global_transfer_unmap()\n");
 
        ctx->ws->buffer_unmap(buffer->chunk->pool->bo->cs_buf);
-}
-
-struct pipe_transfer * r600_compute_global_get_transfer(
-       struct pipe_context *ctx_,
-       struct pipe_resource *resource,
-       unsigned level,
-       unsigned usage,
-       const struct pipe_box *box)
-{
-       struct r600_context *ctx = (struct r600_context *)ctx_;
-       struct compute_memory_pool *pool = ctx->screen->global_pool;
-
-       compute_memory_finalize_pending(pool, ctx_);
-
-       assert(resource->target == PIPE_BUFFER);
-       struct r600_context *rctx = (struct r600_context*)ctx_;
-       struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
-
-       COMPUTE_DBG("* r600_compute_global_get_transfer()\n"
-                       "level = %u, usage = %u, box(x = %u, y = %u, z = %u "
-                       "width = %u, height = %u, depth = %u)\n", level, usage,
-                       box->x, box->y, box->z, box->width, box->height,
-                       box->depth);
-
-       transfer->resource = resource;
-       transfer->level = level;
-       transfer->usage = usage;
-       transfer->box = *box;
-       transfer->stride = 0;
-       transfer->layer_stride = 0;
-       transfer->data = NULL;
-
-       /* Note strides are zero, this is ok for buffers, but not for
-       * textures 2d & higher at least.
-       */
-       return transfer;
-}
-
-void r600_compute_global_transfer_destroy(
-       struct pipe_context *ctx_,
-       struct pipe_transfer *transfer)
-{
-       struct r600_context *rctx = (struct r600_context*)ctx_;
-       util_slab_free(&rctx->pool_transfers, transfer);
+       util_slab_free(&ctx->pool_transfers, transfer);
 }
 
 void r600_compute_global_transfer_flush_region(
index f29d91b9349e26b5f02e5e3379383cbe47289a7c..e68ebd8585e8f410db1a72e78c07cdcd74636299 100644 (file)
@@ -41,11 +41,14 @@ void evergreen_emit_cs_shader(struct r600_context *rctx, struct r600_atom * atom
 
 struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ);
 void r600_compute_global_buffer_destroy(struct pipe_screen *screen, struct pipe_resource *res);
-void* r600_compute_global_transfer_map(struct pipe_context *ctx, struct pipe_transfer* transfer);
+void *r600_compute_global_transfer_map(
+       struct pipe_context *ctx_,
+       struct pipe_resource *resource,
+       unsigned level,
+       unsigned usage,
+       const struct pipe_box *box,
+       struct pipe_transfer **ptransfer);
 void r600_compute_global_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer* transfer);
-struct pipe_transfer * r600_compute_global_get_transfer(struct pipe_context *, struct pipe_resource *, unsigned level,
-                                                        unsigned usage, const struct pipe_box *);
-void r600_compute_global_transfer_destroy(struct pipe_context *, struct pipe_transfer *);
 void r600_compute_global_transfer_flush_region( struct pipe_context *, struct pipe_transfer *, const struct pipe_box *);
 void r600_compute_global_transfer_inline_write( struct pipe_context *, struct pipe_resource *, unsigned level,
                                                 unsigned usage, const struct pipe_box *, const void *data, unsigned stride, unsigned layer_stride);
index 0b0ac3460e1bfb3fec66028a2fa3d7ea9e2fe5d9..90ab2475d75fdaee463965fa73d74d42641294ab 100644 (file)
@@ -37,33 +37,6 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
        FREE(rbuffer);
 }
 
-static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
-                                              struct pipe_resource *resource,
-                                              unsigned level,
-                                              unsigned usage,
-                                              const struct pipe_box *box)
-{
-       struct r600_context *rctx = (struct r600_context*)ctx;
-       struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
-
-       assert(box->x + box->width <= resource->width0);
-
-       transfer->transfer.resource = resource;
-       transfer->transfer.level = level;
-       transfer->transfer.usage = usage;
-       transfer->transfer.box = *box;
-       transfer->transfer.stride = 0;
-       transfer->transfer.layer_stride = 0;
-       transfer->transfer.data = NULL;
-       transfer->staging = NULL;
-       transfer->offset = 0;
-
-       /* Note strides are zero, this is ok for buffers, but not for
-        * textures 2d & higher at least.
-        */
-       return &transfer->transfer;
-}
-
 static void r600_set_constants_dirty_if_bound(struct r600_context *rctx,
                                              struct r600_resource *rbuffer)
 {
@@ -87,16 +60,47 @@ static void r600_set_constants_dirty_if_bound(struct r600_context *rctx,
        }
 }
 
-static void *r600_buffer_transfer_map(struct pipe_context *pipe,
-                                     struct pipe_transfer *transfer)
+static void *r600_buffer_get_transfer(struct pipe_context *ctx,
+                                     struct pipe_resource *resource,
+                                      unsigned level,
+                                      unsigned usage,
+                                      const struct pipe_box *box,
+                                     struct pipe_transfer **ptransfer,
+                                     void *data, struct r600_resource *staging)
 {
-       struct r600_resource *rbuffer = r600_resource(transfer->resource);
-       struct r600_context *rctx = (struct r600_context*)pipe;
+       struct r600_context *rctx = (struct r600_context*)ctx;
+       struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+
+       transfer->transfer.resource = resource;
+       transfer->transfer.level = level;
+       transfer->transfer.usage = usage;
+       transfer->transfer.box = *box;
+       transfer->transfer.stride = 0;
+       transfer->transfer.layer_stride = 0;
+       transfer->transfer.data = NULL;
+       transfer->staging = NULL;
+       transfer->offset = 0;
+       transfer->staging = staging;
+       *ptransfer = &transfer->transfer;
+       return data;
+}
+
+static void *r600_buffer_transfer_map(struct pipe_context *ctx,
+                                      struct pipe_resource *resource,
+                                      unsigned level,
+                                      unsigned usage,
+                                      const struct pipe_box *box,
+                                     struct pipe_transfer **ptransfer)
+{
+       struct r600_context *rctx = (struct r600_context*)ctx;
+       struct r600_resource *rbuffer = r600_resource(resource);
        uint8_t *data;
 
-       if (transfer->usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE &&
-           !(transfer->usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
-               assert(transfer->usage & PIPE_TRANSFER_WRITE);
+       assert(box->x + box->width <= resource->width0);
+
+       if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE &&
+           !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+               assert(usage & PIPE_TRANSFER_WRITE);
 
                /* Check if mapping this buffer would cause waiting for the GPU. */
                if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rbuffer->cs_buf, RADEON_USAGE_READWRITE) ||
@@ -134,37 +138,44 @@ static void *r600_buffer_transfer_map(struct pipe_context *pipe,
                }
        }
 #if 0 /* this is broken (see Bug 53130) */
-       else if ((transfer->usage & PIPE_TRANSFER_DISCARD_RANGE) &&
-                !(transfer->usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
+       else if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
+                !(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
                 rctx->screen->has_streamout &&
                 /* The buffer range must be aligned to 4. */
-                transfer->box.x % 4 == 0 && transfer->box.width % 4 == 0) {
-               assert(transfer->usage & PIPE_TRANSFER_WRITE);
+                box->x % 4 == 0 && box->width % 4 == 0) {
+               assert(usage & PIPE_TRANSFER_WRITE);
 
                /* Check if mapping this buffer would cause waiting for the GPU. */
                if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rbuffer->cs_buf, RADEON_USAGE_READWRITE) ||
                    rctx->ws->buffer_is_busy(rbuffer->buf, RADEON_USAGE_READWRITE)) {
                        /* Do a wait-free write-only transfer using a temporary buffer. */
-                       struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-
-                       rtransfer->staging = (struct r600_resource*)
-                               pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
-                                                  PIPE_USAGE_STAGING, transfer->box.width);
-                       return rctx->ws->buffer_map(rtransfer->staging->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+                       struct r600_resource *staging = (struct r600_resource*)
+                               pipe_buffer_create(ctx->screen, PIPE_BIND_VERTEX_BUFFER,
+                                                  PIPE_USAGE_STAGING, box->width);
+                       data = rctx->ws->buffer_map(staging->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+
+                       if (!data)
+                               return NULL;
+                       return r600_buffer_get_transfer(ctx, resource, level, usage, box,
+                                                       ptransfer, data, staging);
                }
        }
 #endif
 
-       data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, transfer->usage);
-       if (!data)
+       data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, usage);
+       if (!data) {
                return NULL;
+       }
+       data += box->x;
 
-       return (uint8_t*)data + transfer->box.x;
+       return r600_buffer_get_transfer(ctx, resource, level, usage, box,
+                                       ptransfer, data, NULL);
 }
 
 static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
                                        struct pipe_transfer *transfer)
 {
+       struct r600_context *rctx = (struct r600_context*)pipe;
        struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
 
        if (rtransfer->staging) {
@@ -176,12 +187,6 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
                                 &rtransfer->staging->b.b, &box);
                pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
        }
-}
-
-static void r600_transfer_destroy(struct pipe_context *ctx,
-                                 struct pipe_transfer *transfer)
-{
-       struct r600_context *rctx = (struct r600_context*)ctx;
        util_slab_free(&rctx->pool_transfers, transfer);
 }
 
@@ -189,8 +194,6 @@ static const struct u_resource_vtbl r600_buffer_vtbl =
 {
        u_default_resource_get_handle,          /* get_handle */
        r600_buffer_destroy,                    /* resource_destroy */
-       r600_get_transfer,                      /* get_transfer */
-       r600_transfer_destroy,                  /* transfer_destroy */
        r600_buffer_transfer_map,               /* transfer_map */
        NULL,                                   /* transfer_flush_region */
        r600_buffer_transfer_unmap,             /* transfer_unmap */
index 1a91d5d57559cde4ed3906b56690af2efb4b11e1..5e637f64a4aeaac2732191c071103246915143fc 100644 (file)
@@ -68,10 +68,8 @@ void r600_init_screen_resource_functions(struct pipe_screen *screen)
 
 void r600_init_context_resource_functions(struct r600_context *r600)
 {
-       r600->context.get_transfer = u_get_transfer_vtbl;
        r600->context.transfer_map = u_transfer_map_vtbl;
        r600->context.transfer_flush_region = u_default_transfer_flush_region;
        r600->context.transfer_unmap = u_transfer_unmap_vtbl;
-       r600->context.transfer_destroy = u_transfer_destroy_vtbl;
        r600->context.transfer_inline_write = u_default_transfer_inline_write;
 }
index bf7fffa44c5ade56ece363948090e0ec72c9b4d5..7ebf59e23a5b51de59faa6dbd31d514362101c8c 100644 (file)
@@ -141,17 +141,4 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
                                     struct pipe_resource *texture,
                                     struct r600_texture **staging);
 
-/* r600_texture.c texture transfer functions. */
-struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
-                                               struct pipe_resource *texture,
-                                               unsigned level,
-                                               unsigned usage,
-                                               const struct pipe_box *box);
-void r600_texture_transfer_destroy(struct pipe_context *ctx,
-                                  struct pipe_transfer *trans);
-void* r600_texture_transfer_map(struct pipe_context *ctx,
-                               struct pipe_transfer* transfer);
-void r600_texture_transfer_unmap(struct pipe_context *ctx,
-                                struct pipe_transfer* transfer);
-
 #endif
index 4fb10ca031d96bdf0868c23e4844424129e1dde2..785eeffcab5d83a47b7fc05cec3b929b666fb09b 100644 (file)
@@ -240,17 +240,7 @@ static void r600_texture_destroy(struct pipe_screen *screen,
        FREE(rtex);
 }
 
-static const struct u_resource_vtbl r600_texture_vtbl =
-{
-       r600_texture_get_handle,        /* get_handle */
-       r600_texture_destroy,           /* resource_destroy */
-       r600_texture_get_transfer,      /* get_transfer */
-       r600_texture_transfer_destroy,  /* transfer_destroy */
-       r600_texture_transfer_map,      /* transfer_map */
-       NULL,                           /* transfer_flush_region */
-       r600_texture_transfer_unmap,    /* transfer_unmap */
-       NULL                            /* transfer_inline_write */
-};
+static const struct u_resource_vtbl r600_texture_vtbl;
 
 /* The number of samples can be specified independently of the texture. */
 void r600_texture_get_fmask_info(struct r600_screen *rscreen,
@@ -603,17 +593,26 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
        return true;
 }
 
-struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
-                                               struct pipe_resource *texture,
-                                               unsigned level,
-                                               unsigned usage,
-                                               const struct pipe_box *box)
+static void *r600_texture_transfer_map(struct pipe_context *ctx,
+                                      struct pipe_resource *texture,
+                                      unsigned level,
+                                      unsigned usage,
+                                      const struct pipe_box *box,
+                                      struct pipe_transfer **ptransfer)
 {
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct r600_texture *rtex = (struct r600_texture*)texture;
        struct pipe_resource resource;
        struct r600_transfer *trans;
        boolean use_staging_texture = FALSE;
+       enum pipe_format format = texture->format;
+       struct radeon_winsys_cs_handle *buf;
+       unsigned offset = 0;
+       char *map;
+
+       if ((texture->bind & PIPE_BIND_GLOBAL) && texture->target == PIPE_BUFFER) {
+               return r600_compute_global_transfer_map(ctx, texture, level, usage, box, ptransfer);
+       }
 
        /* We cannot map a tiled texture directly because the data is
         * in a different order, therefore we do detiling using a blit.
@@ -644,7 +643,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
        trans = CALLOC_STRUCT(r600_transfer);
        if (trans == NULL)
                return NULL;
-       pipe_resource_reference(&trans->transfer.resource, texture);
+       trans->transfer.resource = texture;
        trans->transfer.level = level;
        trans->transfer.usage = usage;
        trans->transfer.box = *box;
@@ -657,7 +656,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
 
                if (!r600_init_flushed_depth_texture(ctx, texture, &staging_depth)) {
                        R600_ERR("failed to create temporary texture to hold untiled copy\n");
-                       pipe_resource_reference(&trans->transfer.resource, NULL);
                        FREE(trans);
                        return NULL;
                }
@@ -670,7 +668,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
                trans->transfer.stride = staging_depth->surface.level[level].pitch_bytes;
                trans->offset = r600_texture_get_offset(staging_depth, level, box->z);
                trans->staging = (struct r600_resource*)staging_depth;
-               return &trans->transfer;
        } else if (use_staging_texture) {
                resource.target = PIPE_TEXTURE_2D;
                resource.format = texture->format;
@@ -697,7 +694,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
                trans->staging = (struct r600_resource*)ctx->screen->resource_create(ctx->screen, &resource);
                if (trans->staging == NULL) {
                        R600_ERR("failed to create temporary texture to hold untiled copy\n");
-                       pipe_resource_reference(&trans->transfer.resource, NULL);
                        FREE(trans);
                        return NULL;
                }
@@ -709,79 +705,41 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
                        /* Always referenced in the blit. */
                        r600_flush(ctx, NULL, 0);
                }
-               return &trans->transfer;
-       }
-       trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
-       trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
-       trans->offset = r600_texture_get_offset(rtex, level, box->z);
-       return &trans->transfer;
-}
-
-void r600_texture_transfer_destroy(struct pipe_context *ctx,
-                                  struct pipe_transfer *transfer)
-{
-       struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-       struct pipe_resource *texture = transfer->resource;
-       struct r600_texture *rtex = (struct r600_texture*)texture;
-
-       if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
-               if (rtex->is_depth) {
-                       ctx->resource_copy_region(ctx, texture, transfer->level,
-                                                 transfer->box.x, transfer->box.y, transfer->box.z,
-                                                 &rtransfer->staging->b.b, transfer->level,
-                                                 &transfer->box);
-               } else {
-                       r600_copy_from_staging_texture(ctx, rtransfer);
-               }
-       }
-
-       if (rtransfer->staging)
-               pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
-
-       pipe_resource_reference(&transfer->resource, NULL);
-       FREE(transfer);
-}
-
-void* r600_texture_transfer_map(struct pipe_context *ctx,
-                               struct pipe_transfer* transfer)
-{
-       struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-       struct radeon_winsys_cs_handle *buf;
-       struct r600_texture *rtex =
-                       (struct r600_texture*)transfer->resource;
-       enum pipe_format format = transfer->resource->format;
-       unsigned offset = 0;
-       char *map;
-
-       if ((transfer->resource->bind & PIPE_BIND_GLOBAL) && transfer->resource->target == PIPE_BUFFER) {
-               return r600_compute_global_transfer_map(ctx, transfer);
+       } else {
+               trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
+               trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
+               trans->offset = r600_texture_get_offset(rtex, level, box->z);
        }
 
-       if (rtransfer->staging) {
-               buf = ((struct r600_resource *)rtransfer->staging)->cs_buf;
+       if (trans->staging) {
+               buf = ((struct r600_resource *)trans->staging)->cs_buf;
        } else {
-               buf = ((struct r600_resource *)transfer->resource)->cs_buf;
+               buf = ((struct r600_resource *)texture)->cs_buf;
        }
 
-       if (rtex->is_depth || !rtransfer->staging)
-               offset = rtransfer->offset +
-                       transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
-                       transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+       if (rtex->is_depth || !trans->staging)
+               offset = trans->offset +
+                       box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+                       box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 
-       if (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
+       if (!(map = rctx->ws->buffer_map(buf, rctx->cs, usage))) {
+               pipe_resource_reference((struct pipe_resource**)&trans->staging, NULL);
+               FREE(trans);
                return NULL;
        }
 
+       *ptransfer = &trans->transfer;
        return map + offset;
 }
 
-void r600_texture_transfer_unmap(struct pipe_context *ctx,
-                                struct pipe_transfer* transfer)
+static void r600_texture_transfer_unmap(struct pipe_context *ctx,
+                                       struct pipe_transfer* transfer)
 {
        struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct radeon_winsys_cs_handle *buf;
+       struct pipe_resource *texture = transfer->resource;
+       struct r600_texture *rtex = (struct r600_texture*)texture;
 
        if ((transfer->resource->bind & PIPE_BIND_GLOBAL) && transfer->resource->target == PIPE_BUFFER) {
                return r600_compute_global_transfer_unmap(ctx, transfer);
@@ -793,6 +751,22 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx,
                buf = ((struct r600_resource *)transfer->resource)->cs_buf;
        }
        rctx->ws->buffer_unmap(buf);
+
+       if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
+               if (rtex->is_depth) {
+                       ctx->resource_copy_region(ctx, texture, transfer->level,
+                                                 transfer->box.x, transfer->box.y, transfer->box.z,
+                                                 &rtransfer->staging->b.b, transfer->level,
+                                                 &transfer->box);
+               } else {
+                       r600_copy_from_staging_texture(ctx, rtransfer);
+               }
+       }
+
+       if (rtransfer->staging)
+               pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
+
+       FREE(transfer);
 }
 
 void r600_init_surface_functions(struct r600_context *r600)
@@ -1178,3 +1152,13 @@ out_unknown:
        /* R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format)); */
        return ~0;
 }
+
+static const struct u_resource_vtbl r600_texture_vtbl =
+{
+       r600_texture_get_handle,        /* get_handle */
+       r600_texture_destroy,           /* resource_destroy */
+       r600_texture_transfer_map,      /* transfer_map */
+       NULL,                           /* transfer_flush_region */
+       r600_texture_transfer_unmap,    /* transfer_unmap */
+       NULL                            /* transfer_inline_write */
+};
index ec9d87e48660509866c908da9a301f6bbed2d743..7fae048d1f57f516096cc6de9a89e31c9b31537d 100644 (file)
@@ -46,15 +46,24 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
        FREE(rbuffer);
 }
 
-static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
-                                              struct pipe_resource *resource,
-                                              unsigned level,
-                                              unsigned usage,
-                                              const struct pipe_box *box)
+static void *r600_buffer_transfer_map(struct pipe_context *ctx,
+                                      struct pipe_resource *resource,
+                                      unsigned level,
+                                      unsigned usage,
+                                      const struct pipe_box *box,
+                                      struct pipe_transfer **ptransfer)
 {
        struct r600_context *rctx = (struct r600_context*)ctx;
-       struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+       struct pipe_transfer *transfer;
+        struct si_resource *rbuffer = si_resource(resource);
+        uint8_t *data;
 
+       data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, usage);
+        if (!data) {
+               return NULL;
+        }
+
+       transfer = util_slab_alloc(&rctx->pool_transfers);
        transfer->resource = resource;
        transfer->level = level;
        transfer->usage = usage;
@@ -62,31 +71,16 @@ static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
        transfer->stride = 0;
        transfer->layer_stride = 0;
        transfer->data = NULL;
-
-       /* Note strides are zero, this is ok for buffers, but not for
-        * textures 2d & higher at least.
-        */
-       return transfer;
-}
-
-static void *r600_buffer_transfer_map(struct pipe_context *pipe,
-                                     struct pipe_transfer *transfer)
-{
-       struct si_resource *rbuffer = si_resource(transfer->resource);
-       struct r600_context *rctx = (struct r600_context*)pipe;
-       uint8_t *data;
-
-       data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, transfer->usage);
-       if (!data)
-               return NULL;
+        *ptransfer = transfer;
 
        return (uint8_t*)data + transfer->box.x;
 }
 
-static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
+static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
                                        struct pipe_transfer *transfer)
 {
-       /* no-op */
+       struct r600_context *rctx = (struct r600_context*)ctx;
+       util_slab_free(&rctx->pool_transfers, transfer);
 }
 
 static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
@@ -95,19 +89,10 @@ static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
 {
 }
 
-static void r600_transfer_destroy(struct pipe_context *ctx,
-                                 struct pipe_transfer *transfer)
-{
-       struct r600_context *rctx = (struct r600_context*)ctx;
-       util_slab_free(&rctx->pool_transfers, transfer);
-}
-
 static const struct u_resource_vtbl r600_buffer_vtbl =
 {
        u_default_resource_get_handle,          /* get_handle */
        r600_buffer_destroy,                    /* resource_destroy */
-       r600_get_transfer,                      /* get_transfer */
-       r600_transfer_destroy,                  /* transfer_destroy */
        r600_buffer_transfer_map,               /* transfer_map */
        r600_buffer_transfer_flush_region,      /* transfer_flush_region */
        r600_buffer_transfer_unmap,             /* transfer_unmap */
index a4888a703b4cce60f2c97c8264ffabe092e477f8..33ccd003090da43945e8d3cb3fd9080a5e6b56a8 100644 (file)
@@ -54,10 +54,8 @@ void r600_init_screen_resource_functions(struct pipe_screen *screen)
 
 void r600_init_context_resource_functions(struct r600_context *r600)
 {
-       r600->context.get_transfer = u_get_transfer_vtbl;
        r600->context.transfer_map = u_transfer_map_vtbl;
        r600->context.transfer_flush_region = u_transfer_flush_region_vtbl;
        r600->context.transfer_unmap = u_transfer_unmap_vtbl;
-       r600->context.transfer_destroy = u_transfer_destroy_vtbl;
        r600->context.transfer_inline_write = u_default_transfer_inline_write;
 }
index e6f72c88b058bdcd6b6809d9c4a45b61d22c8288..8fae79200b68330acc7d248a166531aeb1f994d1 100644 (file)
@@ -254,17 +254,23 @@ static void r600_texture_destroy(struct pipe_screen *screen,
        FREE(rtex);
 }
 
-static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
-                                                    struct pipe_resource *texture,
-                                                    unsigned level,
-                                                    unsigned usage,
-                                                    const struct pipe_box *box)
+static void *si_texture_transfer_map(struct pipe_context *ctx,
+                                    struct pipe_resource *texture,
+                                    unsigned level,
+                                    unsigned usage,
+                                    const struct pipe_box *box,
+                                    struct pipe_transfer **ptransfer)
 {
+       struct r600_context *rctx = (struct r600_context *)ctx;
        struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
        struct pipe_resource resource;
        struct r600_transfer *trans;
        int r;
        boolean use_staging_texture = FALSE;
+       struct radeon_winsys_cs_handle *buf;
+       enum pipe_format format = texture->format;
+       unsigned offset = 0;
+       char *map;
 
        /* We cannot map a tiled texture directly because the data is
         * in a different order, therefore we do detiling using a blit.
@@ -316,7 +322,6 @@ static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
                }
                trans->transfer.stride = rtex->flushed_depth_texture->surface.level[level].pitch_bytes;
                trans->offset = r600_texture_get_offset(rtex->flushed_depth_texture, level, box->z);
-               return &trans->transfer;
        } else if (use_staging_texture) {
                resource.target = PIPE_TEXTURE_2D;
                resource.format = texture->format;
@@ -355,66 +360,35 @@ static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
                        /* Always referenced in the blit. */
                        radeonsi_flush(ctx, NULL, 0);
                }
-               return &trans->transfer;
-       }
-       trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
-       trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
-       trans->offset = r600_texture_get_offset(rtex, level, box->z);
-       return &trans->transfer;
-}
-
-static void si_texture_transfer_destroy(struct pipe_context *ctx,
-                                       struct pipe_transfer *transfer)
-{
-       struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-       struct pipe_resource *texture = transfer->resource;
-       struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
-
-       if (rtransfer->staging_texture) {
-               if (transfer->usage & PIPE_TRANSFER_WRITE) {
-                       r600_copy_from_staging_texture(ctx, rtransfer);
-               }
-               pipe_resource_reference(&rtransfer->staging_texture, NULL);
-       }
-
-       if (rtex->depth && !rtex->is_flushing_texture) {
-               if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture)
-                       r600_blit_push_depth(ctx, rtex);
+       } else {
+               trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
+               trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
+               trans->offset = r600_texture_get_offset(rtex, level, box->z);
        }
 
-       pipe_resource_reference(&transfer->resource, NULL);
-       FREE(transfer);
-}
-
-static void* si_texture_transfer_map(struct pipe_context *ctx,
-                                    struct pipe_transfer* transfer)
-{
-       struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-       struct radeon_winsys_cs_handle *buf;
-       enum pipe_format format = transfer->resource->format;
-       unsigned offset = 0;
-       char *map;
-
-       if (rtransfer->staging_texture) {
-               buf = si_resource(rtransfer->staging_texture)->cs_buf;
+       if (trans->staging_texture) {
+               buf = si_resource(trans->staging_texture)->cs_buf;
        } else {
-               struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
+               struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
 
                if (rtex->flushed_depth_texture)
                        buf = rtex->flushed_depth_texture->resource.cs_buf;
                else
-                       buf = si_resource(transfer->resource)->cs_buf;
+                       buf = si_resource(texture)->cs_buf;
 
-               offset = rtransfer->offset +
-                       transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
-                       transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+               offset = trans->offset +
+                       box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+                       box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
        }
 
-       if (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
+       if (!(map = rctx->ws->buffer_map(buf, rctx->cs, usage))) {
+               pipe_resource_reference(&trans->staging_texture, NULL);
+               pipe_resource_reference(&trans->transfer.resource, NULL);
+               FREE(trans);
                return NULL;
        }
 
+       *ptransfer = &trans->transfer;
        return map + offset;
 }
 
@@ -424,6 +398,8 @@ static void si_texture_transfer_unmap(struct pipe_context *ctx,
        struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
        struct r600_context *rctx = (struct r600_context*)ctx;
        struct radeon_winsys_cs_handle *buf;
+       struct pipe_resource *texture = transfer->resource;
+       struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
 
        if (rtransfer->staging_texture) {
                buf = si_resource(rtransfer->staging_texture)->cs_buf;
@@ -437,14 +413,27 @@ static void si_texture_transfer_unmap(struct pipe_context *ctx,
                }
        }
        rctx->ws->buffer_unmap(buf);
+
+       if (rtransfer->staging_texture) {
+               if (transfer->usage & PIPE_TRANSFER_WRITE) {
+                       r600_copy_from_staging_texture(ctx, rtransfer);
+               }
+               pipe_resource_reference(&rtransfer->staging_texture, NULL);
+       }
+
+       if (rtex->depth && !rtex->is_flushing_texture) {
+               if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture)
+                       r600_blit_push_depth(ctx, rtex);
+       }
+
+       pipe_resource_reference(&transfer->resource, NULL);
+       FREE(transfer);
 }
 
 static const struct u_resource_vtbl r600_texture_vtbl =
 {
        r600_texture_get_handle,        /* get_handle */
        r600_texture_destroy,           /* resource_destroy */
-       si_texture_get_transfer,        /* get_transfer */
-       si_texture_transfer_destroy,    /* transfer_destroy */
        si_texture_transfer_map,        /* transfer_map */
        u_default_transfer_flush_region,/* transfer_flush_region */
        si_texture_transfer_unmap,      /* transfer_unmap */
index 59d5af9590a82b48fe69c86587a3bfec1e364c0f..0b59a0121c2f5954d7b7cb0160c6c90551ac0052 100644 (file)
@@ -1019,65 +1019,33 @@ rbug_context_surface_destroy(struct pipe_context *_pipe,
 
 
 
-static struct pipe_transfer *
-rbug_context_get_transfer(struct pipe_context *_context,
+static void *
+rbug_context_transfer_map(struct pipe_context *_context,
                           struct pipe_resource *_resource,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **transfer)
 {
    struct rbug_context *rb_pipe = rbug_context(_context);
    struct rbug_resource *rb_resource = rbug_resource(_resource);
    struct pipe_context *context = rb_pipe->pipe;
    struct pipe_resource *resource = rb_resource->resource;
    struct pipe_transfer *result;
+   void *map;
 
    pipe_mutex_lock(rb_pipe->call_mutex);
-   result = context->get_transfer(context,
-                                  resource,
-                                  level,
-                                  usage,
-                                  box);
+   map = context->transfer_map(context,
+                               resource,
+                               level,
+                               usage,
+                               box, &result);
    pipe_mutex_unlock(rb_pipe->call_mutex);
 
-   if (result)
-      return rbug_transfer_create(rb_pipe, rb_resource, result);
-   return NULL;
+   *transfer = rbug_transfer_create(rb_pipe, rb_resource, result);
+   return *transfer ? map : NULL;
 }
 
-static void
-rbug_context_transfer_destroy(struct pipe_context *_pipe,
-                              struct pipe_transfer *_transfer)
-{
-   struct rbug_context *rb_pipe = rbug_context(_pipe);
-   struct rbug_transfer *rb_transfer =rbug_transfer(_transfer);
-
-   pipe_mutex_lock(rb_pipe->call_mutex);
-   rbug_transfer_destroy(rb_pipe,
-                         rb_transfer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
-}
-
-static void *
-rbug_context_transfer_map(struct pipe_context *_context,
-                          struct pipe_transfer *_transfer)
-{
-   struct rbug_context *rb_pipe = rbug_context(_context);
-   struct rbug_transfer *rb_transfer = rbug_transfer(_transfer);
-   struct pipe_context *context = rb_pipe->pipe;
-   struct pipe_transfer *transfer = rb_transfer->transfer;
-   void *ret;
-
-   pipe_mutex_lock(rb_pipe->call_mutex);
-   ret = context->transfer_map(context,
-                                transfer);
-   pipe_mutex_unlock(rb_pipe->call_mutex);
-
-   return ret;
-}
-
-
-
 static void
 rbug_context_transfer_flush_region(struct pipe_context *_context,
                                    struct pipe_transfer *_transfer,
@@ -1108,6 +1076,8 @@ rbug_context_transfer_unmap(struct pipe_context *_context,
    pipe_mutex_lock(rb_pipe->call_mutex);
    context->transfer_unmap(context,
                            transfer);
+   rbug_transfer_destroy(rb_pipe,
+                         rb_transfer);
    pipe_mutex_unlock(rb_pipe->call_mutex);
 }
 
@@ -1217,8 +1187,6 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy;
    rb_pipe->base.create_surface = rbug_context_create_surface;
    rb_pipe->base.surface_destroy = rbug_context_surface_destroy;
-   rb_pipe->base.get_transfer = rbug_context_get_transfer;
-   rb_pipe->base.transfer_destroy = rbug_context_transfer_destroy;
    rb_pipe->base.transfer_map = rbug_context_transfer_map;
    rb_pipe->base.transfer_unmap = rbug_context_transfer_unmap;
    rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region;
index 4608b884181aa46953cfe0217388cb090afe826a..9cbc0e02f4afc6c7e2f04c3f053abff0d84dc2cb 100644 (file)
@@ -266,12 +266,10 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
    }
 
    tex = tr_tex->resource;
-   t = pipe_get_transfer(context, tex,
-                         gptr->level, gptr->face + gptr->zslice,
-                         PIPE_TRANSFER_READ,
-                         gptr->x, gptr->y, gptr->w, gptr->h);
-
-   map = context->transfer_map(context, t);
+   map = pipe_transfer_map(context, tex,
+                           gptr->level, gptr->face + gptr->zslice,
+                           PIPE_TRANSFER_READ,
+                           gptr->x, gptr->y, gptr->w, gptr->h, &t);
 
    rbug_send_texture_read_reply(tr_rbug->con, serial,
                                 t->resource->format,
@@ -285,7 +283,6 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
                                 NULL);
 
    context->transfer_unmap(context, t);
-   context->transfer_destroy(context, t);
 
    pipe_mutex_unlock(rb_screen->list_mutex);
 
index 15f5db40093eb61c01438b8ce48e6c7d0b0f6baa..c64b14c183287279b8937d018a6d9b29342a7a9e 100644 (file)
@@ -184,7 +184,7 @@ rbug_transfer_create(struct rbug_context *rb_context,
    return &rb_transfer->base;
 
 error:
-   rb_context->pipe->transfer_destroy(rb_context->pipe, transfer);
+   rb_context->pipe->transfer_unmap(rb_context->pipe, transfer);
    return NULL;
 }
 
@@ -193,8 +193,6 @@ rbug_transfer_destroy(struct rbug_context *rb_context,
                       struct rbug_transfer *rb_transfer)
 {
    pipe_resource_reference(&rb_transfer->base.resource, NULL);
-   rb_transfer->pipe->transfer_destroy(rb_context->pipe,
-                                       rb_transfer->transfer);
    FREE(rb_transfer);
 }
 
index 891bb261d8ad33af998d22aace51e3e43a65438a..e2cc1e17daefd348e03aaf87401c58fb832cbcf9 100644 (file)
 #include "sp_screen.h"
 
 
-/**
- * Map any drawing surfaces which aren't already mapped
- */
-void
-softpipe_map_transfers(struct softpipe_context *sp)
-{
-   unsigned i;
-
-   for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
-      sp_tile_cache_map_transfers(sp->cbuf_cache[i]);
-   }
-
-   sp_tile_cache_map_transfers(sp->zsbuf_cache);
-}
-
-
-/**
- * Unmap any mapped drawing surfaces
- */
-void
-softpipe_unmap_transfers(struct softpipe_context *sp)
-{
-   uint i;
-
-   for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
-      sp_tile_cache_unmap_transfers(sp->cbuf_cache[i]);
-   }
-
-   sp_tile_cache_unmap_transfers(sp->zsbuf_cache);
-}
-
-
 static void
 softpipe_destroy( struct pipe_context *pipe )
 {
index f9fc923a184a8330df667d6e01e47c05041e4507..59226fb9c153a944a565f5f2df8eab700575e276 100644 (file)
@@ -73,8 +73,6 @@ softpipe_draw_vbo(struct pipe_context *pipe,
       softpipe_update_derived(sp, sp->reduced_api_prim);
    }
 
-   softpipe_map_transfers(sp);
-
    /* Map vertex buffers */
    for (i = 0; i < sp->num_vertex_buffers; i++) {
       const void *buf = sp->vertex_buffer[i].user_buffer;
index 28660850d294065f7f20b6e5515862d798d80fce..e28236afc5065bbb35d9e4de38d473ef16ab5fe8 100644 (file)
@@ -75,14 +75,6 @@ softpipe_flush( struct pipe_context *pipe,
 
    softpipe->dirty_render_cache = FALSE;
 
-   /* Need this call for hardware buffers before swapbuffers.
-    *
-    * there should probably be another/different flush-type function
-    * that's called before swapbuffers because we don't always want
-    * to unmap surfaces when flushing.
-    */
-   softpipe_unmap_transfers(softpipe);
-
    /* Enable to dump BMPs of the color/depth buffers each frame */
 #if 0
    if(flags & PIPE_FLUSH_FRAME) {
index 6df40c663941c16654d1f0a13fe57a8ea02f9180..eb85b0689ea7ab47d3753556286a81feb4f7cd67 100644 (file)
@@ -158,12 +158,6 @@ void
 softpipe_draw_vbo(struct pipe_context *pipe,
                   const struct pipe_draw_info *info);
 
-void
-softpipe_map_transfers(struct softpipe_context *sp);
-
-void
-softpipe_unmap_transfers(struct softpipe_context *sp);
-
 void
 softpipe_map_texture_surfaces(struct softpipe_context *sp);
 
index 7e1ac6c88fd6d6839ed021c4f2a5dc9a883bafe0..b6a848bc5a77575dfafa0bb523ec99d65db2127c 100644 (file)
@@ -74,10 +74,10 @@ sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc)
          /*assert(tc->entries[pos].x < 0);*/
       }
       if (tc->transfer) {
-         tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
+         tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
       }
       if (tc->tex_trans) {
-         tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+         tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
       }
 
       FREE( tc );
@@ -131,14 +131,10 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
    if (!sp_tex_tile_is_compat_view(tc, view)) {
       pipe_resource_reference(&tc->texture, texture);
 
-      if (tc->tex_trans) {
-         if (tc->tex_trans_map) {
-            tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
-            tc->tex_trans_map = NULL;
-         }
-
-         tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+      if (tc->tex_trans_map) {
+         tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
          tc->tex_trans = NULL;
+         tc->tex_trans_map = NULL;
       }
 
       if (view) {
@@ -236,14 +232,10 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
          /* get new transfer (view into texture) */
          unsigned width, height, layer;
 
-         if (tc->tex_trans) {
-            if (tc->tex_trans_map) {
-               tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
-               tc->tex_trans_map = NULL;
-            }
-
-            tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+         if (tc->tex_trans_map) {
+            tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
             tc->tex_trans = NULL;
+            tc->tex_trans_map = NULL;
          }
 
          width = u_minify(tc->texture->width0, addr.bits.level);
@@ -256,14 +248,12 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
             layer = addr.bits.face + addr.bits.z;
          }
 
-         tc->tex_trans = 
-            pipe_get_transfer(tc->pipe, tc->texture,
+         tc->tex_trans_map =
+            pipe_transfer_map(tc->pipe, tc->texture,
                               addr.bits.level,
                               layer,
                               PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED,
-                              0, 0, width, height);
-
-         tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans);
+                              0, 0, width, height, &tc->tex_trans);
 
          tc->tex_face = addr.bits.face;
          tc->tex_level = addr.bits.level;
@@ -274,8 +264,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
        * the image format.
        */
       if (!zs && util_format_is_pure_uint(tc->format)) {
-         pipe_get_tile_ui_format(tc->pipe,
-                                 tc->tex_trans,
+         pipe_get_tile_ui_format(tc->tex_trans, tc->tex_trans_map,
                                  addr.bits.x * TILE_SIZE,
                                  addr.bits.y * TILE_SIZE,
                                  TILE_SIZE,
@@ -283,8 +272,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
                                  tc->format,
                                  (unsigned *) tile->data.colorui);
       } else if (!zs && util_format_is_pure_sint(tc->format)) {
-         pipe_get_tile_i_format(tc->pipe,
-                                tc->tex_trans,
+         pipe_get_tile_i_format(tc->tex_trans, tc->tex_trans_map,
                                 addr.bits.x * TILE_SIZE,
                                 addr.bits.y * TILE_SIZE,
                                 TILE_SIZE,
@@ -292,8 +280,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
                                 tc->format,
                                 (int *) tile->data.colori);
       } else {
-         pipe_get_tile_rgba_format(tc->pipe,
-                                   tc->tex_trans,
+         pipe_get_tile_rgba_format(tc->tex_trans, tc->tex_trans_map,
                                    addr.bits.x * TILE_SIZE,
                                    addr.bits.y * TILE_SIZE,
                                    TILE_SIZE,
index 50137fe6227cd489bdd3c57a9a87bf58717725f3..b4bca076bdaf4d6d29cae3313e80ee2c29dab6f5 100644 (file)
@@ -331,15 +331,22 @@ softpipe_surface_destroy(struct pipe_context *pipe,
  * \param usage  bitmask of PIPE_TRANSFER_x flags
  * \param box  the 1D/2D/3D region of interest
  */
-static struct pipe_transfer *
-softpipe_get_transfer(struct pipe_context *pipe,
+static void *
+softpipe_transfer_map(struct pipe_context *pipe,
                       struct pipe_resource *resource,
                       unsigned level,
                       unsigned usage,
-                      const struct pipe_box *box)
+                      const struct pipe_box *box,
+                      struct pipe_transfer **transfer)
 {
+   struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
    struct softpipe_resource *spr = softpipe_resource(resource);
    struct softpipe_transfer *spt;
+   struct pipe_transfer *pt;
+   enum pipe_format format = resource->format;
+   const unsigned hgt = u_minify(spr->base.height0, level);
+   const unsigned nblocksy = util_format_get_nblocksy(format, hgt);
+   uint8_t *map;
 
    assert(resource);
    assert(level <= resource->last_level);
@@ -384,69 +391,41 @@ softpipe_get_transfer(struct pipe_context *pipe,
    }
 
    spt = CALLOC_STRUCT(softpipe_transfer);
-   if (spt) {
-      struct pipe_transfer *pt = &spt->base;
-      enum pipe_format format = resource->format;
-      const unsigned hgt = u_minify(spr->base.height0, level);
-      const unsigned nblocksy = util_format_get_nblocksy(format, hgt);
-
-      pipe_resource_reference(&pt->resource, resource);
-      pt->level = level;
-      pt->usage = usage;
-      pt->box = *box;
-      pt->stride = spr->stride[level];
-      pt->layer_stride = pt->stride * nblocksy;
-
-      spt->offset = sp_get_tex_image_offset(spr, level, box->z);
-      spt->offset += 
-         box->y / util_format_get_blockheight(format) * spt->base.stride +
-         box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+   if (!spt)
+      return NULL;
 
-      return pt;
-   }
-   return NULL;
-}
+   pt = &spt->base;
 
+   pipe_resource_reference(&pt->resource, resource);
+   pt->level = level;
+   pt->usage = usage;
+   pt->box = *box;
+   pt->stride = spr->stride[level];
+   pt->layer_stride = pt->stride * nblocksy;
 
-/**
- * Free a pipe_transfer object which was created with
- * softpipe_get_transfer().
- */
-static void 
-softpipe_transfer_destroy(struct pipe_context *pipe,
-                          struct pipe_transfer *transfer)
-{
-   pipe_resource_reference(&transfer->resource, NULL);
-   FREE(transfer);
-}
+   spt->offset = sp_get_tex_image_offset(spr, level, box->z);
 
+   spt->offset +=
+         box->y / util_format_get_blockheight(format) * spt->base.stride +
+         box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 
-/**
- * Create memory mapping for given pipe_transfer object.
- */
-static void *
-softpipe_transfer_map(struct pipe_context *pipe,
-                      struct pipe_transfer *transfer)
-{
-   struct softpipe_transfer *spt = softpipe_transfer(transfer);
-   struct softpipe_resource *spr = softpipe_resource(transfer->resource);
-   struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
-   uint8_t *map;
-   
    /* resources backed by display target treated specially:
     */
    if (spr->dt) {
-      map = winsys->displaytarget_map(winsys, spr->dt, transfer->usage);
+      map = winsys->displaytarget_map(winsys, spr->dt, usage);
    }
    else {
       map = spr->data;
    }
 
-   if (map == NULL)
+   if (map == NULL) {
+      pipe_resource_reference(&pt->resource, NULL);
+      FREE(spt);
       return NULL;
-   else
-      return map + spt->offset;
+   }
+
+   *transfer = pt;
+   return map + spt->offset;
 }
 
 
@@ -472,6 +451,9 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
       /* Mark the texture as dirty to expire the tile caches. */
       spr->timestamp++;
    }
+
+   pipe_resource_reference(&transfer->resource, NULL);
+   FREE(transfer);
 }
 
 /**
@@ -509,8 +491,6 @@ softpipe_user_buffer_create(struct pipe_screen *screen,
 void
 softpipe_init_texture_funcs(struct pipe_context *pipe)
 {
-   pipe->get_transfer = softpipe_get_transfer;
-   pipe->transfer_destroy = softpipe_transfer_destroy;
    pipe->transfer_map = softpipe_transfer_map;
    pipe->transfer_unmap = softpipe_transfer_unmap;
 
index 659ac58e5b0f5997b37ead181061ed77e3eb8dd1..8d581112fcd7cd40f566fa4e26c2db8906104f92 100644 (file)
@@ -141,7 +141,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
       FREE( tc->tile );
 
       if (tc->transfer) {
-         tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
+         tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
       }
 
       FREE( tc );
@@ -158,27 +158,24 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
 {
    struct pipe_context *pipe = tc->pipe;
 
-   if (tc->transfer) {
+   if (tc->transfer_map) {
       if (ps == tc->surface)
          return;
 
-      if (tc->transfer_map) {
-         pipe->transfer_unmap(pipe, tc->transfer);
-         tc->transfer_map = NULL;
-      }
-
-      pipe->transfer_destroy(pipe, tc->transfer);
+      pipe->transfer_unmap(pipe, tc->transfer);
       tc->transfer = NULL;
+      tc->transfer_map = NULL;
    }
 
    tc->surface = ps;
 
    if (ps) {
-      tc->transfer = pipe_get_transfer(pipe, ps->texture,
-                                       ps->u.tex.level, ps->u.tex.first_layer,
-                                       PIPE_TRANSFER_READ_WRITE |
-                                       PIPE_TRANSFER_UNSYNCHRONIZED,
-                                       0, 0, ps->width, ps->height);
+      tc->transfer_map = pipe_transfer_map(pipe, ps->texture,
+                                           ps->u.tex.level, ps->u.tex.first_layer,
+                                           PIPE_TRANSFER_READ_WRITE |
+                                           PIPE_TRANSFER_UNSYNCHRONIZED,
+                                           0, 0, ps->width, ps->height,
+                                           &tc->transfer);
 
       tc->depth_stencil = util_format_is_depth_or_stencil(ps->format);
    }
@@ -195,24 +192,6 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
 }
 
 
-void
-sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc)
-{
-   if (tc->transfer && !tc->transfer_map)
-      tc->transfer_map = tc->pipe->transfer_map(tc->pipe, tc->transfer);
-}
-
-
-void
-sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc)
-{
-   if (tc->transfer_map) {
-      tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
-      tc->transfer_map = NULL;
-   }
-}
-
-
 /**
  * Set pixels in a tile to the given clear color/value, float.
  */
@@ -349,24 +328,23 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
          if (is_clear_flag_set(tc->clear_flags, addr)) {
             /* write the scratch tile to the surface */
             if (tc->depth_stencil) {
-               pipe_put_tile_raw(tc->pipe,
-                                 pt,
+               pipe_put_tile_raw(pt, tc->transfer_map,
                                  x, y, TILE_SIZE, TILE_SIZE,
                                  tc->tile->data.any, 0/*STRIDE*/);
             }
             else {
                if (util_format_is_pure_uint(tc->surface->format)) {
-                  pipe_put_tile_ui_format(tc->pipe, pt,
+                  pipe_put_tile_ui_format(pt, tc->transfer_map,
                                           x, y, TILE_SIZE, TILE_SIZE,
                                           pt->resource->format,
                                           (unsigned *) tc->tile->data.colorui128);
                } else if (util_format_is_pure_sint(tc->surface->format)) {
-                  pipe_put_tile_i_format(tc->pipe, pt,
+                  pipe_put_tile_i_format(pt, tc->transfer_map,
                                          x, y, TILE_SIZE, TILE_SIZE,
                                          pt->resource->format,
                                          (int *) tc->tile->data.colori128);
                } else {
-                  pipe_put_tile_rgba(tc->pipe, pt,
+                  pipe_put_tile_rgba(pt, tc->transfer_map,
                                      x, y, TILE_SIZE, TILE_SIZE,
                                      (float *) tc->tile->data.color);
                }
@@ -389,7 +367,7 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos)
 {
    if (!tc->tile_addrs[pos].bits.invalid) {
       if (tc->depth_stencil) {
-         pipe_put_tile_raw(tc->pipe, tc->transfer,
+         pipe_put_tile_raw(tc->transfer, tc->transfer_map,
                            tc->tile_addrs[pos].bits.x * TILE_SIZE,
                            tc->tile_addrs[pos].bits.y * TILE_SIZE,
                            TILE_SIZE, TILE_SIZE,
@@ -397,21 +375,21 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos)
       }
       else {
          if (util_format_is_pure_uint(tc->surface->format)) {
-            pipe_put_tile_ui_format(tc->pipe, tc->transfer,
+            pipe_put_tile_ui_format(tc->transfer, tc->transfer_map,
                                     tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                     tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                     TILE_SIZE, TILE_SIZE,
                                     tc->surface->format,
                                     (unsigned *) tc->entries[pos]->data.colorui128);
          } else if (util_format_is_pure_sint(tc->surface->format)) {
-            pipe_put_tile_i_format(tc->pipe, tc->transfer,
+            pipe_put_tile_i_format(tc->transfer, tc->transfer_map,
                                    tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                    tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                    TILE_SIZE, TILE_SIZE,
                                    tc->surface->format,
                                    (int *) tc->entries[pos]->data.colori128);
          } else {
-            pipe_put_tile_rgba_format(tc->pipe, tc->transfer,
+            pipe_put_tile_rgba_format(tc->transfer, tc->transfer_map,
                                       tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                       tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                       TILE_SIZE, TILE_SIZE,
@@ -516,7 +494,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
       if (tc->tile_addrs[pos].bits.invalid == 0) {
          /* put dirty tile back in framebuffer */
          if (tc->depth_stencil) {
-            pipe_put_tile_raw(tc->pipe, pt,
+            pipe_put_tile_raw(pt, tc->transfer_map,
                               tc->tile_addrs[pos].bits.x * TILE_SIZE,
                               tc->tile_addrs[pos].bits.y * TILE_SIZE,
                               TILE_SIZE, TILE_SIZE,
@@ -524,21 +502,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
          }
          else {
             if (util_format_is_pure_uint(tc->surface->format)) {
-               pipe_put_tile_ui_format(tc->pipe, pt,
+               pipe_put_tile_ui_format(pt, tc->transfer_map,
                                       tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                       tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                       TILE_SIZE, TILE_SIZE,
                                       tc->surface->format,
                                       (unsigned *) tile->data.colorui128);
             } else if (util_format_is_pure_sint(tc->surface->format)) {
-               pipe_put_tile_i_format(tc->pipe, pt,
+               pipe_put_tile_i_format(pt, tc->transfer_map,
                                       tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                       tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                       TILE_SIZE, TILE_SIZE,
                                       tc->surface->format,
                                       (int *) tile->data.colori128);
             } else {
-               pipe_put_tile_rgba_format(tc->pipe, pt,
+               pipe_put_tile_rgba_format(pt, tc->transfer_map,
                                          tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                          tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                          TILE_SIZE, TILE_SIZE,
@@ -563,7 +541,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
       else {
          /* get new tile data from transfer */
          if (tc->depth_stencil) {
-            pipe_get_tile_raw(tc->pipe, pt,
+            pipe_get_tile_raw(pt, tc->transfer_map,
                               tc->tile_addrs[pos].bits.x * TILE_SIZE,
                               tc->tile_addrs[pos].bits.y * TILE_SIZE,
                               TILE_SIZE, TILE_SIZE,
@@ -571,21 +549,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
          }
          else {
             if (util_format_is_pure_uint(tc->surface->format)) {
-               pipe_get_tile_ui_format(tc->pipe, pt,
+               pipe_get_tile_ui_format(pt, tc->transfer_map,
                                          tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                          tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                          TILE_SIZE, TILE_SIZE,
                                          tc->surface->format,
                                          (unsigned *) tile->data.colorui128);
             } else if (util_format_is_pure_sint(tc->surface->format)) {
-               pipe_get_tile_i_format(tc->pipe, pt,
+               pipe_get_tile_i_format(pt, tc->transfer_map,
                                          tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                          tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                          TILE_SIZE, TILE_SIZE,
                                          tc->surface->format,
                                          (int *) tile->data.colori128);
             } else {
-               pipe_get_tile_rgba_format(tc->pipe, pt,
+               pipe_get_tile_rgba_format(pt, tc->transfer_map,
                                          tc->tile_addrs[pos].bits.x * TILE_SIZE,
                                          tc->tile_addrs[pos].bits.y * TILE_SIZE,
                                          TILE_SIZE, TILE_SIZE,
index 775676b4bf5b7f9050363dc14e6129eb46bfc671..8d0466b8191216a44858fb91be64481556f13fc9 100644 (file)
@@ -112,12 +112,6 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
 extern struct pipe_surface *
 sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
 
-extern void
-sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc);
-
 extern void
 sp_flush_tile_cache(struct softpipe_tile_cache *tc);
 
index 890c953a3c260bcabda71394d9777f2ae72a3359..79951b34db52c651fda853a24a04f1004a068b1c 100644 (file)
@@ -58,11 +58,9 @@ svga_resource_from_handle(struct pipe_screen * screen,
 void
 svga_init_resource_functions(struct svga_context *svga)
 {
-   svga->pipe.get_transfer = u_get_transfer_vtbl;
    svga->pipe.transfer_map = u_transfer_map_vtbl;
    svga->pipe.transfer_flush_region = u_transfer_flush_region_vtbl;
    svga->pipe.transfer_unmap = u_transfer_unmap_vtbl;
-   svga->pipe.transfer_destroy = u_transfer_destroy_vtbl;
    svga->pipe.transfer_inline_write = u_transfer_inline_write_vtbl;
 }
 
index fa713ee88adda16c864983942dcfee6276e6faf1..87a4a9b7a829677db72c5826a35c102f02f92464 100644 (file)
@@ -62,17 +62,19 @@ svga_buffer_needs_hw_storage(unsigned usage)
  * the end result is exactly the same as if one DMA was used for every mapped
  * range.
  */
-static struct pipe_transfer *
-svga_buffer_get_transfer(struct pipe_context *pipe,
+static void *
+svga_buffer_transfer_map(struct pipe_context *pipe,
                          struct pipe_resource *resource,
                          unsigned level,
                          unsigned usage,
-                         const struct pipe_box *box)
+                         const struct pipe_box *box,
+                         struct pipe_transfer **ptransfer)
 {
    struct svga_context *svga = svga_context(pipe);
    struct svga_screen *ss = svga_screen(pipe->screen);
    struct svga_buffer *sbuf = svga_buffer(resource);
    struct pipe_transfer *transfer;
+   uint8_t *map;
 
    transfer = CALLOC_STRUCT(pipe_transfer);
    if (transfer == NULL) {
@@ -186,21 +188,6 @@ svga_buffer_get_transfer(struct pipe_context *pipe,
       }
    }
 
-   return transfer;
-}
-
-
-/**
- * Map a range of a buffer.
- */
-static void *
-svga_buffer_transfer_map( struct pipe_context *pipe,
-                          struct pipe_transfer *transfer )
-{
-   struct svga_buffer *sbuf = svga_buffer(transfer->resource);
-
-   uint8_t *map;
-
    if (sbuf->swbuf) {
       /* User/malloc buffer */
       map = sbuf->swbuf;
@@ -218,6 +205,7 @@ svga_buffer_transfer_map( struct pipe_context *pipe,
    if (map) {
       ++sbuf->map.count;
       map += transfer->box.x;
+      *ptransfer = transfer;
    }
    
    return map;
@@ -280,16 +268,6 @@ svga_buffer_transfer_unmap( struct pipe_context *pipe,
    }
 
    pipe_mutex_unlock(ss->swc_mutex);
-}
-
-
-/**
- * Destroy transfer
- */
-static void
-svga_buffer_transfer_destroy(struct pipe_context *pipe,
-                             struct pipe_transfer *transfer)
-{
    FREE(transfer);
 }
 
@@ -325,8 +303,6 @@ struct u_resource_vtbl svga_buffer_vtbl =
 {
    u_default_resource_get_handle,      /* get_handle */
    svga_buffer_destroy,                     /* resource_destroy */
-   svga_buffer_get_transfer,        /* get_transfer */
-   svga_buffer_transfer_destroy,     /* transfer_destroy */
    svga_buffer_transfer_map,        /* transfer_map */
    svga_buffer_transfer_flush_region,  /* transfer_flush_region */
    svga_buffer_transfer_unmap,      /* transfer_unmap */
index 97ec7eeea7ec38fda66d245bbfb50e99edb40e65..1d796cb6a9ba01aa65e6056181301aabce8eb84f 100644 (file)
@@ -236,12 +236,13 @@ svga_texture_destroy(struct pipe_screen *screen,
 /* XXX: Still implementing this as if it was a screen function, but
  * can now modify it to queue transfers on the context.
  */
-static struct pipe_transfer *
-svga_texture_get_transfer(struct pipe_context *pipe,
+static void *
+svga_texture_transfer_map(struct pipe_context *pipe,
                           struct pipe_resource *texture,
                           unsigned level,
                           unsigned usage,
-                          const struct pipe_box *box)
+                          const struct pipe_box *box,
+                          struct pipe_transfer **ptransfer)
 {
    struct svga_context *svga = svga_context(pipe);
    struct svga_screen *ss = svga_screen(pipe->screen);
@@ -259,7 +260,7 @@ svga_texture_get_transfer(struct pipe_context *pipe,
    if (!st)
       return NULL;
 
-   pipe_resource_reference(&st->base.resource, texture);
+   st->base.resource = texture;
    st->base.level = level;
    st->base.usage = usage;
    st->base.box = *box;
@@ -305,8 +306,22 @@ svga_texture_get_transfer(struct pipe_context *pipe,
       svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM, flags);
    }
 
-   return &st->base;
+   if (st->swbuf) {
+      *ptransfer = &st->base;
+      return st->swbuf;
+   } else {
+      /* The wait for read transfers already happened when svga_transfer_dma
+       * was called. */
+      void *map = sws->buffer_map(sws, st->hwbuf, usage);
+      if (!map)
+         goto fail;
+
+      *ptransfer = &st->base;
+      return map;
+   }
 
+fail:
+   FREE(st->swbuf);
 no_swbuf:
    sws->buffer_destroy(sws, st->hwbuf);
 no_hwbuf:
@@ -315,26 +330,6 @@ no_hwbuf:
 }
 
 
-/* XXX: Still implementing this as if it was a screen function, but
- * can now modify it to queue transfers on the context.
- */
-static void *
-svga_texture_transfer_map( struct pipe_context *pipe,
-                          struct pipe_transfer *transfer )
-{
-   struct svga_screen *ss = svga_screen(pipe->screen);
-   struct svga_winsys_screen *sws = ss->sws;
-   struct svga_transfer *st = svga_transfer(transfer);
-
-   if(st->swbuf)
-      return st->swbuf;
-   else
-      /* The wait for read transfers already happened when svga_transfer_dma
-       * was called. */
-      return sws->buffer_map(sws, st->hwbuf, transfer->usage);
-}
-
-
 /* XXX: Still implementing this as if it was a screen function, but
  * can now modify it to queue transfers on the context.
  */
@@ -342,24 +337,14 @@ static void
 svga_texture_transfer_unmap(struct pipe_context *pipe,
                            struct pipe_transfer *transfer)
 {
+   struct svga_context *svga = svga_context(pipe);
    struct svga_screen *ss = svga_screen(pipe->screen);
    struct svga_winsys_screen *sws = ss->sws;
    struct svga_transfer *st = svga_transfer(transfer);
-   
+   struct svga_texture *tex = svga_texture(transfer->resource);
+
    if(!st->swbuf)
       sws->buffer_unmap(sws, st->hwbuf);
-}
-
-
-static void
-svga_texture_transfer_destroy(struct pipe_context *pipe,
-                             struct pipe_transfer *transfer)
-{
-   struct svga_context *svga = svga_context(pipe);
-   struct svga_texture *tex = svga_texture(transfer->resource);
-   struct svga_screen *ss = svga_screen(pipe->screen);
-   struct svga_winsys_screen *sws = ss->sws;
-   struct svga_transfer *st = svga_transfer(transfer);
 
    if (st->base.usage & PIPE_TRANSFER_WRITE) {
       SVGA3dSurfaceDMAFlags flags;
@@ -381,7 +366,6 @@ svga_texture_transfer_destroy(struct pipe_context *pipe,
          tex->defined[0][transfer->level] = TRUE;
    }
 
-   pipe_resource_reference(&st->base.resource, NULL);
    FREE(st->swbuf);
    sws->buffer_destroy(sws, st->hwbuf);
    FREE(st);
@@ -392,8 +376,6 @@ struct u_resource_vtbl svga_texture_vtbl =
 {
    svga_texture_get_handle,          /* get_handle */
    svga_texture_destroy,             /* resource_destroy */
-   svga_texture_get_transfer,        /* get_transfer */
-   svga_texture_transfer_destroy,     /* transfer_destroy */
    svga_texture_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,   /* transfer_flush_region */
    svga_texture_transfer_unmap,              /* transfer_unmap */
index 33557aa937aef707204e3953f678ab19106cd7aa..8900cdde18d46c9923a43dba03b7ca2b277d1f18 100644 (file)
@@ -131,8 +131,10 @@ svga_vbuf_render_map_vertices( struct vbuf_render *render )
                                          &svga_render->vbuf_transfer);
       if (ptr)
          return ptr + svga_render->vbuf_offset;
-      else
+      else {
+         svga_render->vbuf_transfer = NULL;
          return NULL;
+      }
    }
    else {
       /* we probably ran out of memory when allocating the vertex buffer */
index affdfca228fd573bd4519b2395557b00cdfa3d6a..dd1b5a00de71c1b3126e9fa266a824478188b819 100644 (file)
@@ -1377,18 +1377,20 @@ trace_context_destroy(struct pipe_context *_pipe)
  */
 
 
-static struct pipe_transfer *
-trace_context_get_transfer(struct pipe_context *_context,
+static void *
+trace_context_transfer_map(struct pipe_context *_context,
                            struct pipe_resource *_resource,
                            unsigned level,
                            unsigned usage,
-                           const struct pipe_box *box)
+                           const struct pipe_box *box,
+                           struct pipe_transfer **transfer)
 {
    struct trace_context *tr_context = trace_context(_context);
    struct trace_resource *tr_res = trace_resource(_resource);
    struct pipe_context *context = tr_context->pipe;
    struct pipe_resource *texture = tr_res->resource;
    struct pipe_transfer *result = NULL;
+   void *map;
 
    assert(texture->screen == context->screen);
 
@@ -1397,48 +1399,21 @@ trace_context_get_transfer(struct pipe_context *_context,
     * to transfer_inline_write and ignore read transfers.
     */
 
-   result = context->get_transfer(context, texture, level, usage, box);
-
-   if (result)
-      result = trace_transfer_create(tr_context, tr_res, result);
-
-   return result;
-}
-
-
-static void
-trace_context_transfer_destroy(struct pipe_context *_context,
-                               struct pipe_transfer *_transfer)
-{
-   struct trace_context *tr_context = trace_context(_context);
-   struct trace_transfer *tr_trans = trace_transfer(_transfer);
-
-   trace_transfer_destroy(tr_context, tr_trans);
-}
+   map = context->transfer_map(context, texture, level, usage, box, &result);
+   if (!map)
+      return NULL;
 
+   *transfer = trace_transfer_create(tr_context, tr_res, result);
 
-static void *
-trace_context_transfer_map(struct pipe_context *_context,
-                          struct pipe_transfer *_transfer)
-{
-   struct trace_context *tr_context = trace_context(_context);
-   struct trace_transfer *tr_trans = trace_transfer(_transfer);
-   struct pipe_context *context = tr_context->pipe;
-   struct pipe_transfer *transfer = tr_trans->transfer;
-   void *map;
-
-   map = context->transfer_map(context, transfer);
-   if(map) {
-      if(transfer->usage & PIPE_TRANSFER_WRITE) {
-         assert(!tr_trans->map);
-         tr_trans->map = map;
+   if (map) {
+      if(usage & PIPE_TRANSFER_WRITE) {
+         trace_transfer(*transfer)->map = map;
       }
    }
 
-   return map;
+   return *transfer ? map : NULL;
 }
 
-
 static void
 trace_context_transfer_flush_region( struct pipe_context *_context,
                                     struct pipe_transfer *_transfer,
@@ -1500,6 +1475,7 @@ trace_context_transfer_unmap(struct pipe_context *_context,
    }
 
    context->transfer_unmap(context, transfer);
+   trace_transfer_destroy(tr_ctx, tr_trans);
 }
 
 
@@ -1667,8 +1643,6 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(render_condition);
    TR_CTX_INIT(texture_barrier);
 
-   TR_CTX_INIT(get_transfer);
-   TR_CTX_INIT(transfer_destroy);
    TR_CTX_INIT(transfer_map);
    TR_CTX_INIT(transfer_unmap);
    TR_CTX_INIT(transfer_flush_region);
index 648b7a4f1ccf7fa98ca7f250f19bd70d1482dd76..81ebc9ee770032a7a56ba749d3b0d942ace1a73e 100644 (file)
@@ -139,7 +139,7 @@ trace_transfer_create(struct trace_context *tr_ctx,
    return &tr_trans->base;
 
 error:
-   tr_ctx->pipe->transfer_destroy(tr_ctx->pipe, transfer);
+   tr_ctx->pipe->transfer_unmap(tr_ctx->pipe, transfer);
    return NULL;
 }
 
@@ -148,11 +148,7 @@ void
 trace_transfer_destroy(struct trace_context *tr_context,
                        struct trace_transfer *tr_trans)
 {
-   struct pipe_context *context = tr_context->pipe;
-   struct pipe_transfer *transfer = tr_trans->transfer;
-
    pipe_resource_reference(&tr_trans->base.resource, NULL);
-   context->transfer_destroy(context, transfer);
    FREE(tr_trans);
 }
 
index 09760ddbe0f77a574643fa372ed526046dac4daa..761761da77354a83be4db75ff92d37392a0b9843 100644 (file)
@@ -60,6 +60,7 @@ struct pipe_shader_state;
 struct pipe_stencil_ref;
 struct pipe_stream_output_target;
 struct pipe_surface;
+struct pipe_transfer;
 struct pipe_vertex_buffer;
 struct pipe_vertex_element;
 struct pipe_video_buffer;
@@ -374,22 +375,21 @@ struct pipe_context {
                            struct pipe_surface *);
 
    /**
-    * Get a transfer object for transferring data to/from a texture.
+    * Map a resource.
     *
     * Transfers are (by default) context-private and allow uploads to be
-    * interleaved with
+    * interleaved with rendering.
+    *
+    * out_transfer will contain the transfer object that must be passed
+    * to all the other transfer functions. It also contains useful
+    * information (like texture strides).
     */
-   struct pipe_transfer *(*get_transfer)(struct pipe_context *,
-                                         struct pipe_resource *resource,
-                                         unsigned level,
-                                         unsigned usage,  /* a combination of PIPE_TRANSFER_x */
-                                         const struct pipe_box *);
-
-   void (*transfer_destroy)(struct pipe_context *,
-                            struct pipe_transfer *);
-
-   void *(*transfer_map)( struct pipe_context *,
-                          struct pipe_transfer *transfer );
+   void *(*transfer_map)(struct pipe_context *,
+                         struct pipe_resource *resource,
+                         unsigned level,
+                         unsigned usage,  /* a combination of PIPE_TRANSFER_x */
+                         const struct pipe_box *,
+                         struct pipe_transfer **out_transfer);
 
    /* If transfer was created with WRITE|FLUSH_EXPLICIT, only the
     * regions specified with this call are guaranteed to be written to
@@ -399,9 +399,8 @@ struct pipe_context {
                                  struct pipe_transfer *transfer,
                                  const struct pipe_box *);
 
-   void (*transfer_unmap)( struct pipe_context *,
-                           struct pipe_transfer *transfer );
-
+   void (*transfer_unmap)(struct pipe_context *,
+                          struct pipe_transfer *transfer);
 
    /* One-shot transfer operation with data supplied in a user
     * pointer.  XXX: strides??
index aed1ea60207cd00748bc9e006a32d38a442538ad..b145bc0e8ee19845aa11ee8edf298d23e738c22d 100644 (file)
@@ -205,7 +205,7 @@ enum pipe_transfer_usage {
    PIPE_TRANSFER_READ = (1 << 0),
    
    /**
-    * Resource contents will be written back at transfer_destroy
+    * Resource contents will be written back at transfer_unmap
     * time (or modified as a result of being accessed directly).
     */
    PIPE_TRANSFER_WRITE = (1 << 1),
@@ -300,8 +300,8 @@ enum pipe_transfer_usage {
 #define PIPE_BIND_INDEX_BUFFER         (1 << 5) /* draw_elements */
 #define PIPE_BIND_CONSTANT_BUFFER      (1 << 6) /* set_constant_buffer */
 #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_BIND_TRANSFER_WRITE       (1 << 9) /* transfer_map */
+#define PIPE_BIND_TRANSFER_READ        (1 << 10) /* transfer_map */
 #define PIPE_BIND_STREAM_OUTPUT        (1 << 11) /* set_stream_output_buffers */
 #define PIPE_BIND_CURSOR               (1 << 16) /* mouse cursor */
 #define PIPE_BIND_CUSTOM               (1 << 17) /* state-tracker/winsys usages */
index 0c671f47388b1a38815b75cfa1ab2359cbde42b3..80bcd2a851a3a0cd33328415ba22d77177088e4f 100644 (file)
@@ -177,14 +177,10 @@ mapping::mapping(command_queue &q, resource &r,
                      (flags & CL_MAP_READ ? PIPE_TRANSFER_READ : 0 ) |
                      (blocking ? PIPE_TRANSFER_UNSYNCHRONIZED : 0));
 
-   pxfer = pctx->get_transfer(pctx, r.pipe, 0, usage,
-                              box(origin + r.offset, region));
-   if (!pxfer)
-      throw error(CL_OUT_OF_RESOURCES);
-
-   p = pctx->transfer_map(pctx, pxfer);
+   p = pctx->transfer_map(pctx, r.pipe, 0, usage,
+                          box(origin + r.offset, region), &pxfer);
    if (!p) {
-      pctx->transfer_destroy(pctx, pxfer);
+      pxfer = NULL;
       throw error(CL_OUT_OF_RESOURCES);
    }
 }
@@ -198,6 +194,5 @@ mapping::mapping(mapping &&m) :
 mapping::~mapping() {
    if (pxfer) {
       pctx->transfer_unmap(pctx, pxfer);
-      pctx->transfer_destroy(pctx, pxfer);
    }
 }
index 07612bd5f9a9748bec2a33cd902fe7cc9a3a0219..8c387e3a2bcc3d96449a269f7d504e011b67dfdf 100644 (file)
@@ -1506,15 +1506,16 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                        return E_INVALIDARG;
                if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT)
                        usage |= PIPE_TRANSFER_DONTBLOCK;
-               struct pipe_transfer* transfer = pipe->get_transfer(pipe, resource->resource, level, usage, &box);
-               if(!transfer) {
+               struct pipe_transfer* transfer;
+                void *map = pipe->transfer_map(pipe, resource->resource, level, usage, &box, &transfer);
+               if(!map) {
                        if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT)
                                return DXGI_ERROR_WAS_STILL_DRAWING;
                        else
                                return E_FAIL;
                }
                resource->transfers[subresource] = transfer;
-               mapped_resource->pData = pipe->transfer_map(pipe, transfer);
+               mapped_resource->pData = map;
                mapped_resource->RowPitch = transfer->stride;
                mapped_resource->DepthPitch = transfer->layer_stride;
                return S_OK;
@@ -1530,7 +1531,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                if(i != resource->transfers.end())
                {
                        pipe->transfer_unmap(pipe, i->second);
-                       pipe->transfer_destroy(pipe, i->second);
                        resource->transfers.erase(i);
                }
        }
index c4c4264d35158f40a73f92463494d917dbdf5ed3..5247126527d7535824cda7a414597a68574cc17f 100644 (file)
@@ -257,11 +257,10 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
 
    get_drawable_info(dPriv, &x, &y, &w, &h);
 
-   transfer = pipe_get_transfer(pipe, res,
-                                0, 0, // level, layer,
-                                PIPE_TRANSFER_WRITE,
-                                x, y, w, h);
-   map = pipe_transfer_map(pipe, transfer);
+   map = pipe_transfer_map(pipe, res,
+                           0, 0, // level, layer,
+                           PIPE_TRANSFER_WRITE,
+                           x, y, w, h, &transfer);
 
    /* Copy the Drawable content to the mapped texture buffer */
    get_image(dPriv, x, y, w, h, map);
@@ -275,7 +274,6 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
    }
 
    pipe_transfer_unmap(pipe, transfer);
-   pipe_transfer_destroy(pipe, transfer);
 }
 
 /*
index 7e915567a4332285da1593516c5e37525ecce88a..607584f0195233f9d8f042f3f8bd420bb9ed70ea 100644 (file)
@@ -1368,12 +1368,12 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
 
       internal_format = choose_pixel_format(drawable->xm_visual);
 
-      tex_xfer = pipe_get_transfer(pipe, res,
-                                   0, 0,    /* level, layer */
-                                   PIPE_TRANSFER_WRITE,
-                                   x, y,
-                                   w, h);
-      if (!tex_xfer)
+      map = pipe_transfer_map(pipe, res,
+                              0, 0,    /* level, layer */
+                              PIPE_TRANSFER_WRITE,
+                              x, y,
+                              w, h, &tex_xfer);
+      if (!map)
          return;
 
       /* Grab the XImage that we want to turn into a texture. */
@@ -1385,14 +1385,7 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
                       ZPixmap);
 
       if (!img) {
-         pipe_transfer_destroy(pipe, tex_xfer);
-         return;
-      }
-
-      map = pipe_transfer_map(pipe, tex_xfer);
-
-      if (!map) {
-         pipe_transfer_destroy(pipe, tex_xfer);
+         pipe_transfer_unmap(pipe, tex_xfer);
          return;
       }
 
@@ -1407,8 +1400,6 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
 
       pipe_transfer_unmap(pipe, tex_xfer);
 
-      pipe_transfer_destroy(pipe, tex_xfer);
-
       st->teximage(st,
                    ST_TEXTURE_2D,
                    0,    /* level */
index 5b25e63d28e48703dd382563619b638be6922862..dd3c1a834bba84c371cdfb7f3239038305019f64 100644 (file)
@@ -207,15 +207,8 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
 
    res = vlsurface->sampler_view->texture;
    box = RectToPipeBox(source_rect, res);
-   transfer = pipe->get_transfer(pipe, res, 0, PIPE_TRANSFER_READ, &box);
-   if (transfer == NULL) {
-      pipe_mutex_unlock(vlsurface->device->mutex);
-      return VDP_STATUS_RESOURCES;
-   }
-
-   map = pipe_transfer_map(pipe, transfer);
-   if (map == NULL) {
-      pipe_transfer_destroy(pipe, transfer);
+   map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer);
+   if (!map) {
       pipe_mutex_unlock(vlsurface->device->mutex);
       return VDP_STATUS_RESOURCES;
    }
@@ -224,7 +217,6 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
                   box.width, box.height, map, transfer->stride, 0, 0);
 
    pipe_transfer_unmap(pipe, transfer);
-   pipe_transfer_destroy(pipe, transfer);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
    return VDP_STATUS_OK;
index cc866a6ca0d13daaa43d5e69e12b9402492d34d1..bcc33c0f9b02fb2fced3b0338c9386b01fa0a7ad 100644 (file)
@@ -236,15 +236,9 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
          struct pipe_transfer *transfer;
          uint8_t *map;
 
-         transfer = pipe->get_transfer(pipe, sv->texture, 0, PIPE_TRANSFER_READ, &box);
-         if (transfer == NULL) {
-            pipe_mutex_unlock(vlsurface->device->mutex);
-            return VDP_STATUS_RESOURCES;
-         }
-
-         map = pipe_transfer_map(pipe, transfer);
-         if (map == NULL) {
-            pipe_transfer_destroy(pipe, transfer);
+         map = pipe->transfer_map(pipe, sv->texture, 0,
+                                       PIPE_TRANSFER_READ, &box, &transfer);
+         if (!map) {
             pipe_mutex_unlock(vlsurface->device->mutex);
             return VDP_STATUS_RESOURCES;
          }
@@ -254,7 +248,6 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
                         box.width, box.height, map, transfer->stride, 0, 0);
 
          pipe_transfer_unmap(pipe, transfer);
-         pipe_transfer_destroy(pipe, transfer);
       }
    }
    pipe_mutex_unlock(vlsurface->device->mutex);
index afa5213d9a8ba24fc1e2c850cce2a5da7dd36199..f5856db4405be7957cb65cbd70ef13f7f4a41b58 100644 (file)
@@ -78,15 +78,15 @@ static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx,
    tex = screen->resource_create(screen, &templ);
 
    { /* upload color_data */
-      struct pipe_transfer *transfer =
-         pipe_get_transfer(pipe, tex,
+      struct pipe_transfer *transfer;
+      void *map =
+         pipe_transfer_map(pipe, tex,
                            0, 0,
                            PIPE_TRANSFER_READ_WRITE ,
-                           0, 0, tex->width0, tex->height0);
-      void *map = pipe->transfer_map(pipe, transfer);
+                           0, 0, tex->width0, tex->height0,
+                           &transfer);
       memcpy(map, color_data, sizeof(VGint)*color_data_len);
       pipe->transfer_unmap(pipe, transfer);
-      pipe->transfer_destroy(pipe, transfer);
    }
 
    return tex;
index 2cb5622f817c91123371dfe3be7618dd6fd92a96..300868c252c7b2250b73db88c4b98c27aac9816a 100644 (file)
@@ -442,24 +442,26 @@ void vegaReadPixels(void * data, VGint dataStride,
    {
       VGint y = (stfb->height - sy) - 1, yStep = -1;
       struct pipe_transfer *transfer;
+      void *map;
 
-      transfer = pipe_get_transfer(pipe, strb->texture,  0, 0,
-                                   PIPE_TRANSFER_READ,
-                                   0, 0, sx + width, stfb->height - sy);
+      map = pipe_transfer_map(pipe, strb->texture,  0, 0,
+                              PIPE_TRANSFER_READ,
+                              0, 0, sx + width, stfb->height - sy,
+                              &transfer);
 
       /* Do a row at a time to flip image data vertically */
       for (i = 0; i < height; i++) {
 #if 0
          debug_printf("%d-%d  == %d\n", sy, height, y);
 #endif
-         pipe_get_tile_rgba(pipe, transfer, sx, y, width, 1, df);
+         pipe_get_tile_rgba(transfer, map, sx, y, width, 1, df);
          y += yStep;
          _vega_pack_rgba_span_float(ctx, width, temp, dataFormat,
                                     dst + yoffset + xoffset);
          dst += dataStride;
       }
 
-      pipe->transfer_destroy(pipe, transfer);
+      pipe->transfer_unmap(pipe, transfer);
    }
 }
 
index c42315e4bbade8f787bb09351b778153ea1f73ab..74a84e0a81dc91c4dd19b68820467d11544bc5bf 100644 (file)
@@ -418,17 +418,19 @@ void image_sub_data(struct vg_image *image,
    }
 
    { /* upload color_data */
-      struct pipe_transfer *transfer = pipe_get_transfer(
-         pipe, texture, 0, 0,
-         PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0);
+      struct pipe_transfer *transfer;
+      void *map = pipe_transfer_map(pipe, texture, 0, 0,
+                                    PIPE_TRANSFER_WRITE, 0, 0,
+                                    texture->width0, texture->height0,
+                                    &transfer);
       src += (dataStride * yoffset);
       for (i = 0; i < height; i++) {
          _vega_unpack_float_span_rgba(ctx, width, xoffset, src, dataFormat, temp);
-         pipe_put_tile_rgba(pipe, transfer, x+image->x, y+image->y, width, 1, df);
+         pipe_put_tile_rgba(transfer, map, x+image->x, y+image->y, width, 1, df);
          y += yStep;
          src += dataStride;
       }
-      pipe->transfer_destroy(pipe, transfer);
+      pipe->transfer_unmap(pipe, transfer);
    }
 }
 
@@ -448,25 +450,26 @@ void image_get_sub_data(struct vg_image * image,
    VGubyte *dst = (VGubyte *)data;
 
    {
-      struct pipe_transfer *transfer =
-         pipe_get_transfer(pipe,
+      struct pipe_transfer *transfer;
+      void *map =
+         pipe_transfer_map(pipe,
                            image->sampler_view->texture,  0, 0,
                            PIPE_TRANSFER_READ,
                            0, 0,
                            image->x + image->width,
-                           image->y + image->height);
+                           image->y + image->height, &transfer);
       /* Do a row at a time to flip image data vertically */
       for (i = 0; i < height; i++) {
 #if 0
          debug_printf("%d-%d  == %d\n", sy, height, y);
 #endif
-         pipe_get_tile_rgba(pipe, transfer, sx+image->x, y, width, 1, df);
+         pipe_get_tile_rgba(transfer, map, sx+image->x, y, width, 1, df);
          y += yStep;
          _vega_pack_rgba_span_float(ctx, width, temp, dataFormat, dst);
          dst += dataStride;
       }
 
-      pipe->transfer_destroy(pipe, transfer);
+      pipe->transfer_unmap(pipe, transfer);
    }
 }
 
index 40b4b2502f18dbaeaf8755c9df3e5cda1ffebf28..f73e60c9e6d7ef68191aff2a2f80c231a221baec 100644 (file)
@@ -160,13 +160,13 @@ static INLINE struct pipe_resource *create_gradient_texture(struct vg_paint *p)
    tex = screen->resource_create(screen, &templ);
 
    { /* upload color_data */
-      struct pipe_transfer *transfer =
-         pipe_get_transfer(p->base.ctx->pipe, tex, 0, 0,
-                           PIPE_TRANSFER_WRITE, 0, 0, 1024, 1);
-      void *map = pipe->transfer_map(pipe, transfer);
+      struct pipe_transfer *transfer;
+      void *map =
+         pipe_transfer_map(p->base.ctx->pipe, tex, 0, 0,
+                           PIPE_TRANSFER_WRITE, 0, 0, 1024, 1,
+                           &transfer);
       memcpy(map, p->gradient.color_data, sizeof(VGint)*1024);
       pipe->transfer_unmap(pipe, transfer);
-      pipe->transfer_destroy(pipe, transfer);
    }
 
    return tex;
index 2e9806bb0a96ac8958a3e3807827fa5e66fa57d1..93dae137ba193bbf35cd552579196f8ece8ac7d2 100644 (file)
@@ -103,15 +103,11 @@ xa_surface_dma(struct xa_context *ctx,
        w = boxes->x2 - boxes->x1;
        h = boxes->y2 - boxes->y1;
 
-       transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
-                                    transfer_direction, boxes->x1, boxes->y1,
-                                    w, h);
-       if (!transfer)
-           return -XA_ERR_NORES;
-
-       map = pipe_transfer_map(ctx->pipe, transfer);
+       map = pipe_transfer_map(pipe, srf->tex, 0, 0,
+                                transfer_direction, boxes->x1, boxes->y1,
+                                w, h, &transfer);
        if (!map)
-           goto out_no_map;
+           return -XA_ERR_NORES;
 
        if (to_surface) {
            util_copy_rect(map, srf->tex->format, transfer->stride,
@@ -122,14 +118,10 @@ xa_surface_dma(struct xa_context *ctx,
                           0);
        }
        pipe->transfer_unmap(pipe, transfer);
-       pipe->transfer_destroy(pipe, transfer);
        if (to_surface)
            pipe->flush(pipe, &ctx->last_fence);
     }
     return XA_ERR_NONE;
- out_no_map:
-    pipe->transfer_destroy(pipe, transfer);
-    return -XA_ERR_NORES;
 }
 
 XA_EXPORT void *
@@ -154,15 +146,12 @@ xa_surface_map(struct xa_context *ctx,
     if (!transfer_direction)
        return NULL;
 
-    srf->transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
-                                     transfer_direction, 0, 0,
-                                     srf->tex->width0, srf->tex->height0);
-    if (!srf->transfer)
-       return NULL;
-
-    map = pipe_transfer_map(pipe, srf->transfer);
+    map = pipe_transfer_map(pipe, srf->tex, 0, 0,
+                            transfer_direction, 0, 0,
+                            srf->tex->width0, srf->tex->height0,
+                            &srf->transfer);
     if (!map)
-       pipe->transfer_destroy(pipe, srf->transfer);
+       return NULL;
 
     srf->mapping_pipe = pipe;
     return map;
@@ -175,7 +164,6 @@ xa_surface_unmap(struct xa_surface *srf)
        struct pipe_context *pipe = srf->mapping_pipe;
 
        pipe->transfer_unmap(pipe, srf->transfer);
-       pipe->transfer_destroy(pipe, srf->transfer);
        srf->transfer = NULL;
     }
 }
index 6a78abebcb10865622d5a6e2919f7667471c8314..11888096e66f3479dabb122b62bfd10d72080526 100644 (file)
@@ -240,16 +240,14 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
        crtcp->cursor_handle = whandle.handle;
     }
 
-    transfer = pipe_get_transfer(ctx, crtcp->cursor_tex,
-                                 0, 0,
-                                 PIPE_TRANSFER_WRITE,
-                                 0, 0, 64, 64);
-    ptr = ctx->transfer_map(ctx, transfer);
+    ptr = pipe_transfer_map(ctx, crtcp->cursor_tex,
+                            0, 0,
+                            PIPE_TRANSFER_WRITE,
+                            0, 0, 64, 64, &transfer);
     util_copy_rect(ptr, crtcp->cursor_tex->format,
                   transfer->stride, 0, 0,
                   64, 64, (void*)image, 64 * 4, 0, 0);
     ctx->transfer_unmap(ctx, transfer);
-    ctx->transfer_destroy(ctx, transfer);
     ctx->flush(ctx, &fence);
 
     if (fence) {
index 11985c547fd7f05bd5eb1dfc7439e007f1747003..c8f20acdec7c7428adf4638168eaf85664fd0edc 100644 (file)
@@ -201,24 +201,23 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x,  int y, int w,  int h, char *dst,
     struct exa_context *exa = ms->exa;
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
     struct pipe_transfer *transfer;
+    void *map;
 
     if (!priv || !priv->tex)
        return FALSE;
 
-    transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
-                                 PIPE_TRANSFER_READ, x, y, w, h);
-    if (!transfer)
+    map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
+                            PIPE_TRANSFER_READ, x, y, w, h, &transfer);
+    if (!map)
        return FALSE;
 
     exa_debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
                  x, y, w, h, dst_pitch);
 
     util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
-                  w, h, exa->pipe->transfer_map(exa->pipe, transfer),
-                  transfer->stride, 0, 0);
+                  w, h, map, transfer->stride, 0, 0);
 
     exa->pipe->transfer_unmap(exa->pipe, transfer);
-    exa->pipe->transfer_destroy(exa->pipe, transfer);
 
     return TRUE;
 }
@@ -233,24 +232,24 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
     struct exa_context *exa = ms->exa;
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
     struct pipe_transfer *transfer;
+    void *map;
 
     if (!priv || !priv->tex)
        return FALSE;
 
-    transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
-                                 PIPE_TRANSFER_WRITE, x, y, w, h);
-    if (!transfer)
+    map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
+                            PIPE_TRANSFER_WRITE, x, y, w, h, &transfer);
+    if (!map)
        return FALSE;
 
     exa_debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
                  x, y, w, h, src_pitch);
 
-    util_copy_rect(exa->pipe->transfer_map(exa->pipe, transfer),
+    util_copy_rect(map,
                   priv->tex->format, transfer->stride, 0, 0, w, h,
                   (unsigned char*)src, src_pitch, 0, 0);
 
     exa->pipe->transfer_unmap(exa->pipe, transfer);
-    exa->pipe->transfer_destroy(exa->pipe, transfer);
 
     return TRUE;
 }
@@ -279,24 +278,23 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
         assert(pPix->drawable.width <= priv->tex->width0);
         assert(pPix->drawable.height <= priv->tex->height0);
 
-       priv->map_transfer =
-          pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
+       pPix->devPrivate.ptr =
+          pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
 #ifdef EXA_MIXED_PIXMAPS
-                                       PIPE_TRANSFER_MAP_DIRECTLY |
+                             PIPE_TRANSFER_MAP_DIRECTLY |
 #endif
-                                       PIPE_TRANSFER_READ_WRITE,
-                                       0, 0, 
-                                        pPix->drawable.width,
-                                        pPix->drawable.height );
-       if (!priv->map_transfer)
+                             PIPE_TRANSFER_READ_WRITE,
+                             0, 0,
+                             pPix->drawable.width,
+                             pPix->drawable.height,
+                             &priv->map_transfer);
+        if (!pPix->devPrivate.ptr)
 #ifdef EXA_MIXED_PIXMAPS
            return FALSE;
 #else
            FatalError("failed to create transfer\n");
 #endif
 
-       pPix->devPrivate.ptr =
-           exa->pipe->transfer_map(exa->pipe, priv->map_transfer);
        pPix->devKind = priv->map_transfer->stride;
     }
 
@@ -320,7 +318,7 @@ ExaFinishAccess(PixmapPtr pPix, int index)
     if (!priv)
        return;
 
-    if (!priv->map_transfer)
+    if (!priv->map_transfer || pPix->devPrivate.ptr == NULL)
        return;
 
     exa_debug_printf("ExaFinishAccess %d\n", index);
@@ -328,7 +326,6 @@ ExaFinishAccess(PixmapPtr pPix, int index)
     if (--priv->map_count == 0) {
        assert(priv->map_transfer);
        exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer);
-       exa->pipe->transfer_destroy(exa->pipe, priv->map_transfer);
        priv->map_transfer = NULL;
        pPix->devPrivate.ptr = NULL;
     }
index 7cbad702bf46620025e4b9aef52fecb836657a61..3097d000e19d3e67348f822617fb7c57b40f949b 100644 (file)
@@ -312,22 +312,18 @@ copy_packed_data(ScrnInfoPtr pScrn,
    int yidx, uidx, vidx;
    int y_array_size = w * h;
 
-   ytrans = pipe_get_transfer(pipe, dst[0],
-                              0, 0,
-                              PIPE_TRANSFER_WRITE,
-                              left, top, w, h);
-   utrans = pipe_get_transfer(pipe, dst[1],
-                              0, 0,
-                              PIPE_TRANSFER_WRITE,
-                              left, top, w, h);
-   vtrans = pipe_get_transfer(pipe, dst[2],
-                              0, 0,
-                              PIPE_TRANSFER_WRITE,
-                              left, top, w, h);
-
-   ymap = (char*)pipe->transfer_map(pipe, ytrans);
-   umap = (char*)pipe->transfer_map(pipe, utrans);
-   vmap = (char*)pipe->transfer_map(pipe, vtrans);
+   ymap = pipe_transfer_map(pipe, dst[0],
+                            0, 0,
+                            PIPE_TRANSFER_WRITE,
+                            left, top, w, h, &ytrans);
+   umap = pipe_transfer_map(pipe, dst[1],
+                            0, 0,
+                            PIPE_TRANSFER_WRITE,
+                            left, top, w, h, &utrans);
+   vmap = pipe_transfer_map(pipe, dst[2],
+                            0, 0,
+                            PIPE_TRANSFER_WRITE,
+                            left, top, w, h, &vtrans);
 
    yidx = uidx = vidx = 0;
 
@@ -396,9 +392,6 @@ copy_packed_data(ScrnInfoPtr pScrn,
    pipe->transfer_unmap(pipe, ytrans);
    pipe->transfer_unmap(pipe, utrans);
    pipe->transfer_unmap(pipe, vtrans);
-   pipe->transfer_destroy(pipe, ytrans);
-   pipe->transfer_destroy(pipe, utrans);
-   pipe->transfer_destroy(pipe, vtrans);
 }
 
 
index 8e96ce66dc0154d651673919d6ef93bdcdae5bac..3e13aa60a8ffe315465a5715e40fee7e98638847 100644 (file)
@@ -173,20 +173,16 @@ upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst,
    struct pipe_transfer *transfer;
    void *map;
 
-   transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
-   if (!transfer)
+   map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE,
+                            dst_box, &transfer);
+   if (!map)
       return;
 
-   map = pipe->transfer_map(pipe, transfer);
-   if (map) {
-      util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
-                     dst_box->width, dst_box->height,
-                     src, src_stride, src_x, src_y);
+   util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
+                  dst_box->width, dst_box->height,
+                  src, src_stride, src_x, src_y);
 
-      pipe->transfer_unmap(pipe, transfer);
-   }
-
-   pipe->transfer_destroy(pipe, transfer);
+   pipe->transfer_unmap(pipe, transfer);
 }
 
 PUBLIC
@@ -323,20 +319,15 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
    dst = subpicture_priv->sampler;
 
    /* TODO: Assert clear rect is within bounds? Or clip? */
-   transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
-   if (!transfer)
+   map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE,
+                            &dst_box, &transfer);
+   if (!map)
       return XvMCBadSubpicture;
 
-   map = pipe->transfer_map(pipe, transfer);
-   if (map) {
-      util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
-                     dst_box.width, dst_box.height, &uc);
-
-      pipe->transfer_unmap(pipe, transfer);
-   }
-
-   pipe->transfer_destroy(pipe, transfer);
+   util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
+                  dst_box.width, dst_box.height, &uc);
 
+   pipe->transfer_unmap(pipe, transfer);
    return Success;
 }
 
index ffb6bd269d695ad781cf2519d5d59e455b55a70c..04b57323d8aa8d005ebb8d8c328b4433714776fe 100644 (file)
@@ -369,12 +369,10 @@ static void init_tex( void )
    {
       struct pipe_transfer *t;
       uint32_t *ptr;
-      t = pipe_get_transfer(ctx, samptex,
-                            0, 0, /* level, layer */
-                            PIPE_TRANSFER_READ,
-                            0, 0, SIZE, SIZE); /* x, y, width, height */
-
-      ptr = ctx->transfer_map(ctx, t);
+      ptr = pipe_transfer_map(ctx, samptex,
+                              0, 0, /* level, layer */
+                              PIPE_TRANSFER_READ,
+                              0, 0, SIZE, SIZE, &t); /* x, y, width, height */
 
       if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
          assert(0);
@@ -382,8 +380,6 @@ static void init_tex( void )
       }
 
       ctx->transfer_unmap(ctx, t);
-
-      ctx->transfer_destroy(ctx, t);
    }
 
    memset(&sv_template, 0, sizeof sv_template);
index 9250f0b66bb5825dc33d6d88db7ac60889e18117..86bb18d43e61ad287770ac60bd1e45780c9f582d 100644 (file)
@@ -259,7 +259,7 @@ graw_util_create_tex2d(const struct graw_info *info,
    {
       struct pipe_transfer *t;
       uint32_t *ptr;
-      t = pipe_get_transfer(info->ctx, samptex,
+      t = pipe_transfer_map(info->ctx, samptex,
                             0, 0, /* level, layer */
                             PIPE_TRANSFER_READ,
                             0, 0, SIZE, SIZE); /* x, y, width, height */
index 48db759a1122b2a65a9035199c99a7489da610c9..21ec7b7b0b5b6110e82736085ebca2a7761dffd9 100644 (file)
@@ -433,12 +433,10 @@ static void init_tex( void )
    {
       struct pipe_transfer *t;
       uint32_t *ptr;
-      t = pipe_get_transfer(ctx, samptex,
-                            0, 0, /* level, layer */
-                            PIPE_TRANSFER_READ,
-                            0, 0, SIZE, SIZE); /* x, y, width, height */
-
-      ptr = ctx->transfer_map(ctx, t);
+      ptr = pipe_transfer_map(ctx, samptex,
+                              0, 0, /* level, layer */
+                              PIPE_TRANSFER_READ,
+                              0, 0, SIZE, SIZE, &t); /* x, y, width, height */
 
       if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
          assert(0);
@@ -446,8 +444,6 @@ static void init_tex( void )
       }
 
       ctx->transfer_unmap(ctx, t);
-
-      ctx->transfer_destroy(ctx, t);
    }
 
    memset(&sv_template, 0, sizeof sv_template);
index 4703b83db0ea1a4eb30d275e54081e4b8b9ed412..6f4b9f6e7e80375deb990a54e3bab61536a61e66 100644 (file)
@@ -242,12 +242,10 @@ static void init_tex( void )
    {
       struct pipe_transfer *t;
       uint32_t *ptr;
-      t = pipe_get_transfer(ctx, samptex,
-                            0, 0, /* level, layer */
-                            PIPE_TRANSFER_READ,
-                            0, 0, SIZE, SIZE); /* x, y, width, height */
-
-      ptr = ctx->transfer_map(ctx, t);
+      ptr = pipe_transfer_map(ctx, samptex,
+                              0, 0, /* level, layer */
+                              PIPE_TRANSFER_READ,
+                              0, 0, SIZE, SIZE, &t); /* x, y, width, height */
 
       if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
          assert(0);
@@ -255,8 +253,6 @@ static void init_tex( void )
       }
 
       ctx->transfer_unmap(ctx, t);
-
-      ctx->transfer_destroy(ctx, t);
    }
 
    memset(&sv_template, 0, sizeof sv_template);
index d01cdf8e95fd2d63b8011d4e5617bf62723c7061..6c6f065af53e5d69099c3395d4da1d4df518e5e0 100644 (file)
@@ -320,12 +320,10 @@ static void init_tex( void )
    {
       struct pipe_transfer *t;
       uint32_t *ptr;
-      t = pipe_get_transfer(ctx, samptex,
-                            0, 0, /* level, layer */
-                            PIPE_TRANSFER_READ,
-                            0, 0, SIZE, SIZE); /* x, y, width, height */
-
-      ptr = ctx->transfer_map(ctx, t);
+      ptr = pipe_transfer_map(ctx, samptex,
+                              0, 0, /* level, layer */
+                              PIPE_TRANSFER_READ,
+                              0, 0, SIZE, SIZE, &t); /* x, y, width, height */
 
       if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
          assert(0);
@@ -333,8 +331,6 @@ static void init_tex( void )
       }
 
       ctx->transfer_unmap(ctx, t);
-
-      ctx->transfer_destroy(ctx, t);
    }
 
    memset(&sv_template, 0, sizeof sv_template);
index 83790e685d3286e6ebdeb66567de5e36a1c0d380..6162dd0ae72ed28170ba277a0ca08e14196f0b00 100644 (file)
@@ -175,17 +175,13 @@ static void init_prog(struct program *p)
                box.width = 2;
                box.height = 2;
 
-               t = p->pipe->get_transfer(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box);
-
-               ptr = p->pipe->transfer_map(p->pipe, t);
+               ptr = p->pipe->transfer_map(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box, &t);
                ptr[0] = 0xffff0000;
                ptr[1] = 0xff0000ff;
                ptr[2] = 0xff00ff00;
                ptr[3] = 0xffffff00;
                p->pipe->transfer_unmap(p->pipe, t);
 
-               p->pipe->transfer_destroy(p->pipe, t);
-
                u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format);
 
                p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt);
index 51245766d1cd2aae9e08ad3a1f71d04c5f746d38..24e679dec48c42aa75661c3d04b15dc6f95d1a5b 100644 (file)
@@ -90,17 +90,18 @@ wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
    struct pipe_context *pipe = wdt->winsys->pipe;
    struct pipe_resource *tex = wdt->tex;
    struct pipe_transfer *tr;
+   void *map;
 
-   tr = pipe_get_transfer(pipe, tex, 0, 0,
-                          PIPE_TRANSFER_READ_WRITE,
-                          0, 0, wdt->tex->width0, wdt->tex->height0);
-   if (!tr)
+   map = pipe_transfer_map(pipe, tex, 0, 0,
+                           PIPE_TRANSFER_READ_WRITE,
+                           0, 0, wdt->tex->width0, wdt->tex->height0, &tr);
+   if (!map)
       return FALSE;
 
    *stride = tr->stride;
    wdt->stride = tr->stride;
 
-   pipe->transfer_destroy(pipe, tr);
+   pipe->transfer_unmap(pipe, tr);
 
    return TRUE;
 }
@@ -204,13 +205,9 @@ wsw_dt_map(struct sw_winsys *ws,
 
       assert(!wdt->transfer);
 
-      tr = pipe_get_transfer(pipe, tex, 0, 0,
-                             PIPE_TRANSFER_READ_WRITE,
-                             0, 0, wdt->tex->width0, wdt->tex->height0);
-      if (!tr)
-         return NULL;
-
-      ptr = pipe->transfer_map(pipe, tr);
+      ptr = pipe_transfer_map(pipe, tex, 0, 0,
+                              PIPE_TRANSFER_READ_WRITE,
+                              0, 0, wdt->tex->width0, wdt->tex->height0, &tr);
       if (!ptr)
         goto err;
 
@@ -226,7 +223,7 @@ wsw_dt_map(struct sw_winsys *ws,
    return wdt->ptr;
 
 err:
-   pipe->transfer_destroy(pipe, tr);
+   pipe->transfer_unmap(pipe, tr);
    return NULL;
 }
 
@@ -245,7 +242,6 @@ wsw_dt_unmap(struct sw_winsys *ws,
       return;
 
    pipe->transfer_unmap(pipe, wdt->transfer);
-   pipe->transfer_destroy(pipe, wdt->transfer);
    pipe->flush(pipe, NULL);
    wdt->transfer = NULL;
 }
index 8d2317ea1527921f2eab196686aa82a758849aae..b612f784630e46a8eca1cb87e4d89993fc9e5988 100644 (file)
@@ -101,10 +101,9 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
    uint *dest;
    uint i, j;
 
-   transfer = pipe_get_transfer(pipe,
-                                pt, 0, 0, PIPE_TRANSFER_WRITE,
-                                0, 0, texSize, texSize);
-   dest = (uint *) pipe_transfer_map(pipe, transfer);
+   dest = (uint *) pipe_transfer_map(pipe,
+                                     pt, 0, 0, PIPE_TRANSFER_WRITE,
+                                     0, 0, texSize, texSize, &transfer);
 
    /* Pack four 1D maps into a 2D texture:
     * R map is placed horizontally, indexed by S, in channel 0
@@ -127,7 +126,6 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
    }
 
    pipe_transfer_unmap(pipe, transfer);
-   pipe->transfer_destroy(pipe, transfer);
 }
 
 
index e4d6c4a85bf2adec01f57e5bee504e687c69fe07..b024ef0db325482c394db9addc7034ab0d0060f5 100644 (file)
@@ -306,11 +306,9 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
       return NULL;
    }
 
-   transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
-                                PIPE_TRANSFER_WRITE,
-                                0, 0, width, height);
-
-   dest = pipe_transfer_map(pipe, transfer);
+   dest = pipe_transfer_map(st->pipe, pt, 0, 0,
+                            PIPE_TRANSFER_WRITE,
+                            0, 0, width, height, &transfer);
 
    /* Put image into texture transfer */
    memset(dest, 0xff, height * transfer->stride);
@@ -321,8 +319,6 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
 
    /* Release transfer */
    pipe_transfer_unmap(pipe, transfer);
-   pipe->transfer_destroy(pipe, transfer);
-
    return pt;
 }
 
@@ -611,11 +607,10 @@ create_cache_trans(struct st_context *st)
    /* Map the texture transfer.
     * Subsequent glBitmap calls will write into the texture image.
     */
-   cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0,
-                                    PIPE_TRANSFER_WRITE, 0, 0,
-                                    BITMAP_CACHE_WIDTH,
-                                    BITMAP_CACHE_HEIGHT);
-   cache->buffer = pipe_transfer_map(pipe, cache->trans);
+   cache->buffer = pipe_transfer_map(pipe, cache->texture, 0, 0,
+                                     PIPE_TRANSFER_WRITE, 0, 0,
+                                     BITMAP_CACHE_WIDTH,
+                                     BITMAP_CACHE_HEIGHT, &cache->trans);
 
    /* init image to all 0xff */
    memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
@@ -645,13 +640,11 @@ st_flush_bitmap_cache(struct st_context *st)
       /* The texture transfer has been mapped until now.
           * So unmap and release the texture transfer before drawing.
           */
-      if (cache->trans) {
+      if (cache->trans && cache->buffer) {
          if (0)
             print_cache(cache);
          pipe_transfer_unmap(pipe, cache->trans);
          cache->buffer = NULL;
-
-         pipe->transfer_destroy(pipe, cache->trans);
          cache->trans = NULL;
       }
 
@@ -867,9 +860,8 @@ st_destroy_bitmap(struct st_context *st)
    }
 
    if (cache) {
-      if (cache->trans) {
+      if (cache->trans && cache->buffer) {
          pipe_transfer_unmap(pipe, cache->trans);
-         pipe->transfer_destroy(pipe, cache->trans);
       }
       pipe_resource_reference(&st->bitmap.cache->texture, NULL);
       free(st->bitmap.cache);
index b47a2d87f74619bdd2f34c8fa56d2f680910bf44..ac38128dfd9815b9e03883272efdd9918723d0dc 100644 (file)
@@ -298,6 +298,9 @@ st_bufferobj_map_range(struct gl_context *ctx,
       obj->Length = length;
       obj->AccessFlags = access;
    }
+   else {
+      st_obj->transfer = NULL;
+   }
 
    return obj->Pointer;
 }
index a8a01db969d3b573047cb6863391b7aa57b66f04..121496a41cdbcdb146eb58297dff3c57f0789905 100644 (file)
@@ -514,12 +514,10 @@ make_texture(struct st_context *st,
       /* we'll do pixel transfer in a fragment shader */
       ctx->_ImageTransferState = 0x0;
 
-      transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
-                                   PIPE_TRANSFER_WRITE, 0, 0,
-                                   width, height);
-
       /* map texture transfer */
-      dest = pipe_transfer_map(pipe, transfer);
+      dest = pipe_transfer_map(pipe, pt, 0, 0,
+                               PIPE_TRANSFER_WRITE, 0, 0,
+                               width, height, &transfer);
 
 
       /* Put image into texture transfer.
@@ -538,7 +536,6 @@ make_texture(struct st_context *st,
 
       /* unmap */
       pipe_transfer_unmap(pipe, transfer);
-      pipe->transfer_destroy(pipe, transfer);
 
       assert(success);
 
@@ -863,12 +860,10 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
       usage = PIPE_TRANSFER_WRITE;
    }
 
-   pt = pipe_get_transfer(pipe, strb->texture,
-                          strb->rtt_level, strb->rtt_face + strb->rtt_slice,
-                          usage, x, y,
-                          width, height);
-
-   stmap = pipe_transfer_map(pipe, pt);
+   stmap = pipe_transfer_map(pipe, strb->texture,
+                             strb->rtt_level, strb->rtt_face + strb->rtt_slice,
+                             usage, x, y,
+                             width, height, &pt);
 
    pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels);
    assert(pixels);
@@ -996,7 +991,6 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
 
    /* unmap the stencil buffer */
    pipe_transfer_unmap(pipe, pt);
-   pipe->transfer_destroy(pipe, pt);
 }
 
 
@@ -1247,18 +1241,16 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       dsty = rbDraw->Base.Height - dsty - height;
    }
 
-   ptDraw = pipe_get_transfer(pipe,
-                              rbDraw->texture,
-                              rbDraw->rtt_level,
-                              rbDraw->rtt_face + rbDraw->rtt_slice,
-                              usage, dstx, dsty,
-                              width, height);
-
    assert(util_format_get_blockwidth(ptDraw->resource->format) == 1);
    assert(util_format_get_blockheight(ptDraw->resource->format) == 1);
 
    /* map the stencil buffer */
-   drawMap = pipe_transfer_map(pipe, ptDraw);
+   drawMap = pipe_transfer_map(pipe,
+                               rbDraw->texture,
+                               rbDraw->rtt_level,
+                               rbDraw->rtt_face + rbDraw->rtt_slice,
+                               usage, dstx, dsty,
+                               width, height, &ptDraw);
 
    /* draw */
    /* XXX PixelZoom not handled yet */
@@ -1283,7 +1275,6 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
 
    /* unmap the stencil buffer */
    pipe_transfer_unmap(pipe, ptDraw);
-   pipe->transfer_destroy(pipe, ptDraw);
 }
 
 
@@ -1573,13 +1564,15 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    }
    else {
       /* CPU-based fallback/conversion */
-      struct pipe_transfer *ptRead =
-         pipe_get_transfer(st->pipe, rbRead->texture,
+      struct pipe_transfer *ptRead;
+      void *mapRead =
+         pipe_transfer_map(st->pipe, rbRead->texture,
                            rbRead->rtt_level,
                            rbRead->rtt_face + rbRead->rtt_slice,
                            PIPE_TRANSFER_READ,
-                           readX, readY, readW, readH);
+                           readX, readY, readW, readH, &ptRead);
       struct pipe_transfer *ptTex;
+      void *mapTex;
       enum pipe_transfer_usage transfer_usage;
 
       if (ST_DEBUG & DEBUG_FALLBACK)
@@ -1590,8 +1583,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
 
-      ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, transfer_usage,
-                                0, 0, width, height);
+      mapTex = pipe_transfer_map(st->pipe, pt, 0, 0, transfer_usage,
+                                 0, 0, width, height, &ptTex);
 
       /* copy image from ptRead surface to ptTex surface */
       if (type == GL_COLOR) {
@@ -1600,23 +1593,24 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
          enum pipe_format readFormat, drawFormat;
          readFormat = util_format_linear(rbRead->texture->format);
          drawFormat = util_format_linear(pt->format);
-         pipe_get_tile_rgba_format(pipe, ptRead, 0, 0, readW, readH,
+         pipe_get_tile_rgba_format(ptRead, mapRead, 0, 0, readW, readH,
                                    readFormat, buf);
-         pipe_put_tile_rgba_format(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+         pipe_put_tile_rgba_format(ptTex, mapTex, pack.SkipPixels,
+                                   pack.SkipRows,
                                    readW, readH, drawFormat, buf);
          free(buf);
       }
       else {
          /* GL_DEPTH */
          GLuint *buf = malloc(width * height * sizeof(GLuint));
-         pipe_get_tile_z(pipe, ptRead, 0, 0, readW, readH, buf);
-         pipe_put_tile_z(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+         pipe_get_tile_z(ptRead, mapRead, 0, 0, readW, readH, buf);
+         pipe_put_tile_z(ptTex, mapTex, pack.SkipPixels, pack.SkipRows,
                          readW, readH, buf);
          free(buf);
       }
 
-      pipe->transfer_destroy(pipe, ptRead);
-      pipe->transfer_destroy(pipe, ptTex);
+      pipe->transfer_unmap(pipe, ptRead);
+      pipe->transfer_unmap(pipe, ptTex);
    }
 
    /* OK, the texture 'pt' contains the src image/pixels.  Now draw a
index c523795b91f9776cce6b91b782802ecde6f74a28..882fb372b0551107c7d5e9136f9bbbd423b9bd4e 100644 (file)
@@ -708,6 +708,7 @@ st_MapRenderbuffer(struct gl_context *ctx,
    const GLboolean invert = rb->Name == 0;
    unsigned usage;
    GLuint y2;
+   GLubyte *map;
 
    if (strb->software) {
       /* software-allocated renderbuffer (probably an accum buffer) */
@@ -742,13 +743,12 @@ st_MapRenderbuffer(struct gl_context *ctx,
    else
       y2 = y;
 
-   strb->transfer = pipe_get_transfer(pipe,
-                                      strb->texture,
-                                      strb->rtt_level,
-                                      strb->rtt_face + strb->rtt_slice,
-                                      usage, x, y2, w, h);
-   if (strb->transfer) {
-      GLubyte *map = pipe_transfer_map(pipe, strb->transfer);
+    map = pipe_transfer_map(pipe,
+                            strb->texture,
+                            strb->rtt_level,
+                            strb->rtt_face + strb->rtt_slice,
+                            usage, x, y2, w, h, &strb->transfer);
+   if (map) {
       if (invert) {
          *rowStrideOut = -strb->transfer->stride;
          map += (h - 1) * strb->transfer->stride;
@@ -782,7 +782,6 @@ st_UnmapRenderbuffer(struct gl_context *ctx,
    }
 
    pipe_transfer_unmap(pipe, strb->transfer);
-   pipe->transfer_destroy(pipe, strb->transfer);
    strb->transfer = NULL;
 }
 
index a5d997efca4841cf986f3f83044e168a93f30454..5bf3dc699b7e8aeae9b2b155d7dfbb02f8912e4e 100644 (file)
@@ -578,9 +578,10 @@ decompress_with_blit(struct gl_context * ctx,
    const GLuint width = texImage->Width;
    const GLuint height = texImage->Height;
    struct pipe_resource *dst_texture;
-   struct pipe_transfer *tex_xfer;
    struct pipe_blit_info blit;
    unsigned bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_READ);
+   struct pipe_transfer *tex_xfer;
+   ubyte *map;
 
    /* create temp / dest surface */
    if (!util_create_rgba_texture(pipe, width, height, bind,
@@ -610,21 +611,22 @@ decompress_with_blit(struct gl_context * ctx,
    /* blit/render/decompress */
    st->pipe->blit(st->pipe, &blit);
 
-   /* map the dst_surface so we can read from it */
-   tex_xfer = pipe_get_transfer(pipe,
-                                dst_texture, 0, 0,
-                                PIPE_TRANSFER_READ,
-                                0, 0, width, height);
-
    pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels);
 
+   map = pipe_transfer_map(pipe, dst_texture, 0, 0,
+                           PIPE_TRANSFER_READ,
+                           0, 0, width, height, &tex_xfer);
+   if (!map) {
+      goto end;
+   }
+
    /* copy/pack data into user buffer */
    if (_mesa_format_matches_format_and_type(stImage->base.TexFormat,
                                             format, type,
                                             ctx->Pack.SwapBytes)) {
       /* memcpy */
       const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
-      ubyte *map = pipe_transfer_map(pipe, tex_xfer);
+      /* map the dst_surface so we can read from it */
       GLuint row;
       for (row = 0; row < height; row++) {
          GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width,
@@ -655,7 +657,7 @@ decompress_with_blit(struct gl_context * ctx,
             debug_printf("%s: fallback format translation\n", __FUNCTION__);
 
          /* get float[4] rgba row from surface */
-         pipe_get_tile_rgba_format(pipe, tex_xfer, 0, row, width, 1,
+         pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1,
                                    pformat, rgba);
 
          _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
@@ -666,10 +668,10 @@ decompress_with_blit(struct gl_context * ctx,
    }
 
 end:
-   _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
-
-   pipe->transfer_destroy(pipe, tex_xfer);
+   if (map)
+      pipe_transfer_unmap(pipe, tex_xfer);
 
+   _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
    pipe_resource_reference(&dst_texture, NULL);
 }
 
@@ -720,6 +722,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
    struct pipe_transfer *src_trans;
    GLvoid *texDest;
    enum pipe_transfer_usage transfer_usage;
+   void *map;
 
    if (ST_DEBUG & DEBUG_FALLBACK)
       debug_printf("%s: fallback processing\n", __FUNCTION__);
@@ -728,13 +731,13 @@ fallback_copy_texsubimage(struct gl_context *ctx,
       srcY = strb->Base.Height - srcY - height;
    }
 
-   src_trans = pipe_get_transfer(pipe,
-                                 strb->texture,
-                                 strb->rtt_level,
-                                 strb->rtt_face + strb->rtt_slice,
-                                 PIPE_TRANSFER_READ,
-                                 srcX, srcY,
-                                 width, height);
+   map = pipe_transfer_map(pipe,
+                           strb->texture,
+                           strb->rtt_level,
+                           strb->rtt_face + strb->rtt_slice,
+                           PIPE_TRANSFER_READ,
+                           srcX, srcY,
+                           width, height, &src_trans);
 
    if ((baseFormat == GL_DEPTH_COMPONENT ||
         baseFormat == GL_DEPTH_STENCIL) &&
@@ -769,11 +772,12 @@ fallback_copy_texsubimage(struct gl_context *ctx,
       if (data) {
          /* To avoid a large temp memory allocation, do copy row by row */
          for (row = 0; row < height; row++, srcY += yStep) {
-            pipe_get_tile_z(pipe, src_trans, 0, srcY, width, 1, data);
+            pipe_get_tile_z(src_trans, map, 0, srcY, width, 1, data);
             if (scaleOrBias) {
                _mesa_scale_and_bias_depth_uint(ctx, width, data);
             }
-            pipe_put_tile_z(pipe, stImage->transfer, 0, row, width, 1, data);
+            pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1,
+                            data);
          }
       }
       else {
@@ -801,7 +805,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
          /* XXX this usually involves a lot of int/float conversion.
           * try to avoid that someday.
           */
-         pipe_get_tile_rgba_format(pipe, src_trans, 0, 0, width, height,
+         pipe_get_tile_rgba_format(src_trans, map, 0, 0, width, height,
                                    util_format_linear(strb->texture->format),
                                    tempSrc);
 
@@ -828,7 +832,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
    }
 
    st_texture_image_unmap(st, stImage);
-   pipe->transfer_destroy(pipe, src_trans);
+   pipe->transfer_unmap(pipe, src_trans);
 }
 
 
index 8984dc5f96ce54ffc7ad060ff6c36a4f92381b75..d6dbf8d6cf626a161a06e4e8f18fe1befdf3ef56 100644 (file)
@@ -230,7 +230,6 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
 {
    struct st_texture_object *stObj =
       st_texture_object(stImage->base.TexObject);
-   struct pipe_context *pipe = st->pipe;
    GLuint level;
 
    DBG("%s \n", __FUNCTION__);
@@ -243,14 +242,9 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
    else
       level = stImage->base.Level;
 
-   stImage->transfer = pipe_get_transfer(st->pipe, stImage->pt, level,
-                                         stImage->base.Face + zoffset,
-                                         usage, x, y, w, h);
-
-   if (stImage->transfer)
-      return pipe_transfer_map(pipe, stImage->transfer);
-   else
-      return NULL;
+   return pipe_transfer_map(st->pipe, stImage->pt, level,
+                            stImage->base.Face + zoffset,
+                            usage, x, y, w, h, &stImage->transfer);
 }
 
 
@@ -263,8 +257,6 @@ st_texture_image_unmap(struct st_context *st,
    DBG("%s\n", __FUNCTION__);
 
    pipe_transfer_unmap(pipe, stImage->transfer);
-
-   pipe->transfer_destroy(pipe, stImage->transfer);
    stImage->transfer = NULL;
 }
 
@@ -324,13 +316,11 @@ print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src)
    region.height = 1;
    region.depth = 1;
 
-   xfer = pipe->get_transfer(pipe, src, 0, PIPE_TRANSFER_READ, &region);
-   map = pipe->transfer_map(pipe, xfer);
+   map = pipe->transfer_map(pipe, src, 0, PIPE_TRANSFER_READ, &region, &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);
 }