Skip to content

[Impeller][Windows] Uniform not passed to shader #164438

Open

Description

@vulpeep

I'm experiencing an issue with passing a uniform value to my shader in a Flutter application using the flutter_gpu package. Despite setting the intended value in the Dart code, the vertex shader always receives a default matrix of mat4(0.0). A minimal reproducible repository is available here: https://github.com/vulpeep/gpu_image_example.

Steps to Reproduce

  1. CustomPainter setup:

    • In image_painter.dart, a transform matrix is created and written to a uniform buffer.
    • The shader is expected to use this matrix to compute texture coordinates.
  2. Vertex Shader Code:

    #version 460
    
    in vec2 inPosition;
    out vec2 fragTexCoord;
    
    uniform Transform {
        mat4 transform;
    };
    
    void main() {
        gl_Position = vec4(inPosition * 2.0 - 1.0, 0.0, 1.0);
        fragTexCoord = (transform * vec4(vec2(inPosition.x, 1.0 - inPosition.y), 0.0, 1.0)).xy;
    }
  3. Fragment Shader Code:

    #version 460
    
    in vec2 fragTexCoord;
    out vec4 FragColor;
    
    uniform sampler2D uTexture;
    
    void main() {
        FragColor = texture(uTexture, fragTexCoord);
    }
  4. Execution:

    • The Flutter app loads a texture (as shown in utils.dart and image_widget.dart) and renders it via a custom paint widget.
    • Although the uniform is bound with the intended matrix, the output behaves as if no uniform was passed, resulting in incorrect texture mapping.

Behavior

  • Expected: The value set in the Dart code should affect the vertex shader, producing correct texture coordinates and a properly rendered image.
    ScreenshotImage
  • Actual: The shader always defaults to mat4(0.0), ignoring the provided uniform value and leading to unexpected render output.
    ScreenshotImage

Additional Details

  • Flutter version: I'm currently working with Flutter version 3.27.4. Due to an existing Flutter issue Impeller GPU calls fail to render on Windows (GLES) #160948, I am unable to test this problem on later versions.
  • Platform specific behavior: Testing on macOS did not reveal this problem - the uniform is passed correctly on macOS for both Flutter version 3.27.4 and on the master branch.

Activity

  1. danagbemava-nc commented on Mar 3, 2025

    @danagbemava-nc
    Member

    Reproducible using the code sample in the repo shared above. On stable 3.27.4, it renders a red screen, but on stable 3.29.0 and master, it just shows a black screen.

    flutter doctor -v
    [✓] Flutter (Channel stable, 3.29.0, on Microsoft Windows [Version 10.0.26100.2894], locale en-US) [786ms]
        • Flutter version 3.29.0 on channel stable at C:\Users\Deana\fvm\versions\stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 35c388afb5 (3 weeks ago), 2025-02-10 12:48:41 -0800
        • Engine revision f73bfc4522
        • Dart version 3.7.0
        • DevTools version 2.42.2
    
    [✓] Windows Version (11 Home 64-bit, 24H2, 2009) [4.7s]
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [4.0s]
        • Android SDK at C:\Users\Deana\AppData\Local\Android\sdk
        • Platform android-35, build-tools 34.0.0
        • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web [179ms]
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.2) [177ms]
        • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
        • Visual Studio Community 2022 version 17.8.34322.80
        • Windows 10 SDK version 10.0.22621.0
    
    [✓] Android Studio (version 2023.1) [44ms]
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    
    [✓] VS Code (version 1.97.2) [39ms]
        • VS Code at C:\Users\Deana\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.104.0
    
    [✓] Connected device (3 available) [463ms]
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2894]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 133.0.6943.142
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 133.0.3065.82
    
    [✓] Network resources [834ms]
        • All expected network resources are available.
    
    • No issues found!
    
    [!] Flutter (Channel master, 3.30.0-1.0.pre.427, on Microsoft Windows [Version 10.0.26100.2894], locale en-US) [5.9s]
        • Flutter version 3.30.0-1.0.pre.427 on channel master at C:\Users\Deana\fvm\versions\master
        ! Warning: `flutter` on your path resolves to C:\Users\Deana\fvm\versions\stable\bin\flutter, which is not inside your current Flutter SDK checkout at C:\Users\Deana\fvm\versions\master. Consider adding C:\Users\Deana\fvm\versions\master\bin to the front of your path.  
        ! Warning: `dart` on your path resolves to C:\Users\Deana\fvm\versions\stable\bin\dart, which is not inside your current Flutter SDK checkout at C:\Users\Deana\fvm\versions\master. Consider adding C:\Users\Deana\fvm\versions\master\bin to the front of your path.        
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ccdf0c2e3b (2 hours ago), 2025-03-03 01:16:37 -0500
        • Engine revision ccdf0c2e3b
        • Dart version 3.8.0 (build 3.8.0-133.0.dev)
        • DevTools version 2.43.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Windows Version (11 Home 64-bit, 24H2, 2009) [4.7s]
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [3.9s]
        • Android SDK at C:\Users\Deana\AppData\Local\Android\sdk
        • Platform android-35, build-tools 34.0.0
        • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web [246ms]
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.2) [243ms]
        • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
        • Visual Studio Community 2022 version 17.8.34322.80
        • Windows 10 SDK version 10.0.22621.0
    
    [✓] Android Studio (version 2023.1) [47ms]
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    
    [✓] VS Code (version 1.97.2) [42ms]
        • VS Code at C:\Users\Deana\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.104.0
    
    [✓] Connected device (3 available) [524ms]
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2894]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 133.0.6943.142
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 133.0.3065.82
    
    [✓] Network resources [1,731ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  2. added
    engineflutter/engine related. See also e: labels.
    platform-windowsBuilding on or for Windows specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    e: impellerImpeller rendering backend issues and features requests
    and removed
    in triagePresently being triaged by the triage team
    on Mar 3, 2025
  3. added
    P3Issues that are less important to the Flutter project
    on Mar 10, 2025
  4. moved this to 🤔 Needs Triage in Flutter GPUon Mar 10, 2025
  5. lijialin9 commented on Jun 22, 2026

    @lijialin9

    On Windows, launching with --enable-impeller causes CustomPainterto render nothing at all (works fine without Impeller), including basic drawColor and GPU-based rendering. My Flutter version is as follows:
    Flutter 3.45.0-1.0.pre-595 • channel main
    Framework • revision 8c3e681 (19 hours ago) • 2026-06-21 15:53:38 -0400
    Engine • hash e638968b39f342d68f7c1e83b50807f069ab9fc2 (revision 8c3e681) (19 hours ago) • 2026-06-21 19:53:38.000Z
    Tools • Dart 3.13.0 (build 3.13.0-228.0.dev) • DevTools 2.59.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecte: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter-gpufound in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    • Status
      🤔 Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions