mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
nir/opt_intrinsic: rework sample mask opt with vector alu
Purely theoretical issue, for example gl_SampleMaskIn.xx == 0.xx. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Fixes:d3ce8a7f6b("nir: optimize gl_SampleMaskIn to gl_HelperInvocation for radeonsi when possible") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32327> (cherry picked from commit22557497ec)
This commit is contained in:
parent
58dcff008b
commit
ff59f1f58e
2 changed files with 15 additions and 16 deletions
|
|
@ -2924,7 +2924,7 @@
|
|||
"description": "nir/opt_intrinsic: rework sample mask opt with vector alu",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "d3ce8a7f6b93e893929b81f4d6605a2a968730a1",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -319,24 +319,23 @@ opt_intrinsics_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
if (nir_src_parent_instr(use_src)->type == nir_instr_type_alu) {
|
||||
nir_alu_instr *alu = nir_instr_as_alu(nir_src_parent_instr(use_src));
|
||||
|
||||
if (alu->op == nir_op_ieq ||
|
||||
alu->op == nir_op_ine) {
|
||||
/* Check for 0 in either operand. */
|
||||
nir_const_value *const_val =
|
||||
nir_src_as_const_value(alu->src[0].src);
|
||||
if (!const_val)
|
||||
const_val = nir_src_as_const_value(alu->src[1].src);
|
||||
if (!const_val || const_val->i32 != 0)
|
||||
continue;
|
||||
if ((alu->op != nir_op_ieq && alu->op != nir_op_ine) || alu->def.num_components != 1)
|
||||
continue;
|
||||
|
||||
nir_def *new_expr = nir_load_helper_invocation(b, 1);
|
||||
nir_alu_src *alu_src = list_entry(use_src, nir_alu_src, src);
|
||||
unsigned src_index = alu_src - alu->src;
|
||||
nir_scalar other = nir_scalar_chase_alu_src(nir_get_scalar(&alu->def, 0), !src_index);
|
||||
|
||||
if (alu->op == nir_op_ine)
|
||||
new_expr = nir_inot(b, new_expr);
|
||||
if (!nir_scalar_is_const(other) || nir_scalar_as_uint(other))
|
||||
continue;
|
||||
|
||||
nir_def_replace(&alu->def, new_expr);
|
||||
progress = true;
|
||||
}
|
||||
nir_def *new_expr = nir_load_helper_invocation(b, 1);
|
||||
|
||||
if (alu->op == nir_op_ine)
|
||||
new_expr = nir_inot(b, new_expr);
|
||||
|
||||
nir_def_replace(&alu->def, new_expr);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
return progress;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue