#include "drm-uapi/drm_fourcc.h"
+#define ETNA_PIPE_MAP_DISCARD_LEVEL (PIPE_MAP_DRV_PRV << 0)
+
/* Compute offset into a 1D/2D/3D buffer of a certain box.
* This box must be aligned to the block width and height of the
* underlying format. */
if (ptrans->usage & PIPE_MAP_WRITE) {
if (etna_resource_level_needs_flush(res_level)) {
- if (ptrans->usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE)
+ if (ptrans->usage & ETNA_PIPE_MAP_DISCARD_LEVEL)
etna_resource_level_mark_flushed(res_level);
else
etna_copy_resource(pctx, &rsc->base, &rsc->base, ptrans->level, ptrans->level);
if (!trans)
return NULL;
+ assert(level <= prsc->last_level);
+
/*
* Upgrade to UNSYNCHRONIZED if target is PIPE_BUFFER and range is uninitialized.
*/
usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE;
}
+ if ((usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) ||
+ ((usage & PIPE_MAP_DISCARD_RANGE) &&
+ util_texrange_covers_whole_level(prsc, level, box->x, box->y, box->z,
+ box->width, box->height, box->depth)))
+ usage |= ETNA_PIPE_MAP_DISCARD_LEVEL;
+
+
ptrans = &trans->base;
pipe_resource_reference(&ptrans->resource, prsc);
ptrans->level = level;
ptrans->usage = usage;
ptrans->box = *box;
- assert(level <= prsc->last_level);
-
/* This one is a little tricky: if we have a separate render resource, which
* is newer than the base resource we want the transfer to target this one,
* to get the most up-to-date content, but only if we don't have a texture
ptrans->box.height = align(ptrans->box.height, ETNA_RS_HEIGHT_MASK + 1);
}
- if (!(usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE))
+ if ((usage & PIPE_MAP_READ) || !(usage & ETNA_PIPE_MAP_DISCARD_LEVEL))
etna_copy_resource_box(pctx, trans->rsc, &rsc->base, level, &ptrans->box);
/* Switch to using the temporary resource instead */