summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_staging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_staging.c')
-rw-r--r--src/gallium/auxiliary/util/u_staging.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/util/u_staging.c b/src/gallium/auxiliary/util/u_staging.c
index c5d68f8df8..b6bf241a22 100644
--- a/src/gallium/auxiliary/util/u_staging.c
+++ b/src/gallium/auxiliary/util/u_staging.c
@@ -41,6 +41,7 @@ util_staging_resource_template(struct pipe_resource *pt, unsigned width, unsigne
template->width0 = width;
template->height0 = height;
template->depth0 = depth;
+ template->array_size = 1;
template->last_level = 0;
template->nr_samples = pt->nr_samples;
template->bind = 0;
@@ -51,7 +52,7 @@ util_staging_resource_template(struct pipe_resource *pt, unsigned width, unsigne
struct util_staging_transfer *
util_staging_transfer_init(struct pipe_context *pipe,
struct pipe_resource *pt,
- struct pipe_subresource sr,
+ unsigned level,
unsigned usage,
const struct pipe_box *box,
bool direct, struct util_staging_transfer *tx)
@@ -61,7 +62,7 @@ util_staging_transfer_init(struct pipe_context *pipe,
struct pipe_resource staging_resource_template;
pipe_resource_reference(&tx->base.resource, pt);
- tx->base.sr = sr;
+ tx->base.level = level;
tx->base.usage = usage;
tx->base.box = *box;
@@ -82,12 +83,20 @@ util_staging_transfer_init(struct pipe_context *pipe,
if (usage & PIPE_TRANSFER_READ)
{
- struct pipe_subresource dstsr;
+ /* XXX this looks wrong dst is always the same but looping over src z? */
unsigned zi;
- dstsr.face = 0;
- dstsr.level = 0;
- for(zi = 0; zi < box->depth; ++zi)
- pipe->resource_copy_region(pipe, tx->staging_resource, dstsr, 0, 0, 0, tx->base.resource, sr, box->x, box->y, box->z + zi, box->width, box->height);
+ struct pipe_box sbox;
+ sbox.x = box->x;
+ sbox.y = box->y;
+ sbox.z = box->z;
+ sbox.width = box->width;
+ sbox.height = box->height;
+ sbox.depth = 1;
+ for(zi = 0; zi < box->depth; ++zi) {
+ sbox.z = sbox.z + zi;
+ pipe->resource_copy_region(pipe, tx->staging_resource, 0, 0, 0, 0,
+ tx->base.resource, level, &sbox);
+ }
}
return tx;
@@ -101,12 +110,18 @@ util_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *p
if (tx->staging_resource != tx->base.resource)
{
if(tx->base.usage & PIPE_TRANSFER_WRITE) {
- struct pipe_subresource srcsr;
+ /* XXX this looks wrong src is always the same but looping over dst z? */
unsigned zi;
- srcsr.face = 0;
- srcsr.level = 0;
+ struct pipe_box sbox;
+ sbox.x = 0;
+ sbox.y = 0;
+ sbox.z = 0;
+ sbox.width = tx->base.box.width;
+ sbox.height = tx->base.box.height;
+ sbox.depth = 1;
for(zi = 0; zi < tx->base.box.depth; ++zi)
- pipe->resource_copy_region(pipe, tx->base.resource, tx->base.sr, tx->base.box.x, tx->base.box.y, tx->base.box.z + zi, tx->staging_resource, srcsr, 0, 0, 0, tx->base.box.width, tx->base.box.height);
+ pipe->resource_copy_region(pipe, tx->base.resource, tx->base.level, tx->base.box.x, tx->base.box.y, tx->base.box.z + zi,
+ tx->staging_resource, 0, &sbox);
}
pipe_resource_reference(&tx->staging_resource, NULL);