5f16ed4c58
MSL does not support the unary "-" operator on matrix types. Similarly the SPIR-V OpFNegate/OpSNegate operations only work on scalar and vector type. * An expression such as "-<mat>" is now transformed to "-1.0 * <mat>" when generating MSL. * The same expression now generates a component-wise negation in SPIR-V, matching what glslang outputs for GLSL. * A unary "+" is now treated as NOP for MSL, matching the SPIR-V backend. An expression such as "+<expr>" is now evaluated as "<expr>". * The shared/Negation.sksl has been moved to folding/ as much of its contents exercise constant-folding of comparison expressions. * The shared/UnaryPositiveNegative.sksl test has been extended to exercise scalar and matrix types. NOTE: The SPIR-V backend changes have caused a minor re-ordering of SSA IDs generated when writing out a prefix-expression. The affected gold files have been updated. Bug: skia:12627, skia:12992 Change-Id: Iec5cdafc591aed7e49b3b52bda42a02661380bab Reviewed-on: https://skia-review.googlesource.com/c/skia/+/513976 Auto-Submit: Arman Uguray <armansito@google.com> Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Arman Uguray <armansito@google.com>
73 lines
1.5 KiB
Plaintext
73 lines
1.5 KiB
Plaintext
uniform half4 colorWhite, colorGreen, colorRed;
|
|
uniform float2x2 testMatrix2x2;
|
|
uniform float3x3 testMatrix3x3;
|
|
uniform float4x4 testMatrix4x4;
|
|
|
|
bool test_fscalar() {
|
|
float x = colorWhite.r;
|
|
x = +x;
|
|
x = -x;
|
|
return x == -1;
|
|
}
|
|
|
|
bool test_iscalar() {
|
|
int x = int(colorWhite.r);
|
|
x = +x;
|
|
x = -x;
|
|
return x == -1;
|
|
}
|
|
|
|
bool test_fvec() {
|
|
half2 x = colorWhite.rg;
|
|
x = +x;
|
|
x = -x;
|
|
return x == half2(-1);
|
|
}
|
|
|
|
bool test_ivec() {
|
|
int2 x = int2(colorWhite.r);
|
|
x = +x;
|
|
x = -x;
|
|
return x == int2(-1);
|
|
}
|
|
|
|
bool test_mat2() {
|
|
const float2x2 negated = float2x2(-1, -2,
|
|
-3, -4);
|
|
float2x2 x = testMatrix2x2;
|
|
x = +x;
|
|
x = -x;
|
|
return x == negated;
|
|
}
|
|
|
|
bool test_mat3() {
|
|
const float3x3 negated = float3x3(-1, -2, -3,
|
|
-4, -5, -6,
|
|
-7, -8, -9);
|
|
float3x3 x = testMatrix3x3;
|
|
x = +x;
|
|
x = -x;
|
|
return x == negated;
|
|
}
|
|
|
|
bool test_mat4() {
|
|
const float4x4 negated = float4x4(-1, -2, -3, -4,
|
|
-5, -6, -7, -8,
|
|
-9, -10, -11, -12,
|
|
-13, -14, -15, -16);
|
|
float4x4 x = testMatrix4x4;
|
|
x = +x;
|
|
x = -x;
|
|
return x == negated;
|
|
}
|
|
|
|
half4 main(float2 coords) {
|
|
return test_fscalar()
|
|
&& test_iscalar()
|
|
&& test_fvec()
|
|
&& test_ivec()
|
|
&& test_mat2()
|
|
&& test_mat3()
|
|
&& test_mat4() ? colorGreen : colorRed;
|
|
}
|