panfrost: Track buffer initialization
We want to know if a given slice of a buffer is initialized at a particular point in the execution of the program. This is accomplished easily enough -- start out uninitialized and upon an operation writing to the buffer, mark it initialized. The motivation is to optimize away expensive operations (like wallpaper blits) when reading from an uninitialized buffer; since it's uninitialized, the results of these operations are undefined, and it's legal to take the fast path ^_^ Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
@@ -71,6 +71,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
||||
|
||||
rsc->bo = screen->driver->import_bo(screen, whandle);
|
||||
rsc->bo->slices[0].stride = whandle->stride;
|
||||
rsc->bo->slices[0].initialized = true;
|
||||
|
||||
if (screen->ro) {
|
||||
rsc->scanout =
|
||||
@@ -509,7 +510,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
|
||||
transfer->map = rzalloc_size(transfer, transfer->base.layer_stride * box->depth);
|
||||
assert(box->depth == 1);
|
||||
|
||||
if (usage & PIPE_TRANSFER_READ) {
|
||||
if ((usage & PIPE_TRANSFER_READ) && bo->slices[level].initialized) {
|
||||
if (bo->layout == PAN_AFBC) {
|
||||
DBG("Unimplemented: reads from AFBC");
|
||||
} else if (bo->layout == PAN_TILED) {
|
||||
@@ -528,6 +529,12 @@ panfrost_transfer_map(struct pipe_context *pctx,
|
||||
transfer->base.stride = bo->slices[level].stride;
|
||||
transfer->base.layer_stride = bo->cubemap_stride;
|
||||
|
||||
/* By mapping direct-write, we're implicitly already
|
||||
* initialized (maybe), so be conservative */
|
||||
|
||||
if ((usage & PIPE_TRANSFER_WRITE) && (usage & PIPE_TRANSFER_MAP_DIRECTLY))
|
||||
bo->slices[level].initialized = true;
|
||||
|
||||
return bo->cpu
|
||||
+ bo->slices[level].offset
|
||||
+ transfer->base.box.z * bo->cubemap_stride
|
||||
@@ -549,11 +556,12 @@ panfrost_transfer_unmap(struct pipe_context *pctx,
|
||||
struct panfrost_bo *bo = prsrc->bo;
|
||||
|
||||
if (transfer->usage & PIPE_TRANSFER_WRITE) {
|
||||
unsigned level = transfer->level;
|
||||
bo->slices[level].initialized = true;
|
||||
|
||||
if (bo->layout == PAN_AFBC) {
|
||||
DBG("Unimplemented: writes to AFBC\n");
|
||||
} else if (bo->layout == PAN_TILED) {
|
||||
unsigned level = transfer->level;
|
||||
assert(transfer->box.depth == 1);
|
||||
|
||||
panfrost_store_tiled_image(
|
||||
|
Reference in New Issue
Block a user