[Mesa-dev] [PATCH v2] gallium: Implement APPLE_object_purgeable (iris, freedeno, vc4)
Eric Anholt
eric at anholt.net
Wed Feb 27 02:19:32 UTC 2019
Chris Wilson <chris at chris-wilson.co.uk> writes:
> A few of the GEM drivers provide matching ioctls to allow control of
> their bo caches. Hook these up to APPLE_object_purgeable to allow
> clients to discard video memory under pressure where they are able to
> fallback to restoring content themselves, e.g. from their own (presumably
> compressed, on disk) caches.
>
> v2: Refactor the repeated resource purging.
>
> Cc: Eric Anholt <eric at anholt.net>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Rob Clark <robdclark at gmail.com>
> ---
> .../drivers/freedreno/freedreno_resource.c | 10 ++
> .../drivers/freedreno/freedreno_screen.c | 1 +
> src/gallium/drivers/iris/iris_resource.c | 10 ++
> src/gallium/drivers/iris/iris_screen.c | 1 +
> src/gallium/drivers/vc4/vc4_bufmgr.c | 15 ++
> src/gallium/drivers/vc4/vc4_bufmgr.h | 3 +
> src/gallium/drivers/vc4/vc4_resource.c | 10 ++
> src/gallium/drivers/vc4/vc4_screen.c | 3 +
> src/gallium/include/pipe/p_defines.h | 1 +
> src/gallium/include/pipe/p_screen.h | 20 +++
> src/mesa/Makefile.sources | 2 +
> src/mesa/meson.build | 2 +
> src/mesa/state_tracker/st_cb_objectpurge.c | 141 ++++++++++++++++++
> src/mesa/state_tracker/st_cb_objectpurge.h | 38 +++++
> src/mesa/state_tracker/st_context.c | 2 +
> src/mesa/state_tracker/st_extensions.c | 1 +
> 16 files changed, 260 insertions(+)
> create mode 100644 src/mesa/state_tracker/st_cb_objectpurge.c
> create mode 100644 src/mesa/state_tracker/st_cb_objectpurge.h
u_screen.c needs an update so that other drivers get the right defaults.
> diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
> index c12187d7872..d844c5d888a 100644
> --- a/src/gallium/drivers/vc4/vc4_resource.c
> +++ b/src/gallium/drivers/vc4/vc4_resource.c
> @@ -269,6 +269,15 @@ vc4_texture_subdata(struct pipe_context *pctx,
> box);
> }
>
> +static boolean
> +vc4_resource_madvise(struct pipe_screen *pscreen,
> + struct pipe_resource *prsc,
> + boolean dontneed)
> +{
> + struct vc4_resource *rsc = vc4_resource(prsc);
> + return vc4_bo_madvise(rsc->bo, dontneed);
> +}
I think you'd need to flush any readers/writers of the resource.
Otherwise, if outstanding prior rendering using the BO got flushed, the
whole job would -EINVAL instead of rendering.
> +static GLenum
> +st_render_object_purgeable(struct gl_context *ctx,
> + struct gl_renderbuffer *obj,
> + GLenum option)
> +{
> + struct st_renderbuffer *stobj = st_renderbuffer(obj);
> + return st_resource_purgeable(ctx, stobj->texture, option);
> +}
If you purge a renderbuffer that's a single level of a texture object
with miplevels, I don't think we can madvise the whole resource.
Also be careful with purging just depth of packed depth/stencil.
Overall, I'm hesitatant to land support for actually doing anything with
APPLE_object_purgeable when there are no functional tests of it. I
don't mean to actually have tests that force purging, but at least
making sure that we don't accidentally break rendering by having marked
things purgeable at all.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190226/cb993901/attachment.sig>
More information about the mesa-dev
mailing list