Skip to content

SkSL compilation errors are generated when they're irrelevant #182400

@zanderso

Description

@zanderso

Looking at #180861, I think it's the right thing to do, but it doesn't play nicely with shaders that aren't trying to target Skia, like the ones from https://github.com/whynotmake-it/flutter_liquid_glass/tree/main/packages/liquid_glass_renderer.

impellerc doesn't distinguish between iOS and macOS when compiling runtime effects for Metal when deciding whether SkSL also needs to be bundled in the iplr: https://github.com/flutter/flutter/blob/master/engine/src/flutter/impeller/compiler/types.cc#L318.

In particular, the SkSL doesn't need to be bundled for iOS since there's no Skia there at all.

Before the build time error, an iOS app would bundle the SkSL runtime effect shaders, and they'd just never be used.

After the build time errors, the shaders in liquid_glass_renderer cause an app to fail to compile.

The TargetPlatformBundlesSkSL function and the way it's used for runtime effect shaders might just be a bit funky because for runtime effects, you can just specify on the command line what you want included. This is what the Flutter tool does: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_system/tools/shader_compiler.dart#L118

In any case, here's an example of the input glsl, the translation to SkSL, and the SkSL compiler error:

float sceneSDF(vec2 p, int numShapes, float shapeData[MAX_SHAPES * 6], float blend) {
    if (numShapes == 0) {
        return 1e9;
    }
    
    float result = getShapeSDFFromArray(0, p, shapeData);
    ...
 float FLT_flutter_local_sceneSDF(vec2 p, int numShapes, float shapeData[96], float blend) {
    if (numShapes == 0)
    {
        return 1000000000.0;
    }
    int param = 0;
    vec2 param_1 = p;
    float param_2[96] = shapeData;
    float result = FLT_flutter_local_getShapeSDFFromArray(param, param_1, param_2);
...
[        ]            SkSL Error:
[        ]            error: 121: initializers are not permitted on arrays (or structs containing arrays)
[        ]                float param_2[96] = shapeData;

cc @gaaclarke @b-luk

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listplatform-iosiOS applications specificallyplatform-macosteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions