diff --git a/src/nouveau/compiler/nak.rs b/src/nouveau/compiler/nak.rs index fbb77b03315..fa8456c2865 100644 --- a/src/nouveau/compiler/nak.rs +++ b/src/nouveau/compiler/nak.rs @@ -236,9 +236,8 @@ fn encode_hdr_for_nir( cw0.set_field(10..14, shader_type); if let ShaderStageInfo::Fragment(fs_info) = &shader_info.stage { cw0.set_bit(14, fs_info.writes_color > 0xf); - let info_fs = unsafe { &nir.info.__bindgen_anon_1.fs }; let zs_self_dep = fs_key.map_or(false, |key| key.zs_self_dep); - cw0.set_bit(15, info_fs.uses_discard() || zs_self_dep); + cw0.set_bit(15, fs_info.uses_kill || zs_self_dep); } cw0.set_bit(16, false /* TODO: DoesGlobalStore */); cw0.set_field(17..21, 1_u32 /* SassVersion */); diff --git a/src/nouveau/compiler/nak_from_nir.rs b/src/nouveau/compiler/nak_from_nir.rs index 0ea78e68152..5c8a6fe82f8 100644 --- a/src/nouveau/compiler/nak_from_nir.rs +++ b/src/nouveau/compiler/nak_from_nir.rs @@ -1193,9 +1193,19 @@ impl<'a> ShaderFromNir<'a> { }); } nir_intrinsic_demote | nir_intrinsic_discard => { + if let ShaderStageInfo::Fragment(info) = &mut self.info.stage { + info.uses_kill = true; + } else { + panic!("OpKill is only available in fragment shaders"); + } b.push_op(OpKill {}); } nir_intrinsic_demote_if | nir_intrinsic_discard_if => { + if let ShaderStageInfo::Fragment(info) = &mut self.info.stage { + info.uses_kill = true; + } else { + panic!("OpKill is only available in fragment shaders"); + } let cond = self.get_ssa(&srcs[0].as_def())[0]; b.predicate(cond.into()).push_op(OpKill {}); } diff --git a/src/nouveau/compiler/nak_ir.rs b/src/nouveau/compiler/nak_ir.rs index ade147fa0fe..1b589e80dc3 100644 --- a/src/nouveau/compiler/nak_ir.rs +++ b/src/nouveau/compiler/nak_ir.rs @@ -4458,6 +4458,7 @@ pub struct ComputeShaderInfo { #[derive(Debug, Default)] pub struct FragmentShaderInfo { pub reads_sample_mask: bool, + pub uses_kill: bool, pub writes_color: u32, pub writes_sample_mask: bool, pub writes_depth: bool,