dxil: Set UAV_FENCE_THREAD_GROUP any time global isn't required
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 8 Sep 2023 23:17:30 +0000 (16:17 -0700)
committerMarge Bot <emma+marge@anholt.net>
Sat, 9 Sep 2023 04:41:24 +0000 (04:41 +0000)
commit5754461f0591e7aff11e6513bb6117056142c952
tree0b42a018fda8a162944ac242cc574c809fac2968
parentfb3e37a0140571ea374311a4325dad5d770df15c
dxil: Set UAV_FENCE_THREAD_GROUP any time global isn't required

With the new nir_opt_barrier_modes() pass, we may encounter control
barriers with no memory modes set, such as:

   @barrier () (execution_scope=WORKGROUP, memory_scope=WORKGROUP, mem_semantics=ACQ|REL, mem_modes=0)

The DXIL validator documentation [1] mentions an
INSTR.BARRIERMODENOMEMORY validation rule:

   "sync must include some form of memory barrier - _u (UAV) and/or
    _g (Thread Group Shared Memory). Only _t (thread group sync) is
    optional."

We were generating a dx.op.barrier instruction with only one flag,
DXIL_BARRIER_MODE_SYNC_THREAD_GROUP.  This seems to run afoul of the
above validator rule.  So, this patch adjusts the code generator to
set DXIL_BARRIER_MODE_UAV_FENCE_THREAD_GROUP too, whenever
UAV_FENCE_GLOBAL isn't required.

[1] https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24842>
src/microsoft/compiler/nir_to_dxil.c