Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SkSL error: Unknown identifier 'spvInverse' #3

Open
kavi6024 opened this issue Oct 31, 2023 · 5 comments
Open

SkSL error: Unknown identifier 'spvInverse' #3

kavi6024 opened this issue Oct 31, 2023 · 5 comments

Comments

@kavi6024
Copy link

So, I've basically cloned the repo and ran it and then I get this exception.

══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
The following _Exception was thrown:
Exception: Invalid SkSL:
// This SkSL shader is autogenerated by spirv-cross.

float4 flutter_FragCoord;

uniform vec2 resolution;
uniform float pointer;
uniform float origin;
uniform vec4 container;
uniform float cornerRadius;
uniform shader image;
uniform half2 image_size;

vec4 fragColor;

vec2 FLT_flutter_local_FlutterFragCoord()
{
    return flutter_FragCoord.xy;
}

bool FLT_flutter_local_inRect(vec2 p, vec4 rct)
{
    bool _96 = p.x > rct.x;
    bool _105;
    if (_96)
    {
        _105 = p.x < rct.z;
    }
    else
    {
        _105 = _96;
    }
    bool _113;
    if (_105)
    {
        _113 = p.y > rct.y;
    }
    else
    {
        _113 = _105;
    }
    bool _122;
    if (_113)
    {
        _122 = p.y < rct.w;
    }
    else
    {
        _122 = _113;
    }
    bool inRct = _122;
    if (!inRct)
    {
        return false;
    }
    bool _137 = p.x < (rct.x + cornerRadius);
    bool _147;
    if (_137)
    {
        _147 = p.y < (rct.y + cornerRadius);
    }
    else
    {
        _147 = _137;
    }
    if (_147)
    {
        return length(p - vec2(rct.x + cornerRadius, rct.y + cornerRadius)) < cornerRadius;
    }
    bool _171 = p.x > (rct.z - cornerRadius);
    bool _181;
    if (_171)
    {
        _181 = p.y < (rct.y + cornerRadius);
    }
    else
    {
        _181 = _171;
    }
    if (_181)
    {
        return length(p - vec2(rct.z - cornerRadius, rct.y + cornerRadius)) < cornerRadius;
    }
    bool _205 = p.x < (rct.x + cornerRadius);
    bool _215;
    if (_205)
    {
        _215 = p.y > (rct.w - cornerRadius);
    }
    else
    {
        _215 = _205;
    }
    if (_215)
    {
        return length(p - vec2(rct.x + cornerRadius, rct.w - cornerRadius)) < cornerRadius;
    }
    bool _239 = p.x > (rct.z - cornerRadius);
    bool _249;
    if (_239)
    {
        _249 = p.y > (rct.w - cornerRadius);
    }
    else
    {
        _249 = _239;
    }
    if (_249)
    {
        return length(p - vec2(rct.z - cornerRadius, rct.w - cornerRadius)) < cornerRadius;
    }
    return true;
}

mat3 FLT_flutter_local_translate(vec2 p)
{
    return mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(p.x, p.y, 1.0));
}

mat3 FLT_flutter_local_scale(vec2 s, vec2 p)
{
    vec2 param = p;
    vec2 param_1 = -p;
    return (FLT_flutter_local_translate(param) * mat3(vec3(s.x, 0.0, 0.0), vec3(0.0, s.y, 0.0),
vec3(0.0, 0.0, 1.0))) * FLT_flutter_local_translate(param_1);
}

vec2 FLT_flutter_local_project(vec2 p, mat3 m)
{
    return (spvInverse(m) * vec3(p, 1.0)).xy;
}

