[Mesa-dev] [PATCH 2/3] panfrost: Allocate scanout BOs in panfrost device
Boris Brezillon
boris.brezillon at collabora.com
Thu Jul 4 09:11:51 UTC 2019
On Thu, 4 Jul 2019 10:04:42 +0200
Tomeu Vizoso <tomeu.vizoso at collabora.com> wrote:
> @@ -382,11 +362,14 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
>
> /* Tiling textures is almost always faster, unless we only use it once */
>
> +#define SCANOUT (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_DISPLAY_TARGET)
> +
> + bool is_scanout = (res->bind & SCANOUT);
> bool is_texture = (res->bind & PIPE_BIND_SAMPLER_VIEW);
> bool is_2d = res->depth0 == 1 && res->array_size == 1;
> - bool is_streaming = (res->usage != PIPE_USAGE_STREAM);
> + bool is_streaming = (res->usage == PIPE_USAGE_STREAM);
>
> - bool should_tile = is_streaming && is_texture && is_2d;
> + bool should_tile = !is_streaming && is_texture && is_2d && !is_scanout;
>
> /* Depth/stencil can't be tiled, only linear or AFBC */
> should_tile &= !(res->bind & PIPE_BIND_DEPTH_STENCIL);
> @@ -425,10 +408,6 @@ panfrost_resource_create(struct pipe_screen *screen,
> assert(0);
> }
>
> - if (template->bind &
> - (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED))
> - return panfrost_create_scanout_res(screen, template);
> -
> struct panfrost_resource *so = rzalloc(screen, struct panfrost_resource);
> struct panfrost_screen *pscreen = (struct panfrost_screen *) screen;
>
> @@ -440,6 +419,20 @@ panfrost_resource_create(struct pipe_screen *screen,
> util_range_init(&so->valid_buffer_range);
>
> panfrost_resource_create_bo(pscreen, so);
> +
> + /* Set up the "scanout resource" (the dmabuf export of our buffer to
> + * the KMS handle) if the buffer might ever have
> + * resource_get_handle(WINSYS_HANDLE_TYPE_KMS) called on it.
> + */
> + if (template->bind & PIPE_BIND_SCANOUT) {
That's probably intentional but I thought I'd mention it just to be
sure this is what you intend to do: the scanout obj is now only created
when PIPE_BIND_SCANOUT is set while it was previously created for
PIPE_BIND_SHARED and PIPE_BIND_DISPLAY_TARGET too.
> + so->scanout =
> + renderonly_scanout_for_resource(&so->base, pscreen->ro, NULL);
> + if (!so->scanout) {
> + panfrost_resource_destroy(screen, &so->base);
> + return NULL;
> + }
> + }
> +
> return (struct pipe_resource *)so;
> }
>
> diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> index bf599a1497c9..5b316a2b1f37 100644
> --- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> +++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> @@ -90,7 +90,7 @@ struct pipe_screen *kmsro_drm_screen_create(int fd,
> ro.gpu_fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
>
> if (ro.gpu_fd >= 0) {
> - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource,
> + ro.create_for_resource = renderonly_create_gpu_import_for_resource,
> screen = panfrost_drm_screen_create_renderonly(&ro);
> if (!screen)
> close(ro.gpu_fd);
More information about the mesa-dev
mailing list