From 3719983edf3f2ae796d6a0bad3df66acc17d4076 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 1 Aug 2025 07:52:50 -0400 Subject: [PATCH] brw: replace lower_fs_msaa with nir_inline_sysval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alyssa Rosenzweig Reviewed-by: Marek Olšák Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_compile_fs.cpp | 22 +++++++++- src/intel/compiler/brw_nir.h | 2 - src/intel/compiler/brw_nir_lower_fs_msaa.c | 50 ---------------------- src/intel/compiler/meson.build | 1 - 4 files changed, 21 insertions(+), 54 deletions(-) delete mode 100644 src/intel/compiler/brw_nir_lower_fs_msaa.c diff --git a/src/intel/compiler/brw_compile_fs.cpp b/src/intel/compiler/brw_compile_fs.cpp index 9706fb56fac..fa04f0c5121 100644 --- a/src/intel/compiler/brw_compile_fs.cpp +++ b/src/intel/compiler/brw_compile_fs.cpp @@ -1528,7 +1528,27 @@ brw_compile_fs(const struct brw_compiler *compiler, } NIR_PASS(_, nir, brw_nir_move_interpolation_to_top); - NIR_PASS(_, nir, brw_nir_lower_fs_msaa, key); + + if (!brw_wm_prog_key_is_dynamic(key)) { + uint32_t f = 0; + + if (key->multisample_fbo == INTEL_ALWAYS) + f |= INTEL_MSAA_FLAG_MULTISAMPLE_FBO; + + if (key->alpha_to_coverage == INTEL_ALWAYS) + f |= INTEL_MSAA_FLAG_ALPHA_TO_COVERAGE; + + if (key->provoking_vertex_last == INTEL_ALWAYS) + f |= INTEL_MSAA_FLAG_PROVOKING_VERTEX_LAST; + + if (key->persample_interp == INTEL_ALWAYS) { + f |= INTEL_MSAA_FLAG_PERSAMPLE_DISPATCH | + INTEL_MSAA_FLAG_PERSAMPLE_INTERP; + } + + NIR_PASS(_, nir, nir_inline_sysval, nir_intrinsic_load_fs_msaa_intel, f); + } + brw_postprocess_nir(nir, compiler, debug_enabled, key->base.robust_flags); diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h index 11c8ba7c5c3..ec21c56eaf7 100644 --- a/src/intel/compiler/brw_nir.h +++ b/src/intel/compiler/brw_nir.h @@ -178,8 +178,6 @@ bool brw_nir_lower_cs_intrinsics(nir_shader *nir, bool brw_nir_lower_alpha_to_coverage(nir_shader *shader); bool brw_needs_vertex_attributes_bypass(const nir_shader *shader); void brw_nir_lower_fs_barycentrics(nir_shader *shader); -bool brw_nir_lower_fs_msaa(nir_shader *shader, - const struct brw_wm_prog_key *key); void brw_nir_lower_vs_inputs(nir_shader *nir); void brw_nir_lower_vue_inputs(nir_shader *nir, diff --git a/src/intel/compiler/brw_nir_lower_fs_msaa.c b/src/intel/compiler/brw_nir_lower_fs_msaa.c deleted file mode 100644 index 9d99c4723be..00000000000 --- a/src/intel/compiler/brw_nir_lower_fs_msaa.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2025 Intel Corporation - * SPDX-License-Identifier: MIT - */ - -#include "compiler/nir/nir_builder.h" -#include "brw_nir.h" - -static bool -brw_nir_lower_fs_msaa_intel_instr(nir_builder *b, - nir_intrinsic_instr *intrin, - void *data) -{ - if (intrin->intrinsic != nir_intrinsic_load_fs_msaa_intel) - return false; - - b->cursor = nir_before_instr(&intrin->instr); - - const struct brw_wm_prog_key *key = data; - - uint32_t fs_msaa_flags = - (key->multisample_fbo == INTEL_ALWAYS ? - INTEL_MSAA_FLAG_MULTISAMPLE_FBO : 0) | - (key->persample_interp == INTEL_ALWAYS ? - (INTEL_MSAA_FLAG_PERSAMPLE_DISPATCH | - INTEL_MSAA_FLAG_PERSAMPLE_INTERP) : 0) | - (key->alpha_to_coverage == INTEL_ALWAYS ? - INTEL_MSAA_FLAG_ALPHA_TO_COVERAGE : 0) | - (key->provoking_vertex_last == INTEL_ALWAYS ? - INTEL_MSAA_FLAG_PROVOKING_VERTEX_LAST : 0); - - nir_def_replace(&intrin->def, nir_imm_int(b, fs_msaa_flags)); - - return true; -} - -bool -brw_nir_lower_fs_msaa(nir_shader *shader, - const struct brw_wm_prog_key *key) -{ - if (brw_wm_prog_key_is_dynamic(key)) - return false; - - return nir_shader_intrinsics_pass(shader, - brw_nir_lower_fs_msaa_intel_instr, - nir_metadata_control_flow | - nir_metadata_live_defs | - nir_metadata_divergence, - (void *)key); -} diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build index 2b13ae91ae1..e1fc2af924e 100644 --- a/src/intel/compiler/meson.build +++ b/src/intel/compiler/meson.build @@ -73,7 +73,6 @@ libintel_compiler_brw_files = files( 'brw_nir_lower_cs_intrinsics.c', 'brw_nir_lower_alpha_to_coverage.c', 'brw_nir_lower_fs_barycentrics.c', - 'brw_nir_lower_fs_msaa.c', 'brw_nir_lower_immediate_offsets.c', 'brw_nir_lower_intersection_shader.c', 'brw_nir_lower_ray_queries.c',