intel/compiler: Use an existing URB write to end TCS threads when viable
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 4 Aug 2022 03:54:52 +0000 (20:54 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 28 Sep 2022 01:17:42 +0000 (18:17 -0700)
commitbe21d54aca09e4466781c2cc3d83022ef480c3f6
treeb31f471bdd3f182bd3cfa7c8a6d694afed72933a
parent19c40e07302c1622739d7ec8fb506cd618ab3d4b
intel/compiler: Use an existing URB write to end TCS threads when viable

VS, TCS, TES, and GS threads must end with a URB write message with the
EOT (end of thread) bit set.  For VS and TES, we shadow output variables
with temporaries and perform all stores at the end of the shader, giving
us an existing message to do the EOT.

In tessellation control shaders, we don't defer output stores until the
end of the thread like we do for vertex or evaluation shaders.  We just
process store_output and store_per_vertex_output intrinsics where they
occur, which may be in control flow.  So we can't guarantee that there's
a URB write being at the end of the shader.

Traditionally, we've just emitted a separate URB write to finish TCS
threads, doing a writemasked write to an single patch header DWord.
On Broadwell, we need to set a "TR DS Cache Disable" bit, so this is
a convenient spot to do so.  But on other platforms, there's no such
field, and this write is purely wasteful.

Insetad of emitting a separate write, we can just look for an existing
URB write at the end of the program and tag that with EOT, if possible.
We already had code to do this for geometry shaders, so just lift it
into a helper function and reuse it.

No changes in shader-db.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17944>
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_fs.h