gallium: split transfer_inline_write into buffer and texture callbacks
authorMarek Olšák <marek.olsak@amd.com>
Sat, 16 Jul 2016 19:19:48 +0000 (21:19 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 23 Jul 2016 11:33:42 +0000 (13:33 +0200)
to reduce the call indirections with u_resource_vtbl.

The worst call tree you could get was:
  - u_transfer_inline_write_vtbl
    - u_default_transfer_inline_write
      - u_transfer_map_vtbl
        - driver_transfer_map
      - u_transfer_unmap_vtbl
        - driver_transfer_unmap

That's 6 indirect calls. Some drivers only had 5. The goal is to have
1 indirect call for drivers that care. The resource type can be determined
statically at most call sites.

The new interface is:
  pipe_context::buffer_subdata(ctx, resource, usage, offset, size, data)
  pipe_context::texture_subdata(ctx, resource, level, usage, box, data,
                                stride, layer_stride)

v2: fix whitespace, correct ilo's behavior

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Roland Scheidegger <sroland@vmware.com>
57 files changed:
src/gallium/auxiliary/postprocess/pp_mlaa.c
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/util/u_transfer.c
src/gallium/auxiliary/util/u_transfer.h
src/gallium/docs/source/context.rst
src/gallium/drivers/ddebug/dd_context.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/i915/i915_resource.c
src/gallium/drivers/i915/i915_resource.h
src/gallium/drivers/i915/i915_resource_buffer.c
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/ilo/ilo_transfer.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/noop/noop_pipe.c
src/gallium/drivers/nouveau/nouveau_buffer.c
src/gallium/drivers/nouveau/nv30/nv30_miptree.c
src/gallium/drivers/nouveau/nv30/nv30_resource.c
src/gallium/drivers/nouveau/nv50/nv50_miptree.c
src/gallium/drivers/nouveau/nv50/nv50_resource.c
src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
src/gallium/drivers/nouveau/nvc0/nvc0_resource.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/r600/evergreen_compute.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/rbug/rbug_context.c
src/gallium/drivers/softpipe/sp_texture.c
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/swr/swr_context.cpp
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/vc4/vc4_resource.c
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_texture.c
src/gallium/include/pipe/p_context.h
src/gallium/state_trackers/clover/core/resource.cpp
src/gallium/state_trackers/nine/buffer9.h
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/surface9.c
src/gallium/state_trackers/nine/volume9.c
src/gallium/state_trackers/omx/vid_enc.c
src/gallium/state_trackers/va/image.c
src/gallium/state_trackers/vdpau/bitmap.c
src/gallium/state_trackers/vdpau/output.c
src/gallium/state_trackers/vdpau/surface.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/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_texture.c

index a3f58b52f4871183369aa0d3f72c291212adcb4a..502fcf169a6c675dddd274120c38f04e8114abbf 100644 (file)
@@ -62,13 +62,9 @@ static void
 up_consts(struct pp_queue_t *ppq)
 {
    struct pipe_context *pipe = ppq->p->pipe;
-   struct pipe_box box;
-
-   u_box_2d(0, 0, sizeof(constants), 1, &box);
 
-   pipe->transfer_inline_write(pipe, ppq->constbuf, 0, PIPE_TRANSFER_WRITE,
-                               &box, constants, sizeof(constants),
-                               sizeof(constants));
+   pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE,
+                        0, sizeof(constants), constants);
 }
 
 /** Run function of the MLAA filter. */
@@ -280,9 +276,9 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
    
    u_box_2d(0, 0, 165, 165, &box);
 
-   ppq->p->pipe->transfer_inline_write(ppq->p->pipe, ppq->areamaptex, 0,
-                                       PIPE_TRANSFER_WRITE, &box,
-                                       areamap, 165 * 2, sizeof(areamap));
+   ppq->p->pipe->texture_subdata(ppq->p->pipe, ppq->areamaptex, 0,
+                                 PIPE_TRANSFER_WRITE, &box,
+                                 areamap, 165 * 2, sizeof(areamap));
 
    ppq->shaders[n][1] = pp_tgsi_to_state(ppq->p->pipe, offsetvs, true,
                                          "offsetvs");
