etnaviv: allocate TS memory from KMS when resource bind is SCANOUT

Some display engines are able to resolve fast clear and/or compression
on the fly and need access to the TS buffer to do so. As they might
have restrictions on which memory they can access, allocate the TS
buffer memory from the KMS side when the resource should be SCANOUT
capable.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9780>
This commit is contained in:
Lucas Stach 2022-07-13 20:48:33 +02:00 committed by Marge Bot
parent f1f89b2e98
commit 539cc90929
1 changed files with 22 additions and 4 deletions

View File

@ -119,15 +119,33 @@ etna_screen_resource_alloc_ts(struct pipe_screen *pscreen,
DBG_F(ETNA_DBG_RESOURCE_MSGS, "%p: Allocating tile status of size %zu",
rsc, rt_ts_size);
struct etna_bo *rt_ts;
rt_ts = etna_bo_new(screen->dev, rt_ts_size, DRM_ETNA_GEM_CACHE_WC);
if ((rsc->base.bind & PIPE_BIND_SCANOUT) && screen->ro->kms_fd >= 0) {
struct pipe_resource scanout_templat;
struct winsys_handle handle;
if (unlikely(!rt_ts)) {
scanout_templat.format = PIPE_FORMAT_R8_UNORM;
scanout_templat.width0 = align(rt_ts_size, 4096);
scanout_templat.height0 = 1;
rsc->ts_scanout = renderonly_scanout_for_resource(&scanout_templat,
screen->ro, &handle);
if (!rsc->ts_scanout) {
BUG("Problem allocating kms memory for TS resource");
return false;
}
assert(handle.type == WINSYS_HANDLE_TYPE_FD);
rsc->ts_bo = etna_screen_bo_from_handle(pscreen, &handle);
close(handle.handle);
} else {
rsc->ts_bo = etna_bo_new(screen->dev, ts_bo_size, DRM_ETNA_GEM_CACHE_WC);
}
if (unlikely(!rsc->ts_bo)) {
BUG("Problem allocating tile status for resource");
return false;
}
rsc->ts_bo = rt_ts;
rsc->levels[0].ts_offset = 0;
rsc->levels[0].ts_layer_stride = ts_layer_stride;
rsc->levels[0].ts_size = rt_ts_size;