lima/ppir: use a ready list in node_to_instr
authorErico Nunes <nunes.erico@gmail.com>
Sun, 17 May 2020 13:56:42 +0000 (15:56 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 May 2020 21:15:33 +0000 (21:15 +0000)
commitb3023055e075386e96fe2fbf093f0db261c0d9fa
tree4477443381c7151d31d174713fc5d6bbea5482e6
parent9ae8b4af75ea708323352c5c016dc4c72ba9c893
lima/ppir: use a ready list in node_to_instr

After the recent optimizations in ppir lowering that increase options
for combining, node_to_instr now may have multiple options of nodes to
insert and needs to decide which is better.
For example, if an instruction uses both a varying and a texture, there
are two nodes nodes that can be inserted to the load varying slot in the
same instruction (ld_var and ld_coords). It is much more advantageous to
pipeline the load texture coords since that enables the higher precision
path for texture coordinates. However, with the current recursive
expansion, this cannot be influenced.

This simple ready list implementation in node_to_instr allows it to
choose the next node to expand based on a priority score, rather than
relying on the random order coming from the recursive expansion.

Other than preferring nodes with pipeline output (which covers ld_coords
vs ld_var), nodes using later slots in the pipeline are now expanded
first, allowing node_to_instr to make all of the earlier (pipelineable)
nodes available in the ready list so the best one can be chosen when
picking nodes for the earlier slots.

Fixes: 632a921bd0d lima/ppir: optimize tex loads with single successor
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5092>
src/gallium/drivers/lima/ir/pp/node_to_instr.c
src/gallium/drivers/lima/ir/pp/ppir.h