index 207e2aa838f20eb4c86c71bdc3e769112192f576..07f73546ad7d34fb6093e468e5d97b6a2a40608b 100644 (file)
@@ -339,7 +339,6 @@ pipe_buffer_write(struct pipe_context *pipe,
                   unsigned size,
                   const void *data)
 {
-   struct pipe_box box;
    unsigned access = PIPE_TRANSFER_WRITE;
 
    if (offset == 0 && size == buf->width0) {
@@ -348,16 +347,7 @@ pipe_buffer_write(struct pipe_context *pipe,
       access |= PIPE_TRANSFER_DISCARD_RANGE;
    }
 
-   u_box_1d(offset, size, &box);
-
-   pipe->transfer_inline_write( pipe,
-                                buf,
-                                0,
-                                access,
-                                &box,
-                                data,
-                                size,
-                                0);
+   pipe->buffer_subdata(pipe, buf, access, offset, size, data);
 }
 
 /**
@@ -372,18 +362,10 @@ pipe_buffer_write_nooverlap(struct pipe_context *pipe,
                             unsigned offset, unsigned size,
                             const void *data)
 {
-   struct pipe_box box;
-
-   u_box_1d(offset, size, &box);
-
-   pipe->transfer_inline_write(pipe,
-                               buf,
-                               0,
-                               (PIPE_TRANSFER_WRITE |
-                                PIPE_TRANSFER_UNSYNCHRONIZED),
-                               &box,
-                               data,
-                               0, 0);
+   pipe->buffer_subdata(pipe, buf,
+                        (PIPE_TRANSFER_WRITE |
+                         PIPE_TRANSFER_UNSYNCHRONIZED),
+                        offset, size, data);
 }
 
 
index 0610535cd2c95fc4acbb69d12f63284c1493d213..82cf68db958bccc58e678dffbeea3da887fbe3da 100644 (file)
@@ -4,34 +4,58 @@
 #include "util/u_transfer.h"
 #include "util/u_memory.h"
 
-/* One-shot transfer operation with data supplied in a user
- * pointer.  XXX: strides??
- */
-void u_default_transfer_inline_write( struct pipe_context *pipe,
-                                      struct pipe_resource *resource,
-                                      unsigned level,
-                                      unsigned usage,
-                                      const struct pipe_box *box,
-                                      const void *data,
-                                      unsigned stride,
-                                      unsigned layer_stride)
+void u_default_buffer_subdata(struct pipe_context *pipe,
+                              struct pipe_resource *resource,
+                              unsigned usage, unsigned offset,
+                              unsigned size, const void *data)
 {
    struct pipe_transfer *transfer = NULL;
+   struct pipe_box box;
    uint8_t *map = NULL;
 
    assert(!(usage & PIPE_TRANSFER_READ));
 
-   /* the write flag is implicit by the nature of transfer_inline_write */
+   /* the write flag is implicit by the nature of buffer_subdata */
    usage |= PIPE_TRANSFER_WRITE;
 
-   /* transfer_inline_write implicitly discards the rewritten buffer range */
-   if (resource->target == PIPE_BUFFER &&
-       box->x == 0 && box->width == resource->width0) {
+   /* buffer_subdata implicitly discards the rewritten buffer range */
+   if (offset == 0 && size == resource->width0) {
       usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
    } else {
       usage |= PIPE_TRANSFER_DISCARD_RANGE;
    }
 
+   u_box_1d(offset, size, &box);
+
+   map = pipe->transfer_map(pipe, resource, 0, usage, &box, &transfer);
+   if (!map)
+      return;
+
+   memcpy(map, data, size);
+   pipe_transfer_unmap(pipe, transfer);
+}
+
+void u_default_texture_subdata(struct pipe_context *pipe,
+                               struct pipe_resource *resource,
+                               unsigned level,
+                               unsigned usage,
+                               const struct pipe_box *box,
+                               const void *data,
+                               unsigned stride,
+                               unsigned layer_stride)
+{
+   struct pipe_transfer *transfer = NULL;
+   const uint8_t *src_data = data;
+   uint8_t *map = NULL;
+
+   assert(!(usage & PIPE_TRANSFER_READ));
+
+   /* the write flag is implicit by the nature of texture_subdata */
+   usage |= PIPE_TRANSFER_WRITE;
+
+   /* texture_subdata implicitly discards the rewritten buffer range */
+   usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
    map = pipe->transfer_map(pipe,
                             resource,
                             level,
@@ -40,28 +64,18 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
    if (!map)
       return;
 
-   if (resource->target == PIPE_BUFFER) {
-      assert(box->height == 1);
-      assert(box->depth == 1);
-
-      memcpy(map, data, box->width);
-   }
-   else {
-      const uint8_t *src_data = data;
-
-      util_copy_box(map,
-                   resource->format,
-                   transfer->stride, /* bytes */
-                   transfer->layer_stride, /* bytes */
-                    0, 0, 0,
-                   box->width,
-                   box->height,
-                   box->depth,
-                   src_data,
-                   stride,       /* bytes */
-                   layer_stride, /* bytes */
-                   0, 0, 0);
-   }
+   util_copy_box(map,
+                 resource->format,
+                 transfer->stride, /* bytes */
+                 transfer->layer_stride, /* bytes */
+                 0, 0, 0,
+                 box->width,
+                 box->height,
+                 box->depth,
+                 src_data,
+                 stride,       /* bytes */
+                 layer_stride, /* bytes */
+                 0, 0, 0);
 
    pipe_transfer_unmap(pipe, transfer);
 }
@@ -138,27 +152,3 @@ void u_transfer_unmap_vtbl( struct pipe_context *pipe,
    struct u_resource *ur = u_resource(transfer->resource);
    ur->vtbl->transfer_unmap(pipe, transfer);
 }
-
-void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
-                                   struct pipe_resource *resource,
-                                   unsigned level,
-                                   unsigned usage,
-                                   const struct pipe_box *box,
-                                   const void *data,
-                                   unsigned stride,
-                                   unsigned layer_stride)
-{
-   struct u_resource *ur = u_resource(resource);
-   ur->vtbl->transfer_inline_write(pipe,
-                                   resource,
-                                   level,
-                                   usage,
-                                   box,
-                                   data,
-                                   stride,
-                                   layer_stride);
-}
-
-
-
-
index 660dc161d33b01ed65ee91955fef4f8111959760..7f680bc658262fbb55f2cf7fc8c764274c56dc36 100644 (file)
@@ -14,14 +14,19 @@ boolean u_default_resource_get_handle(struct pipe_screen *screen,
                                       struct pipe_resource *resource,
                                       struct winsys_handle *handle);
 
-void u_default_transfer_inline_write( struct pipe_context *pipe,
-                                      struct pipe_resource *resource,
-                                      unsigned level,
-                                      unsigned usage,
-                                      const struct pipe_box *box,
-                                      const void *data,
-                                      unsigned stride,
-                                      unsigned layer_stride);
+void u_default_buffer_subdata(struct pipe_context *pipe,
+                              struct pipe_resource *resource,
+                              unsigned usage, unsigned offset,
+                              unsigned size, const void *data);
+
+void u_default_texture_subdata(struct pipe_context *pipe,
+                               struct pipe_resource *resource,
+                               unsigned level,
+                               unsigned usage,
+                               const struct pipe_box *box,
+                               const void *data,
+                               unsigned stride,
+                               unsigned layer_stride);
 
 void u_default_transfer_flush_region( struct pipe_context *pipe,
                                       struct pipe_transfer *transfer,
@@ -58,15 +63,6 @@ struct u_resource_vtbl {
 
    void (*transfer_unmap)( struct pipe_context *,
                            struct pipe_transfer *transfer );
-
-   void (*transfer_inline_write)( struct pipe_context *pipe,
-                                  struct pipe_resource *resource,
-                                  unsigned level,
-                                  unsigned usage,
-                                  const struct pipe_box *box,
-                                  const void *data,
-                                  unsigned stride,
-                                  unsigned layer_stride);
 };
 
 
@@ -98,13 +94,4 @@ void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
 void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
                             struct pipe_transfer *transfer );
 
-void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
-                                   struct pipe_resource *resource,
-                                   unsigned level,
-                                   unsigned usage,
-                                   const struct pipe_box *box,
-                                   const void *data,
-                                   unsigned stride,
-                                   unsigned layer_stride);
-
 #endif
index 8fb621bcac32cc6108f2348f7d341fe38639bb1b..e646ea02f784f706e2e97823edffb043026dcc25 100644 (file)
@@ -538,8 +538,9 @@ to the transfer object remains unchanged (i.e. it can be non-NULL).
 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 transfer_map, data write, and transfer_unmap all in one.
+``texture_subdata`` and ``buffer_subdata`` perform a simplified
+transfer for simple writes. 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
index 98475b9fe99060436aa32c27a51c4869d5e63444..c0b2b3ddd7e5846a4639f15ad61bd158960f0e2e 100644 (file)
@@ -599,17 +599,28 @@ dd_context_transfer_unmap(struct pipe_context *_pipe,
 }
 
 static void
-dd_context_transfer_inline_write(struct pipe_context *_pipe,
-                                 struct pipe_resource *resource,
-                                 unsigned level, unsigned usage,
-                                 const struct pipe_box *box,
-                                 const void *data, unsigned stride,
-                                 unsigned layer_stride)
+dd_context_buffer_subdata(struct pipe_context *_pipe,
+                          struct pipe_resource *resource,
+                          unsigned usage, unsigned offset,
+                          unsigned size, const void *data)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->buffer_subdata(pipe, resource, usage, offset, size, data);
+}
+
+static void
+dd_context_texture_subdata(struct pipe_context *_pipe,
+                           struct pipe_resource *resource,
+                           unsigned level, unsigned usage,
+                           const struct pipe_box *box,
+                           const void *data, unsigned stride,
+                           unsigned layer_stride)
 {
    struct pipe_context *pipe = dd_context(_pipe)->pipe;
 
-   pipe->transfer_inline_write(pipe, resource, level, usage, box, data,
-                               stride, layer_stride);
+   pipe->texture_subdata(pipe, resource, level, usage, box, data,
+                         stride, layer_stride);
 }
 
 
@@ -767,7 +778,8 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
    CTX_INIT(transfer_map);
    CTX_INIT(transfer_flush_region);
    CTX_INIT(transfer_unmap);
-   CTX_INIT(transfer_inline_write);
+   CTX_INIT(buffer_subdata);
+   CTX_INIT(texture_subdata);
    CTX_INIT(texture_barrier);
    CTX_INIT(memory_barrier);
    /* create_video_codec */
index ded814743314c78a837a1694f3aa886f8b824b49..96d1d88eeedb21947b61168b405861ebabaf7fbc 100644 (file)
@@ -476,7 +476,6 @@ static const struct u_resource_vtbl fd_resource_vtbl = {
                .transfer_map             = fd_resource_transfer_map,
                .transfer_flush_region    = fd_resource_transfer_flush_region,
                .transfer_unmap           = fd_resource_transfer_unmap,
-               .transfer_inline_write    = u_default_transfer_inline_write,
 };
 
 static uint32_t
@@ -864,7 +863,8 @@ fd_resource_context_init(struct pipe_context *pctx)
        pctx->transfer_map = u_transfer_map_vtbl;
        pctx->transfer_flush_region = u_transfer_flush_region_vtbl;
        pctx->transfer_unmap = u_transfer_unmap_vtbl;
-       pctx->transfer_inline_write = u_transfer_inline_write_vtbl;
+       pctx->buffer_subdata = u_default_buffer_subdata;
+        pctx->texture_subdata = u_default_texture_subdata;
        pctx->create_surface = fd_create_surface;
        pctx->surface_destroy = fd_surface_destroy;
        pctx->resource_copy_region = fd_resource_copy_region;
index 3ffb0b7a5d234f82b1563f3fe3448ca4524297ff..8e5572b4cd4591df23fc77713ec5173e7cd044aa 100644 (file)
@@ -39,7 +39,8 @@ i915_init_resource_functions(struct i915_context *i915 )
    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_inline_write = u_transfer_inline_write_vtbl;
+   i915->base.buffer_subdata = i915_buffer_subdata;
+   i915->base.texture_subdata = u_default_texture_subdata;
 }
 
 void
