mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 14:20:11 +01:00
pan/bi: Lower bool to ints
Currently we lower to int32, but once mediump lands we'll be ready for that too. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4276>
This commit is contained in:
parent
1097c69087
commit
12299dead7
2 changed files with 39 additions and 27 deletions
|
|
@ -328,6 +328,11 @@ emit_load_const(bi_context *ctx, nir_load_const_instr *instr)
|
|||
bi_emit(ctx, move);
|
||||
}
|
||||
|
||||
#define BI_CASE_CMP(op) \
|
||||
case op##8: \
|
||||
case op##16: \
|
||||
case op##32: \
|
||||
|
||||
static enum bi_class
|
||||
bi_class_for_nir_alu(nir_op op)
|
||||
{
|
||||
|
|
@ -339,17 +344,19 @@ bi_class_for_nir_alu(nir_op op)
|
|||
case nir_op_isub:
|
||||
return BI_ISUB;
|
||||
|
||||
case nir_op_flt:
|
||||
case nir_op_fge:
|
||||
case nir_op_feq:
|
||||
case nir_op_fne:
|
||||
case nir_op_ilt:
|
||||
case nir_op_ige:
|
||||
case nir_op_ieq:
|
||||
case nir_op_ine:
|
||||
BI_CASE_CMP(nir_op_flt)
|
||||
BI_CASE_CMP(nir_op_fge)
|
||||
BI_CASE_CMP(nir_op_feq)
|
||||
BI_CASE_CMP(nir_op_fne)
|
||||
BI_CASE_CMP(nir_op_ilt)
|
||||
BI_CASE_CMP(nir_op_ige)
|
||||
BI_CASE_CMP(nir_op_ieq)
|
||||
BI_CASE_CMP(nir_op_ine)
|
||||
return BI_CMP;
|
||||
|
||||
case nir_op_bcsel:
|
||||
case nir_op_b8csel:
|
||||
case nir_op_b16csel:
|
||||
case nir_op_b32csel:
|
||||
return BI_CSEL;
|
||||
|
||||
case nir_op_i2i8:
|
||||
|
|
@ -408,17 +415,20 @@ static enum bi_cond
|
|||
bi_cond_for_nir(nir_op op)
|
||||
{
|
||||
switch (op) {
|
||||
case nir_op_flt:
|
||||
case nir_op_ilt:
|
||||
BI_CASE_CMP(nir_op_flt)
|
||||
BI_CASE_CMP(nir_op_ilt)
|
||||
return BI_COND_LT;
|
||||
case nir_op_fge:
|
||||
case nir_op_ige:
|
||||
|
||||
BI_CASE_CMP(nir_op_fge)
|
||||
BI_CASE_CMP(nir_op_ige)
|
||||
return BI_COND_GE;
|
||||
case nir_op_feq:
|
||||
case nir_op_ieq:
|
||||
|
||||
BI_CASE_CMP(nir_op_feq)
|
||||
BI_CASE_CMP(nir_op_ieq)
|
||||
return BI_COND_EQ;
|
||||
case nir_op_fne:
|
||||
case nir_op_ine:
|
||||
|
||||
BI_CASE_CMP(nir_op_fne)
|
||||
BI_CASE_CMP(nir_op_ine)
|
||||
return BI_COND_NE;
|
||||
default:
|
||||
unreachable("Invalid compare");
|
||||
|
|
@ -523,14 +533,14 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
|
|||
case nir_op_fcos:
|
||||
alu.op.special = BI_SPECIAL_FCOS;
|
||||
break;
|
||||
case nir_op_flt:
|
||||
case nir_op_ilt:
|
||||
case nir_op_fge:
|
||||
case nir_op_ige:
|
||||
case nir_op_feq:
|
||||
case nir_op_ieq:
|
||||
case nir_op_fne:
|
||||
case nir_op_ine:
|
||||
BI_CASE_CMP(nir_op_flt)
|
||||
BI_CASE_CMP(nir_op_ilt)
|
||||
BI_CASE_CMP(nir_op_fge)
|
||||
BI_CASE_CMP(nir_op_ige)
|
||||
BI_CASE_CMP(nir_op_feq)
|
||||
BI_CASE_CMP(nir_op_ieq)
|
||||
BI_CASE_CMP(nir_op_fne)
|
||||
BI_CASE_CMP(nir_op_ine)
|
||||
alu.op.compare = bi_cond_for_nir(instr->op);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -835,6 +845,7 @@ bi_optimize_nir(nir_shader *nir)
|
|||
} while (progress);
|
||||
|
||||
NIR_PASS(progress, nir, nir_opt_algebraic_late);
|
||||
NIR_PASS(progress, nir, nir_lower_bool_to_int32);
|
||||
NIR_PASS(progress, nir, bifrost_nir_lower_algebraic_late);
|
||||
NIR_PASS(progress, nir, nir_lower_alu_to_scalar, NULL, NULL);
|
||||
NIR_PASS(progress, nir, nir_lower_load_const_to_scalar);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ algebraic_late = [
|
|||
(('ineg', a), ('isub', 0, a)),
|
||||
]
|
||||
|
||||
for sz in ('16', '32', '64'):
|
||||
algebraic_late += [(('b2f' + sz, 'a@1'), ('bcsel', a, 1.0, 0.0))]
|
||||
for isz in ('8', '16', '32'):
|
||||
for osz in ('16', '32', '64'):
|
||||
algebraic_late += [(('b2f' + osz, 'a@' + isz), ('b' + isz + 'csel', a, 1.0, 0.0))]
|
||||
|
||||
# Midgard is able to type convert down by only one "step" per instruction; if
|
||||
# NIR wants more than one step, we need to break up into multiple instructions
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue