Rewrite matrix polyfilling logic.
The approach used to polyfill has been changed. Previously, we
would create a helper function that took a `_skMatrix22` object
(really an array of vectors) and returned a proper `mat2x2<f32>`,
and call it each time the code accessed a matrix. This worked, but
code which accessed the matrix repeatedly would end up invoking
the helper function over and over again. Now, we do the conversion
from `_skMatrix22` to `mat2x2<f32>` once, at the entrypoint, and
then store the matrix in a global variable; future accesses just
use the global instead.
This approach doesn't scale well if you have dozens and dozens of
matrices that need a polyfill, but in practice, I think we will
only between zero and two for the vast majority of shaders, and
converting them up-front feels nicer. It helps that the common case
is a 2x2 matrix; 3-wide and 4-wide matrices don't need a polyfill.
I also think conversion-at-entrypoint might be the only reasonable
approach for polyfilling arrays.
This CL also adds support for polyfilling within an arrayed
interface block. Previously, this did not work. (I don't know if
we will use arrayed interface blocks, though.)
Change-Id: Ic552978ff50f9800c58f2a8bfdbc3a8df2068275
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/740637
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
11 files changed