index 77fe8b70f79881ccc2c76838dbdbe4445b503a57..0afd09501c69e5ec99e3fdf66c1095e36dd41cce 100644 (file)
@@ -129,4 +129,10 @@ struct pipe_resource *
 i915_buffer_create(struct pipe_screen *screen,
                   const struct pipe_resource *template);
 
+void
+i915_buffer_subdata(struct pipe_context *rm_ctx,
+                    struct pipe_resource *resource,
+                    unsigned usage, unsigned offset,
+                    unsigned size, const void *data);
+
 #endif /* I915_RESOURCE_H */
index fb2e53b014f45a233a1a86b09467a63b85453114..24c954cae34fb3fa0e1b8c01218a15ca8701aed8 100644 (file)
@@ -92,21 +92,15 @@ i915_buffer_transfer_unmap(struct pipe_context *pipe,
    util_slab_free(&i915->transfer_pool, transfer);
 }
 
-static void
-i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx,
-                                   struct pipe_resource *resource,
-                                   unsigned level,
-                                   unsigned usage,
-                                   const struct pipe_box *box,
-                                   const void *data,
-                                   unsigned stride,
-                                   unsigned layer_stride)
+void
+i915_buffer_subdata(struct pipe_context *rm_ctx,
+                    struct pipe_resource *resource,
+                    unsigned usage, unsigned offset,
+                    unsigned size, const void *data)
 {
    struct i915_buffer *buffer = i915_buffer(resource);
 
-   memcpy(buffer->data + box->x,
-          data,
-          box->width);
+   memcpy(buffer->data + offset, data, size);
 }
 
 
@@ -117,7 +111,6 @@ struct u_resource_vtbl i915_buffer_vtbl =
    i915_buffer_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,  /* transfer_flush_region */
    i915_buffer_transfer_unmap,      /* transfer_unmap */
-   i915_buffer_transfer_inline_write /* transfer_inline_write */
 };
 
 
index af9d97a8acc6c55ff254fcedf42ffe660cd8e781..f77bbfde18192d855f7abeed96bb2c489ee6b954 100644 (file)
@@ -818,7 +818,7 @@ i915_texture_transfer_unmap(struct pipe_context *pipe,
 }
 
 #if 0
-static void i915_transfer_inline_write( struct pipe_context *pipe,
+static void i915_texture_subdata(struct pipe_context *pipe,
                                  struct pipe_resource *resource,
                                  unsigned level,
                                  unsigned usage,
@@ -913,7 +913,6 @@ struct u_resource_vtbl i915_texture_vtbl =
    i915_texture_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,   /* transfer_flush_region */
    i915_texture_transfer_unmap,              /* transfer_unmap */
-   u_default_transfer_inline_write    /* transfer_inline_write */
 };
 
 
index 5abd3bebf68a4ce2ca87df3ad5c0d2c40dbda7e5..d243e38fbe2e2eccb63e9e41142daef98282280b 100644 (file)
@@ -1236,32 +1236,15 @@ ilo_transfer_map(struct pipe_context *pipe,
    return ptr;
 }
 
-static void
-ilo_transfer_inline_write(struct pipe_context *pipe,
-                          struct pipe_resource *res,
-                          unsigned level,
-                          unsigned usage,
-                          const struct pipe_box *box,
-                          const void *data,
-                          unsigned stride,
-                          unsigned layer_stride)
+static void ilo_buffer_subdata(struct pipe_context *pipe,
+                               struct pipe_resource *resource,
+                               unsigned usage, unsigned offset,
+                               unsigned size, const void *data)
 {
-   if (likely(res->target == PIPE_BUFFER) &&
-       !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
-      /* they should specify just an offset and a size */
-      assert(level == 0);
-      assert(box->y == 0);
-      assert(box->z == 0);
-      assert(box->height == 1);
-      assert(box->depth == 1);
-
-      buf_pwrite(ilo_context(pipe), res,
-            usage, box->x, box->width, data);
-   }
-   else {
-      u_default_transfer_inline_write(pipe, res,
-            level, usage, box, data, stride, layer_stride);
-   }
+   if (usage & PIPE_TRANSFER_UNSYNCHRONIZED)
+      u_default_buffer_subdata(pipe, resource, usage, offset, size, data);
+   else
+      buf_pwrite(ilo_context(pipe), resource, usage, offset, size, data);
 }
 
 /**
@@ -1273,5 +1256,6 @@ ilo_init_transfer_functions(struct ilo_context *ilo)
    ilo->base.transfer_map = ilo_transfer_map;
    ilo->base.transfer_flush_region = ilo_transfer_flush_region;
    ilo->base.transfer_unmap = ilo_transfer_unmap;
-   ilo->base.transfer_inline_write = ilo_transfer_inline_write;
+   ilo->base.buffer_subdata = ilo_buffer_subdata;
+   ilo->base.texture_subdata = u_default_texture_subdata;
 }
index 36f1c6b1a20e5ddedc62041a02d0f3a266919b0d..0d4c4efe0b972b7951a992ab8a76d6200362e064 100644 (file)
@@ -816,5 +816,6 @@ llvmpipe_init_context_resource_funcs(struct pipe_context *pipe)
    pipe->transfer_unmap = llvmpipe_transfer_unmap;
 
    pipe->transfer_flush_region = u_default_transfer_flush_region;
-   pipe->transfer_inline_write = u_default_transfer_inline_write;
+   pipe->buffer_subdata = u_default_buffer_subdata;
+   pipe->texture_subdata = u_default_texture_subdata;
 }
index 99e5f1ae1a99a15e631996a0b23850700b5dd5fd..097ff21c38becc1da119fd9b29ed9b87e75b6531 100644 (file)
@@ -192,14 +192,21 @@ static void noop_transfer_unmap(struct pipe_context *pipe,
    FREE(transfer);
 }
 
-static void noop_transfer_inline_write(struct pipe_context *pipe,
-                                       struct pipe_resource *resource,
-                                       unsigned level,
-                                       unsigned usage,
-                                       const struct pipe_box *box,
-                                       const void *data,
-                                       unsigned stride,
-                                       unsigned layer_stride)
+static void noop_buffer_subdata(struct pipe_context *pipe,
+                                struct pipe_resource *resource,
+                                unsigned usage, unsigned offset,
+                                unsigned size, const void *data)
+{
+}
+
+static void noop_texture_subdata(struct pipe_context *pipe,
+                                 struct pipe_resource *resource,
+                                 unsigned level,
+                                 unsigned usage,
+                                 const struct pipe_box *box,
+                                 const void *data,
+                                 unsigned stride,
+                                 unsigned layer_stride)
 {
 }
 
@@ -294,7 +301,8 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen,
        ctx->transfer_map = noop_transfer_map;
        ctx->transfer_flush_region = noop_transfer_flush_region;
        ctx->transfer_unmap = noop_transfer_unmap;
-       ctx->transfer_inline_write = noop_transfer_inline_write;
+       ctx->buffer_subdata = noop_buffer_subdata;
+       ctx->texture_subdata = noop_texture_subdata;
        noop_init_state_functions(ctx);
 
        return ctx;
index 7c1421b581552db49efaec04d75ff53fe4db0233..17052b26e9c8efbd8b518052958de2338bc28a97 100644 (file)
@@ -634,7 +634,6 @@ const struct u_resource_vtbl nouveau_buffer_vtbl =
    nouveau_buffer_transfer_map,          /* transfer_map */
    nouveau_buffer_transfer_flush_region, /* transfer_flush_region */
    nouveau_buffer_transfer_unmap,        /* transfer_unmap */
-   u_default_transfer_inline_write    /* transfer_inline_write */
 };
 
 struct pipe_resource *
index c6f696500681d431c08180e2fe53fbd07c72bf08..165b8f29b4bc08f17dbcabb2947dd9a8f58ebeb0 100644 (file)
@@ -358,7 +358,6 @@ const struct u_resource_vtbl nv30_miptree_vtbl = {
    nv30_miptree_transfer_map,
    u_default_transfer_flush_region,
    nv30_miptree_transfer_unmap,
-   u_default_transfer_inline_write
 };
 
 struct pipe_resource *
