Add trunc/round/roundEven SKSL ES3 public APIs.
Improved tests caught a longstanding bug in the compile-time
optimization logic for round/roundEven. These would *always* round to an
even number even when it didn't make sense to do so. (e.g. 3.1 would
round to 4.)
RoundEven isn't available in lower shader models of Direct3D;
SPIRV-Cross throws if it's unavailable. We may need a caps bit for this.
Change-Id: I3cc50238a2116b8d4e2c4059730d8b5cfb2bb056
Bug: skia:12022, skia:12352
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441078
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/resources/sksl/intrinsics/Round.sksl b/resources/sksl/intrinsics/Round.sksl
index e3f6463..420a981 100644
--- a/resources/sksl/intrinsics/Round.sksl
+++ b/resources/sksl/intrinsics/Round.sksl
@@ -1,14 +1,17 @@
-uniform half4 input, expected;
+uniform half4 testInputs; // -1.25, 0, 0.75, 2.25
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
- const half4 constVal = half4(-1.5, -0.5, 0.5, 1.5);
- return (round(input.x) == expected.x &&
- round(input.xy) == expected.xy &&
- round(input.xyz) == expected.xyz &&
- round(input.xyzw) == expected.xyzw &&
- round(constVal.x) == expected.x &&
- round(constVal.xy) == expected.xy &&
- round(constVal.xyz) == expected.xyz &&
- round(constVal.xyzw) == expected.xyzw) ? colorGreen : colorRed;
+ const float4 expectedA = half4(-1.0, 0.0, 1.0, 2.0);
+
+ const float4 constVal = half4(-6.75, -0.475, 3.525, 1.25);
+ const float4 expectedB = half4(-7.0, -0.0, 4.0, 1.0);
+ return (round(testInputs.x) == expectedA.x &&
+ round(testInputs.xy) == expectedA.xy &&
+ round(testInputs.xyz) == expectedA.xyz &&
+ round(testInputs.xyzw) == expectedA.xyzw &&
+ round(constVal.x) == expectedB.x &&
+ round(constVal.xy) == expectedB.xy &&
+ round(constVal.xyz) == expectedB.xyz &&
+ round(constVal.xyzw) == expectedB.xyzw) ? colorGreen : colorRed;
}
diff --git a/resources/sksl/intrinsics/RoundEven.sksl b/resources/sksl/intrinsics/RoundEven.sksl
index 17e4a92..5abfbaa 100644
--- a/resources/sksl/intrinsics/RoundEven.sksl
+++ b/resources/sksl/intrinsics/RoundEven.sksl
@@ -1,14 +1,17 @@
-uniform half4 input, expected;
+uniform half4 testInputs; // -1.25, 0, 0.75, 2.25
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
- const half4 constVal = half4(-1.5, -0.5, 0.5, 1.5);
- return (roundEven(input.x) == expected.x &&
- roundEven(input.xy) == expected.xy &&
- roundEven(input.xyz) == expected.xyz &&
- roundEven(input.xyzw) == expected.xyzw &&
- roundEven(constVal.x) == expected.x &&
- roundEven(constVal.xy) == expected.xy &&
- roundEven(constVal.xyz) == expected.xyz &&
- roundEven(constVal.xyzw) == expected.xyzw) ? colorGreen : colorRed;
+ const float4 expectedA = half4(-1.0, 0.0, 1.0, 2.0);
+
+ const float4 constVal = half4(-6.75, -0.475, 3.5, 2.5);
+ const float4 expectedB = half4(-7.0, -0.0, 4.0, 2.0);
+ return (roundEven(testInputs.x) == expectedA.x &&
+ roundEven(testInputs.xy) == expectedA.xy &&
+ roundEven(testInputs.xyz) == expectedA.xyz &&
+ roundEven(testInputs.xyzw) == expectedA.xyzw &&
+ roundEven(constVal.x) == expectedB.x &&
+ roundEven(constVal.xy) == expectedB.xy &&
+ roundEven(constVal.xyz) == expectedB.xyz &&
+ roundEven(constVal.xyzw) == expectedB.xyzw) ? colorGreen : colorRed;
}
diff --git a/resources/sksl/intrinsics/Trunc.sksl b/resources/sksl/intrinsics/Trunc.sksl
index 2cdf990..c910faa 100644
--- a/resources/sksl/intrinsics/Trunc.sksl
+++ b/resources/sksl/intrinsics/Trunc.sksl
@@ -1,14 +1,17 @@
-uniform half4 input, expected;
+uniform half4 testInputs; // -1.25, 0, 0.75, 2.25
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
- const half4 constVal = half4(-1.5, -0.5, 0.5, 1.5);
- return (trunc(input.x) == expected.x &&
- trunc(input.xy) == expected.xy &&
- trunc(input.xyz) == expected.xyz &&
- trunc(input.xyzw) == expected.xyzw &&
- trunc(constVal.x) == expected.x &&
- trunc(constVal.xy) == expected.xy &&
- trunc(constVal.xyz) == expected.xyz &&
- trunc(constVal.xyzw) == expected.xyzw) ? colorGreen : colorRed;
+ const float4 expectedA = half4(-1.0, 0.0, 0.0, 2.0);
+
+ const float4 constVal = half4(-6.75, -0.5, 3.5, 1.25);
+ const float4 expectedB = half4(-6.0, -0.0, 3.0, 1.0);
+ return (trunc(testInputs.x) == expectedA.x &&
+ trunc(testInputs.xy) == expectedA.xy &&
+ trunc(testInputs.xyz) == expectedA.xyz &&
+ trunc(testInputs.xyzw) == expectedA.xyzw &&
+ trunc(constVal.x) == expectedB.x &&
+ trunc(constVal.xy) == expectedB.xy &&
+ trunc(constVal.xyz) == expectedB.xyz &&
+ trunc(constVal.xyzw) == expectedB.xyzw) ? colorGreen : colorRed;
}
diff --git a/src/sksl/generated/sksl_public.dehydrated.sksl b/src/sksl/generated/sksl_public.dehydrated.sksl
index 4191389..f913210 100644
--- a/src/sksl/generated/sksl_public.dehydrated.sksl
+++ b/src/sksl/generated/sksl_public.dehydrated.sksl
@@ -1,4 +1,4 @@
-static uint8_t SKSL_INCLUDE_sksl_public[] = {5,3,
+static uint8_t SKSL_INCLUDE_sksl_public[] = {27,3,
7,100,101,103,114,101,101,115,
8,36,103,101,110,84,121,112,101,
7,114,97,100,105,97,110,115,
@@ -54,6 +54,9 @@
9,36,103,101,110,85,84,121,112,101,
14,105,110,116,66,105,116,115,84,111,70,108,111,97,116,
15,117,105,110,116,66,105,116,115,84,111,70,108,111,97,116,
+5,116,114,117,110,99,
+5,114,111,117,110,100,
+9,114,111,117,110,100,69,118,101,110,
6,108,101,110,103,116,104,
2,112,48,
2,112,49,
@@ -110,7 +113,7 @@
1,112,
4,100,70,100,120,
4,100,70,100,121,
-48,223,1,
+48,238,1,
52,1,0,
17,2,0,
49,2,0,10,0,3,
@@ -965,742 +968,793 @@
17,55,0,
46,2,0,3,
29,22,1,
-17,104,1,1,21,1,
-46,145,0,
+37,
+16,0,16,0,0,104,1,1,21,1,
+46,2,0,
52,23,1,
17,55,0,
46,5,0,3,
51,24,1,2,
46,22,1,
29,25,1,
-17,104,1,1,23,1,
-46,153,0,
+37,
+16,0,16,0,0,104,1,1,23,1,
+46,5,0,
46,25,1,
52,26,1,
-17,111,1,
+17,55,0,
46,2,0,3,
-52,27,1,
-17,114,1,
+29,27,1,
+37,
+16,0,16,0,0,110,1,1,26,1,
+46,2,0,
+52,28,1,
+17,55,0,
+46,5,0,3,
+51,29,1,2,
+46,27,1,
+29,30,1,
+37,
+16,0,16,0,0,110,1,1,28,1,
+46,5,0,
+46,30,1,
+52,31,1,
+17,55,0,
46,2,0,3,
-29,28,1,
-17,117,1,2,26,1,27,1,
-46,145,0,
-52,29,1,
-17,111,1,
-46,5,0,3,
-52,30,1,
-17,114,1,
-46,5,0,3,
-51,31,1,2,
-46,28,1,
29,32,1,
-17,117,1,2,29,1,30,1,
-46,153,0,
-46,32,1,
+37,
+16,0,16,0,0,116,1,1,31,1,
+46,2,0,
52,33,1,
17,55,0,
-46,2,0,3,
-52,34,1,
-17,67,0,
-46,2,0,3,
+46,5,0,3,
+51,34,1,2,
+46,32,1,
29,35,1,
-17,126,1,2,33,1,34,1,
-46,145,0,
+37,
+16,0,16,0,0,116,1,1,33,1,
+46,5,0,
+46,35,1,
52,36,1,
17,55,0,
+46,2,0,3,
+29,37,1,
+17,126,1,1,36,1,
+46,145,0,
+52,38,1,
+17,55,0,
46,5,0,3,
-52,37,1,
-17,67,0,
-46,5,0,3,
-51,38,1,2,
-46,35,1,
-29,39,1,
-17,126,1,2,36,1,37,1,
+51,39,1,2,
+46,37,1,
+29,40,1,
+17,126,1,1,38,1,
46,153,0,
-46,39,1,
-52,40,1,
-17,55,0,
-49,41,1,130,1,3,
+46,40,1,
+52,41,1,
+17,133,1,
+46,2,0,3,
52,42,1,
-17,67,0,
-46,41,1,3,
+17,136,1,
+46,2,0,3,
29,43,1,
-17,137,1,2,40,1,42,1,
-46,41,1,
+17,139,1,2,41,1,42,1,
+46,145,0,
52,44,1,
-17,55,0,
-49,45,1,143,1,3,
-52,46,1,
-17,67,0,
-46,45,1,3,
-51,47,1,2,
+17,133,1,
+46,5,0,3,
+52,45,1,
+17,136,1,
+46,5,0,3,
+51,46,1,2,
46,43,1,
-29,48,1,
-17,137,1,2,44,1,46,1,
-46,45,1,
-46,48,1,
-52,49,1,
+29,47,1,
+17,139,1,2,44,1,45,1,
+46,153,0,
+46,47,1,
+52,48,1,
17,55,0,
46,2,0,3,
+52,49,1,
+17,67,0,
+46,2,0,3,
29,50,1,
-17,149,1,1,49,1,
-46,2,0,
+17,148,1,2,48,1,49,1,
+46,145,0,
52,51,1,
17,55,0,
46,5,0,3,
-51,52,1,2,
+52,52,1,
+17,67,0,
+46,5,0,3,
+51,53,1,2,
46,50,1,
-29,53,1,
-17,149,1,1,51,1,
-46,5,0,
-46,53,1,
-52,54,1,
-17,159,1,
-46,2,0,3,
+29,54,1,
+17,148,1,2,51,1,52,1,
+46,153,0,
+46,54,1,
52,55,1,
-17,161,1,
-46,2,0,3,
-52,56,1,
-17,163,1,
-46,2,0,3,
-29,57,1,
-17,168,1,3,54,1,55,1,56,1,
-46,2,0,
-52,58,1,
-17,159,1,
-46,5,0,3,
+17,55,0,
+49,56,1,152,1,3,
+52,57,1,
+17,67,0,
+46,56,1,3,
+29,58,1,
+17,159,1,2,55,1,57,1,
+46,56,1,
52,59,1,
-17,161,1,
-46,5,0,3,
-52,60,1,
-17,163,1,
-46,5,0,3,
-51,61,1,2,
-46,57,1,
-29,62,1,
-17,168,1,3,58,1,59,1,60,1,
-46,5,0,
-46,62,1,
-52,63,1,
-17,161,1,
-46,2,0,3,
+17,55,0,
+49,60,1,165,1,3,
+52,61,1,
+17,67,0,
+46,60,1,3,
+51,62,1,2,
+46,58,1,
+29,63,1,
+17,159,1,2,59,1,61,1,
+46,60,1,
+46,63,1,
52,64,1,
-17,159,1,
+17,55,0,
46,2,0,3,
29,65,1,
-17,180,1,2,63,1,64,1,
+17,171,1,1,64,1,
46,2,0,
52,66,1,
-17,161,1,
+17,55,0,
46,5,0,3,
-52,67,1,
-17,159,1,
-46,5,0,3,
-51,68,1,2,
+51,67,1,2,
46,65,1,
-29,69,1,
-17,180,1,2,66,1,67,1,
+29,68,1,
+17,171,1,1,66,1,
46,5,0,
-46,69,1,
+46,68,1,
+52,69,1,
+17,181,1,
+46,2,0,3,
52,70,1,
-17,161,1,
+17,183,1,
46,2,0,3,
52,71,1,
-17,159,1,
+17,185,1,
46,2,0,3,
-52,72,1,
-17,188,1,
-46,145,0,3,
-29,73,1,
-17,192,1,3,70,1,71,1,72,1,
+29,72,1,
+17,190,1,3,69,1,70,1,71,1,
46,2,0,
+52,73,1,
+17,181,1,
+46,5,0,3,
52,74,1,
-17,161,1,
+17,183,1,
46,5,0,3,
52,75,1,
-17,159,1,
+17,185,1,
46,5,0,3,
-52,76,1,
-17,188,1,
-46,153,0,3,
-51,77,1,2,
-46,73,1,
-29,78,1,
-17,192,1,3,74,1,75,1,76,1,
+51,76,1,2,
+46,72,1,
+29,77,1,
+17,190,1,3,73,1,74,1,75,1,
46,5,0,
-46,78,1,
+46,77,1,
+52,78,1,
+17,183,1,
+46,2,0,3,
52,79,1,
-17,55,0,
-49,80,1,200,1,3,
+17,181,1,
+46,2,0,3,
+29,80,1,
+17,202,1,2,78,1,79,1,
+46,2,0,
52,81,1,
-17,67,0,
-46,80,1,3,
-29,82,1,
-17,211,1,2,79,1,81,1,
+17,183,1,
+46,5,0,3,
+52,82,1,
+17,181,1,
+46,5,0,3,
+51,83,1,2,
46,80,1,
-52,83,1,
-17,55,0,
-49,84,1,226,1,3,
+29,84,1,
+17,202,1,2,81,1,82,1,
+46,5,0,
+46,84,1,
52,85,1,
-17,67,0,
-46,84,1,3,
-51,86,1,2,
-46,82,1,
-29,87,1,
-17,211,1,2,83,1,85,1,
-46,84,1,
-46,87,1,
-52,88,1,
-17,238,1,
-46,80,1,3,
-29,89,1,
-37,
-16,0,16,0,0,240,1,1,88,1,
-46,145,0,
+17,183,1,
+46,2,0,3,
+52,86,1,
+17,181,1,
+46,2,0,3,
+52,87,1,
+17,210,1,
+46,145,0,3,
+29,88,1,
+17,214,1,3,85,1,86,1,87,1,
+46,2,0,
+52,89,1,
+17,183,1,
+46,5,0,3,
52,90,1,
-17,238,1,
-46,84,1,3,
-51,91,1,2,
-46,89,1,
-29,92,1,
-37,
-16,0,16,0,0,240,1,1,90,1,
-46,153,0,
-46,92,1,
-52,93,1,
-17,238,1,
-46,80,1,3,
-29,94,1,
-37,
-16,0,16,0,0,252,1,1,93,1,
-46,80,1,
-52,95,1,
-17,238,1,
-46,84,1,3,
-51,96,1,2,
-46,94,1,
+17,181,1,
+46,5,0,3,
+52,91,1,
+17,210,1,
+46,153,0,3,
+51,92,1,2,
+46,88,1,
+29,93,1,
+17,214,1,3,89,1,90,1,91,1,
+46,5,0,
+46,93,1,
+52,94,1,
+17,55,0,
+49,95,1,222,1,3,
+52,96,1,
+17,67,0,
+46,95,1,3,
29,97,1,
-37,
-16,0,16,0,0,252,1,1,95,1,
-46,84,1,
-46,97,1,
+17,233,1,2,94,1,96,1,
+46,95,1,
52,98,1,
-17,238,1,
-49,99,1,6,2,3,
-51,100,1,3,
-46,94,1,
+17,55,0,
+49,99,1,248,1,3,
+52,100,1,
+17,67,0,
+46,99,1,3,
+51,101,1,2,
46,97,1,
-29,101,1,
-37,
-16,0,16,0,0,252,1,1,98,1,
-49,102,1,15,2,
-46,101,1,
+29,102,1,
+17,233,1,2,98,1,100,1,
+46,99,1,
+46,102,1,
52,103,1,
-17,238,1,
-49,104,1,24,2,3,
-51,105,1,4,
-46,94,1,
-46,97,1,
-46,101,1,
-29,106,1,
+17,4,2,
+46,95,1,3,
+29,104,1,
37,
-16,0,16,0,0,252,1,1,103,1,
-49,107,1,32,2,
-46,106,1,
+16,0,16,0,0,6,2,1,103,1,
+46,145,0,
+52,105,1,
+17,4,2,
+46,99,1,3,
+51,106,1,2,
+46,104,1,
+29,107,1,
+37,
+16,0,16,0,0,6,2,1,105,1,
+46,153,0,
+46,107,1,
52,108,1,
-17,238,1,
-49,109,1,40,2,3,
-51,110,1,5,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-29,111,1,
+17,4,2,
+46,95,1,3,
+29,109,1,
37,
-16,0,16,0,0,252,1,1,108,1,
-49,112,1,49,2,
-46,111,1,
+16,0,16,0,0,18,2,1,108,1,
+46,95,1,
+52,110,1,
+17,4,2,
+46,99,1,3,
+51,111,1,2,
+46,109,1,
+29,112,1,
+37,
+16,0,16,0,0,18,2,1,110,1,
+46,99,1,
+46,112,1,
52,113,1,
-17,238,1,
-49,114,1,58,2,3,
-51,115,1,6,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
+17,4,2,
+49,114,1,28,2,3,
+51,115,1,3,
+46,109,1,
+46,112,1,
29,116,1,
37,
-16,0,16,0,0,252,1,1,113,1,
-49,117,1,66,2,
+16,0,16,0,0,18,2,1,113,1,
+49,117,1,37,2,
46,116,1,
52,118,1,
-17,238,1,
-46,102,1,3,
-51,119,1,7,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
-46,116,1,
-29,120,1,
-37,
-16,0,16,0,0,252,1,1,118,1,
-46,99,1,
-46,120,1,
-52,121,1,
-17,238,1,
-46,107,1,3,
-51,122,1,8,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
-46,116,1,
-46,120,1,
-29,123,1,
-37,
-16,0,16,0,0,252,1,1,121,1,
-46,104,1,
-46,123,1,
-52,124,1,
-17,238,1,
-49,125,1,74,2,3,
-51,126,1,9,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
-46,116,1,
-46,120,1,
-46,123,1,
-29,127,1,
-37,
-16,0,16,0,0,252,1,1,124,1,
-49,128,1,83,2,
-46,127,1,
-52,129,1,
-17,238,1,
-49,130,1,92,2,3,
-51,131,1,10,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
-46,116,1,
-46,120,1,
-46,123,1,
-46,127,1,
-29,132,1,
-37,
-16,0,16,0,0,252,1,1,129,1,
-49,133,1,100,2,
-46,132,1,
-52,134,1,
-17,238,1,
-46,112,1,3,
-51,135,1,11,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
-46,116,1,
-46,120,1,
-46,123,1,
-46,127,1,
-46,132,1,
-29,136,1,
-37,
-16,0,16,0,0,252,1,1,134,1,
+17,4,2,
+49,119,1,46,2,3,
+51,120,1,4,
46,109,1,
-46,136,1,
-52,137,1,
-17,238,1,
-46,117,1,3,
-51,138,1,12,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
+46,112,1,
46,116,1,
-46,120,1,
-46,123,1,
-46,127,1,
-46,132,1,
-46,136,1,
-29,139,1,
+29,121,1,
37,
-16,0,16,0,0,252,1,1,137,1,
-46,114,1,
-46,139,1,
-52,140,1,
-17,238,1,
-46,128,1,3,
-51,141,1,13,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
+16,0,16,0,0,18,2,1,118,1,
+49,122,1,54,2,
+46,121,1,
+52,123,1,
+17,4,2,
+49,124,1,62,2,3,
+51,125,1,5,
+46,109,1,
+46,112,1,
46,116,1,
-46,120,1,
-46,123,1,
-46,127,1,
-46,132,1,
-46,136,1,
-46,139,1,
+46,121,1,
+29,126,1,
+37,
+16,0,16,0,0,18,2,1,123,1,
+49,127,1,71,2,
+46,126,1,
+52,128,1,
+17,4,2,
+49,129,1,80,2,3,
+51,130,1,6,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+29,131,1,
+37,
+16,0,16,0,0,18,2,1,128,1,
+49,132,1,88,2,
+46,131,1,
+52,133,1,
+17,4,2,
+46,117,1,3,
+51,134,1,7,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+29,135,1,
+37,
+16,0,16,0,0,18,2,1,133,1,
+46,114,1,
+46,135,1,
+52,136,1,
+17,4,2,
+46,122,1,3,
+51,137,1,8,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+29,138,1,
+37,
+16,0,16,0,0,18,2,1,136,1,
+46,119,1,
+46,138,1,
+52,139,1,
+17,4,2,
+49,140,1,96,2,3,
+51,141,1,9,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
29,142,1,
37,
-16,0,16,0,0,252,1,1,140,1,
-46,125,1,
+16,0,16,0,0,18,2,1,139,1,
+49,143,1,105,2,
46,142,1,
-52,143,1,
-17,238,1,
-46,133,1,3,
-51,144,1,14,
-46,94,1,
-46,97,1,
-46,101,1,
-46,106,1,
-46,111,1,
+52,144,1,
+17,4,2,
+49,145,1,114,2,3,
+51,146,1,10,
+46,109,1,
+46,112,1,
46,116,1,
-46,120,1,
-46,123,1,
-46,127,1,
-46,132,1,
-46,136,1,
-46,139,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
46,142,1,
-29,145,1,
-37,
-16,0,16,0,0,252,1,1,143,1,
-46,130,1,
-46,145,1,
-52,146,1,
-17,238,1,
-46,80,1,3,
29,147,1,
-17,108,2,1,146,1,
-46,80,1,
-52,148,1,
-17,238,1,
-46,84,1,3,
-51,149,1,2,
+37,
+16,0,16,0,0,18,2,1,144,1,
+49,148,1,122,2,
46,147,1,
-29,150,1,
-17,108,2,1,148,1,
-46,84,1,
-46,150,1,
-52,151,1,
-17,55,0,
-49,152,1,116,2,3,
-52,153,1,
-17,67,0,
-46,152,1,3,
+52,149,1,
+17,4,2,
+46,127,1,3,
+51,150,1,11,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
+46,142,1,
+46,147,1,
+29,151,1,
+37,
+16,0,16,0,0,18,2,1,149,1,
+46,124,1,
+46,151,1,
+52,152,1,
+17,4,2,
+46,132,1,3,
+51,153,1,12,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
+46,142,1,
+46,147,1,
+46,151,1,
29,154,1,
-17,121,2,2,151,1,153,1,
-49,155,1,130,2,
-52,156,1,
-17,55,0,
-49,157,1,136,2,3,
-52,158,1,
-17,67,0,
-46,157,1,3,
-51,159,1,2,
+37,
+16,0,16,0,0,18,2,1,152,1,
+46,129,1,
46,154,1,
+52,155,1,
+17,4,2,
+46,143,1,3,
+51,156,1,13,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
+46,142,1,
+46,147,1,
+46,151,1,
+46,154,1,
+29,157,1,
+37,
+16,0,16,0,0,18,2,1,155,1,
+46,140,1,
+46,157,1,
+52,158,1,
+17,4,2,
+46,148,1,3,
+51,159,1,14,
+46,109,1,
+46,112,1,
+46,116,1,
+46,121,1,
+46,126,1,
+46,131,1,
+46,135,1,
+46,138,1,
+46,142,1,
+46,147,1,
+46,151,1,
+46,154,1,
+46,157,1,
29,160,1,
-17,121,2,2,156,1,158,1,
-46,155,1,
+37,
+16,0,16,0,0,18,2,1,158,1,
+46,145,1,
46,160,1,
52,161,1,
-17,55,0,
-49,162,1,142,2,3,
+17,4,2,
+46,95,1,3,
+29,162,1,
+17,130,2,1,161,1,
+46,95,1,
52,163,1,
-17,67,0,
-46,162,1,3,
-51,164,1,3,
-46,154,1,
-46,160,1,
+17,4,2,
+46,99,1,3,
+51,164,1,2,
+46,162,1,
29,165,1,
-17,121,2,2,161,1,163,1,
-46,155,1,
+17,130,2,1,163,1,
+46,99,1,
46,165,1,
52,166,1,
17,55,0,
-46,152,1,3,
-52,167,1,
+49,167,1,138,2,3,
+52,168,1,
17,67,0,
-46,152,1,3,
-29,168,1,
-17,148,2,2,166,1,167,1,
-46,155,1,
-52,169,1,
+46,167,1,3,
+29,169,1,
+17,143,2,2,166,1,168,1,
+49,170,1,152,2,
+52,171,1,
17,55,0,
-46,157,1,3,
-52,170,1,
-17,67,0,
-46,157,1,3,
-51,171,1,2,
-46,168,1,
-29,172,1,
-17,148,2,2,169,1,170,1,
-46,155,1,
-46,172,1,
+49,172,1,158,2,3,
52,173,1,
-17,55,0,
-46,162,1,3,
-52,174,1,
17,67,0,
-46,162,1,3,
-51,175,1,3,
-46,168,1,
-46,172,1,
-29,176,1,
-17,148,2,2,173,1,174,1,
-46,155,1,
-46,176,1,
-52,177,1,
+46,172,1,3,
+51,174,1,2,
+46,169,1,
+29,175,1,
+17,143,2,2,171,1,173,1,
+46,170,1,
+46,175,1,
+52,176,1,
17,55,0,
-46,152,1,3,
+49,177,1,164,2,3,
52,178,1,
17,67,0,
-46,152,1,3,
-29,179,1,
-17,162,2,2,177,1,178,1,
-46,155,1,
-52,180,1,
-17,55,0,
-46,157,1,3,
+46,177,1,3,
+51,179,1,3,
+46,169,1,
+46,175,1,
+29,180,1,
+17,143,2,2,176,1,178,1,
+46,170,1,
+46,180,1,
52,181,1,
+17,55,0,
+46,167,1,3,
+52,182,1,
17,67,0,
-46,157,1,3,
-51,182,1,2,
-46,179,1,
+46,167,1,3,
29,183,1,
-17,162,2,2,180,1,181,1,
-46,155,1,
-46,183,1,
+17,170,2,2,181,1,182,1,
+46,170,1,
52,184,1,
17,55,0,
-46,162,1,3,
+46,172,1,3,
52,185,1,
17,67,0,
-46,162,1,3,
-51,186,1,3,
-46,179,1,
+46,172,1,3,
+51,186,1,2,
46,183,1,
29,187,1,
-17,162,2,2,184,1,185,1,
-46,155,1,
+17,170,2,2,184,1,185,1,
+46,170,1,
46,187,1,
52,188,1,
17,55,0,
-46,152,1,3,
+46,177,1,3,
52,189,1,
17,67,0,
-46,152,1,3,
-29,190,1,
-17,174,2,2,188,1,189,1,
-46,155,1,
-52,191,1,
-17,55,0,
-46,157,1,3,
+46,177,1,3,
+51,190,1,3,
+46,183,1,
+46,187,1,
+29,191,1,
+17,170,2,2,188,1,189,1,
+46,170,1,
+46,191,1,
52,192,1,
+17,55,0,
+46,167,1,3,
+52,193,1,
17,67,0,
-46,157,1,3,
-51,193,1,2,
-46,190,1,
+46,167,1,3,
29,194,1,
-17,174,2,2,191,1,192,1,
-46,155,1,
-46,194,1,
+17,184,2,2,192,1,193,1,
+46,170,1,
52,195,1,
17,55,0,
-46,162,1,3,
+46,172,1,3,
52,196,1,
17,67,0,
-46,162,1,3,
-51,197,1,3,
-46,190,1,
+46,172,1,3,
+51,197,1,2,
46,194,1,
29,198,1,
-17,174,2,2,195,1,196,1,
-46,155,1,
+17,184,2,2,195,1,196,1,
+46,170,1,
46,198,1,
52,199,1,
17,55,0,
-46,152,1,3,
+46,177,1,3,
52,200,1,
17,67,0,
-46,152,1,3,
-29,201,1,
-17,191,2,2,199,1,200,1,
-46,155,1,
-52,202,1,
-17,55,0,
-46,157,1,3,
+46,177,1,3,
+51,201,1,3,
+46,194,1,
+46,198,1,
+29,202,1,
+17,184,2,2,199,1,200,1,
+46,170,1,
+46,202,1,
52,203,1,
+17,55,0,
+46,167,1,3,
+52,204,1,
17,67,0,
-46,157,1,3,
-51,204,1,2,
-46,201,1,
+46,167,1,3,
29,205,1,
-17,191,2,2,202,1,203,1,
-46,155,1,
-46,205,1,
+17,196,2,2,203,1,204,1,
+46,170,1,
52,206,1,
17,55,0,
-46,162,1,3,
+46,172,1,3,
52,207,1,
17,67,0,
-46,162,1,3,
-51,208,1,3,
-46,201,1,
+46,172,1,3,
+51,208,1,2,
46,205,1,
29,209,1,
-17,191,2,2,206,1,207,1,
-46,155,1,
+17,196,2,2,206,1,207,1,
+46,170,1,
46,209,1,
52,210,1,
17,55,0,
-46,155,1,3,
+46,177,1,3,
52,211,1,
17,67,0,
-46,155,1,3,
-51,212,1,4,
-46,201,1,
+46,177,1,3,
+51,212,1,3,
46,205,1,
46,209,1,
29,213,1,
-17,191,2,2,210,1,211,1,
-46,155,1,
+17,196,2,2,210,1,211,1,
+46,170,1,
46,213,1,
52,214,1,
17,55,0,
-46,152,1,3,
+46,167,1,3,
52,215,1,
17,67,0,
-46,152,1,3,
+46,167,1,3,
29,216,1,
-17,197,2,2,214,1,215,1,
-46,155,1,
+17,213,2,2,214,1,215,1,
+46,170,1,
52,217,1,
17,55,0,
-46,157,1,3,
+46,172,1,3,
52,218,1,
17,67,0,
-46,157,1,3,
+46,172,1,3,
51,219,1,2,
46,216,1,
29,220,1,
-17,197,2,2,217,1,218,1,
-46,155,1,
+17,213,2,2,217,1,218,1,
+46,170,1,
46,220,1,
52,221,1,
17,55,0,
-46,162,1,3,
+46,177,1,3,
52,222,1,
17,67,0,
-46,162,1,3,
+46,177,1,3,
51,223,1,3,
46,216,1,
46,220,1,
29,224,1,
-17,197,2,2,221,1,222,1,
-46,155,1,
+17,213,2,2,221,1,222,1,
+46,170,1,
46,224,1,
52,225,1,
17,55,0,
-46,155,1,3,
+46,170,1,3,
52,226,1,
17,67,0,
-46,155,1,3,
+46,170,1,3,
51,227,1,4,
46,216,1,
46,220,1,
46,224,1,
29,228,1,
-17,197,2,2,225,1,226,1,
-46,155,1,
+17,213,2,2,225,1,226,1,
+46,170,1,
46,228,1,
52,229,1,
17,55,0,
-46,155,1,3,
-29,230,1,
-17,206,2,1,229,1,
-49,231,1,210,2,
+46,167,1,3,
+52,230,1,
+17,67,0,
+46,167,1,3,
+29,231,1,
+17,219,2,2,229,1,230,1,
+46,170,1,
52,232,1,
17,55,0,
-46,155,1,3,
-29,233,1,
-17,215,2,1,232,1,
+46,172,1,3,
+52,233,1,
+17,67,0,
+46,172,1,3,
+51,234,1,2,
46,231,1,
-52,234,1,
-17,55,0,
-46,155,1,3,
29,235,1,
-17,219,2,1,234,1,
-46,155,1,
+17,219,2,2,232,1,233,1,
+46,170,1,
+46,235,1,
52,236,1,
-17,223,2,
-49,237,1,229,2,3,
-29,238,1,
-17,235,2,1,236,1,
-46,237,1,
-52,239,1,
-17,223,2,
-49,240,1,244,2,3,
-51,241,1,2,
-46,238,1,
-29,242,1,
-17,235,2,1,239,1,
-46,240,1,
-46,242,1,
-52,243,1,
-17,251,2,
-46,2,0,3,
-29,244,1,
-37,
-16,0,16,0,0,253,2,1,243,1,
-46,2,0,
-52,245,1,
-17,251,2,
-46,2,0,3,
-29,246,1,
-37,
-16,0,16,0,0,2,3,1,245,1,
-46,2,0,
+17,55,0,
+46,177,1,3,
+52,237,1,
+17,67,0,
+46,177,1,3,
+51,238,1,3,
+46,231,1,
+46,235,1,
+29,239,1,
+17,219,2,2,236,1,237,1,
+46,170,1,
+46,239,1,
+52,240,1,
+17,55,0,
+46,170,1,3,
+52,241,1,
+17,67,0,
+46,170,1,3,
+51,242,1,4,
+46,231,1,
+46,235,1,
+46,239,1,
+29,243,1,
+17,219,2,2,240,1,241,1,
+46,170,1,
+46,243,1,
+52,244,1,
+17,55,0,
+46,170,1,3,
+29,245,1,
+17,228,2,1,244,1,
+49,246,1,232,2,
52,247,1,
-17,251,2,
-46,5,0,3,
-51,248,1,2,
-46,244,1,
-29,249,1,
-37,
-16,0,16,0,0,253,2,1,247,1,
-46,5,0,
-46,249,1,
-52,250,1,
-17,251,2,
-46,5,0,3,
-51,251,1,2,
+17,55,0,
+46,170,1,3,
+29,248,1,
+17,237,2,1,247,1,
46,246,1,
-29,252,1,
+52,249,1,
+17,55,0,
+46,170,1,3,
+29,250,1,
+17,241,2,1,249,1,
+46,170,1,
+52,251,1,
+17,245,2,
+49,252,1,251,2,3,
+29,253,1,
+17,1,3,1,251,1,
+46,252,1,
+52,254,1,
+17,245,2,
+49,255,1,10,3,3,
+51,0,2,2,
+46,253,1,
+29,1,2,
+17,1,3,1,254,1,
+46,255,1,
+46,1,2,
+52,2,2,
+17,17,3,
+46,2,0,3,
+29,3,2,
37,
-16,0,16,0,0,2,3,1,250,1,
+16,0,16,0,0,19,3,1,2,2,
+46,2,0,
+52,4,2,
+17,17,3,
+46,2,0,3,
+29,5,2,
+37,
+16,0,16,0,0,24,3,1,4,2,
+46,2,0,
+52,6,2,
+17,17,3,
+46,5,0,3,
+51,7,2,2,
+46,3,2,
+29,8,2,
+37,
+16,0,16,0,0,19,3,1,6,2,
46,5,0,
-46,252,1,62,0,
+46,8,2,
+52,9,2,
+17,17,3,
+46,5,0,3,
+51,10,2,2,
+46,5,2,
+29,11,2,
+37,
+16,0,16,0,0,24,3,1,9,2,
+46,5,0,
+46,11,2,65,0,
118,0,
33,0,
71,0,
-205,1,
-203,1,
+220,1,
+218,1,
28,0,
66,0,
46,0,
@@ -1709,43 +1763,45 @@
202,0,
18,0,
56,0,
-38,1,
-218,1,
-221,1,
+53,1,
+233,1,
+236,1,
8,0,
-80,1,
-24,1,
-31,1,
-185,1,
+95,1,
+39,1,
+46,1,
+200,1,
88,0,
98,0,
-52,1,
+67,1,
7,1,
9,1,
128,0,
138,0,
-159,1,
-170,1,
+174,1,
+185,1,
11,1,
-126,1,
+141,1,
113,0,
-17,1,
-137,1,
-148,1,
+32,1,
+152,1,
+163,1,
93,0,
103,0,
-75,1,
+90,1,
183,0,
168,0,
226,0,
153,0,
-43,1,
-207,1,
-200,1,
+58,1,
+222,1,
+215,1,
83,0,
3,0,
-59,1,
-68,1,
+74,1,
+83,1,
+22,1,
+27,1,
207,0,
123,0,
13,0,
@@ -1755,43 +1811,44 @@
241,0,
23,0,
61,0,
-121,1,
+136,1,
+17,1,
13,1,
-211,1,
+226,1,
20,
-28,238,1,
+28,253,1,
2,
48,0,0,0,0,1,
40,
8,
-46,237,1,2,
+46,252,1,2,
1,
45,
-55,236,1,0,3,0,1,2,50,
+55,251,1,0,3,0,1,2,50,
27,
46,153,0,185,0,2,
45,
-55,236,1,0,1,3,
+55,251,1,0,1,3,
25,
46,153,0,23,183,209,56,
45,
-55,236,1,0,1,3,1,0,
-28,242,1,
+55,251,1,0,1,3,1,0,
+28,1,2,
2,
48,0,0,0,0,1,
40,
8,
-46,240,1,2,
+46,255,1,2,
1,
45,
-55,239,1,0,3,0,1,2,50,
+55,254,1,0,3,0,1,2,50,
27,
46,145,0,177,0,2,
45,
-55,239,1,0,1,3,
+55,254,1,0,1,3,
25,
46,145,0,23,183,209,56,
45,
-55,239,1,0,1,3,1,0,
+55,254,1,0,1,3,1,0,
21,};
static constexpr size_t SKSL_INCLUDE_sksl_public_LENGTH = sizeof(SKSL_INCLUDE_sksl_public);
diff --git a/src/sksl/ir/SkSLFunctionCall.cpp b/src/sksl/ir/SkSLFunctionCall.cpp
index 20a8770..c04bd48 100644
--- a/src/sksl/ir/SkSLFunctionCall.cpp
+++ b/src/sksl/ir/SkSLFunctionCall.cpp
@@ -430,7 +430,11 @@
double evaluate_cosh(double a, double, double) { return std::cosh(a); }
double evaluate_tanh(double a, double, double) { return std::tanh(a); }
double evaluate_trunc(double a, double, double) { return std::trunc(a); }
-double evaluate_round(double a, double, double) { return std::round(a / 2) * 2; }
+double evaluate_round(double a, double, double) {
+ // The semantics of std::remainder guarantee a rounded-to-even result here, regardless of the
+ // current float-rounding mode.
+ return a - std::remainder(a, 1.0);
+}
double evaluate_floatBitsToInt(double a, double, double) { return pun_value<float, int32_t> (a); }
double evaluate_floatBitsToUint(double a, double, double) { return pun_value<float, uint32_t>(a); }
double evaluate_intBitsToFloat(double a, double, double) { return pun_value<int32_t, float>(a); }
diff --git a/src/sksl/sksl_public.sksl b/src/sksl/sksl_public.sksl
index 7300864..a2712f4 100644
--- a/src/sksl/sksl_public.sksl
+++ b/src/sksl/sksl_public.sksl
@@ -103,6 +103,12 @@
$es3 $genUType floatBitsToUint($genType value);
$es3 $genType intBitsToFloat ($genIType value);
$es3 $genType uintBitsToFloat($genUType value);
+$es3 $genType trunc($genType x);
+$es3 $genHType trunc($genHType x);
+$es3 $genType round($genType x);
+$es3 $genHType round($genHType x);
+$es3 $genType roundEven($genType x);
+$es3 $genHType roundEven($genHType x);
// 8.4 : Geometric Functions
float length($genType x);
diff --git a/tests/SkSLTest.cpp b/tests/SkSLTest.cpp
index 4a97da8..c5e7f7f 100644
--- a/tests/SkSLTest.cpp
+++ b/tests/SkSLTest.cpp
@@ -221,8 +221,11 @@
SKSL_TEST(SkSLIntrinsicMinFloat, "intrinsics/MinFloat.sksl")
// skbug.com/11919: Fails on Adreno + Vulkan
SKSL_TEST_CPU(SkSLIntrinsicMixFloat, "intrinsics/MixFloat.sksl")
+SKSL_TEST_ES3(SkSLIntrinsicRound, "intrinsics/Round.sksl")
+SKSL_TEST_ES3(SkSLIntrinsicRoundEven, "intrinsics/RoundEven.sksl")
SKSL_TEST(SkSLIntrinsicSignFloat, "intrinsics/SignFloat.sksl")
SKSL_TEST(SkSLIntrinsicStep, "intrinsics/Step.sksl")
+SKSL_TEST_ES3(SkSLIntrinsicTrunc, "intrinsics/Trunc.sksl")
SKSL_TEST_ES3(SkSLIntrinsicTranspose, "intrinsics/Transpose.sksl")
SKSL_TEST_ES3(SkSLArrayNarrowingConversions, "runtime/ArrayNarrowingConversions.rts")
diff --git a/tests/sksl/intrinsics/Round.asm.frag b/tests/sksl/intrinsics/Round.asm.frag
index ce549eb..6c5d52e 100644
--- a/tests/sksl/intrinsics/Round.asm.frag
+++ b/tests/sksl/intrinsics/Round.asm.frag
@@ -6,12 +6,12 @@
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %_UniformBuffer "_UniformBuffer"
-OpMemberName %_UniformBuffer 0 "input"
-OpMemberName %_UniformBuffer 1 "expected"
-OpMemberName %_UniformBuffer 2 "colorGreen"
-OpMemberName %_UniformBuffer 3 "colorRed"
+OpMemberName %_UniformBuffer 0 "testInputs"
+OpMemberName %_UniformBuffer 1 "colorGreen"
+OpMemberName %_UniformBuffer 2 "colorRed"
OpName %_entrypoint_v "_entrypoint_v"
OpName %main "main"
+OpName %expectedA "expectedA"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
@@ -22,42 +22,23 @@
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 2 Offset 32
OpMemberDecorate %_UniformBuffer 2 RelaxedPrecision
-OpMemberDecorate %_UniformBuffer 3 Offset 48
-OpMemberDecorate %_UniformBuffer 3 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
-OpDecorate %27 RelaxedPrecision
-OpDecorate %32 RelaxedPrecision
OpDecorate %33 RelaxedPrecision
-OpDecorate %36 RelaxedPrecision
-OpDecorate %37 RelaxedPrecision
-OpDecorate %41 RelaxedPrecision
+OpDecorate %38 RelaxedPrecision
+OpDecorate %39 RelaxedPrecision
OpDecorate %43 RelaxedPrecision
-OpDecorate %44 RelaxedPrecision
+OpDecorate %45 RelaxedPrecision
OpDecorate %46 RelaxedPrecision
-OpDecorate %47 RelaxedPrecision
OpDecorate %54 RelaxedPrecision
OpDecorate %56 RelaxedPrecision
OpDecorate %57 RelaxedPrecision
-OpDecorate %60 RelaxedPrecision
-OpDecorate %61 RelaxedPrecision
+OpDecorate %66 RelaxedPrecision
OpDecorate %68 RelaxedPrecision
-OpDecorate %70 RelaxedPrecision
-OpDecorate %72 RelaxedPrecision
-OpDecorate %81 RelaxedPrecision
-OpDecorate %82 RelaxedPrecision
-OpDecorate %88 RelaxedPrecision
-OpDecorate %90 RelaxedPrecision
-OpDecorate %91 RelaxedPrecision
-OpDecorate %97 RelaxedPrecision
-OpDecorate %99 RelaxedPrecision
-OpDecorate %100 RelaxedPrecision
-OpDecorate %107 RelaxedPrecision
-OpDecorate %109 RelaxedPrecision
-OpDecorate %120 RelaxedPrecision
-OpDecorate %123 RelaxedPrecision
-OpDecorate %124 RelaxedPrecision
+OpDecorate %80 RelaxedPrecision
+OpDecorate %83 RelaxedPrecision
+OpDecorate %84 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -65,7 +46,7 @@
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
-%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float %v4float
+%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
@@ -75,24 +56,23 @@
%19 = OpConstantComposite %v2float %float_0 %float_0
%_ptr_Function_v2float = OpTypePointer Function %v2float
%23 = OpTypeFunction %v4float %_ptr_Function_v2float
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_n1 = OpConstant %float -1
+%float_1 = OpConstant %float 1
+%float_2 = OpConstant %float 2
+%31 = OpConstantComposite %v4float %float_n1 %float_0 %float_1 %float_2
%false = OpConstantFalse %bool
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
-%int_1 = OpConstant %int 1
+%47 = OpConstantComposite %v2float %float_n1 %float_0
%v2bool = OpTypeVector %bool 2
%v3float = OpTypeVector %float 3
+%59 = OpConstantComposite %v3float %float_n1 %float_0 %float_1
%v3bool = OpTypeVector %bool 3
%v4bool = OpTypeVector %bool 4
-%float_n2 = OpConstant %float -2
-%float_n0 = OpConstant %float -0
-%88 = OpConstantComposite %v2float %float_n2 %float_n0
-%97 = OpConstantComposite %v3float %float_n2 %float_n0 %float_0
-%float_2 = OpConstant %float 2
-%107 = OpConstantComposite %v4float %float_n2 %float_n0 %float_0 %float_2
-%_ptr_Function_v4float = OpTypePointer Function %v4float
+%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
-%int_3 = OpConstant %int 3
%_entrypoint_v = OpFunction %void None %15
%16 = OpLabel
%20 = OpVariable %_ptr_Function_v2float Function
@@ -104,30 +84,26 @@
%main = OpFunction %v4float None %23
%24 = OpFunctionParameter %_ptr_Function_v2float
%25 = OpLabel
-%113 = OpVariable %_ptr_Function_v4float Function
-%28 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%32 = OpLoad %v4float %28
-%33 = OpCompositeExtract %float %32 0
-%27 = OpExtInst %float %1 Round %33
-%34 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%36 = OpLoad %v4float %34
-%37 = OpCompositeExtract %float %36 0
-%38 = OpFOrdEqual %bool %27 %37
-OpSelectionMerge %40 None
-OpBranchConditional %38 %39 %40
-%39 = OpLabel
-%42 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%43 = OpLoad %v4float %42
-%44 = OpVectorShuffle %v2float %43 %43 0 1
-%41 = OpExtInst %v2float %1 Round %44
-%45 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%46 = OpLoad %v4float %45
-%47 = OpVectorShuffle %v2float %46 %46 0 1
-%48 = OpFOrdEqual %v2bool %41 %47
+%expectedA = OpVariable %_ptr_Function_v4float Function
+%74 = OpVariable %_ptr_Function_v4float Function
+OpStore %expectedA %31
+%34 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%38 = OpLoad %v4float %34
+%39 = OpCompositeExtract %float %38 0
+%33 = OpExtInst %float %1 Round %39
+%40 = OpFOrdEqual %bool %33 %float_n1
+OpSelectionMerge %42 None
+OpBranchConditional %40 %41 %42
+%41 = OpLabel
+%44 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%45 = OpLoad %v4float %44
+%46 = OpVectorShuffle %v2float %45 %45 0 1
+%43 = OpExtInst %v2float %1 Round %46
+%48 = OpFOrdEqual %v2bool %43 %47
%50 = OpAll %bool %48
-OpBranch %40
-%40 = OpLabel
-%51 = OpPhi %bool %false %25 %50 %39
+OpBranch %42
+%42 = OpLabel
+%51 = OpPhi %bool %false %25 %50 %41
OpSelectionMerge %53 None
OpBranchConditional %51 %52 %53
%52 = OpLabel
@@ -135,82 +111,36 @@
%56 = OpLoad %v4float %55
%57 = OpVectorShuffle %v3float %56 %56 0 1 2
%54 = OpExtInst %v3float %1 Round %57
-%59 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%60 = OpLoad %v4float %59
-%61 = OpVectorShuffle %v3float %60 %60 0 1 2
-%62 = OpFOrdEqual %v3bool %54 %61
-%64 = OpAll %bool %62
+%60 = OpFOrdEqual %v3bool %54 %59
+%62 = OpAll %bool %60
OpBranch %53
%53 = OpLabel
-%65 = OpPhi %bool %false %40 %64 %52
-OpSelectionMerge %67 None
-OpBranchConditional %65 %66 %67
-%66 = OpLabel
-%69 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%70 = OpLoad %v4float %69
-%68 = OpExtInst %v4float %1 Round %70
-%71 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%72 = OpLoad %v4float %71
-%73 = OpFOrdEqual %v4bool %68 %72
-%75 = OpAll %bool %73
-OpBranch %67
-%67 = OpLabel
-%76 = OpPhi %bool %false %53 %75 %66
-OpSelectionMerge %78 None
-OpBranchConditional %76 %77 %78
+%63 = OpPhi %bool %false %42 %62 %52
+OpSelectionMerge %65 None
+OpBranchConditional %63 %64 %65
+%64 = OpLabel
+%67 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%68 = OpLoad %v4float %67
+%66 = OpExtInst %v4float %1 Round %68
+%69 = OpLoad %v4float %expectedA
+%70 = OpFOrdEqual %v4bool %66 %69
+%72 = OpAll %bool %70
+OpBranch %65
+%65 = OpLabel
+%73 = OpPhi %bool %false %53 %72 %64
+OpSelectionMerge %77 None
+OpBranchConditional %73 %75 %76
+%75 = OpLabel
+%78 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
+%80 = OpLoad %v4float %78
+OpStore %74 %80
+OpBranch %77
+%76 = OpLabel
+%81 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
+%83 = OpLoad %v4float %81
+OpStore %74 %83
+OpBranch %77
%77 = OpLabel
-%80 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%81 = OpLoad %v4float %80
-%82 = OpCompositeExtract %float %81 0
-%83 = OpFOrdEqual %bool %float_n2 %82
-OpBranch %78
-%78 = OpLabel
-%84 = OpPhi %bool %false %67 %83 %77
-OpSelectionMerge %86 None
-OpBranchConditional %84 %85 %86
-%85 = OpLabel
-%89 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%90 = OpLoad %v4float %89
-%91 = OpVectorShuffle %v2float %90 %90 0 1
-%92 = OpFOrdEqual %v2bool %88 %91
-%93 = OpAll %bool %92
-OpBranch %86
-%86 = OpLabel
-%94 = OpPhi %bool %false %78 %93 %85
-OpSelectionMerge %96 None
-OpBranchConditional %94 %95 %96
-%95 = OpLabel
-%98 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%99 = OpLoad %v4float %98
-%100 = OpVectorShuffle %v3float %99 %99 0 1 2
-%101 = OpFOrdEqual %v3bool %97 %100
-%102 = OpAll %bool %101
-OpBranch %96
-%96 = OpLabel
-%103 = OpPhi %bool %false %86 %102 %95
-OpSelectionMerge %105 None
-OpBranchConditional %103 %104 %105
-%104 = OpLabel
-%108 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%109 = OpLoad %v4float %108
-%110 = OpFOrdEqual %v4bool %107 %109
-%111 = OpAll %bool %110
-OpBranch %105
-%105 = OpLabel
-%112 = OpPhi %bool %false %96 %111 %104
-OpSelectionMerge %117 None
-OpBranchConditional %112 %115 %116
-%115 = OpLabel
-%118 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
-%120 = OpLoad %v4float %118
-OpStore %113 %120
-OpBranch %117
-%116 = OpLabel
-%121 = OpAccessChain %_ptr_Uniform_v4float %10 %int_3
-%123 = OpLoad %v4float %121
-OpStore %113 %123
-OpBranch %117
-%117 = OpLabel
-%124 = OpLoad %v4float %113
-OpReturnValue %124
+%84 = OpLoad %v4float %74
+OpReturnValue %84
OpFunctionEnd
diff --git a/tests/sksl/intrinsics/Round.glsl b/tests/sksl/intrinsics/Round.glsl
index 215af92..6ec2b81 100644
--- a/tests/sksl/intrinsics/Round.glsl
+++ b/tests/sksl/intrinsics/Round.glsl
@@ -1,9 +1,9 @@
out vec4 sk_FragColor;
-uniform vec4 input;
-uniform vec4 expected;
+uniform vec4 testInputs;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
- return ((((((round(input.x) == expected.x && round(input.xy) == expected.xy) && round(input.xyz) == expected.xyz) && round(input) == expected) && -2.0 == expected.x) && vec2(-2.0, -0.0) == expected.xy) && vec3(-2.0, -0.0, 0.0) == expected.xyz) && vec4(-2.0, -0.0, 0.0, 2.0) == expected ? colorGreen : colorRed;
+ const vec4 expectedA = vec4(-1.0, 0.0, 1.0, 2.0);
+ return ((round(testInputs.x) == -1.0 && round(testInputs.xy) == vec2(-1.0, 0.0)) && round(testInputs.xyz) == vec3(-1.0, 0.0, 1.0)) && round(testInputs) == expectedA ? colorGreen : colorRed;
}
diff --git a/tests/sksl/intrinsics/Round.metal b/tests/sksl/intrinsics/Round.metal
index 4e74099..5fdf776 100644
--- a/tests/sksl/intrinsics/Round.metal
+++ b/tests/sksl/intrinsics/Round.metal
@@ -2,8 +2,7 @@
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
- float4 input;
- float4 expected;
+ float4 testInputs;
float4 colorGreen;
float4 colorRed;
};
@@ -15,6 +14,7 @@
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
- _out.sk_FragColor = ((((((round(_uniforms.input.x) == _uniforms.expected.x && all(round(_uniforms.input.xy) == _uniforms.expected.xy)) && all(round(_uniforms.input.xyz) == _uniforms.expected.xyz)) && all(round(_uniforms.input) == _uniforms.expected)) && -2.0 == _uniforms.expected.x) && all(float2(-2.0, -0.0) == _uniforms.expected.xy)) && all(float3(-2.0, -0.0, 0.0) == _uniforms.expected.xyz)) && all(float4(-2.0, -0.0, 0.0, 2.0) == _uniforms.expected) ? _uniforms.colorGreen : _uniforms.colorRed;
+ const float4 expectedA = float4(-1.0, 0.0, 1.0, 2.0);
+ _out.sk_FragColor = ((round(_uniforms.testInputs.x) == -1.0 && all(round(_uniforms.testInputs.xy) == float2(-1.0, 0.0))) && all(round(_uniforms.testInputs.xyz) == float3(-1.0, 0.0, 1.0))) && all(round(_uniforms.testInputs) == expectedA) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}
diff --git a/tests/sksl/intrinsics/RoundEven.asm.frag b/tests/sksl/intrinsics/RoundEven.asm.frag
index 413e218..8e56515 100644
--- a/tests/sksl/intrinsics/RoundEven.asm.frag
+++ b/tests/sksl/intrinsics/RoundEven.asm.frag
@@ -6,12 +6,12 @@
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %_UniformBuffer "_UniformBuffer"
-OpMemberName %_UniformBuffer 0 "input"
-OpMemberName %_UniformBuffer 1 "expected"
-OpMemberName %_UniformBuffer 2 "colorGreen"
-OpMemberName %_UniformBuffer 3 "colorRed"
+OpMemberName %_UniformBuffer 0 "testInputs"
+OpMemberName %_UniformBuffer 1 "colorGreen"
+OpMemberName %_UniformBuffer 2 "colorRed"
OpName %_entrypoint_v "_entrypoint_v"
OpName %main "main"
+OpName %expectedA "expectedA"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
@@ -22,42 +22,23 @@
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 2 Offset 32
OpMemberDecorate %_UniformBuffer 2 RelaxedPrecision
-OpMemberDecorate %_UniformBuffer 3 Offset 48
-OpMemberDecorate %_UniformBuffer 3 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
-OpDecorate %27 RelaxedPrecision
-OpDecorate %32 RelaxedPrecision
OpDecorate %33 RelaxedPrecision
-OpDecorate %36 RelaxedPrecision
-OpDecorate %37 RelaxedPrecision
-OpDecorate %41 RelaxedPrecision
+OpDecorate %38 RelaxedPrecision
+OpDecorate %39 RelaxedPrecision
OpDecorate %43 RelaxedPrecision
-OpDecorate %44 RelaxedPrecision
+OpDecorate %45 RelaxedPrecision
OpDecorate %46 RelaxedPrecision
-OpDecorate %47 RelaxedPrecision
OpDecorate %54 RelaxedPrecision
OpDecorate %56 RelaxedPrecision
OpDecorate %57 RelaxedPrecision
-OpDecorate %60 RelaxedPrecision
-OpDecorate %61 RelaxedPrecision
+OpDecorate %66 RelaxedPrecision
OpDecorate %68 RelaxedPrecision
-OpDecorate %70 RelaxedPrecision
-OpDecorate %72 RelaxedPrecision
-OpDecorate %81 RelaxedPrecision
-OpDecorate %82 RelaxedPrecision
-OpDecorate %88 RelaxedPrecision
-OpDecorate %90 RelaxedPrecision
-OpDecorate %91 RelaxedPrecision
-OpDecorate %97 RelaxedPrecision
-OpDecorate %99 RelaxedPrecision
-OpDecorate %100 RelaxedPrecision
-OpDecorate %107 RelaxedPrecision
-OpDecorate %109 RelaxedPrecision
-OpDecorate %120 RelaxedPrecision
-OpDecorate %123 RelaxedPrecision
-OpDecorate %124 RelaxedPrecision
+OpDecorate %80 RelaxedPrecision
+OpDecorate %83 RelaxedPrecision
+OpDecorate %84 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -65,7 +46,7 @@
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
-%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float %v4float
+%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
@@ -75,24 +56,23 @@
%19 = OpConstantComposite %v2float %float_0 %float_0
%_ptr_Function_v2float = OpTypePointer Function %v2float
%23 = OpTypeFunction %v4float %_ptr_Function_v2float
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_n1 = OpConstant %float -1
+%float_1 = OpConstant %float 1
+%float_2 = OpConstant %float 2
+%31 = OpConstantComposite %v4float %float_n1 %float_0 %float_1 %float_2
%false = OpConstantFalse %bool
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
-%int_1 = OpConstant %int 1
+%47 = OpConstantComposite %v2float %float_n1 %float_0
%v2bool = OpTypeVector %bool 2
%v3float = OpTypeVector %float 3
+%59 = OpConstantComposite %v3float %float_n1 %float_0 %float_1
%v3bool = OpTypeVector %bool 3
%v4bool = OpTypeVector %bool 4
-%float_n2 = OpConstant %float -2
-%float_n0 = OpConstant %float -0
-%88 = OpConstantComposite %v2float %float_n2 %float_n0
-%97 = OpConstantComposite %v3float %float_n2 %float_n0 %float_0
-%float_2 = OpConstant %float 2
-%107 = OpConstantComposite %v4float %float_n2 %float_n0 %float_0 %float_2
-%_ptr_Function_v4float = OpTypePointer Function %v4float
+%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
-%int_3 = OpConstant %int 3
%_entrypoint_v = OpFunction %void None %15
%16 = OpLabel
%20 = OpVariable %_ptr_Function_v2float Function
@@ -104,30 +84,26 @@
%main = OpFunction %v4float None %23
%24 = OpFunctionParameter %_ptr_Function_v2float
%25 = OpLabel
-%113 = OpVariable %_ptr_Function_v4float Function
-%28 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%32 = OpLoad %v4float %28
-%33 = OpCompositeExtract %float %32 0
-%27 = OpExtInst %float %1 RoundEven %33
-%34 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%36 = OpLoad %v4float %34
-%37 = OpCompositeExtract %float %36 0
-%38 = OpFOrdEqual %bool %27 %37
-OpSelectionMerge %40 None
-OpBranchConditional %38 %39 %40
-%39 = OpLabel
-%42 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%43 = OpLoad %v4float %42
-%44 = OpVectorShuffle %v2float %43 %43 0 1
-%41 = OpExtInst %v2float %1 RoundEven %44
-%45 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%46 = OpLoad %v4float %45
-%47 = OpVectorShuffle %v2float %46 %46 0 1
-%48 = OpFOrdEqual %v2bool %41 %47
+%expectedA = OpVariable %_ptr_Function_v4float Function
+%74 = OpVariable %_ptr_Function_v4float Function
+OpStore %expectedA %31
+%34 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%38 = OpLoad %v4float %34
+%39 = OpCompositeExtract %float %38 0
+%33 = OpExtInst %float %1 RoundEven %39
+%40 = OpFOrdEqual %bool %33 %float_n1
+OpSelectionMerge %42 None
+OpBranchConditional %40 %41 %42
+%41 = OpLabel
+%44 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%45 = OpLoad %v4float %44
+%46 = OpVectorShuffle %v2float %45 %45 0 1
+%43 = OpExtInst %v2float %1 RoundEven %46
+%48 = OpFOrdEqual %v2bool %43 %47
%50 = OpAll %bool %48
-OpBranch %40
-%40 = OpLabel
-%51 = OpPhi %bool %false %25 %50 %39
+OpBranch %42
+%42 = OpLabel
+%51 = OpPhi %bool %false %25 %50 %41
OpSelectionMerge %53 None
OpBranchConditional %51 %52 %53
%52 = OpLabel
@@ -135,82 +111,36 @@
%56 = OpLoad %v4float %55
%57 = OpVectorShuffle %v3float %56 %56 0 1 2
%54 = OpExtInst %v3float %1 RoundEven %57
-%59 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%60 = OpLoad %v4float %59
-%61 = OpVectorShuffle %v3float %60 %60 0 1 2
-%62 = OpFOrdEqual %v3bool %54 %61
-%64 = OpAll %bool %62
+%60 = OpFOrdEqual %v3bool %54 %59
+%62 = OpAll %bool %60
OpBranch %53
%53 = OpLabel
-%65 = OpPhi %bool %false %40 %64 %52
-OpSelectionMerge %67 None
-OpBranchConditional %65 %66 %67
-%66 = OpLabel
-%69 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%70 = OpLoad %v4float %69
-%68 = OpExtInst %v4float %1 RoundEven %70
-%71 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%72 = OpLoad %v4float %71
-%73 = OpFOrdEqual %v4bool %68 %72
-%75 = OpAll %bool %73
-OpBranch %67
-%67 = OpLabel
-%76 = OpPhi %bool %false %53 %75 %66
-OpSelectionMerge %78 None
-OpBranchConditional %76 %77 %78
+%63 = OpPhi %bool %false %42 %62 %52
+OpSelectionMerge %65 None
+OpBranchConditional %63 %64 %65
+%64 = OpLabel
+%67 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%68 = OpLoad %v4float %67
+%66 = OpExtInst %v4float %1 RoundEven %68
+%69 = OpLoad %v4float %expectedA
+%70 = OpFOrdEqual %v4bool %66 %69
+%72 = OpAll %bool %70
+OpBranch %65
+%65 = OpLabel
+%73 = OpPhi %bool %false %53 %72 %64
+OpSelectionMerge %77 None
+OpBranchConditional %73 %75 %76
+%75 = OpLabel
+%78 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
+%80 = OpLoad %v4float %78
+OpStore %74 %80
+OpBranch %77
+%76 = OpLabel
+%81 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
+%83 = OpLoad %v4float %81
+OpStore %74 %83
+OpBranch %77
%77 = OpLabel
-%80 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%81 = OpLoad %v4float %80
-%82 = OpCompositeExtract %float %81 0
-%83 = OpFOrdEqual %bool %float_n2 %82
-OpBranch %78
-%78 = OpLabel
-%84 = OpPhi %bool %false %67 %83 %77
-OpSelectionMerge %86 None
-OpBranchConditional %84 %85 %86
-%85 = OpLabel
-%89 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%90 = OpLoad %v4float %89
-%91 = OpVectorShuffle %v2float %90 %90 0 1
-%92 = OpFOrdEqual %v2bool %88 %91
-%93 = OpAll %bool %92
-OpBranch %86
-%86 = OpLabel
-%94 = OpPhi %bool %false %78 %93 %85
-OpSelectionMerge %96 None
-OpBranchConditional %94 %95 %96
-%95 = OpLabel
-%98 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%99 = OpLoad %v4float %98
-%100 = OpVectorShuffle %v3float %99 %99 0 1 2
-%101 = OpFOrdEqual %v3bool %97 %100
-%102 = OpAll %bool %101
-OpBranch %96
-%96 = OpLabel
-%103 = OpPhi %bool %false %86 %102 %95
-OpSelectionMerge %105 None
-OpBranchConditional %103 %104 %105
-%104 = OpLabel
-%108 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%109 = OpLoad %v4float %108
-%110 = OpFOrdEqual %v4bool %107 %109
-%111 = OpAll %bool %110
-OpBranch %105
-%105 = OpLabel
-%112 = OpPhi %bool %false %96 %111 %104
-OpSelectionMerge %117 None
-OpBranchConditional %112 %115 %116
-%115 = OpLabel
-%118 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
-%120 = OpLoad %v4float %118
-OpStore %113 %120
-OpBranch %117
-%116 = OpLabel
-%121 = OpAccessChain %_ptr_Uniform_v4float %10 %int_3
-%123 = OpLoad %v4float %121
-OpStore %113 %123
-OpBranch %117
-%117 = OpLabel
-%124 = OpLoad %v4float %113
-OpReturnValue %124
+%84 = OpLoad %v4float %74
+OpReturnValue %84
OpFunctionEnd
diff --git a/tests/sksl/intrinsics/RoundEven.glsl b/tests/sksl/intrinsics/RoundEven.glsl
index 8aa8a1f..02e983a 100644
--- a/tests/sksl/intrinsics/RoundEven.glsl
+++ b/tests/sksl/intrinsics/RoundEven.glsl
@@ -1,9 +1,9 @@
out vec4 sk_FragColor;
-uniform vec4 input;
-uniform vec4 expected;
+uniform vec4 testInputs;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
- return ((((((roundEven(input.x) == expected.x && roundEven(input.xy) == expected.xy) && roundEven(input.xyz) == expected.xyz) && roundEven(input) == expected) && -2.0 == expected.x) && vec2(-2.0, -0.0) == expected.xy) && vec3(-2.0, -0.0, 0.0) == expected.xyz) && vec4(-2.0, -0.0, 0.0, 2.0) == expected ? colorGreen : colorRed;
+ const vec4 expectedA = vec4(-1.0, 0.0, 1.0, 2.0);
+ return ((roundEven(testInputs.x) == -1.0 && roundEven(testInputs.xy) == vec2(-1.0, 0.0)) && roundEven(testInputs.xyz) == vec3(-1.0, 0.0, 1.0)) && roundEven(testInputs) == expectedA ? colorGreen : colorRed;
}
diff --git a/tests/sksl/intrinsics/RoundEven.metal b/tests/sksl/intrinsics/RoundEven.metal
index a8494ec..5d627dc 100644
--- a/tests/sksl/intrinsics/RoundEven.metal
+++ b/tests/sksl/intrinsics/RoundEven.metal
@@ -2,8 +2,7 @@
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
- float4 input;
- float4 expected;
+ float4 testInputs;
float4 colorGreen;
float4 colorRed;
};
@@ -15,6 +14,7 @@
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
- _out.sk_FragColor = ((((((rint(_uniforms.input.x) == _uniforms.expected.x && all(rint(_uniforms.input.xy) == _uniforms.expected.xy)) && all(rint(_uniforms.input.xyz) == _uniforms.expected.xyz)) && all(rint(_uniforms.input) == _uniforms.expected)) && -2.0 == _uniforms.expected.x) && all(float2(-2.0, -0.0) == _uniforms.expected.xy)) && all(float3(-2.0, -0.0, 0.0) == _uniforms.expected.xyz)) && all(float4(-2.0, -0.0, 0.0, 2.0) == _uniforms.expected) ? _uniforms.colorGreen : _uniforms.colorRed;
+ const float4 expectedA = float4(-1.0, 0.0, 1.0, 2.0);
+ _out.sk_FragColor = ((rint(_uniforms.testInputs.x) == -1.0 && all(rint(_uniforms.testInputs.xy) == float2(-1.0, 0.0))) && all(rint(_uniforms.testInputs.xyz) == float3(-1.0, 0.0, 1.0))) && all(rint(_uniforms.testInputs) == expectedA) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}
diff --git a/tests/sksl/intrinsics/Trunc.asm.frag b/tests/sksl/intrinsics/Trunc.asm.frag
index 8223770..f1fb960 100644
--- a/tests/sksl/intrinsics/Trunc.asm.frag
+++ b/tests/sksl/intrinsics/Trunc.asm.frag
@@ -6,12 +6,12 @@
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %_UniformBuffer "_UniformBuffer"
-OpMemberName %_UniformBuffer 0 "input"
-OpMemberName %_UniformBuffer 1 "expected"
-OpMemberName %_UniformBuffer 2 "colorGreen"
-OpMemberName %_UniformBuffer 3 "colorRed"
+OpMemberName %_UniformBuffer 0 "testInputs"
+OpMemberName %_UniformBuffer 1 "colorGreen"
+OpMemberName %_UniformBuffer 2 "colorRed"
OpName %_entrypoint_v "_entrypoint_v"
OpName %main "main"
+OpName %expectedA "expectedA"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
@@ -22,42 +22,23 @@
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 2 Offset 32
OpMemberDecorate %_UniformBuffer 2 RelaxedPrecision
-OpMemberDecorate %_UniformBuffer 3 Offset 48
-OpMemberDecorate %_UniformBuffer 3 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
-OpDecorate %27 RelaxedPrecision
OpDecorate %32 RelaxedPrecision
-OpDecorate %33 RelaxedPrecision
-OpDecorate %36 RelaxedPrecision
OpDecorate %37 RelaxedPrecision
-OpDecorate %41 RelaxedPrecision
-OpDecorate %43 RelaxedPrecision
+OpDecorate %38 RelaxedPrecision
+OpDecorate %42 RelaxedPrecision
OpDecorate %44 RelaxedPrecision
-OpDecorate %46 RelaxedPrecision
-OpDecorate %47 RelaxedPrecision
-OpDecorate %54 RelaxedPrecision
+OpDecorate %45 RelaxedPrecision
+OpDecorate %53 RelaxedPrecision
+OpDecorate %55 RelaxedPrecision
OpDecorate %56 RelaxedPrecision
-OpDecorate %57 RelaxedPrecision
-OpDecorate %60 RelaxedPrecision
-OpDecorate %61 RelaxedPrecision
-OpDecorate %68 RelaxedPrecision
-OpDecorate %70 RelaxedPrecision
-OpDecorate %72 RelaxedPrecision
-OpDecorate %81 RelaxedPrecision
+OpDecorate %65 RelaxedPrecision
+OpDecorate %67 RelaxedPrecision
+OpDecorate %79 RelaxedPrecision
OpDecorate %82 RelaxedPrecision
-OpDecorate %88 RelaxedPrecision
-OpDecorate %90 RelaxedPrecision
-OpDecorate %91 RelaxedPrecision
-OpDecorate %97 RelaxedPrecision
-OpDecorate %99 RelaxedPrecision
-OpDecorate %100 RelaxedPrecision
-OpDecorate %107 RelaxedPrecision
-OpDecorate %109 RelaxedPrecision
-OpDecorate %120 RelaxedPrecision
-OpDecorate %123 RelaxedPrecision
-OpDecorate %124 RelaxedPrecision
+OpDecorate %83 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -65,7 +46,7 @@
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
-%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float %v4float
+%_UniformBuffer = OpTypeStruct %v4float %v4float %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
@@ -75,24 +56,22 @@
%19 = OpConstantComposite %v2float %float_0 %float_0
%_ptr_Function_v2float = OpTypePointer Function %v2float
%23 = OpTypeFunction %v4float %_ptr_Function_v2float
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_n1 = OpConstant %float -1
+%float_2 = OpConstant %float 2
+%30 = OpConstantComposite %v4float %float_n1 %float_0 %float_0 %float_2
%false = OpConstantFalse %bool
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
-%int_1 = OpConstant %int 1
+%46 = OpConstantComposite %v2float %float_n1 %float_0
%v2bool = OpTypeVector %bool 2
%v3float = OpTypeVector %float 3
+%58 = OpConstantComposite %v3float %float_n1 %float_0 %float_0
%v3bool = OpTypeVector %bool 3
%v4bool = OpTypeVector %bool 4
-%float_n1 = OpConstant %float -1
-%float_n0 = OpConstant %float -0
-%88 = OpConstantComposite %v2float %float_n1 %float_n0
-%97 = OpConstantComposite %v3float %float_n1 %float_n0 %float_0
-%float_1 = OpConstant %float 1
-%107 = OpConstantComposite %v4float %float_n1 %float_n0 %float_0 %float_1
-%_ptr_Function_v4float = OpTypePointer Function %v4float
+%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
-%int_3 = OpConstant %int 3
%_entrypoint_v = OpFunction %void None %15
%16 = OpLabel
%20 = OpVariable %_ptr_Function_v2float Function
@@ -104,113 +83,63 @@
%main = OpFunction %v4float None %23
%24 = OpFunctionParameter %_ptr_Function_v2float
%25 = OpLabel
-%113 = OpVariable %_ptr_Function_v4float Function
-%28 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%32 = OpLoad %v4float %28
-%33 = OpCompositeExtract %float %32 0
-%27 = OpExtInst %float %1 Trunc %33
-%34 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%36 = OpLoad %v4float %34
-%37 = OpCompositeExtract %float %36 0
-%38 = OpFOrdEqual %bool %27 %37
-OpSelectionMerge %40 None
-OpBranchConditional %38 %39 %40
-%39 = OpLabel
-%42 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%43 = OpLoad %v4float %42
-%44 = OpVectorShuffle %v2float %43 %43 0 1
-%41 = OpExtInst %v2float %1 Trunc %44
-%45 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%46 = OpLoad %v4float %45
-%47 = OpVectorShuffle %v2float %46 %46 0 1
-%48 = OpFOrdEqual %v2bool %41 %47
-%50 = OpAll %bool %48
-OpBranch %40
+%expectedA = OpVariable %_ptr_Function_v4float Function
+%73 = OpVariable %_ptr_Function_v4float Function
+OpStore %expectedA %30
+%33 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%37 = OpLoad %v4float %33
+%38 = OpCompositeExtract %float %37 0
+%32 = OpExtInst %float %1 Trunc %38
+%39 = OpFOrdEqual %bool %32 %float_n1
+OpSelectionMerge %41 None
+OpBranchConditional %39 %40 %41
%40 = OpLabel
-%51 = OpPhi %bool %false %25 %50 %39
-OpSelectionMerge %53 None
-OpBranchConditional %51 %52 %53
+%43 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%44 = OpLoad %v4float %43
+%45 = OpVectorShuffle %v2float %44 %44 0 1
+%42 = OpExtInst %v2float %1 Trunc %45
+%47 = OpFOrdEqual %v2bool %42 %46
+%49 = OpAll %bool %47
+OpBranch %41
+%41 = OpLabel
+%50 = OpPhi %bool %false %25 %49 %40
+OpSelectionMerge %52 None
+OpBranchConditional %50 %51 %52
+%51 = OpLabel
+%54 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%55 = OpLoad %v4float %54
+%56 = OpVectorShuffle %v3float %55 %55 0 1 2
+%53 = OpExtInst %v3float %1 Trunc %56
+%59 = OpFOrdEqual %v3bool %53 %58
+%61 = OpAll %bool %59
+OpBranch %52
%52 = OpLabel
-%55 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%56 = OpLoad %v4float %55
-%57 = OpVectorShuffle %v3float %56 %56 0 1 2
-%54 = OpExtInst %v3float %1 Trunc %57
-%59 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%60 = OpLoad %v4float %59
-%61 = OpVectorShuffle %v3float %60 %60 0 1 2
-%62 = OpFOrdEqual %v3bool %54 %61
-%64 = OpAll %bool %62
-OpBranch %53
-%53 = OpLabel
-%65 = OpPhi %bool %false %40 %64 %52
-OpSelectionMerge %67 None
-OpBranchConditional %65 %66 %67
-%66 = OpLabel
-%69 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
-%70 = OpLoad %v4float %69
-%68 = OpExtInst %v4float %1 Trunc %70
-%71 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%72 = OpLoad %v4float %71
-%73 = OpFOrdEqual %v4bool %68 %72
-%75 = OpAll %bool %73
-OpBranch %67
-%67 = OpLabel
-%76 = OpPhi %bool %false %53 %75 %66
-OpSelectionMerge %78 None
-OpBranchConditional %76 %77 %78
-%77 = OpLabel
-%80 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%81 = OpLoad %v4float %80
-%82 = OpCompositeExtract %float %81 0
-%83 = OpFOrdEqual %bool %float_n1 %82
-OpBranch %78
-%78 = OpLabel
-%84 = OpPhi %bool %false %67 %83 %77
-OpSelectionMerge %86 None
-OpBranchConditional %84 %85 %86
-%85 = OpLabel
-%89 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%90 = OpLoad %v4float %89
-%91 = OpVectorShuffle %v2float %90 %90 0 1
-%92 = OpFOrdEqual %v2bool %88 %91
-%93 = OpAll %bool %92
-OpBranch %86
-%86 = OpLabel
-%94 = OpPhi %bool %false %78 %93 %85
-OpSelectionMerge %96 None
-OpBranchConditional %94 %95 %96
-%95 = OpLabel
-%98 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%99 = OpLoad %v4float %98
-%100 = OpVectorShuffle %v3float %99 %99 0 1 2
-%101 = OpFOrdEqual %v3bool %97 %100
-%102 = OpAll %bool %101
-OpBranch %96
-%96 = OpLabel
-%103 = OpPhi %bool %false %86 %102 %95
-OpSelectionMerge %105 None
-OpBranchConditional %103 %104 %105
-%104 = OpLabel
-%108 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
-%109 = OpLoad %v4float %108
-%110 = OpFOrdEqual %v4bool %107 %109
-%111 = OpAll %bool %110
-OpBranch %105
-%105 = OpLabel
-%112 = OpPhi %bool %false %96 %111 %104
-OpSelectionMerge %117 None
-OpBranchConditional %112 %115 %116
-%115 = OpLabel
-%118 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
-%120 = OpLoad %v4float %118
-OpStore %113 %120
-OpBranch %117
-%116 = OpLabel
-%121 = OpAccessChain %_ptr_Uniform_v4float %10 %int_3
-%123 = OpLoad %v4float %121
-OpStore %113 %123
-OpBranch %117
-%117 = OpLabel
-%124 = OpLoad %v4float %113
-OpReturnValue %124
+%62 = OpPhi %bool %false %41 %61 %51
+OpSelectionMerge %64 None
+OpBranchConditional %62 %63 %64
+%63 = OpLabel
+%66 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
+%67 = OpLoad %v4float %66
+%65 = OpExtInst %v4float %1 Trunc %67
+%68 = OpLoad %v4float %expectedA
+%69 = OpFOrdEqual %v4bool %65 %68
+%71 = OpAll %bool %69
+OpBranch %64
+%64 = OpLabel
+%72 = OpPhi %bool %false %52 %71 %63
+OpSelectionMerge %76 None
+OpBranchConditional %72 %74 %75
+%74 = OpLabel
+%77 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
+%79 = OpLoad %v4float %77
+OpStore %73 %79
+OpBranch %76
+%75 = OpLabel
+%80 = OpAccessChain %_ptr_Uniform_v4float %10 %int_2
+%82 = OpLoad %v4float %80
+OpStore %73 %82
+OpBranch %76
+%76 = OpLabel
+%83 = OpLoad %v4float %73
+OpReturnValue %83
OpFunctionEnd
diff --git a/tests/sksl/intrinsics/Trunc.glsl b/tests/sksl/intrinsics/Trunc.glsl
index 11369ac..66301e1 100644
--- a/tests/sksl/intrinsics/Trunc.glsl
+++ b/tests/sksl/intrinsics/Trunc.glsl
@@ -1,9 +1,9 @@
out vec4 sk_FragColor;
-uniform vec4 input;
-uniform vec4 expected;
+uniform vec4 testInputs;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
- return ((((((trunc(input.x) == expected.x && trunc(input.xy) == expected.xy) && trunc(input.xyz) == expected.xyz) && trunc(input) == expected) && -1.0 == expected.x) && vec2(-1.0, -0.0) == expected.xy) && vec3(-1.0, -0.0, 0.0) == expected.xyz) && vec4(-1.0, -0.0, 0.0, 1.0) == expected ? colorGreen : colorRed;
+ const vec4 expectedA = vec4(-1.0, 0.0, 0.0, 2.0);
+ return ((trunc(testInputs.x) == -1.0 && trunc(testInputs.xy) == vec2(-1.0, 0.0)) && trunc(testInputs.xyz) == vec3(-1.0, 0.0, 0.0)) && trunc(testInputs) == expectedA ? colorGreen : colorRed;
}
diff --git a/tests/sksl/intrinsics/Trunc.metal b/tests/sksl/intrinsics/Trunc.metal
index c678523..f84c660 100644
--- a/tests/sksl/intrinsics/Trunc.metal
+++ b/tests/sksl/intrinsics/Trunc.metal
@@ -2,8 +2,7 @@
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
- float4 input;
- float4 expected;
+ float4 testInputs;
float4 colorGreen;
float4 colorRed;
};
@@ -15,6 +14,7 @@
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
- _out.sk_FragColor = ((((((trunc(_uniforms.input.x) == _uniforms.expected.x && all(trunc(_uniforms.input.xy) == _uniforms.expected.xy)) && all(trunc(_uniforms.input.xyz) == _uniforms.expected.xyz)) && all(trunc(_uniforms.input) == _uniforms.expected)) && -1.0 == _uniforms.expected.x) && all(float2(-1.0, -0.0) == _uniforms.expected.xy)) && all(float3(-1.0, -0.0, 0.0) == _uniforms.expected.xyz)) && all(float4(-1.0, -0.0, 0.0, 1.0) == _uniforms.expected) ? _uniforms.colorGreen : _uniforms.colorRed;
+ const float4 expectedA = float4(-1.0, 0.0, 0.0, 2.0);
+ _out.sk_FragColor = ((trunc(_uniforms.testInputs.x) == -1.0 && all(trunc(_uniforms.testInputs.xy) == float2(-1.0, 0.0))) && all(trunc(_uniforms.testInputs.xyz) == float3(-1.0, 0.0, 0.0))) && all(trunc(_uniforms.testInputs) == expectedA) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}