asahi: Impose limits on resource shadowing
authorAsahi Lina <lina@asahilina.net>
Sat, 22 Jul 2023 09:37:40 +0000 (18:37 +0900)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 20:31:27 +0000 (20:31 +0000)
commit721aa39ad9090932f945c38ce1cd95502e81a4e5
tree5af973871f7ea6f9e57011fd60887458f9acaf9d
parent9d668f87d3d10efdfdc758a5e29c961fbee550aa
asahi: Impose limits on resource shadowing

Apps can have pathological use cases where huge resources are shadowed
repeatedly. An app that alternately writes to a resource and then uses
it to draw can create an unbounded amount of shadow BOs.

To fix this, introduce both a maximum resource size for shadowing, and a
maximum cumulative size that resource may be shadowed before we start
flushing readers. The flush path then clears the counter, as does the
happy path where there are no readers left after flushing writers.

Fixes massive memory bloating in Firefox and probably others.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>
src/gallium/drivers/asahi/agx_pipe.c
src/gallium/drivers/asahi/agx_state.h