iris: Implement PIPE_FLUSH_DEFERRED support.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 5 Aug 2019 20:18:39 +0000 (13:18 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 1 May 2020 19:00:02 +0000 (19:00 +0000)
commit1800e4b58caaa89acfe45c95d0d22e533b50ee03
treeba5c00720849eb9f298be79aa5c78121dbf17fd5
parentdf09efe8df40f39dc791f39fde07b37a48157eea
iris: Implement PIPE_FLUSH_DEFERRED support.

(Co-authored with Chris Wilson.)

Frequently, games create fences and later check them with a timeout of
0 to see if that work has completed yet.  They do not want the work to
be flushed immediately upon fence creation.

This is what PIPE_FLUSH_DEFERRED does - it inhibits the flush at fence
creation time, but still guarantees that a flush will occur later on
once fence_finish() is called.

Since syncpts can only occur at batch boundaries, when deferring a
flush, we have to wait for the syncpt at the end of the batch being
constructed.  This is later than desired, but safe if blocking.  To
avoid extra delays, we additionally insert a PIPE_CONTROL to write an
availability bit at the exact point of the fence.  We can poll this
on the CPU, allowing us to check whether the fence has gone by, even
if the batch hasn't completed.  It can also let us skip kernel calls.

Improves performance in Bioshock Infinite by 10% on Icelake GT2 on
-ForceCompatLevel=5 settings.  Thanks to Felix Degrood and Mark Janes
for helping notice the extraneous stalls and batches, Marek Olšák for
adding deferred flush support to Gallium to solve this issue, and
Chris Wilson for reworking a lot of the internals of this work.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3802>
src/gallium/drivers/iris/iris_fence.c