ir3: Fix bug with shaders that only exit via discard
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 21 Apr 2020 09:36:40 +0000 (11:36 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 09:49:40 +0000 (09:49 +0000)
commit4daa3917a38a6d18ba7cc66071342b9f7fa92f53
treea86e6828fbe3eba97709701ee5f526449f880ad7
parent8cfa60eab85bfe08098ddd014da861b9e3f6aca3
ir3: Fix bug with shaders that only exit via discard

discard is supposed to be a terminator, killing the thread, so that it's
possible to exit main solely by a discard e.g. inside of an infinite
loop. However, it currently isn't treated as a terminator in NIR due to
workarounds turning it into demote (d3d-style kill) and even if that
were fixed, we probably wouldn't want to treat discard_if as a jump
since otherwise the scheduler wouldn't be able to schedule things around
it. So, add this workaround which inserts jump instructions as
necessary to guarantee that the program always terminates.

This fixes a hang in dEQP-VK.graphicsfuzz.while-inside-switch, which
conditionally does a discard inside an infinite loop.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4658>
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_legalize.c