Rename SkSL's 2D cross product builtin function
Note that the 2D cross product isn't defined. There are at least two possible interpretations of what that might mean. This name makes it clearer that we're asking for the length of the resulting vector, if we computed the 3D cross product (assuming Z == 0 for both vectors). It also eliminates name overlap between builtin functions and actual intrinsics. Change-Id: I24e8bc0ab2ec91aaace20f0dd3e8565c10bd44a0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/484440 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
09adf0bfc3
commit
fde20db7ca
@ -1,9 +1,9 @@
|
||||
uniform half2 ah, bh;
|
||||
uniform float2 af, bf;
|
||||
void main() {
|
||||
sk_FragColor.x = cross(ah, bh);
|
||||
sk_FragColor.y = half(cross(af, bf));
|
||||
sk_FragColor.z = cross(half2(3, 0), half2(-1, 4));
|
||||
sk_FragColor.x = cross_length_2d(ah, bh);
|
||||
sk_FragColor.y = half(cross_length_2d(af, bf));
|
||||
sk_FragColor.z = cross_length_2d(half2(3, 0), half2(-1, 4));
|
||||
sk_FragColor.xyz = cross(half3(3, 0, 2), half3(-1, 4, 2));
|
||||
sk_FragColor.yzw = cross(half3(1, 4, -7), half3(2, -1, 4));
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
uniform half2 ah, bh;
|
||||
uniform float2 af, bf;
|
||||
void main() {
|
||||
sk_FragColor.x = cross(ah, bh);
|
||||
sk_FragColor.y = half(cross(af, bf));
|
||||
sk_FragColor.x = cross_length_2d(ah, bh);
|
||||
sk_FragColor.y = half(cross_length_2d(af, bf));
|
||||
}
|
||||
|
@ -106,9 +106,9 @@ std::unique_ptr<GrGeometryProcessor::ProgramImpl> HullShader::makeProgramImpl(
|
||||
float2 v3 = p3 - p0;
|
||||
|
||||
// Reorder the points so v2 bisects v1 and v3.
|
||||
if (sign(cross(v2, v1)) == sign(cross(v2, v3))) {
|
||||
if (sign(cross_length_2d(v2, v1)) == sign(cross_length_2d(v2, v3))) {
|
||||
float2 tmp = p2;
|
||||
if (sign(cross(v1, v2)) != sign(cross(v1, v3))) {
|
||||
if (sign(cross_length_2d(v1, v2)) != sign(cross_length_2d(v1, v3))) {
|
||||
p2 = p1; // swap(p2, p1)
|
||||
p1 = tmp;
|
||||
} else {
|
||||
@ -141,7 +141,7 @@ std::unique_ptr<GrGeometryProcessor::ProgramImpl> HullShader::makeProgramImpl(
|
||||
v->codeAppendf(R"(
|
||||
next = p%i - p%i;)", (i + 1) % 4, i);
|
||||
v->codeAppendf(R"(
|
||||
dir = sign(cross(prev, next));
|
||||
dir = sign(cross_length_2d(prev, next));
|
||||
if (vertexidx == %i) {
|
||||
vertexdir = dir;
|
||||
localcoord = p%i;
|
||||
|
@ -150,7 +150,7 @@ void GrStrokeTessellationShader::HardwareImpl::onEmitCode(EmitArgs& args, GrGPAr
|
||||
// Calculate the number of segments to chop the join into.
|
||||
float cosTheta = cosine_between_vectors(prevJoinTangent, tan0);
|
||||
float joinRotation = (cosTheta == 1) ? 0 : acos(cosTheta);
|
||||
if (cross(prevJoinTangent, tan0) < 0) {
|
||||
if (cross_length_2d(prevJoinTangent, tan0) < 0) {
|
||||
joinRotation = -joinRotation;
|
||||
}
|
||||
float joinRadialSegments = abs(joinRotation) * NUM_RADIAL_SEGMENTS_PER_RADIAN;
|
||||
@ -202,9 +202,9 @@ void GrStrokeTessellationShader::HardwareImpl::onEmitCode(EmitArgs& args, GrGPAr
|
||||
// We formulate this as a quadratic equation: F' x F'' == aT^2 + bT + c == 0.
|
||||
// See: https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf
|
||||
// NOTE: We only need the roots, so a uniform scale factor does not affect the solution.
|
||||
float a = cross(A, B);
|
||||
float b = cross(A, C);
|
||||
float c = cross(B, C);
|
||||
float a = cross_length_2d(A, B);
|
||||
float b = cross_length_2d(A, C);
|
||||
float c = cross_length_2d(B, C);
|
||||
float b_over_2 = b*.5;
|
||||
float discr_over_4 = b_over_2*b_over_2 - a*c;
|
||||
|
||||
|
@ -189,7 +189,7 @@ void GrStrokeTessellationShader::InstancedImpl::onEmitCode(EmitArgs& args, GrGPA
|
||||
// Find which direction the curve turns.
|
||||
// NOTE: Since the curve is not allowed to inflect, we can just check F'(.5) x F''(.5).
|
||||
// NOTE: F'(.5) x F''(.5) has the same sign as (P2 - P0) x (P3 - P1)
|
||||
float turn = cross(p2 - p0, p3 - p1);
|
||||
float turn = cross_length_2d(p2 - p0, p3 - p1);
|
||||
float combinedEdgeID = abs(edgeID) - numEdgesInJoin;
|
||||
if (combinedEdgeID < 0) {
|
||||
tan1 = tan0;
|
||||
@ -199,7 +199,7 @@ void GrStrokeTessellationShader::InstancedImpl::onEmitCode(EmitArgs& args, GrGPA
|
||||
if (lastControlPoint != p0) {
|
||||
tan0 = p0 - lastControlPoint;
|
||||
}
|
||||
turn = cross(tan0, tan1);
|
||||
turn = cross_length_2d(tan0, tan1);
|
||||
}
|
||||
|
||||
// Calculate the curve's starting angle and rotation.
|
||||
|
@ -1,4 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
static uint8_t SKSL_INCLUDE_sksl_gpu[] = {189,8,
|
||||
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,
|
||||
@ -224,6 +224,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
16,98,108,101,110,100,95,108,117,109,105,110,111,115,105,116,121,
|
||||
8,117,110,112,114,101,109,117,108,
|
||||
4,112,114,111,106,
|
||||
15,99,114,111,115,115,95,108,101,110,103,116,104,95,50,100,
|
||||
6,114,101,115,117,108,116,
|
||||
43,109,117,115,116,71,117,97,114,100,68,105,118,105,115,105,111,110,69,118,101,110,65,102,116,101,114,69,120,112,108,105,99,105,116,90,101,114,111,67,104,101,99,107,
|
||||
5,100,101,108,116,97,
|
||||
@ -239,7 +240,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
25,98,117,105,108,116,105,110,68,101,116,101,114,109,105,110,97,110,116,83,117,112,112,111,114,116,
|
||||
8,102,108,111,97,116,50,120,50,
|
||||
7,104,97,108,102,50,120,50,
|
||||
48,211,3,
|
||||
48,210,3,
|
||||
52,1,0,
|
||||
17,2,0,
|
||||
49,2,0,10,0,3,
|
||||
@ -3528,27 +3529,21 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
52,255,3,
|
||||
17,164,1,
|
||||
46,136,1,3,
|
||||
51,0,4,3,
|
||||
46,179,1,
|
||||
46,184,1,
|
||||
29,1,4,
|
||||
17,123,2,2,254,3,255,3,
|
||||
29,0,4,
|
||||
17,25,8,2,254,3,255,3,
|
||||
46,167,0,
|
||||
46,1,4,
|
||||
52,2,4,
|
||||
52,1,4,
|
||||
17,35,1,
|
||||
46,11,2,3,
|
||||
52,3,4,
|
||||
52,2,4,
|
||||
17,164,1,
|
||||
46,11,2,3,
|
||||
51,4,4,4,
|
||||
46,179,1,
|
||||
46,184,1,
|
||||
46,1,4,
|
||||
29,5,4,
|
||||
17,123,2,2,2,4,3,4,
|
||||
51,3,4,2,
|
||||
46,0,4,
|
||||
29,4,4,
|
||||
17,25,8,2,1,4,2,4,
|
||||
46,175,0,
|
||||
46,5,4,132,0,
|
||||
46,4,4,133,0,
|
||||
171,3,
|
||||
177,3,
|
||||
123,3,
|
||||
@ -3602,7 +3597,8 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
10,1,
|
||||
55,0,
|
||||
77,0,
|
||||
209,3,
|
||||
169,1,
|
||||
208,3,
|
||||
36,3,
|
||||
39,3,
|
||||
49,0,
|
||||
@ -3889,11 +3885,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
28,177,3,
|
||||
2,
|
||||
48,1,0,
|
||||
52,6,4,
|
||||
17,25,8,
|
||||
52,5,4,
|
||||
17,41,8,
|
||||
46,21,2,2,1,0,
|
||||
0,0,3,
|
||||
53,6,4,
|
||||
53,5,4,
|
||||
46,21,2,0,
|
||||
8,
|
||||
46,21,2,4,
|
||||
@ -3929,7 +3925,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
22,
|
||||
1,
|
||||
45,
|
||||
55,6,4,2,3,0,1,2,73,
|
||||
55,5,4,2,3,0,1,2,73,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
@ -3948,15 +3944,15 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
45,
|
||||
55,176,3,0,1,3,
|
||||
40,
|
||||
55,6,4,0,1,
|
||||
55,5,4,0,1,
|
||||
28,180,3,
|
||||
2,
|
||||
48,1,0,
|
||||
52,7,4,
|
||||
17,25,8,
|
||||
52,6,4,
|
||||
17,41,8,
|
||||
46,21,2,2,1,0,
|
||||
0,0,3,
|
||||
53,7,4,
|
||||
53,6,4,
|
||||
46,21,2,0,
|
||||
27,
|
||||
46,21,2,138,3,2,
|
||||
@ -3965,11 +3961,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
22,
|
||||
1,
|
||||
45,
|
||||
55,7,4,1,3,0,1,2,66,
|
||||
55,6,4,1,3,0,1,2,66,
|
||||
27,
|
||||
46,181,1,199,0,2,
|
||||
45,
|
||||
55,7,4,0,3,0,1,2,
|
||||
55,6,4,0,3,0,1,2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
@ -3982,15 +3978,15 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
45,
|
||||
55,179,3,0,3,0,1,2,
|
||||
40,
|
||||
55,7,4,0,1,
|
||||
55,6,4,0,1,
|
||||
28,183,3,
|
||||
2,
|
||||
48,1,0,
|
||||
52,8,4,
|
||||
17,25,8,
|
||||
52,7,4,
|
||||
17,41,8,
|
||||
46,21,2,2,1,0,
|
||||
0,0,3,
|
||||
53,8,4,
|
||||
53,7,4,
|
||||
46,21,2,0,
|
||||
27,
|
||||
46,21,2,138,3,2,
|
||||
@ -3999,11 +3995,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
22,
|
||||
1,
|
||||
45,
|
||||
55,8,4,1,3,0,1,2,66,
|
||||
55,7,4,1,3,0,1,2,66,
|
||||
27,
|
||||
46,181,1,223,0,2,
|
||||
45,
|
||||
55,8,4,0,3,0,1,2,
|
||||
55,7,4,0,3,0,1,2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
@ -4016,13 +4012,13 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
45,
|
||||
55,182,3,0,3,0,1,2,
|
||||
40,
|
||||
55,8,4,0,1,
|
||||
55,7,4,0,1,
|
||||
28,186,3,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
50,
|
||||
41,32,8,
|
||||
41,48,8,
|
||||
1,
|
||||
55,184,3,0,52,
|
||||
1,
|
||||
@ -4037,7 +4033,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
50,
|
||||
41,32,8,
|
||||
41,48,8,
|
||||
1,
|
||||
55,187,3,0,52,
|
||||
1,
|
||||
@ -4069,11 +4065,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,192,3,0,1,1,1,
|
||||
2,
|
||||
48,1,0,
|
||||
52,9,4,
|
||||
17,76,8,
|
||||
52,8,4,
|
||||
17,92,8,
|
||||
46,175,0,2,1,0,
|
||||
0,0,2,
|
||||
53,9,4,
|
||||
53,8,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
@ -4082,7 +4078,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,191,3,0,1,0,
|
||||
30,0,
|
||||
1,
|
||||
55,9,4,0,67,
|
||||
55,8,4,0,67,
|
||||
25,
|
||||
46,175,0,0,0,0,0,
|
||||
2,
|
||||
@ -4115,7 +4111,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
48,0,0,0,0,2,
|
||||
22,
|
||||
1,
|
||||
55,9,4,1,66,
|
||||
55,8,4,1,66,
|
||||
27,
|
||||
46,175,0,199,0,2,
|
||||
45,
|
||||
@ -4127,12 +4123,12 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,192,3,0,1,0,51,
|
||||
45,
|
||||
55,191,3,0,1,1,
|
||||
55,9,4,0,
|
||||
55,8,4,0,
|
||||
40,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
55,9,4,0,51,
|
||||
55,8,4,0,51,
|
||||
45,
|
||||
55,191,3,0,1,1,49,
|
||||
1,
|
||||
@ -4240,11 +4236,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,197,3,0,1,1,1,
|
||||
2,
|
||||
48,1,0,
|
||||
52,10,4,
|
||||
17,76,8,
|
||||
52,9,4,
|
||||
17,92,8,
|
||||
46,175,0,2,1,0,
|
||||
0,0,2,
|
||||
53,10,4,
|
||||
53,9,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,223,0,2,
|
||||
@ -4269,7 +4265,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
55,10,4,0,51,
|
||||
55,9,4,0,51,
|
||||
45,
|
||||
55,197,3,0,1,1,49,
|
||||
1,
|
||||
@ -4400,46 +4396,46 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,207,3,0,1,1,
|
||||
2,
|
||||
48,4,0,
|
||||
52,10,4,
|
||||
17,98,8,
|
||||
46,175,0,2,
|
||||
52,11,4,
|
||||
17,82,8,
|
||||
17,103,8,
|
||||
46,175,0,2,
|
||||
52,12,4,
|
||||
17,87,8,
|
||||
17,108,8,
|
||||
46,175,0,2,
|
||||
52,13,4,
|
||||
17,92,8,
|
||||
46,175,0,2,
|
||||
52,14,4,
|
||||
17,98,8,
|
||||
17,114,8,
|
||||
46,175,0,2,4,0,
|
||||
1,0,
|
||||
0,0,
|
||||
3,0,
|
||||
2,0,5,
|
||||
53,11,4,
|
||||
53,10,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,207,3,0,1,0,51,
|
||||
45,
|
||||
55,207,3,0,1,0,
|
||||
53,12,4,
|
||||
53,11,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
55,11,4,0,51,
|
||||
55,10,4,0,51,
|
||||
45,
|
||||
55,207,3,0,1,0,
|
||||
53,13,4,
|
||||
53,12,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,207,3,0,1,1,51,
|
||||
45,
|
||||
55,207,3,0,1,1,
|
||||
53,14,4,
|
||||
53,13,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
55,13,4,0,51,
|
||||
55,12,4,0,51,
|
||||
45,
|
||||
55,207,3,0,1,1,
|
||||
40,
|
||||
@ -4449,7 +4445,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
55,13,4,0,51,
|
||||
55,12,4,0,51,
|
||||
1,
|
||||
45,
|
||||
55,206,3,0,1,0,50,
|
||||
@ -4477,7 +4473,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,175,0,0,0,64,65,51,
|
||||
45,
|
||||
55,207,3,0,1,1,51,
|
||||
55,11,4,0,51,
|
||||
55,10,4,0,51,
|
||||
1,
|
||||
45,
|
||||
55,206,3,0,1,1,50,
|
||||
@ -4490,7 +4486,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
1,
|
||||
25,
|
||||
46,175,0,0,0,128,65,51,
|
||||
55,12,4,0,51,
|
||||
55,11,4,0,51,
|
||||
1,
|
||||
45,
|
||||
55,206,3,0,1,1,50,
|
||||
@ -4500,10 +4496,10 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
45,
|
||||
55,206,3,0,1,0,50,
|
||||
1,
|
||||
55,14,4,0,51,
|
||||
55,13,4,0,51,
|
||||
45,
|
||||
55,206,3,0,1,0,
|
||||
55,13,4,0,1,
|
||||
55,12,4,0,1,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
@ -4716,116 +4712,116 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
28,226,3,
|
||||
2,
|
||||
48,4,0,
|
||||
52,14,4,
|
||||
17,120,8,
|
||||
46,175,0,2,
|
||||
52,15,4,
|
||||
17,104,8,
|
||||
46,175,0,2,
|
||||
52,16,4,
|
||||
17,25,8,
|
||||
17,41,8,
|
||||
46,181,1,2,
|
||||
52,17,4,
|
||||
17,108,8,
|
||||
52,16,4,
|
||||
17,124,8,
|
||||
46,175,0,2,
|
||||
52,18,4,
|
||||
17,116,8,
|
||||
52,17,4,
|
||||
17,132,8,
|
||||
46,175,0,2,4,0,
|
||||
0,0,
|
||||
3,0,
|
||||
2,0,
|
||||
1,0,6,
|
||||
53,15,4,
|
||||
53,14,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,222,3,1,
|
||||
55,225,3,0,
|
||||
53,16,4,
|
||||
53,15,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
1,
|
||||
55,15,4,0,50,
|
||||
55,14,4,0,50,
|
||||
27,
|
||||
46,175,0,222,3,1,
|
||||
55,223,3,0,49,
|
||||
55,223,3,0,
|
||||
53,16,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,199,0,2,
|
||||
27,
|
||||
46,175,0,199,0,2,
|
||||
45,
|
||||
55,15,4,0,1,0,
|
||||
45,
|
||||
55,15,4,0,1,1,
|
||||
45,
|
||||
55,15,4,0,1,2,
|
||||
53,17,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,199,0,2,
|
||||
27,
|
||||
46,175,0,199,0,2,
|
||||
45,
|
||||
55,16,4,0,1,0,
|
||||
45,
|
||||
55,16,4,0,1,1,
|
||||
45,
|
||||
55,16,4,0,1,2,
|
||||
53,18,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,223,0,2,
|
||||
27,
|
||||
46,175,0,223,0,2,
|
||||
45,
|
||||
55,16,4,0,1,0,
|
||||
55,15,4,0,1,0,
|
||||
45,
|
||||
55,16,4,0,1,1,
|
||||
55,15,4,0,1,1,
|
||||
45,
|
||||
55,16,4,0,1,2,
|
||||
55,15,4,0,1,2,
|
||||
30,0,
|
||||
1,
|
||||
1,
|
||||
55,17,4,0,70,
|
||||
55,16,4,0,70,
|
||||
25,
|
||||
46,175,0,0,0,0,0,62,
|
||||
1,
|
||||
55,15,4,0,68,
|
||||
55,17,4,0,
|
||||
55,14,4,0,68,
|
||||
55,16,4,0,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
22,
|
||||
1,
|
||||
55,16,4,1,66,
|
||||
55,15,4,1,66,
|
||||
1,
|
||||
55,15,4,0,49,
|
||||
55,14,4,0,49,
|
||||
1,
|
||||
1,
|
||||
55,16,4,0,50,
|
||||
55,15,4,0,51,
|
||||
27,
|
||||
46,175,0,186,3,2,
|
||||
55,15,4,0,
|
||||
1,
|
||||
55,15,4,0,50,
|
||||
55,17,4,0,1,
|
||||
55,14,4,0,51,
|
||||
27,
|
||||
46,175,0,186,3,2,
|
||||
55,14,4,0,
|
||||
1,
|
||||
55,14,4,0,50,
|
||||
55,16,4,0,1,
|
||||
56,
|
||||
30,0,
|
||||
1,
|
||||
1,
|
||||
55,18,4,0,69,
|
||||
55,17,4,0,69,
|
||||
55,224,3,0,62,
|
||||
1,
|
||||
55,18,4,0,68,
|
||||
55,15,4,0,
|
||||
55,17,4,0,68,
|
||||
55,14,4,0,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
1,
|
||||
55,15,4,0,49,
|
||||
55,14,4,0,49,
|
||||
27,
|
||||
46,181,1,190,3,2,
|
||||
1,
|
||||
1,
|
||||
55,16,4,0,50,
|
||||
55,15,4,0,51,
|
||||
55,15,4,0,50,
|
||||
55,14,4,0,51,
|
||||
1,
|
||||
55,224,3,0,50,
|
||||
55,15,4,0,
|
||||
55,14,4,0,
|
||||
1,
|
||||
55,18,4,0,50,
|
||||
55,15,4,0,1,
|
||||
55,17,4,0,50,
|
||||
55,14,4,0,1,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
55,16,4,0,1,1,
|
||||
55,15,4,0,1,1,
|
||||
28,228,3,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
@ -4892,11 +4888,11 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
28,234,3,
|
||||
2,
|
||||
48,1,0,
|
||||
52,19,4,
|
||||
52,18,4,
|
||||
17,123,7,
|
||||
46,175,0,2,1,0,
|
||||
0,0,2,
|
||||
53,19,4,
|
||||
53,18,4,
|
||||
46,175,0,0,
|
||||
27,
|
||||
46,175,0,228,3,1,
|
||||
@ -4921,7 +4917,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
27,
|
||||
46,181,1,231,3,2,
|
||||
55,232,3,0,
|
||||
55,19,4,0,1,
|
||||
55,18,4,0,1,
|
||||
30,0,
|
||||
1,
|
||||
45,
|
||||
@ -4936,7 +4932,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,231,3,2,
|
||||
45,
|
||||
55,232,3,0,3,0,2,1,
|
||||
55,19,4,0,3,0,2,1,1,
|
||||
55,18,4,0,3,0,2,1,1,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
@ -4945,7 +4941,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,231,3,2,
|
||||
45,
|
||||
55,232,3,0,3,2,0,1,
|
||||
55,19,4,0,3,1,2,0,1,1,
|
||||
55,18,4,0,3,1,2,0,1,1,
|
||||
30,0,
|
||||
1,
|
||||
45,
|
||||
@ -4960,7 +4956,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,231,3,2,
|
||||
45,
|
||||
55,232,3,0,3,1,0,2,
|
||||
55,19,4,0,3,1,0,2,1,
|
||||
55,18,4,0,3,1,0,2,1,
|
||||
30,0,
|
||||
1,
|
||||
45,
|
||||
@ -4975,7 +4971,7 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,231,3,2,
|
||||
45,
|
||||
55,232,3,0,3,1,2,0,
|
||||
55,19,4,0,3,2,0,1,1,
|
||||
55,18,4,0,3,2,0,1,1,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
@ -4984,37 +4980,37 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,231,3,2,
|
||||
45,
|
||||
55,232,3,0,3,2,1,0,
|
||||
55,19,4,0,3,2,1,0,1,1,
|
||||
55,18,4,0,3,2,1,0,1,1,
|
||||
28,237,3,
|
||||
2,
|
||||
48,3,0,
|
||||
52,20,4,
|
||||
52,19,4,
|
||||
17,47,7,
|
||||
46,175,0,2,
|
||||
52,21,4,
|
||||
17,124,8,
|
||||
52,20,4,
|
||||
17,140,8,
|
||||
46,181,1,2,
|
||||
52,22,4,
|
||||
17,128,8,
|
||||
52,21,4,
|
||||
17,144,8,
|
||||
46,181,1,2,3,0,
|
||||
0,0,
|
||||
2,0,
|
||||
1,0,4,
|
||||
53,20,4,
|
||||
53,19,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,236,3,0,1,3,51,
|
||||
45,
|
||||
55,235,3,0,1,3,
|
||||
53,21,4,
|
||||
53,20,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
55,235,3,0,3,0,1,2,51,
|
||||
45,
|
||||
55,236,3,0,1,3,
|
||||
53,22,4,
|
||||
53,21,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
@ -5032,53 +5028,53 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,226,3,3,
|
||||
27,
|
||||
46,181,1,234,3,2,
|
||||
55,21,4,0,
|
||||
55,22,4,0,
|
||||
55,20,4,0,
|
||||
55,22,4,0,49,
|
||||
55,21,4,0,
|
||||
55,19,4,0,
|
||||
55,21,4,0,49,
|
||||
45,
|
||||
55,236,3,0,3,0,1,2,50,
|
||||
55,22,4,0,49,
|
||||
55,21,4,0,49,
|
||||
45,
|
||||
55,235,3,0,3,0,1,2,50,
|
||||
55,21,4,0,
|
||||
55,20,4,0,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
55,235,3,0,1,3,49,
|
||||
45,
|
||||
55,236,3,0,1,3,50,
|
||||
55,20,4,0,1,
|
||||
55,19,4,0,1,
|
||||
28,240,3,
|
||||
2,
|
||||
48,3,0,
|
||||
52,23,4,
|
||||
52,22,4,
|
||||
17,47,7,
|
||||
46,175,0,2,
|
||||
52,24,4,
|
||||
17,124,8,
|
||||
52,23,4,
|
||||
17,140,8,
|
||||
46,181,1,2,
|
||||
52,25,4,
|
||||
17,128,8,
|
||||
52,24,4,
|
||||
17,144,8,
|
||||
46,181,1,2,3,0,
|
||||
0,0,
|
||||
2,0,
|
||||
1,0,4,
|
||||
53,23,4,
|
||||
53,22,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,239,3,0,1,3,51,
|
||||
45,
|
||||
55,238,3,0,1,3,
|
||||
53,24,4,
|
||||
53,23,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
55,238,3,0,3,0,1,2,51,
|
||||
45,
|
||||
55,239,3,0,1,3,
|
||||
53,25,4,
|
||||
53,24,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
@ -5096,53 +5092,53 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
46,181,1,226,3,3,
|
||||
27,
|
||||
46,181,1,234,3,2,
|
||||
55,25,4,0,
|
||||
55,24,4,0,
|
||||
55,23,4,0,
|
||||
55,25,4,0,49,
|
||||
55,22,4,0,
|
||||
55,24,4,0,49,
|
||||
45,
|
||||
55,239,3,0,3,0,1,2,50,
|
||||
55,25,4,0,49,
|
||||
55,24,4,0,49,
|
||||
45,
|
||||
55,238,3,0,3,0,1,2,50,
|
||||
55,24,4,0,
|
||||
55,23,4,0,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
55,238,3,0,1,3,49,
|
||||
45,
|
||||
55,239,3,0,1,3,50,
|
||||
55,23,4,0,1,
|
||||
55,22,4,0,1,
|
||||
28,243,3,
|
||||
2,
|
||||
48,3,0,
|
||||
52,26,4,
|
||||
52,25,4,
|
||||
17,47,7,
|
||||
46,175,0,2,
|
||||
52,27,4,
|
||||
17,124,8,
|
||||
52,26,4,
|
||||
17,140,8,
|
||||
46,181,1,2,
|
||||
52,28,4,
|
||||
17,128,8,
|
||||
52,27,4,
|
||||
17,144,8,
|
||||
46,181,1,2,3,0,
|
||||
0,0,
|
||||
2,0,
|
||||
1,0,4,
|
||||
53,26,4,
|
||||
53,25,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,242,3,0,1,3,51,
|
||||
45,
|
||||
55,241,3,0,1,3,
|
||||
53,27,4,
|
||||
53,26,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
55,241,3,0,3,0,1,2,51,
|
||||
45,
|
||||
55,242,3,0,1,3,
|
||||
53,28,4,
|
||||
53,27,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
@ -5158,52 +5154,52 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
1,
|
||||
27,
|
||||
46,181,1,226,3,3,
|
||||
55,27,4,0,
|
||||
55,26,4,0,
|
||||
55,28,4,0,49,
|
||||
55,25,4,0,
|
||||
55,27,4,0,49,
|
||||
45,
|
||||
55,242,3,0,3,0,1,2,50,
|
||||
55,28,4,0,49,
|
||||
55,27,4,0,49,
|
||||
45,
|
||||
55,241,3,0,3,0,1,2,50,
|
||||
55,27,4,0,
|
||||
55,26,4,0,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
55,241,3,0,1,3,49,
|
||||
45,
|
||||
55,242,3,0,1,3,50,
|
||||
55,26,4,0,1,
|
||||
55,25,4,0,1,
|
||||
28,246,3,
|
||||
2,
|
||||
48,3,0,
|
||||
52,29,4,
|
||||
52,28,4,
|
||||
17,47,7,
|
||||
46,175,0,2,
|
||||
52,30,4,
|
||||
17,124,8,
|
||||
52,29,4,
|
||||
17,140,8,
|
||||
46,181,1,2,
|
||||
52,31,4,
|
||||
17,128,8,
|
||||
52,30,4,
|
||||
17,144,8,
|
||||
46,181,1,2,3,0,
|
||||
0,0,
|
||||
2,0,
|
||||
1,0,4,
|
||||
53,29,4,
|
||||
53,28,4,
|
||||
46,175,0,0,
|
||||
1,
|
||||
45,
|
||||
55,245,3,0,1,3,51,
|
||||
45,
|
||||
55,244,3,0,1,3,
|
||||
53,30,4,
|
||||
53,29,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
55,244,3,0,3,0,1,2,51,
|
||||
45,
|
||||
55,245,3,0,1,3,
|
||||
53,31,4,
|
||||
53,30,4,
|
||||
46,181,1,0,
|
||||
1,
|
||||
45,
|
||||
@ -5219,22 +5215,22 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
1,
|
||||
27,
|
||||
46,181,1,226,3,3,
|
||||
55,31,4,0,
|
||||
55,29,4,0,
|
||||
55,30,4,0,49,
|
||||
55,30,4,0,
|
||||
55,28,4,0,
|
||||
55,29,4,0,49,
|
||||
45,
|
||||
55,245,3,0,3,0,1,2,50,
|
||||
55,31,4,0,49,
|
||||
55,30,4,0,49,
|
||||
45,
|
||||
55,244,3,0,3,0,1,2,50,
|
||||
55,30,4,0,
|
||||
55,29,4,0,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
55,244,3,0,1,3,49,
|
||||
45,
|
||||
55,245,3,0,1,3,50,
|
||||
55,29,4,0,1,
|
||||
55,28,4,0,1,
|
||||
28,248,3,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
@ -5278,16 +5274,16 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,252,3,0,2,0,1,52,
|
||||
45,
|
||||
55,252,3,0,1,2,1,
|
||||
28,1,4,
|
||||
28,0,4,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
50,
|
||||
41,132,8,
|
||||
41,148,8,
|
||||
27,
|
||||
46,167,0,83,2,1,
|
||||
8,
|
||||
49,32,4,158,8,2,
|
||||
49,31,4,174,8,2,
|
||||
55,254,3,0,
|
||||
55,255,3,0,
|
||||
1,
|
||||
@ -5301,28 +5297,28 @@ static uint8_t SKSL_INCLUDE_sksl_gpu[] = {173,8,
|
||||
55,254,3,0,1,1,51,
|
||||
45,
|
||||
55,255,3,0,1,0,1,
|
||||
28,5,4,
|
||||
28,4,4,
|
||||
2,
|
||||
48,0,0,0,0,1,
|
||||
40,
|
||||
50,
|
||||
41,132,8,
|
||||
41,148,8,
|
||||
27,
|
||||
46,175,0,86,2,1,
|
||||
8,
|
||||
49,33,4,167,8,2,
|
||||
49,32,4,183,8,2,
|
||||
55,1,4,0,
|
||||
55,2,4,0,
|
||||
55,3,4,0,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
55,2,4,0,1,0,51,
|
||||
55,1,4,0,1,0,51,
|
||||
45,
|
||||
55,3,4,0,1,1,50,
|
||||
55,2,4,0,1,1,50,
|
||||
1,
|
||||
45,
|
||||
55,2,4,0,1,1,51,
|
||||
55,1,4,0,1,1,51,
|
||||
45,
|
||||
55,3,4,0,1,0,1,
|
||||
55,2,4,0,1,0,1,
|
||||
21,};
|
||||
static constexpr size_t SKSL_INCLUDE_sksl_gpu_LENGTH = sizeof(SKSL_INCLUDE_sksl_gpu);
|
||||
|
@ -505,12 +505,12 @@ float2 proj(float3 p) { return p.xy / p.z; }
|
||||
|
||||
// Implement cross() as a determinant to communicate our intent more clearly to the compiler.
|
||||
// NOTE: Due to precision issues, it might be the case that cross(a, a) != 0.
|
||||
float cross(float2 a, float2 b) {
|
||||
float cross_length_2d(float2 a, float2 b) {
|
||||
return sk_Caps.builtinDeterminantSupport ? determinant(float2x2(a, b))
|
||||
: a.x*b.y - a.y*b.x;
|
||||
}
|
||||
|
||||
half cross(half2 a, half2 b) {
|
||||
half cross_length_2d(half2 a, half2 b) {
|
||||
return sk_Caps.builtinDeterminantSupport ? determinant(half2x2(a, b))
|
||||
: a.x*b.y - a.y*b.x;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
fBUniform = args.fUniformHandler->addUniform(&fp, kFragment_GrShaderFlag,
|
||||
GrSLType::kFloat2_GrSLType, "b", &b);
|
||||
args.fFragBuilder->codeAppendf(R"(
|
||||
float crossProduct = cross(%s, %s);
|
||||
float crossProduct = cross_length_2d(%s, %s);
|
||||
float2 visualization = clamp(float2(-sign(crossProduct), sign(crossProduct)),
|
||||
float2(0), float2(1));
|
||||
return half2(visualization).xy01;)", a, b);
|
||||
|
@ -10,8 +10,8 @@ OpMemberName %_UniformBuffer 0 "ah"
|
||||
OpMemberName %_UniformBuffer 1 "bh"
|
||||
OpMemberName %_UniformBuffer 2 "af"
|
||||
OpMemberName %_UniformBuffer 3 "bf"
|
||||
OpName %cross_hh2h2 "cross_hh2h2"
|
||||
OpName %cross_ff2f2 "cross_ff2f2"
|
||||
OpName %cross_length_2d_hh2h2 "cross_length_2d_hh2h2"
|
||||
OpName %cross_length_2d_ff2f2 "cross_length_2d_ff2f2"
|
||||
OpName %main "main"
|
||||
OpDecorate %sk_FragColor RelaxedPrecision
|
||||
OpDecorate %sk_FragColor Location 0
|
||||
@ -61,7 +61,7 @@ OpDecorate %57 RelaxedPrecision
|
||||
%_ptr_Output_float = OpTypePointer Output %float
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%cross_hh2h2 = OpFunction %float None %16
|
||||
%cross_length_2d_hh2h2 = OpFunction %float None %16
|
||||
%18 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%19 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%20 = OpLabel
|
||||
@ -78,7 +78,7 @@ OpDecorate %57 RelaxedPrecision
|
||||
%31 = OpFSub %float %25 %30
|
||||
OpReturnValue %31
|
||||
OpFunctionEnd
|
||||
%cross_ff2f2 = OpFunction %float None %16
|
||||
%cross_length_2d_ff2f2 = OpFunction %float None %16
|
||||
%32 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%33 = OpFunctionParameter %_ptr_Function_v2float
|
||||
%34 = OpLabel
|
||||
@ -107,7 +107,7 @@ OpStore %54 %53
|
||||
%55 = OpAccessChain %_ptr_Uniform_v2float %12 %int_1
|
||||
%57 = OpLoad %v2float %55
|
||||
OpStore %58 %57
|
||||
%59 = OpFunctionCall %float %cross_hh2h2 %54 %58
|
||||
%59 = OpFunctionCall %float %cross_length_2d_hh2h2 %54 %58
|
||||
%60 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0
|
||||
OpStore %60 %59
|
||||
%62 = OpAccessChain %_ptr_Uniform_v2float %12 %int_2
|
||||
@ -116,7 +116,7 @@ OpStore %65 %64
|
||||
%66 = OpAccessChain %_ptr_Uniform_v2float %12 %int_3
|
||||
%68 = OpLoad %v2float %66
|
||||
OpStore %69 %68
|
||||
%70 = OpFunctionCall %float %cross_ff2f2 %65 %69
|
||||
%70 = OpFunctionCall %float %cross_length_2d_ff2f2 %65 %69
|
||||
%71 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_1
|
||||
OpStore %71 %70
|
||||
OpReturn
|
||||
|
@ -4,13 +4,13 @@ uniform vec2 ah;
|
||||
uniform vec2 bh;
|
||||
uniform vec2 af;
|
||||
uniform vec2 bf;
|
||||
float cross_hh2h2(vec2 a, vec2 b) {
|
||||
float cross_length_2d_hh2h2(vec2 a, vec2 b) {
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
float cross_ff2f2(vec2 a, vec2 b) {
|
||||
float cross_length_2d_ff2f2(vec2 a, vec2 b) {
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
void main() {
|
||||
sk_FragColor.x = cross_hh2h2(ah, bh);
|
||||
sk_FragColor.y = cross_ff2f2(af, bf);
|
||||
sk_FragColor.x = cross_length_2d_hh2h2(ah, bh);
|
||||
sk_FragColor.y = cross_length_2d_ff2f2(af, bf);
|
||||
}
|
||||
|
@ -12,16 +12,16 @@ struct Inputs {
|
||||
struct Outputs {
|
||||
half4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
half cross_hh2h2(half2 a, half2 b) {
|
||||
half cross_length_2d_hh2h2(half2 a, half2 b) {
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
float cross_ff2f2(float2 a, float2 b) {
|
||||
float cross_length_2d_ff2f2(float2 a, float2 b) {
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
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.x = cross_hh2h2(_uniforms.ah, _uniforms.bh);
|
||||
_out.sk_FragColor.y = half(cross_ff2f2(_uniforms.af, _uniforms.bf));
|
||||
_out.sk_FragColor.x = cross_length_2d_hh2h2(_uniforms.ah, _uniforms.bh);
|
||||
_out.sk_FragColor.y = half(cross_length_2d_ff2f2(_uniforms.af, _uniforms.bf));
|
||||
return _out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user