From 400f0bfba123e829fafa6449e6d45e11b6f20e78 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Thu, 11 Apr 2019 23:54:03 +0800 Subject: [PATCH] lima: lower bool to float when building shaders 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 Reviewed-by: Qiang Yu --- src/gallium/drivers/lima/ir/gp/nir.c | 2 +- src/gallium/drivers/lima/ir/pp/nir.c | 3 +-- src/gallium/drivers/lima/lima_program.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/lima/ir/gp/nir.c b/src/gallium/drivers/lima/ir/gp/nir.c index 69790024ba0..6e0b8995da4 100644 --- a/src/gallium/drivers/lima/ir/gp/nir.c +++ b/src/gallium/drivers/lima/ir/gp/nir.c @@ -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, diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 0a5fe13e312..4f15f7c1564 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -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) diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index 1b6d65a2dba..b524499dde9 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -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; -- 2.30.2