pan/va: Handle terminal barriers
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 27 Jun 2022 19:37:49 +0000 (15:37 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Jul 2022 14:48:09 +0000 (14:48 +0000)
commit154929d731f3da96336c0653b553bf164c07cddf
tree38efcd42d1d5c55dfc72838c9b9b1fa52cda1c46
parent4ee6345d2e7bd5c2b98977a9edea94796b6aafae
pan/va: Handle terminal barriers

If a shader ends with a workgroup barrier, it must wait for slot #7 at the end
to finish the barrier. After inserting flow control, we get:

   BARRIER
   NOP.wait
   NOP.end

Currently, the flow control pass assumes that .end implies all other control
flow, and will merge this down to

   BARRIER.end

However, this is incorrect. Slot #7 is no longer waited on. In theory, this
cannot affect the correctness of the shader. In practice, the hardware checks
that all barriers are reached. Terminating without waiting on slot #7 first
raises an INSTR_BARRIER_FAULT. We need to weaken the flow control merging
slightly to avoid this incorrect merge, instead emitting:

   BARRIER.wait
   NOP.end

Of course, all of these cases are inefficient: terminal barriers shouldn't be
emitted in the first place. I wrote out an optimization for this. We can merge
it if we find a workload that it actually helps.

Fixes test_half.vstore_half.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17264>
src/panfrost/bifrost/valhall/test/test-merge-flow.cpp
src/panfrost/bifrost/valhall/va_merge_flow.c