lima: lower bool to float when building shaders
authorIcenowy Zheng <icenowy@aosc.io>
Thu, 11 Apr 2019 15:54:03 +0000 (23:54 +0800)
committerIcenowy Zheng <icenowy@aosc.io>
Fri, 12 Apr 2019 05:40:47 +0000 (13:40 +0800)
Both processors of Mali Utgard are float-only, so bool are not
acceptable data type of them. Fortunately the NIR compiler
infrastructure has a lower pass to lower bool to float.

Call this lower pass to lower bool to float for both GP and PP. This
makes Glamor on Xorg server 1.20.3 at least doesn't hang when starting
gtk3-demo.

The old map of nir op bcsel is changed to fcsel, and the map of b2f32 in
PP is dropped because it's not needed now (it's originally only mapped
to ppir_op_mov).

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
src/gallium/drivers/lima/ir/gp/nir.c
src/gallium/drivers/lima/ir/pp/nir.c
src/gallium/drivers/lima/lima_program.c

index 69790024ba05a7ae37dc103626b4a522669ef60e..6e0b8995da4db0cb58cd1c1daee99cc727aeb0f7 100644 (file)
@@ -111,7 +111,7 @@ static int nir_to_gpir_opcodes[nir_num_opcodes] = {
    [nir_op_frsq] = gpir_op_rsqrt,
    [nir_op_slt] = gpir_op_lt,
    [nir_op_sge] = gpir_op_ge,
-   [nir_op_bcsel] = gpir_op_select,
+   [nir_op_fcsel] = gpir_op_select,
    [nir_op_ffloor] = gpir_op_floor,
    [nir_op_fsign] = gpir_op_sign,
    [nir_op_seq] = gpir_op_eq,
index 0a5fe13e3122311a8d5f2600af29901cdd51415d..4f15f7c156438c1625069705455bf844ee5df56d 100644 (file)
@@ -147,9 +147,8 @@ static int nir_to_ppir_opcodes[nir_num_opcodes] = {
    [nir_op_sne] = ppir_op_ne,
    [nir_op_fne] = ppir_op_ne,
    [nir_op_fnot] = ppir_op_not,
-   [nir_op_bcsel] = ppir_op_select,
+   [nir_op_fcsel] = ppir_op_select,
    [nir_op_inot] = ppir_op_not,
-   [nir_op_b2f32] = ppir_op_mov,
 };
 
 static ppir_node *ppir_emit_alu(ppir_block *block, nir_instr *ni)
index 1b6d65a2dbad4c417ac0c78472c992710bf88423..b524499dde9c36802a29d8a38c159c240882bb63 100644 (file)
@@ -89,6 +89,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
    NIR_PASS_V(s, lima_nir_lower_uniform_to_scalar);
    NIR_PASS_V(s, nir_lower_io_to_scalar,
               nir_var_shader_in|nir_var_shader_out);
+   NIR_PASS_V(s, nir_lower_bool_to_float);
 
    do {
       progress = false;
@@ -124,6 +125,7 @@ lima_program_optimize_fs_nir(struct nir_shader *s)
 
    NIR_PASS_V(s, nir_lower_io, nir_var_all, type_size, 0);
    NIR_PASS_V(s, nir_lower_regs_to_ssa);
+   NIR_PASS_V(s, nir_lower_bool_to_float);
 
    do {
       progress = false;