index 4d215d2e61663fb6c84e4fdb8ae6b317f5a18573..6238a2384cb3587d474c674b6e57b4da009d6236 100644 (file)
@@ -90,7 +90,8 @@ nv30_resource_init(struct pipe_context *pipe)
    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_inline_write = u_transfer_inline_write_vtbl;
+   pipe->buffer_subdata = u_default_buffer_subdata;
+   pipe->texture_subdata = u_default_texture_subdata;
    pipe->create_surface = nv30_miptree_surface_new;
    pipe->surface_destroy = nv30_miptree_surface_del;
    pipe->resource_copy_region = nv30_resource_copy_region;
index 745011977b3d3d317f9f197b4a28f0819760b010..f2e304fde6212eb455933cbd55789d479ac6e919 100644 (file)
@@ -204,7 +204,6 @@ const struct u_resource_vtbl nv50_miptree_vtbl =
    nv50_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nv50_miptree_transfer_unmap,     /* transfer_unmap */
-   u_default_transfer_inline_write  /* transfer_inline_write */
 };
 
 static inline bool
index b090a30aed6bffb1d596c4cd55bd7bf3ca40ce33..aed8c6241d4b10deb1ae8fdb57d0c2739899f817 100644 (file)
@@ -97,7 +97,8 @@ nv50_init_resource_functions(struct pipe_context *pcontext)
    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_inline_write = u_transfer_inline_write_vtbl;
+   pcontext->buffer_subdata = u_default_buffer_subdata;
+   pcontext->texture_subdata = u_default_texture_subdata;
    pcontext->create_surface = nv50_surface_create;
    pcontext->surface_destroy = nv50_surface_destroy;
    pcontext->invalidate_resource = nv50_invalidate_resource;
index ed1ac48315b3a489bd0546485862bbe94b45bb8e..27674f72a7c07936ab751e59a034528ffba9c512 100644 (file)
@@ -240,7 +240,6 @@ const struct u_resource_vtbl nvc0_miptree_vtbl =
    nvc0_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nvc0_miptree_transfer_unmap,     /* transfer_unmap */
-   u_default_transfer_inline_write  /* transfer_inline_write */
 };
 
 struct pipe_resource *
index 0aee5890fd88b677c98cffb9ca6fb9491a5975a3..9bafe3d835db049bdfcd3f55d88ee9ccd7b72eed 100644 (file)
@@ -49,7 +49,8 @@ nvc0_init_resource_functions(struct pipe_context *pcontext)
    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_inline_write = u_transfer_inline_write_vtbl;
+   pcontext->buffer_subdata = u_default_buffer_subdata;
+   pcontext->texture_subdata = u_default_texture_subdata;
    pcontext->create_surface = nvc0_surface_create;
    pcontext->surface_destroy = nv50_surface_destroy;
    pcontext->invalidate_resource = nv50_invalidate_resource;
index 701fd249d307ee9b7ccbebfc5732be8df26b6b4c..3da5fefef6def6f1cadc4298968e792ea55aff23 100644 (file)
@@ -43,7 +43,8 @@ void r300_init_resource_functions(struct r300_context *r300)
    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_inline_write = u_default_transfer_inline_write;
+   r300->context.buffer_subdata = u_default_buffer_subdata;
+   r300->context.texture_subdata = u_default_texture_subdata;
    r300->context.create_surface = r300_create_surface;
    r300->context.surface_destroy = r300_surface_destroy;
 }
index 5b69b24f59b25a64bfa99fc67f3fea9ba5653966..069e9fdc6b0717ecad73c6d38ff51a4443936212 100644 (file)
@@ -152,7 +152,6 @@ static const struct u_resource_vtbl r300_buffer_vtbl =
    r300_buffer_transfer_map,           /* transfer_map */
    NULL,                               /* transfer_flush_region */
    r300_buffer_transfer_unmap,         /* transfer_unmap */
-   NULL   /* transfer_inline_write */
 };
 
 struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
index 14372da62e422218aed875eda236f88222f23714..2fc93c2dfd6a634580e4a9efbc8807f727fc57c3 100644 (file)
@@ -1058,7 +1058,6 @@ static const struct u_resource_vtbl r300_texture_vtbl =
     r300_texture_transfer_map,      /* transfer_map */
     NULL,                           /* transfer_flush_region */
     r300_texture_transfer_unmap,    /* transfer_unmap */
-    NULL /* transfer_inline_write */
 };
 
 /* The common texture constructor. */
index b711786da29b43d9c727f59a214a8a95ed6c2361..292b5e32afd3675d8c5d7580d227ce65e14b9594 100644 (file)
@@ -977,18 +977,6 @@ static void r600_compute_global_transfer_flush_region(struct pipe_context *ctx,
        assert(0 && "TODO");
 }
 
-static void r600_compute_global_transfer_inline_write(struct pipe_context *pipe,
-                                                     struct pipe_resource *resource,
-                                                     unsigned level,
-                                                     unsigned usage,
-                                                     const struct pipe_box *box,
-                                                     const void *data,
-                                                     unsigned stride,
-                                                     unsigned layer_stride)
-{
-       assert(0 && "TODO");
-}
-
 static void r600_compute_global_buffer_destroy(struct pipe_screen *screen,
                                               struct pipe_resource *res)
 {
@@ -1014,7 +1002,6 @@ static const struct u_resource_vtbl r600_global_buffer_vtbl =
        r600_compute_global_transfer_map, /* transfer_map */
        r600_compute_global_transfer_flush_region,/* transfer_flush_region */
        r600_compute_global_transfer_unmap, /* transfer_unmap */
-       r600_compute_global_transfer_inline_write /* transfer_inline_write */
 };
 
 struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen,
index 9583d70489e9f4b2aa0b7c9115b97105d505381c..b5c8697ac5290aaeea8452703a2bfc2386818773 100644 (file)
@@ -456,7 +456,6 @@ static const struct u_resource_vtbl r600_buffer_vtbl =
        r600_buffer_transfer_map,       /* transfer_map */
        r600_buffer_flush_region,       /* transfer_flush_region */
        r600_buffer_transfer_unmap,     /* transfer_unmap */
-       NULL                            /* transfer_inline_write */
 };
 
 static struct r600_resource *
index 647832b5f6ebf032fb3dab9c1f060125c2ccaac9..4ef58cae282061106fa292b429b597bbdf0e7f24 100644 (file)
@@ -422,8 +422,9 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        rctx->b.transfer_map = u_transfer_map_vtbl;
        rctx->b.transfer_flush_region = u_transfer_flush_region_vtbl;
        rctx->b.transfer_unmap = u_transfer_unmap_vtbl;
-       rctx->b.transfer_inline_write = u_default_transfer_inline_write;
-        rctx->b.memory_barrier = r600_memory_barrier;
+       rctx->b.buffer_subdata = u_default_buffer_subdata;
+       rctx->b.texture_subdata = u_default_texture_subdata;
+       rctx->b.memory_barrier = r600_memory_barrier;
        rctx->b.flush = r600_flush_from_st;
        rctx->b.set_debug_callback = r600_set_debug_callback;
 
index 7763f812141c96eb6d5453cd94eda7fa3f33d10f..f7c2f80ec3c01f649da62406877548f60f178366 100644 (file)
@@ -1628,7 +1628,6 @@ static const struct u_resource_vtbl r600_texture_vtbl =
        r600_texture_transfer_map,      /* transfer_map */
        u_default_transfer_flush_region, /* transfer_flush_region */
        r600_texture_transfer_unmap,    /* transfer_unmap */
-       NULL                            /* transfer_inline_write */
 };
 
 struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