void FLT_main()
{
    vec2 xy = FLT_flutter_local_FlutterFragCoord();
    vec2 center = resolution * 0.5;
    float dx = origin - pointer;
    float x = container.z - dx;
    float d = xy.x - x;
    if (d > 150.0)
    {
        fragColor = vec4(0.0);
        vec2 param = xy;
        vec4 param_1 = container;
        if (FLT_flutter_local_inRect(param, param_1))
        {
            fragColor.w = mix(0.5, 0.0, (d - 150.0) / 150.0);
        }
    }
    else
    {
        if (d > 0.0)
        {
            float theta = asin(d / 150.0);
            float d1 = theta * 150.0;
            float d2 = (3.1415927410125732421875 - theta) * 150.0;
            vec2 s = vec2(1.0 + ((1.0 - sin(1.57079637050628662109375 + theta)) *
0.100000001490116119384765625));
            vec2 param_2 = s;
            vec2 param_3 = center;
            mat3 transform = FLT_flutter_local_scale(param_2, param_3);
            vec2 param_4 = xy;
            mat3 param_5 = transform;
            vec2 uv = FLT_flutter_local_project(param_4, param_5);
            vec2 p1 = vec2(x + d1, uv.y);
            s = vec2(1.10000002384185791015625 + (sin(1.57079637050628662109375 + theta) *
0.100000001490116119384765625));
            vec2 param_6 = s;
            vec2 param_7 = center;
            transform = FLT_flutter_local_scale(param_6, param_7);
            vec2 param_8 = xy;
            mat3 param_9 = transform;
            uv = FLT_flutter_local_project(param_8, param_9);
            vec2 p2 = vec2(x + d2, uv.y);
            vec2 param_10 = p2;
            vec4 param_11 = container;
            if (FLT_flutter_local_inRect(param_10, param_11))
            {
                fragColor = image.eval(image_size *  p2 / resolution);
            }
            else
            {
                vec2 param_12 = p1;
                vec4 param_13 = container;
                if (FLT_flutter_local_inRect(param_12, param_13))
                {
                    fragColor = image.eval(image_size *  p1 / resolution);
                    vec4 _422 = fragColor;
                    vec3 _424 = _422.xyz * pow(clamp((150.0 - d) / 150.0, 0.0, 1.0),
0.20000000298023223876953125);
                    fragColor.x = _424.x;
                    fragColor.y = _424.y;
                    fragColor.z = _424.z;
                }
                else
                {
                    vec2 param_14 = xy;
                    vec4 param_15 = container;
                    if (FLT_flutter_local_inRect(param_14, param_15))
                    {
                        fragColor = vec4(0.0, 0.0, 0.0, 0.5);
                    }
                }
            }
        }
        else
        {
            vec2 s_1 = vec2(1.2000000476837158203125);
            vec2 param_16 = s_1;
            vec2 param_17 = center;
            mat3 transform_1 = FLT_flutter_local_scale(param_16, param_17);
            vec2 param_18 = xy;
            mat3 param_19 = transform_1;
            vec2 uv_1 = FLT_flutter_local_project(param_18, param_19);
            vec2 p_1 = vec2((x + abs(d)) + 471.2388916015625, uv_1.y);
            vec2 param_20 = p_1;
            vec4 param_21 = container;
            if (FLT_flutter_local_inRect(param_20, param_21))
            {
                fragColor = image.eval(image_size *  p_1 / resolution);
            }
            else
            {
                fragColor = image.eval(image_size *  xy / resolution);
            }
        }
    }
}

half4 main(float2 iFragCoord)
{
      flutter_FragCoord = float4(iFragCoord, 0, 0);
      FLT_main();
      return fragColor;
}

SkSL Error:
error: 128: unknown identifier 'spvInverse'
    return (spvInverse(m) * vec3(p, 1.0)).xy;
            ^^^^^^^^^^
1 error

When the exception was thrown, this was the stack:
#0      new FragmentProgram._fromAsset (dart:ui/painting.dart:4453:7)
#1      FragmentProgram.fromAsset.<anonymous closure> (dart:ui/painting.dart:4480:55)
(elided 3 frames from dart:async)

Another exception was thrown: Exception: Invalid SkSL:

And I haven't made any changes to the original .frag file.

@Rahiche
Copy link
Owner

Rahiche commented Nov 1, 2023

I'll take a look this weekend, I tried this on iOS, MacOS, Web and Android for what it's worth if you are using another platform I have't tested let me know

@DyeghoCunha
Copy link

I had the same Issue, didnt changed a thing, i am trying on Android Studio, android emulator, i am using Windows, dont have any Apple device to try on.... i tested on Web too, and had the same issue

@sbis04
Copy link

sbis04 commented Nov 5, 2023

Seems like running as a MacOS app is also giving the exact same error (using Flutter stable v3.13.8)

@Rahiche
Copy link
Owner

Rahiche commented Nov 5, 2023

Thanks everyone, seems like the new version of flutter does not have support natively for spvInverse
I have fixed the issue now, checkout the latest main

@sbis04
Copy link

sbis04 commented Nov 6, 2023

@Rahiche Amazing man! And thanks for making this project open-sourced!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants