mesa/src/intel/compiler/brw_nir_lower_fs_msaa.c
Lionel Landwerlin c467444670 brw/nir: use a new intrinsic for fs_msaa_flag
Avoid NIR code doing offset computations.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34109>
2025-05-08 06:48:34 +00:00

48 lines
1.4 KiB
C

/*
* 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);
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);
}