index 77f09b001a85c9d2bb910370380d6a5c3d4d7ed3..83914d3615b56eb15e513f435528de90c6b0e8c9 100644 (file)
@@ -1141,14 +1141,31 @@ rbug_context_transfer_unmap(struct pipe_context *_context,
 
 
 static void
-rbug_context_transfer_inline_write(struct pipe_context *_context,
-                                   struct pipe_resource *_resource,
-                                   unsigned level,
-                                   unsigned usage,
-                                   const struct pipe_box *box,
-                                   const void *data,
-                                   unsigned stride,
-                                   unsigned layer_stride)
+rbug_context_buffer_subdata(struct pipe_context *_context,
+                            struct pipe_resource *_resource,
+                            unsigned usage, unsigned offset,
+                            unsigned size, const void *data)
+{
+   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;
+
+   pipe_mutex_lock(rb_pipe->call_mutex);
+   context->buffer_subdata(context, resource, usage, offset, size, data);
+   pipe_mutex_unlock(rb_pipe->call_mutex);
+}
+
+
+static void
+rbug_context_texture_subdata(struct pipe_context *_context,
+                             struct pipe_resource *_resource,
+                             unsigned level,
+                             unsigned usage,
+                             const struct pipe_box *box,
+                             const void *data,
+                             unsigned stride,
+                             unsigned layer_stride)
 {
    struct rbug_context *rb_pipe = rbug_context(_context);
    struct rbug_resource *rb_resource = rbug_resource(_resource);
@@ -1156,14 +1173,14 @@ rbug_context_transfer_inline_write(struct pipe_context *_context,
    struct pipe_resource *resource = rb_resource->resource;
 
    pipe_mutex_lock(rb_pipe->call_mutex);
-   context->transfer_inline_write(context,
-                                  resource,
-                                  level,
-                                  usage,
-                                  box,
-                                  data,
-                                  stride,
-                                  layer_stride);
+   context->texture_subdata(context,
+                            resource,
+                            level,
+                            usage,
+                            box,
+                            data,
+                            stride,
+                            layer_stride);
    pipe_mutex_unlock(rb_pipe->call_mutex);
 }
 
@@ -1252,7 +1269,8 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    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;
-   rb_pipe->base.transfer_inline_write = rbug_context_transfer_inline_write;
+   rb_pipe->base.buffer_subdata = rbug_context_buffer_subdata;
+   rb_pipe->base.texture_subdata = rbug_context_texture_subdata;
 
    rb_pipe->pipe = pipe;
 
index 64666fee03f82a3b25377572fc8a630cf73fa853..9c64397d0b9763e48abf49ee20bc09a866ba05fe 100644 (file)
@@ -514,7 +514,8 @@ softpipe_init_texture_funcs(struct pipe_context *pipe)
    pipe->transfer_unmap = softpipe_transfer_unmap;
 
    pipe->transfer_flush_region = u_default_transfer_flush_region;
-   pipe->transfer_inline_write = u_default_transfer_inline_write;
+   pipe->buffer_subdata = u_default_buffer_subdata;
+   pipe->texture_subdata = u_default_texture_subdata;
 
    pipe->create_surface = softpipe_create_surface;
    pipe->surface_destroy = softpipe_surface_destroy;
index 264ac335405b79ae97b6e9814540c345e6da890c..6a297a2ae024b529ccce861129beb5e754eca7e8 100644 (file)
@@ -107,7 +107,8 @@ svga_init_resource_functions(struct svga_context *svga)
    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_inline_write = u_transfer_inline_write_vtbl;
+   svga->pipe.buffer_subdata = u_default_buffer_subdata;
+   svga->pipe.texture_subdata = u_default_texture_subdata;
 
    if (svga_have_vgpu10(svga)) {
       svga->pipe.generate_mipmap = svga_texture_generate_mipmap;
index a92a5c1190437bf5808b6481f77d79ea01a2e834..68ce103f75081eae9e7271a131ada8c5c0d80199 100644 (file)
@@ -369,7 +369,6 @@ struct u_resource_vtbl svga_buffer_vtbl =
    svga_buffer_transfer_map,        /* transfer_map */
    svga_buffer_transfer_flush_region,  /* transfer_flush_region */
    svga_buffer_transfer_unmap,      /* transfer_unmap */
-   u_default_transfer_inline_write   /* transfer_inline_write */
 };
 
 
index 9e1aaabd18c75452de3a488f769a79ac13cc1140..230221a386784f747d51e67ae40409028b60ddb7 100644 (file)
@@ -779,7 +779,6 @@ struct u_resource_vtbl svga_texture_vtbl =
    svga_texture_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,   /* transfer_flush_region */
    svga_texture_transfer_unmap,              /* transfer_unmap */
-   u_default_transfer_inline_write    /* transfer_inline_write */
 };
 
 
index 1f3a14cb9c8a2dd83578e4e8caf6670fac2c5509..1083c9de194ec02adb6020c1c6c491036901a853 100644 (file)
@@ -376,7 +376,8 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
    ctx->pipe.transfer_unmap = swr_transfer_unmap;
 
    ctx->pipe.transfer_flush_region = u_default_transfer_flush_region;
-   ctx->pipe.transfer_inline_write = u_default_transfer_inline_write;
+   ctx->pipe.buffer_subdata = u_default_buffer_subdata;
+   ctx->pipe.texture_subdata = u_default_texture_subdata;
 
    ctx->pipe.resource_copy_region = swr_resource_copy;
    ctx->pipe.render_condition = swr_render_condition;
index c1ad991eedec13840a7ce38d47301488ec063b13..65d7f4eca7978ffbb061528df6deb31237e6424d 100644 (file)
@@ -1470,7 +1470,7 @@ trace_context_transfer_map(struct pipe_context *_context,
 
    /*
     * Map and transfers can't be serialized so we convert all write transfers
-    * to transfer_inline_write and ignore read transfers.
+    * to texture/buffer_subdata and ignore read transfers.
     */
 
    map = context->transfer_map(context, texture, level, usage, box, &result);
@@ -1512,7 +1512,7 @@ trace_context_transfer_unmap(struct pipe_context *_context,
 
    if (tr_trans->map) {
       /*
-       * Fake a transfer_inline_write
+       * Fake a texture/buffer_subdata
        */
 
       struct pipe_resource *resource = transfer->resource;
@@ -1522,7 +1522,10 @@ trace_context_transfer_unmap(struct pipe_context *_context,
       unsigned stride = transfer->stride;
       unsigned layer_stride = transfer->layer_stride;
 
-      trace_dump_call_begin("pipe_context", "transfer_inline_write");
+      if (resource->target == PIPE_BUFFER)
+         trace_dump_call_begin("pipe_context", "buffer_subdata");
+      else
+         trace_dump_call_begin("pipe_context", "texture_subdata");
 
       trace_dump_arg(ptr, context);
       trace_dump_arg(ptr, resource);
@@ -1552,14 +1555,47 @@ trace_context_transfer_unmap(struct pipe_context *_context,
 
 
 static void
-trace_context_transfer_inline_write(struct pipe_context *_context,
-                                    struct pipe_resource *_resource,
-                                    unsigned level,
-                                    unsigned usage,
-                                    const struct pipe_box *box,
-                                    const void *data,
-                                    unsigned stride,
-                                    unsigned layer_stride)
+trace_context_buffer_subdata(struct pipe_context *_context,
+                             struct pipe_resource *_resource,
+                             unsigned usage, unsigned offset,
+                             unsigned size, const void *data)
+{
+   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 *resource = tr_res->resource;
+   struct pipe_box box;
+
+   assert(resource->screen == context->screen);
+
+   trace_dump_call_begin("pipe_context", "buffer_subdata");
+
+   trace_dump_arg(ptr, context);
+   trace_dump_arg(ptr, resource);
+   trace_dump_arg(uint, usage);
+   trace_dump_arg(uint, offset);
+   trace_dump_arg(uint, size);
+
+   trace_dump_arg_begin("data");
+   u_box_1d(offset, size, &box);
+   trace_dump_box_bytes(data, resource, &box, 0, 0);
+   trace_dump_arg_end();
+
+   trace_dump_call_end();
+
+   context->buffer_subdata(context, resource, usage, offset, size, data);
+}
+
+
+static void
+trace_context_texture_subdata(struct pipe_context *_context,
+                              struct pipe_resource *_resource,
+                              unsigned level,
+                              unsigned usage,
+                              const struct pipe_box *box,
+                              const void *data,
+                              unsigned stride,
+                              unsigned layer_stride)
 {
    struct trace_context *tr_context = trace_context(_context);
    struct trace_resource *tr_res = trace_resource(_resource);
@@ -1568,7 +1604,7 @@ trace_context_transfer_inline_write(struct pipe_context *_context,
 
    assert(resource->screen == context->screen);
 
-   trace_dump_call_begin("pipe_context", "transfer_inline_write");
+   trace_dump_call_begin("pipe_context", "texture_subdata");
 
    trace_dump_arg(ptr, context);
    trace_dump_arg(ptr, resource);
@@ -1589,8 +1625,8 @@ trace_context_transfer_inline_write(struct pipe_context *_context,
 
    trace_dump_call_end();
 
-   context->transfer_inline_write(context, resource, level, usage, box,
-                                  data, stride, layer_stride);
+   context->texture_subdata(context, resource, level, usage, box,
+                            data, stride, layer_stride);
 }
 
 
@@ -1873,7 +1909,8 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(transfer_map);
    TR_CTX_INIT(transfer_unmap);
    TR_CTX_INIT(transfer_flush_region);
-   TR_CTX_INIT(transfer_inline_write);
+   TR_CTX_INIT(buffer_subdata);
+   TR_CTX_INIT(texture_subdata);
 
 #undef TR_CTX_INIT
 
index 08d7d207f7987b1c968b9ba54b837314032b4566..398aa8181df0d399ae7ac43c0c3966554d4cd469 100644 (file)
@@ -353,7 +353,6 @@ static const struct u_resource_vtbl vc4_resource_vtbl = {
         .transfer_map             = vc4_resource_transfer_map,
         .transfer_flush_region    = u_default_transfer_flush_region,
         .transfer_unmap           = vc4_resource_transfer_unmap,
-        .transfer_inline_write    = u_default_transfer_inline_write,
 };
 
 static void
@@ -985,7 +984,8 @@ vc4_resource_context_init(struct pipe_context *pctx)
         pctx->transfer_map = u_transfer_map_vtbl;
         pctx->transfer_flush_region = u_transfer_flush_region_vtbl;
         pctx->transfer_unmap = u_transfer_unmap_vtbl;
-        pctx->transfer_inline_write = u_transfer_inline_write_vtbl;
+        pctx->buffer_subdata = u_default_buffer_subdata;
+        pctx->texture_subdata = u_default_texture_subdata;
         pctx->create_surface = vc4_create_surface;
         pctx->surface_destroy = vc4_surface_destroy;
         pctx->resource_copy_region = util_resource_copy_region;
index 94034072439d6f9b33b3c0a7f06e2df62585e2ef..153df8dd0c93a7fbc7715c9dff54bdae85782c6d 100644 (file)
@@ -145,7 +145,6 @@ static const struct u_resource_vtbl virgl_buffer_vtbl =
    virgl_buffer_transfer_map,                /* transfer_map */
    virgl_buffer_transfer_flush_region,       /* transfer_flush_region */
    virgl_buffer_transfer_unmap,              /* transfer_unmap */
-   virgl_transfer_inline_write               /* transfer_inline_write */
 };
 
 struct pipe_resource *virgl_buffer_create(struct virgl_screen *vs,
index 2b3794765e23e2953990231fd15888e1763fb68e..441b0c117038eb120a41dfddd56cffce4a937176 100644 (file)
@@ -82,10 +82,22 @@ void virgl_init_screen_resource_functions(struct pipe_screen *screen)
     screen->resource_destroy = u_resource_destroy_vtbl;
 }
 
+static void virgl_buffer_subdata(struct pipe_context *pipe,
+                                 struct pipe_resource *resource,
+                                 unsigned usage, unsigned offset,
+                                 unsigned size, const void *data)
+{
+   struct pipe_box box;
+
+   u_box_1d(offset, size, &box);
+   virgl_transfer_inline_write(pipe, resource, 0, usage, &box, data, 0, 0);
+}
+
 void virgl_init_context_resource_functions(struct pipe_context *ctx)
 {
     ctx->transfer_map = u_transfer_map_vtbl;
     ctx->transfer_flush_region = u_transfer_flush_region_vtbl;
     ctx->transfer_unmap = u_transfer_unmap_vtbl;
-    ctx->transfer_inline_write = u_transfer_inline_write_vtbl;
+    ctx->buffer_subdata = virgl_buffer_subdata;
+    ctx->texture_subdata = u_default_texture_subdata;
 }
index 34db0560fe97706f9ff9e22fdb90845008ef720e..64b6744462d98764f60e70374273faeefff37b0c 100644 (file)
@@ -304,7 +304,6 @@ static const struct u_resource_vtbl virgl_texture_vtbl =
    virgl_texture_transfer_map,          /* transfer_map */
    NULL,                                /* transfer_flush_region */
    virgl_texture_transfer_unmap,        /* transfer_unmap */
-   u_default_transfer_inline_write      /* transfer_inline_write */
 };
 
 struct pipe_resource *
index 0c88e00de165965fc190f65ac5a4746885d130fb..fe567b67197b6be61f1ca0ec60f4c5fea08e8bfc 100644 (file)
@@ -519,16 +519,23 @@ struct pipe_context {
                           struct pipe_transfer *transfer);
 
    /* One-shot transfer operation with data supplied in a user
-    * pointer.  XXX: strides??
-    */
-   void (*transfer_inline_write)( struct pipe_context *,
-                                  struct pipe_resource *,
-                                  unsigned level,
-                                  unsigned usage, /* a combination of PIPE_TRANSFER_x */
-                                  const struct pipe_box *,
-                                  const void *data,
-                                  unsigned stride,
-                                  unsigned layer_stride);
+    * pointer.
+    */
+   void (*buffer_subdata)(struct pipe_context *,
+                          struct pipe_resource *,
+                          unsigned usage, /* a combination of PIPE_TRANSFER_x */
+                          unsigned offset,
+                          unsigned size,
+                          const void *data);
+
+   void (*texture_subdata)(struct pipe_context *,
+                           struct pipe_resource *,
+                           unsigned level,
+                           unsigned usage, /* a combination of PIPE_TRANSFER_x */
+                           const struct pipe_box *,
+                           const void *data,
+                           unsigned stride,
+                           unsigned layer_stride);
 
    /**
     * Flush any pending framebuffer writes and invalidate texture caches.
index 10a29a94eac4498eda633dea65347dd8918beda2..83781d39c01e904934e83b2928c7f1248b4725ce 100644 (file)
@@ -161,9 +161,13 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj,
       box rect { {{ 0, 0, 0 }}, {{ info.width0, info.height0, info.depth0 }} };
       unsigned cpp = util_format_get_blocksize(info.format);
 
-      q.pipe->transfer_inline_write(q.pipe, pipe, 0, PIPE_TRANSFER_WRITE,
-                                    rect, data_ptr, cpp * info.width0,
-                                    cpp * info.width0 * info.height0);
+      if (pipe->target == PIPE_BUFFER)
+         q.pipe->buffer_subdata(q.pipe, pipe, PIPE_TRANSFER_WRITE,
+                                0, info.width0, data_ptr);
+      else
+         q.pipe->texture_subdata(q.pipe, pipe, 0, PIPE_TRANSFER_WRITE,
+                                 rect, data_ptr, cpp * info.width0,
+                                 cpp * info.width0 * info.height0);
    }
 }
 
index 8bdb4326a4ca0971314d69775246324544a4f1fd..c109cf66140b894964830e743d0fb7200ece67c0 100644 (file)
@@ -88,10 +88,10 @@ NineBuffer9_Upload( struct NineBuffer9 *This )
     struct pipe_context *pipe = This->pipe;
 
     assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty);
-    pipe->transfer_inline_write(pipe, This->base.resource, 0, 0,
-                                &This->managed.dirty_box,
-                                (char *)This->managed.data + This->managed.dirty_box.x,
-                                This->size, This->size);
+    pipe->buffer_subdata(pipe, This->base.resource, 0,
+                         This->managed.dirty_box.x,
+                         This->managed.dirty_box.width,
+                         (char *)This->managed.data + This->managed.dirty_box.x);
     This->managed.dirty = FALSE;
 }
 
index 6aa632501122cdd8b8b3d758f62309bfa1003a6f..fd098ca68ea5f097b4430c95e5d5b628caaa5680 100644 (file)
@@ -86,8 +86,7 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device);
         DBG("upload ConstantF [%u .. %u]\n", x, (x) + (c) - 1); \
         box.x = (p) * 4 * sizeof(float); \
         box.width = (c) * 4 * sizeof(float); \
-        pipe->transfer_inline_write(pipe, buf, 0, usage, &box, &((d)[p * 4]), \
-                                    0, 0); \
+        pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, &((d)[p * 4])); \
     } while(0)
 
 /* OK, this is a bit ugly ... */
@@ -186,7 +185,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
        box.x = x;
        box.width = c * 4;
        DBG("upload ConstantB [%u .. %u]\n", x, x + c - 1);
-       pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data_b, 0, 0);
+       pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data_b);
     }
 
     /* int4 */
@@ -203,7 +202,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
             box.x += x * 4 * sizeof(int);
             box.width = c * 4 * sizeof(int);
             c = 0;
-            pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+            pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
         }
     }
     if (c) {
@@ -212,7 +211,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
         box.x  = buf->width0 - (NINE_MAX_CONST_I * 4 + NINE_MAX_CONST_B) * 4;
         box.x += x * 4 * sizeof(int);
         box.width = c * 4 * sizeof(int);
-        pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+        pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
     }
 
     /* TODO: only upload these when shader itself changes */
@@ -224,7 +223,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
             n += r->end - r->bgn;
             box.width = (r->end - r->bgn) * 4 * sizeof(float);
             data = &lconstf_data[4 * n];
-            pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+            pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
             r = r->next;
         }
     }
