gallium/u_threaded: flush batch when hitting mapping limit
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fri, 10 Apr 2020 12:40:37 +0000 (14:40 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 16 Apr 2020 08:36:04 +0000 (08:36 +0000)
commit15cf7d170b3391ebde58f954cd2b90fff35b1ce5
treed3911100ab3db26e17cb64c341cfbc3422d32c63
parent35b396392880871b8cc06172dafff238e67c44cc
gallium/u_threaded: flush batch when hitting mapping limit

tc_transfer_map maps buffers directly, but the unmap operation is executed
in the driver thread.
When an application does a lot of map/unmap operations, without flushing,
this increase the RAM used (and eventually get the app killed by the oom-killer).

This commit allows tc to keep track of how many bytes were mapped during
the current batch. When this estimation becomes higher than a threshold,
we flush the batch.

See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2735
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4508>
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/auxiliary/util/u_threaded_context.h