Module: Mesa Branch: main Commit: 539cc909292b78ea2c9b1148464edec14ff9d8ed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=539cc909292b78ea2c9b1148464edec14ff9d8ed
Author: Lucas Stach <[email protected]> Date: Wed Jul 13 20:48:33 2022 +0200 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 <[email protected]> Tested-by: Guido Günther <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9780> --- src/gallium/drivers/etnaviv/etnaviv_resource.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c index 22fdf1b7f76..5ae018c882a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -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; + + 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(!rt_ts)) { + 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;