index 2606dbfcfa86abb39670bc8b217a4bb57b014c3c..6a4a0d9dc74020ed0a126a243835b29644ba41ac 100644 (file)
@@ -673,8 +673,8 @@ NineSurface9_UploadSelf( struct NineSurface9 *This,
 
     ptr = NineSurface9_GetSystemMemPointer(This, box.x, box.y);
 
-    pipe->transfer_inline_write(pipe, res, This->level, 0,
-                                &box, ptr, This->stride, 0);
+    pipe->texture_subdata(pipe, res, This->level, 0,
+                          &box, ptr, This->stride, 0);
 
     return D3D_OK;
 }
index 1fdc63881979e70f42f24c7831931d8da8f5a13a..0302b099931734416eb6ac84d452c467daf843c4 100644 (file)
@@ -496,8 +496,8 @@ NineVolume9_UploadSelf( struct NineVolume9 *This,
 
     ptr = NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z);
 
-    pipe->transfer_inline_write(pipe, res, This->level, 0, &box,
-                                ptr, This->stride, This->layer_stride);
+    pipe->texture_subdata(pipe, res, This->level, 0, &box,
+                          ptr, This->stride, This->layer_stride);
 
     return D3D_OK;
 }
index 642238e53f00303a77edcd0e7f2b64c4cc49b208..0d7ab28fb3700357f6395390892861c66ee5fc4c 100644 (file)
@@ -905,16 +905,16 @@ static OMX_ERRORTYPE enc_LoadImage(omx_base_PortType *port, OMX_BUFFERHEADERTYPE
       box.width = def->nFrameWidth;
       box.height = def->nFrameHeight;
       box.depth = 1;
-      priv->s_pipe->transfer_inline_write(priv->s_pipe, views[0]->texture, 0,
-                                          PIPE_TRANSFER_WRITE, &box,
-                                          ptr, def->nStride, 0);
+      priv->s_pipe->texture_subdata(priv->s_pipe, views[0]->texture, 0,
+                                    PIPE_TRANSFER_WRITE, &box,
+                                    ptr, def->nStride, 0);
       ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height);
       box.width = def->nFrameWidth / 2;
       box.height = def->nFrameHeight / 2;
       box.depth = 1;
