aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2019-07-17 00:11:55 (GMT)
committerChia-I Wu <olvaffe@gmail.com>2019-07-20 01:04:37 (GMT)
commit324c20304e82fc1e36cd0d293653bf1533edc854 (patch)
tree17009233ffed221c8a65b586909560a2d6124961
parent2b8ad8807822b0b314798f99e1f656371d1fe2e8 (diff)
downloadexternal_mesa3d-324c20304e82fc1e36cd0d293653bf1533edc854.zip
external_mesa3d-324c20304e82fc1e36cd0d293653bf1533edc854.tar.gz
external_mesa3d-324c20304e82fc1e36cd0d293653bf1533edc854.tar.bz2
virgl: rework virgl_transfer_queue_extend
Do not take a transfer and do the memcpy. Add a _buffer suffix to the function name to make it clear that it is only for buffers. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.c6
-rw-r--r--src/gallium/drivers/virgl/virgl_transfer_queue.c35
-rw-r--r--src/gallium/drivers/virgl/virgl_transfer_queue.h8
3 files changed, 24 insertions, 25 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 436f705..dcc0bce 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -546,7 +546,6 @@ static bool virgl_buffer_transfer_extend(struct pipe_context *ctx,
struct virgl_resource *vbuf = virgl_resource(resource);
struct virgl_transfer dummy_trans = { 0 };
bool flush;
- struct virgl_transfer *queued;
/*
* Attempts to short circuit the entire process of mapping and unmapping
@@ -566,11 +565,10 @@ static bool virgl_buffer_transfer_extend(struct pipe_context *ctx,
box->x, box->x + box->width))
return false;
- queued = virgl_transfer_queue_extend(&vctx->queue, &dummy_trans);
- if (!queued || !queued->hw_res_map)
+ if (!virgl_transfer_queue_extend_buffer(&vctx->queue,
+ vbuf->hw_res, box->x, box->width, data))
return false;
- memcpy(queued->hw_res_map + dummy_trans.offset, data, box->width);
util_range_add(&vbuf->valid_buffer_range, box->x, box->x + box->width);
return true;
diff --git a/src/gallium/drivers/virgl/virgl_transfer_queue.c b/src/gallium/drivers/virgl/virgl_transfer_queue.c
index 3cba98f..34ea518 100644
--- a/src/gallium/drivers/virgl/virgl_transfer_queue.c
+++ b/src/gallium/drivers/virgl/virgl_transfer_queue.c
@@ -355,27 +355,26 @@ bool virgl_transfer_queue_is_queued(struct virgl_transfer_queue *queue,
false);
}
-struct virgl_transfer *
-virgl_transfer_queue_extend(struct virgl_transfer_queue *queue,
- struct virgl_transfer *transfer)
+bool
+virgl_transfer_queue_extend_buffer(struct virgl_transfer_queue *queue,
+ const struct virgl_hw_res *hw_res,
+ unsigned offset, unsigned size,
+ const void *data)
{
- struct virgl_transfer *queued = NULL;
+ struct virgl_transfer *queued;
+ struct pipe_box box;
- /* We don't support extending from copy transfers. */
- assert(!transfer->copy_src_hw_res);
+ u_box_1d(offset, size, &box);
+ queued = virgl_transfer_queue_find_overlap(queue, hw_res, 0, &box, true);
+ if (!queued)
+ return false;
- if (transfer->base.resource->target == PIPE_BUFFER) {
- queued = virgl_transfer_queue_find_overlap(queue,
- transfer->hw_res,
- transfer->base.level,
- &transfer->base.box,
- true);
- }
+ assert(queued->base.resource->target == PIPE_BUFFER);
+ assert(queued->hw_res_map);
- if (queued) {
- u_box_union_2d(&queued->base.box, &queued->base.box, &transfer->base.box);
- queued->offset = queued->base.box.x;
- }
+ memcpy(queued->hw_res_map + offset, data, size);
+ u_box_union_2d(&queued->base.box, &queued->base.box, &box);
+ queued->offset = queued->base.box.x;
- return queued;
+ return true;
}
diff --git a/src/gallium/drivers/virgl/virgl_transfer_queue.h b/src/gallium/drivers/virgl/virgl_transfer_queue.h
index e377e08..ef2c401 100644
--- a/src/gallium/drivers/virgl/virgl_transfer_queue.h
+++ b/src/gallium/drivers/virgl/virgl_transfer_queue.h
@@ -56,9 +56,11 @@ bool virgl_transfer_queue_is_queued(struct virgl_transfer_queue *queue,
/*
* Search the transfer queue for a transfer suitable for extension and
- * extend it to include the new transfer.
+ * extend it to include the specified data.
*/
-struct virgl_transfer * virgl_transfer_queue_extend(
- struct virgl_transfer_queue *queue, struct virgl_transfer *transfer);
+bool virgl_transfer_queue_extend_buffer(struct virgl_transfer_queue *queue,
+ const struct virgl_hw_res *hw_res,
+ unsigned offset, unsigned size,
+ const void *data);
#endif /* VIRGL_TRANSFER_QUEUE_H */