summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2017-07-12 12:12:33 +0200
committerLucas Stach <l.stach@pengutronix.de>2017-07-12 12:15:38 +0200
commit89dfd5112cf115df2acfe76d51fa92d93d8eb2b6 (patch)
treeda29355e6432af8fc5ecc285c6b2f74a32bf0696
parent1efbb8d916d613b2202a4f522ab104b0b895f020 (diff)
downloadmesa-etna-modifiers.tar.gz
mesa-etna-modifiers.tar.xz
fixup! etnaviv: keep cached shadow for staging resourceetna-modifiers
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_resource.c8
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_transfer.c23
2 files changed, 22 insertions, 9 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 206948c597..916b06a2b1 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -545,6 +545,14 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
goto fail;
}
+ /* XXX: This is a hack and will not work with resources that end up used as
+ * render target, but we lack the proper usage information here.
+ * We optimistically allocate a staging buffer here to speed up texture
+ * uploads.
+ */
+ if (rsc->layout == ETNA_LAYOUT_TILED)
+ rsc->staging_buffer = MALLOC(etna_bo_size(rsc->bo));
+
if (rsc->layout == ETNA_LAYOUT_LINEAR) {
/*
* Both sampler and pixel pipes can't handle linear, create a compatible
diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index c1888059c3..cac2036161 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -84,14 +84,12 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans)
* FIXME: we need to invalidate the tile status. */
etna_copy_resource(pctx, ptrans->resource, trans->rsc, ptrans->level,
trans->rsc->last_level);
- } else if (trans->staging || rsc->staging_buffer) {
- void *staging = trans->staging;
+ } else if (trans->staging) {
/* If the resource has a permanent staging buffer all writes will have
* gone there without any synchronization of the GPU BO at all. To
* flush the write, we need to pull the GPU BO in the CPU domain first.
*/
if (unlikely(rsc->staging_buffer)) {
- staging = rsc->staging_buffer;
if (!(ptrans->usage & PIPE_TRANSFER_UNSYNCHRONIZED))
etna_bo_cpu_prep(rsc->bo, DRM_ETNA_PREP_WRITE);
}
@@ -102,7 +100,7 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans)
if (rsc->layout == ETNA_LAYOUT_TILED) {
etna_texture_tile(
mapped + ptrans->box.z * res_level->layer_stride,
- staging, ptrans->box.x, ptrans->box.y,
+ trans->staging, ptrans->box.x, ptrans->box.y,
res_level->stride, ptrans->box.width, ptrans->box.height,
ptrans->stride, util_format_get_blocksize(rsc->base.format));
} else if (rsc->layout == ETNA_LAYOUT_LINEAR) {
@@ -110,12 +108,15 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans)
res_level->layer_stride, ptrans->box.x,
ptrans->box.y, ptrans->box.z, ptrans->box.width,
ptrans->box.height, ptrans->box.depth,
- staging, ptrans->stride,
+ trans->staging, ptrans->stride,
ptrans->layer_stride, 0, 0, 0 /* src x,y,z */);
} else {
BUG("unsupported tiling %i", rsc->layout);
}
- if (trans->staging)
+ /* For resources without a permanent staging buffer, the transfer has a
+ * temporary staging buffer allocated.
+ */
+ if (!rsc->staging_buffer)
FREE(trans->staging);
}
@@ -185,13 +186,17 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc,
/* If there is a staging buf all resource reads/writes are to be done there. */
if (unlikely(rsc->staging_buffer)) {
+ struct etna_resource_level *res_level = &rsc->levels[level];
/* Currently we support this only for sampler-only resources */
assert(((rsc->layout == ETNA_LAYOUT_LINEAR) ||
(rsc->layout == ETNA_LAYOUT_TILED)) &&
!rsc->texture);
- ptrans->stride = rsc->levels[level].stride;
- ptrans->layer_stride = rsc->levels[level].layer_stride;
- return rsc->staging_buffer;
+ ptrans->stride = res_level->stride;
+ ptrans->layer_stride = res_level->layer_stride;
+ trans->staging = rsc->staging_buffer + res_level->offset +
+ etna_compute_offset(prsc->format, box, res_level->stride,
+ res_level->layer_stride);
+ return trans->staging;
}
if (rsc->texture && !etna_resource_newer(rsc, etna_resource(rsc->texture))) {