-      priv->s_pipe->transfer_inline_write(priv->s_pipe, views[1]->texture, 0,
-                                          PIPE_TRANSFER_WRITE, &box,
-                                          ptr, def->nStride, 0);
+      priv->s_pipe->texture_subdata(priv->s_pipe, views[1]->texture, 0,
+                                    PIPE_TRANSFER_WRITE, &box,
+                                    ptr, def->nStride, 0);
    } else {
       struct pipe_blit_info blit;
       struct vl_video_buffer *dst_buf = (struct vl_video_buffer *)vbuf;
index 1b956e36bc17ddde88165d35bc9b6af8b2d0d68f..36b24695edf57e3eb4256e7968c6d439ce456d8a 100644 (file)
@@ -515,10 +515,10 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image,
       vlVaVideoSurfaceSize(surf, i, &width, &height);
       for (j = 0; j < views[i]->texture->array_size; ++j) {
          struct pipe_box dst_box = {0, 0, j, width, height, 1};
-         drv->pipe->transfer_inline_write(drv->pipe, views[i]->texture, 0,
-            PIPE_TRANSFER_WRITE, &dst_box,
-            data[i] + pitches[i] * j,
-            pitches[i] * views[i]->texture->array_size, 0);
+         drv->pipe->texture_subdata(drv->pipe, views[i]->texture, 0,
+                                    PIPE_TRANSFER_WRITE, &dst_box,
+                                    data[i] + pitches[i] * j,
+                                    pitches[i] * views[i]->texture->array_size, 0);
       }
    }
    pipe_mutex_unlock(drv->mutex);
index 35c8820433d71ecda76dc2ff02f504fc6bb50568..fd67a986c61cb87059d5630e0730f62d19e5ef15 100644 (file)
@@ -201,9 +201,9 @@ vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
    vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
-   pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0,
-                               PIPE_TRANSFER_WRITE, &dst_box, *source_data,
-                               *source_pitches, 0);
+   pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
+                         PIPE_TRANSFER_WRITE, &dst_box, *source_data,
+                         *source_pitches, 0);
 
    pipe_mutex_unlock(vlsurface->device->mutex);
 
index 8a064e849b65d99852344b6f0c340a460002433e..0b4f081be3e79981fdb2c9a5c8e5d6af5d31dd0d 100644 (file)
@@ -257,9 +257,9 @@ vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
    vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
 
    dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
-   pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0,
-                               PIPE_TRANSFER_WRITE, &dst_box, *source_data,
-                               *source_pitches, 0);
+   pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
+                         PIPE_TRANSFER_WRITE, &dst_box, *source_data,
+                         *source_pitches, 0);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
    return VDP_STATUS_OK;
@@ -346,9 +346,9 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    box.height = res->height0;
    box.depth = res->depth0;
 
-   context->transfer_inline_write(context, res, 0, PIPE_TRANSFER_WRITE, &box,
-                                  source_data[0], source_pitch[0],
-                                  source_pitch[0] * res->height0);
+   context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box,
+                            source_data[0], source_pitch[0],
+                            source_pitch[0] * res->height0);
 
    memset(&sv_tmpl, 0, sizeof(sv_tmpl));
    u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -379,8 +379,8 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    box.height = res->height0;
    box.depth = res->depth0;
 
-   context->transfer_inline_write(context, res, 0, PIPE_TRANSFER_WRITE, &box, color_table,
-                                  util_format_get_stride(colortbl_format, res->width0), 0);
+   context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box, color_table,
+                            util_format_get_stride(colortbl_format, res->width0), 0);
 
    memset(&sv_tmpl, 0, sizeof(sv_tmpl));
    u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -485,8 +485,8 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
          sv->texture->width0, sv->texture->height0, 1
       };
 
-      pipe->transfer_inline_write(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box,
-                                  source_data[i], source_pitches[i], 0);
+      pipe->texture_subdata(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box,
+                            source_data[i], source_pitches[i], 0);
    }
 
    if (!csc_matrix) {
index 7998527b2d1067537664264c796e4c39151b8093..6dc479a6726e0a31fc8f9d77ad6a4d149b72ee70 100644 (file)
@@ -359,11 +359,11 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
             width, height, 1
          };
 
-         pipe->transfer_inline_write(pipe, sv->texture, 0,
-                                     PIPE_TRANSFER_WRITE, &dst_box,
-                                     source_data[i] + source_pitches[i] * j,
-                                     source_pitches[i] * sv->texture->array_size,
-                                     0);
+         pipe->texture_subdata(pipe, sv->texture, 0,
+                               PIPE_TRANSFER_WRITE, &dst_box,
+                               source_data[i] + source_pitches[i] * j,
+                               source_pitches[i] * sv->texture->array_size,
+                               0);
       }
    }
    pipe_mutex_unlock(p_surf->device->mutex);
