Use generic types to specify square forms of outerProduct.

This reduces our memory footprint slightly (smaller dehydrated data,
fewer IRNodes in the rehydrated GPU module).

This required a small tweak to our built-in types. $squareMat and
$squareHMat are now aligned with our $vec/$genType generics. (The "1x1
matrix" case is explicitly marked as invalid, allowing `float2x2` to
match up with `float2` and `half2x2` to match up with `half2`.)

Change-Id: I219a7be42102afbf60bb6857b53ac2b4f469113d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447187
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-09-09 11:05:26 -04:00
parent feb1e1274c
commit 997c3eda28
3 changed files with 2446 additions and 2560 deletions

View File

@ -158,10 +158,10 @@ BuiltinTypes::BuiltinTypes()
"$hmat",
{fHalf2x2.get(), fHalf2x3.get(), fHalf2x4.get(), fHalf3x2.get(), fHalf3x3.get(),
fHalf3x4.get(), fHalf4x2.get(), fHalf4x3.get(), fHalf4x4.get()}))
, fSquareMat(Type::MakeGenericType("$squareMat", {fFloat2x2.get(), fFloat3x3.get(),
fFloat4x4.get()}))
, fSquareHMat(Type::MakeGenericType("$squareHMat", {fHalf2x2.get(), fHalf3x3.get(),
fHalf4x4.get()}))
, fSquareMat(Type::MakeGenericType("$squareMat", {fInvalid.get(), fFloat2x2.get(),
fFloat3x3.get(), fFloat4x4.get()}))
, fSquareHMat(Type::MakeGenericType("$squareHMat", {fInvalid.get(), fHalf2x2.get(),
fHalf3x3.get(), fHalf4x4.get()}))
, fVec(Type::MakeGenericType("$vec", {fInvalid.get(), fFloat2.get(), fFloat3.get(),
fFloat4.get()}))
, fHVec(Type::MakeGenericType("$hvec", {fInvalid.get(), fHalf2.get(), fHalf3.get(),

File diff suppressed because it is too large Load Diff

View File

@ -144,18 +144,14 @@ $genType refract($genType I, $genType N, float eta);
$genHType refract($genHType I, $genHType N, half eta);
$mat matrixCompMult($mat x, $mat y);
$hmat matrixCompMult($hmat x, $hmat y);
float2x2 outerProduct(float2 c, float2 r);
float3x3 outerProduct(float3 c, float3 r);
float4x4 outerProduct(float4 c, float4 r);
$squareMat outerProduct($vec c, $vec r);
float2x3 outerProduct(float3 c, float2 r);
float3x2 outerProduct(float2 c, float3 r);
float2x4 outerProduct(float4 c, float2 r);
float4x2 outerProduct(float2 c, float4 r);
float3x4 outerProduct(float4 c, float3 r);
float4x3 outerProduct(float3 c, float4 r);
half2x2 outerProduct(half2 c, half2 r);
half3x3 outerProduct(half3 c, half3 r);
half4x4 outerProduct(half4 c, half4 r);
$squareHMat outerProduct($hvec c, $hvec r);
half2x3 outerProduct(half3 c, half2 r);
half3x2 outerProduct(half2 c, half3 r);
half2x4 outerProduct(half4 c, half2 r);