ardera / flutter-pi

A light-weight Flutter Engine Embedder for Linux Embedded that runs without X11 or Wayland.
MIT License
1.6k stars 160 forks source link

Shader compilation error, unknown identifier '_dstColor' #451

Open dev-dtplus opened 1 day ago

dev-dtplus commented 1 day ago

Error 1

Positioned(
      top: 53,
      left: 234,
      child: Opacity(opacity: 1.0,child: Container(decoration: BoxDecoration(backgroundBlendMode: BlendMode.overlay, color: Colors.red),child: Image.asset("assets/images/runner.png"))),
),

This code snippet throws the following errors.

Shader compilation error
------------------------
   1    uniform half ublend_S1;in half4 vcolor_S0;void main() {// Stage 0, QuadPerEdgeAAGeometryProcessor
   2    half4 outputColor_S0;outputColor_S0 = vcolor_S0;const half4 outputCoverage_S0 = half4(1);{ // Xfer Processor: Custom Xfermode
   3    sk_FragColor = blend_overlay(ublend_S1, outputColor_S0, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}}
Errors:
error: 3: unknown identifier '_dstColor'
sk_FragColor = blend_overlay(ublend_S1, outputColor_S0, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}
                                                        ^^^^^^^^^
error: 3: unknown identifier '_dstColor'
...S0, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}
                                                                                                       ^^^^^^^^^
2 errors

Error 2


  RunnerPainter({required this.image, required this.overlayImage, required this.overlayRect});

  ui.Image image;
  ui.Image overlayImage;
  Rect overlayRect;

  @override
  void paint(Canvas canvas, Size size) {
    canvas.clipRect(overlayRect.translate(-234, -103));

    var paint = Paint()
      ..color = const Color.fromARGB(255, 255, 255, 255)
      ..style = PaintingStyle.stroke
      ..strokeWidth = 2;

    canvas.drawImage(image, Offset.zero, paint);

    paint = Paint()
      ..color = const Color.fromARGB(255, 255, 255, 255)
      ..style = PaintingStyle.fill
      ..blendMode = BlendMode.overlay;
    canvas.drawImage(overlayImage, overlayRect.translate(-234, -103).topLeft, paint);

    //canvas.drawPath(package, paint);
    canvas.save();
    canvas.restore();
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

And this throws the following errors.

Shader compilation error
------------------------
   1    uniform float3x3 umatrix_S1_c0;uniform half ublend_S2;sampler2D uTextureSampler_0_S1;
   2    in float vcoverage_S0;in float2 vTransformedCoords_3_S0;half4 TextureEffect_S1_c0_c0(half4 _input) {
   3    return sample(uTextureSampler_0_S1, vTransformedCoords_3_S0);}
   4
   5    half4 MatrixEffect_S1_c0(half4 _input) {
   6    return TextureEffect_S1_c0_c0(_input);
   7    }
   8
   9    half4 DisableCoverageAsAlpha_S1(half4 _input) {
  10    _input = MatrixEffect_S1_c0(_input);
  11    half4 _tmp_0_inColor = _input;
  12    return half4(_input);
  13    }
  14
  15    void main() {// Stage 0, QuadPerEdgeAAGeometryProcessor
  16    half4 outputColor_S0 = half4(1);float coverage = vcoverage_S0;half4 outputCoverage_S0 = half4(coverage);half4 output_S1;output_S1 = DisableCoverageAsAlpha_S1(outputColor_S0);{ // Xfer Processor: Custom Xfermode
  17    sk_FragColor = blend_overlay(ublend_S2, output_S1, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}}
Errors:
error: 17: unknown identifier '_dstColor'
sk_FragColor = blend_overlay(ublend_S2, output_S1, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}
                                                   ^^^^^^^^^
error: 17: unknown identifier '_dstColor'
...S1, _dstColor);sk_FragColor = outputCoverage_S0 * sk_FragColor + (half4(1.0) - outputCoverage_S0) * _dstColor;}
                                                                                                       ^^^^^^^^^
2 errors

Windows build doesn't have the problem. if you remove blendMode from that code snippet, no error is thrown.

I also tried --enable-software-rendering, but got the same error.

--Tested envs
Flutter 3.19.6 with flutterpi_tool 0.3.0
Flutter 3.24.3 with flutterpi_tool 0.5.4

If there is any additional information I can provide, please let me know. This may be a duplicate of #238, but when someone raised an issue in the flutter repo, they were told to address it in this repo.

dev-dtplus commented 1 day ago
Stack(children: [
  Positioned(
    top: 103,
    left: 234,
    child: Image.asset("assets/images/runner.png"),
  ),
  Positioned(child: ClipRect(
    child: Opacity(opacity: 1.0,
      child: BackdropFilter(
        filter: ui.ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
        child: const SizedBox(
          width: 356,
          height: 748,
        ),
      ),
    ),
  )),
],
),

I don't know if it's the same kind of error, but other effects that use blendMode also don't work. (BackdropFilter)