Skip to content

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

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.

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
    No fields configured for issues without a type.

    Projects

    Status
    🤔 Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions