From d2901de09ed33200c5753aebc094529316e61f66 Mon Sep 17 00:00:00 2001 From: Erico Nunes Date: Sun, 28 Jul 2019 21:25:42 +0200 Subject: [PATCH] lima/ppir: lower texture projection Lower texture projection in ppir using nir_lower_tex and nir_lower_tex. This will insert a mul with the coordinate division before the load varying. Even though the lima pp supports projection in the load varying instruction while loading the coordinates (from a register or a varying), it requires that both the coordinates and projector be components in a single register. nir currently handles them in separate ssa, and attempting to merge them manually may end up in worse code than just doing the coordinate division manually. So for now let's just lower the projection to add support for it in lima. In the future, an optimization pass may be implemented in lima to ensure that both coords and projector come in the same register, then this lowering may be disabled and in this case lima may use the built-in projection and save the mul instruction from lowering. Signed-off-by: Erico Nunes Reviewed-by: Qiang Yu --- src/gallium/drivers/lima/lima_program.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index c99b8cbf14e..0a9e522ba36 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -68,6 +68,10 @@ static const nir_shader_compiler_options fs_nir_options = { .lower_rotate = true, }; +static const struct nir_lower_tex_options tex_options = { + .lower_txp = ~0u, +}; + const void * lima_program_get_compiler_options(enum pipe_shader_type shader) { @@ -138,6 +142,7 @@ lima_program_optimize_fs_nir(struct nir_shader *s) NIR_PASS_V(s, nir_lower_fragcoord_wtrans); 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_tex, &tex_options); do { progress = false; -- 2.30.2