index bd5259afe467436e92b5e467f327a77d2ab29710..b23769259ec980d3c9721e56d2e0bff4e4092e54 100644 (file)
@@ -311,14 +311,14 @@ static void init_tex( void )
 
    u_box_2d(0,0,SIZE,SIZE, &box);
 
-   ctx->transfer_inline_write(ctx,
-                              samptex,
-                              0,
-                              PIPE_TRANSFER_WRITE,
-                              &box,
-                              tex2d,
-                              sizeof tex2d[0],
-                              sizeof tex2d);
+   ctx->texture_subdata(ctx,
+                        samptex,
+                        0,
+                        PIPE_TRANSFER_WRITE,
+                        &box,
+                        tex2d,
+                        sizeof tex2d[0],
+                        sizeof tex2d);
 
    /* Possibly read back & compare against original data:
     */
index 5d72bb9d4a7cb653456d99f12b5a859b17f5f07b..f6033855aa065a9bc1b2d60c767e7d3a21f0965e 100644 (file)
@@ -242,14 +242,14 @@ graw_util_create_tex2d(const struct graw_info *info,
 
    u_box_2d(0, 0, width, height, &box);
 
-   info->ctx->transfer_inline_write(info->ctx,
-                                    tex,
-                                    0,
-                                    PIPE_TRANSFER_WRITE,
-                                    &box,
-                                    data,
-                                    row_stride,
-                                    image_bytes);
+   info->ctx->texture_subdata(info->ctx,
+                              tex,
+                              0,
+                              PIPE_TRANSFER_WRITE,
+                              &box,
+                              data,
+                              row_stride,
+                              image_bytes);
 
    /* Possibly read back & compare against original data:
     */
index c680b62eaaa75de47e0c15911b80a582d25516ab..00fb59161a8a2c60fcf5fb4b3423961b45ebfef2 100644 (file)
@@ -149,7 +149,6 @@ static float constants2[] =
 static void init_fs_constbuf( void )
 {
    struct pipe_resource templat;
-   struct pipe_box box;
 
    templat.target = PIPE_BUFFER;
    templat.format = PIPE_FORMAT_R8_UNORM;
@@ -169,34 +168,18 @@ static void init_fs_constbuf( void )
       exit(4);
 
    {
-      u_box_2d(0,0,sizeof(constants1),1, &box);
-
-      ctx->transfer_inline_write(ctx,
-                                 constbuf1,
-                                 0,
-                                 PIPE_TRANSFER_WRITE,
-                                 &box,
-                                 constants1,
-                                 sizeof constants1,
-                                 sizeof constants1);
-
+      ctx->buffer_subdata(ctx, constbuf1,
+                          PIPE_TRANSFER_WRITE,
+                          0, sizeof(constants1), constants1);
 
       pipe_set_constant_buffer(ctx,
                                PIPE_SHADER_GEOMETRY, 0,
                                constbuf1);
    }
    {
-      u_box_2d(0,0,sizeof(constants2),1, &box);
-
-      ctx->transfer_inline_write(ctx,
-                                 constbuf2,
-                                 0,
-                                 PIPE_TRANSFER_WRITE,
-                                 &box,
-                                 constants2,
-                                 sizeof constants2,
-                                 sizeof constants2);
-
+      ctx->buffer_subdata(ctx, constbuf2,
+                          PIPE_TRANSFER_WRITE,
+                          0, sizeof(constants2), constants2);
 
       pipe_set_constant_buffer(ctx,
                                PIPE_SHADER_GEOMETRY, 1,
@@ -418,14 +401,14 @@ static void init_tex( void )
 
    u_box_2d(0,0,SIZE,SIZE, &box);
 
-   ctx->transfer_inline_write(ctx,
-                              samptex,
-                              0,
-                              PIPE_TRANSFER_WRITE,
-                              &box,
-                              tex2d,
-                              sizeof tex2d[0],
-                              sizeof tex2d);
+   ctx->texture_subdata(ctx,
+                        samptex,
+                        0,
+                        PIPE_TRANSFER_WRITE,
+                        &box,
+                        tex2d,
+                        sizeof tex2d[0],
+         sizeof tex2d);
 
    /* Possibly read back & compare against original data:
     */
index 97f241ff844d7095a97c6dc1a0fa5a60743fd791..d1bee359261e077fd29bba937a66c0560a18d9f6 100644 (file)
@@ -226,14 +226,14 @@ static void init_tex( void )
 
    u_box_2d(0,0,SIZE,SIZE, &box);
 
-   ctx->transfer_inline_write(ctx,
-                              samptex,
-                              0,
-                              PIPE_TRANSFER_WRITE,
-                              &box,
-                              tex2d,
-                              sizeof tex2d[0],
-                              sizeof tex2d);
+   ctx->texture_subdata(ctx,
+                        samptex,
+                        0,
+                        PIPE_TRANSFER_WRITE,
+                        &box,
+                        tex2d,
+                        sizeof tex2d[0],
+                        sizeof tex2d);
 
    /* Possibly read back & compare against original data:
     */
index 3a55131669ba52984ef37a43588ff7ae23847450..48f06f461d873e945e75702bcfcc4f60ce90133e 100644 (file)
@@ -100,15 +100,9 @@ static void init_fs_constbuf( void )
 
    u_box_2d(0,0,sizeof(constants),1, &box);
 
-   ctx->transfer_inline_write(ctx,
-                              constbuf,
-                              0,
-                              PIPE_TRANSFER_WRITE,
-                              &box,
-                              constants,
-                              sizeof constants,
-                              sizeof constants);
-
+   ctx->buffer_subdata(ctx, constbuf,
+                       PIPE_TRANSFER_WRITE,
+                       0, sizeof(constants), constants);
 
    pipe_set_constant_buffer(ctx,
                             PIPE_SHADER_VERTEX, 0,
@@ -305,14 +299,14 @@ static void init_tex( void )
 
    u_box_2d(0,0,SIZE,SIZE, &box);
 
-   ctx->transfer_inline_write(ctx,
-                              samptex,
-                              0,
-                              PIPE_TRANSFER_WRITE,
-                              &box,
-                              tex2d,
-                              sizeof tex2d[0],
-                              sizeof tex2d);
+   ctx->texture_subdata(ctx,
+                        samptex,
+                        0,
+                        PIPE_TRANSFER_WRITE,
+                        &box,
+                        tex2d,
+                        sizeof tex2d[0],
+                        sizeof tex2d);
 
    /* Possibly read back & compare against original data:
     */
index 1a8aea3c198fd8d142bedafe515134a7f75b1c7c..2d4c82148c8dd9ab458e11bfd75873e0eaa54178 100644 (file)
@@ -196,12 +196,9 @@ st_bufferobj_data(struct gl_context *ctx,
           * This should be the same as creating a new buffer, but we avoid
           * a lot of validation in Mesa.
           */
-         struct pipe_box box;
-
-         u_box_1d(0, size, &box);
-         pipe->transfer_inline_write(pipe, st_obj->buffer, 0,
-                                    PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
-                                    &box, data, 0, 0);
+         pipe->buffer_subdata(pipe, st_obj->buffer,
+                              PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
+                              0, size, data);
          return GL_TRUE;
       } else if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER)) {
          pipe->invalidate_resource(pipe, st_obj->buffer);
index a76775f6dedcef2ec59254211d0f25d7a76431f4..d2acc71b81c8ae18101595be6c533b053c21de82 100644 (file)
@@ -1339,7 +1339,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
    if (!dst)
       goto fallback;
 
-   /* Try transfer_inline_write, which should be the fastest memcpy path. */
+   /* Try texture_subdata, which should be the fastest memcpy path. */
    if (pixels &&
        !_mesa_is_bufferobj(unpack->BufferObj) &&
        _mesa_texstore_can_use_memcpy(ctx, texImage->_BaseFormat,
@@ -1365,8 +1365,8 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
       }
 
       u_box_3d(xoffset, yoffset, zoffset + dstz, width, height, depth, &box);
-      pipe->transfer_inline_write(pipe, dst, dst_level, 0,
-                                  &box, data, stride, layer_stride);
+      pipe->texture_subdata(pipe, dst, dst_level, 0,
+                            &box, data, stride, layer_stride);
       return;
    }