nak/nir: Use nir_lower_terminate_to_demote()

In NAK, halt turns int OpExit so this gives us exactly the same behavior
as before, just with the increased ability of NIR and our controlf-flow
lowering pass to reason about it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28300>
This commit is contained in:
Faith Ekstrand 2024-03-15 19:19:35 -05:00 committed by Marge Bot
parent cad080412d
commit 8b5e785d9e
2 changed files with 6 additions and 14 deletions

View file

@ -2150,23 +2150,15 @@ impl<'a> ShaderFromNir<'a> {
b.push_op(OpFSOut { srcs: srcs });
}
nir_intrinsic_demote
| nir_intrinsic_discard
| nir_intrinsic_terminate => {
nir_intrinsic_demote | nir_intrinsic_discard => {
if let ShaderIoInfo::Fragment(info) = &mut self.info.io {
info.uses_kill = true;
} else {
panic!("OpKill is only available in fragment shaders");
}
b.push_op(OpKill {});
if intrin.intrinsic == nir_intrinsic_terminate {
b.push_op(OpExit {});
}
}
nir_intrinsic_demote_if
| nir_intrinsic_discard_if
| nir_intrinsic_terminate_if => {
nir_intrinsic_demote_if | nir_intrinsic_discard_if => {
if let ShaderIoInfo::Fragment(info) = &mut self.info.io {
info.uses_kill = true;
} else {
@ -2174,10 +2166,6 @@ impl<'a> ShaderFromNir<'a> {
}
let cond = self.get_ssa(srcs[0].as_def())[0];
b.predicate(cond.into()).push_op(OpKill {});
if intrin.intrinsic == nir_intrinsic_terminate_if {
b.predicate(cond.into()).push_op(OpExit {});
}
}
nir_intrinsic_global_atomic => {
let bit_size = intrin.def.bit_size();

View file

@ -5,6 +5,7 @@
#include "nak_private.h"
#include "nir_builder.h"
#include "nir_control_flow.h"
#include "nir_xfb_info.h"
#include "util/u_math.h"
@ -323,6 +324,9 @@ nak_preprocess_nir(nir_shader *nir, const struct nak_compiler *nak)
OPT(nir, nir_lower_system_values);
OPT(nir, nak_nir_lower_subgroup_id);
OPT(nir, nir_lower_compute_system_values, NULL);
if (nir->info.stage == MESA_SHADER_FRAGMENT)
OPT(nir, nir_lower_terminate_to_demote);
}
static uint16_t