Skip to content

nir: lower load_helper to is_helper if the shader uses demote()

Daniel Schürmann requested to merge daniel-schuermann/mesa:aco_fix_exec into master
nir: lower load_helper to is_helper if the shader uses demote()

load_helper_invocation is an Input Builtin, for which the
value should not change during the execution of a shader.
This new pass inserts an is_helper intrinsic before any
demote() instruction and re-uses its value.

nir: lower is/load_helper to zero if no helper lanes are needed

If there are no helper invocations required during the
execution of the shader, we can assume that there also
are no helper invocations active.

The first patch emits an is_helper intrinsic as soon as it encounters demote() for the first time. The is_helper is placed at the last top_level block before the demote(). Please let me know if this is of a concern: The pass relies partially on the execution order of branches as the case if () { demote() } else { load_helper } is handled differently than if() { load_helper } else { demote() }. I changed it so that every load_helper gets replaced by an is_helper at top_level blocks.

Please note that this is an edge-case that I assume never happens (so performance is probably no requirement here).

Edited by Daniel Schürmann

Merge request reports