gallivm: Use native packs and unpacks for the lerps
authorRoland Scheidegger <sroland@vmware.com>
Tue, 18 Oct 2016 01:37:37 +0000 (03:37 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 18 Oct 2016 23:44:59 +0000 (01:44 +0200)
commit6f2f0daeb49e132f44ca9bf930049470a39c970f
tree10cf69215164c1d3b58130b8d48ccbd594059615
parent7e1e06bc75bd9fc4a5b69c19fc140a6b4775915c
gallivm: Use native packs and unpacks for the lerps

For the texturing packs, things looked pretty terrible. For every
lerp, we were repacking the values, and while those look sort of cheap
with 128bit, with 256bit we end up with 2 of them instead of just 1 but
worse, plus 2 extracts too (the unpack, however, works fine with a
single instruction, albeit only with llvm 3.8 - the vpmovzxbw).

Ideally we'd use more clever pack for llvmpipe backend conversion too
since we actually use the "wrong" shuffle (which is more work) when doing
the fs twiddle just so we end up with the wrong order for being able to
do native pack when converting from 2x8f -> 1x16b. But this requires some
refactoring, since the untwiddle is separate from conversion.

This is only used for avx2 256bit pack/unpack for now.

Improves openarena scores by 8% or so, though overall it's still pretty
disappointing how much faster 256bit vectors are even with avx2 (or
rather, aren't...). And, of course, eliminating the needless
packs/unpacks in the first place would eliminate most of that advantage
(not quite all) from this patch.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_pack.c
src/gallium/auxiliary/gallivm/lp_bld_pack.h