pan/compiler: Allow 16-bit alpha for atest_pan

We just need to handle it while translating NIR to BIR, the hardware can
do automatic widening to 32-bits.

Signed-off-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41096>
This commit is contained in:
Lorenzo Rossi 2026-04-21 19:08:11 +02:00 committed by Marge Bot
parent 2a7d817591
commit abde403a7c
2 changed files with 9 additions and 2 deletions

View file

@ -1786,8 +1786,15 @@ bi_emit_intrinsic(bi_builder *b, nir_intrinsic_instr *instr)
}
case nir_intrinsic_atest_pan: {
unsigned alpha_bit_size = instr->src[1].ssa->bit_size;
assert(alpha_bit_size == 16 || alpha_bit_size == 32);
bi_index coverage = bi_src_index(&instr->src[0]);
bi_index alpha = bi_src_index(&instr->src[1]);
if (alpha_bit_size == 16)
alpha = bi_half(alpha, false);
bi_atest_to(b, dst, coverage, alpha, bi_fau(BIR_FAU_ATEST_PARAM, false));
break;
}

View file

@ -137,7 +137,7 @@ pan_nir_lower_fs_outputs(nir_shader *shader, bool skip_atest)
*/
nir_def *alpha;
if (color0 && glsl_type_is_float_16_32(color0->type))
alpha = nir_f2f32(b, nir_channel(b, nir_load_var(b, color0), 3));
alpha = nir_channel(b, nir_load_var(b, color0), 3);
else
alpha = nir_imm_float(b, 1.0f);
@ -147,7 +147,7 @@ pan_nir_lower_fs_outputs(nir_shader *shader, bool skip_atest)
* skipped for pure integer framebuffers, so the issue is moot.
*/
if (!skip_atest)
coverage = nir_atest_pan(b, coverage, nir_f2f32(b, alpha));
coverage = nir_atest_pan(b, coverage, alpha);
/* We discard depth/stencil writes if early fragment tests is forced. */
if ((out.depth || out.stencil) && !shader->info.fs.early_fragment_tests) {