From 34cc225070bb18ea140f45af7e6235796491fe3a Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 14 Sep 2023 18:10:12 -0500 Subject: [PATCH] nak: Plumb more FS info through to the C API These are needed for state setup, not the shader header so we have to plumb them all the way through to the driver. Part-of: --- src/nouveau/compiler/nak.h | 8 ++++++++ src/nouveau/compiler/nak.rs | 16 +++++++++++++--- src/nouveau/compiler/nak_from_nir.rs | 6 ++++++ src/nouveau/compiler/nak_ir.rs | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/nouveau/compiler/nak.h b/src/nouveau/compiler/nak.h index dfa41f6abc9..49f3f8dc7bd 100644 --- a/src/nouveau/compiler/nak.h +++ b/src/nouveau/compiler/nak.h @@ -58,6 +58,14 @@ struct nak_shader_info { uint16_t smem_size; } cs; + struct { + bool writes_depth; + bool reads_sample_mask; + bool post_depth_coverage; + bool uses_sample_shading; + bool early_fragment_tests; + } fs; + /* Used to initialize the union for other stages */ uint32_t dummy; }; diff --git a/src/nouveau/compiler/nak.rs b/src/nouveau/compiler/nak.rs index 589fec4d294..fbb77b03315 100644 --- a/src/nouveau/compiler/nak.rs +++ b/src/nouveau/compiler/nak.rs @@ -509,9 +509,19 @@ pub extern "C" fn nak_compile_shader( }, } } - _ => nak_shader_info__bindgen_ty_1 { - dummy: 0, - }, + ShaderStageInfo::Fragment(fs_info) => { + let nir_fs_info = unsafe { &nir.info.__bindgen_anon_1.fs }; + nak_shader_info__bindgen_ty_1 { + fs: nak_shader_info__bindgen_ty_1__bindgen_ty_2 { + writes_depth: fs_info.writes_depth, + reads_sample_mask: fs_info.reads_sample_mask, + post_depth_coverage: nir_fs_info.post_depth_coverage(), + uses_sample_shading: nir_fs_info.uses_sample_shading(), + early_fragment_tests: nir_fs_info + .early_fragment_tests(), + }, + } + } }, hdr: encode_hdr_for_nir(nir, &s.info, fs_key), }; diff --git a/src/nouveau/compiler/nak_from_nir.rs b/src/nouveau/compiler/nak_from_nir.rs index 05e05dcdc68..3df50102582 100644 --- a/src/nouveau/compiler/nak_from_nir.rs +++ b/src/nouveau/compiler/nak_from_nir.rs @@ -1300,6 +1300,12 @@ impl<'a> ShaderFromNir<'a> { self.set_dst(&intrin.def, dst); } nir_intrinsic_load_sample_mask_in => { + if let ShaderStageInfo::Fragment(info) = &mut self.info.stage { + info.reads_sample_mask = true; + } else { + panic!("sample_mask_in is only available in fragment shaders"); + } + let dst = b.alloc_ssa(RegFile::GPR, 1); b.push_op(OpPixLd { dst: dst.into(), diff --git a/src/nouveau/compiler/nak_ir.rs b/src/nouveau/compiler/nak_ir.rs index 63e59b9f822..8833c1dd2e4 100644 --- a/src/nouveau/compiler/nak_ir.rs +++ b/src/nouveau/compiler/nak_ir.rs @@ -4338,6 +4338,7 @@ pub struct ComputeShaderInfo { #[derive(Debug, Default)] pub struct FragmentShaderInfo { + pub reads_sample_mask: bool, pub writes_color: u32, pub writes_sample_mask: bool, pub writes_depth: bool,