SPIRV: Simplify matrix->matrix constructor
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>
Thu, 5 Jul 2018 20:19:39 +0000 (13:19 -0700)
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>
Thu, 5 Jul 2018 22:55:12 +0000 (15:55 -0700)
commit112e2858cfd23f7d2510c138cde786aa2abdfd5b
tree7a85d035ce8300d7eb26932e49b3981612a78a9e
parentcd57b4ba0f500b1fa304c80c730284c6a2249d1e
SPIRV: Simplify matrix->matrix constructor

When constructing a matrix from another matrix with smaller dimensions,
there's no need to extract the scalars out of columns and rebuild the
resulting matrix from scalars - instead, we can just construct shorter
vectors with OpShuffle and combine them to the final result.

This keeps the common casts such as mat3(mat4) in vector registers,
which may improve performance for some GPUs, and cleans up output of
translation tools like SPIRV-Cross.

Fixes #1412.
SPIRV/SpvBuilder.cpp
Test/baseResults/hlsl.cbuffer-identifier.vert.out
Test/baseResults/hlsl.mul-truncate.frag.out