Skip to content

[Impeller] SkSL texture scaling parameter is not inserted correctly when texture argument is expression. #139017

@vendik

Description

@vendik

Is there an existing issue for this?

Steps to reproduce

Compile the following fragment shader for an Android device:

#include <flutter/runtime_effect.glsl>

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_screenSize;
uniform vec2 u_texelSize;
uniform sampler2D u_texture;

out vec4 o_fragColor;

void main() {
  vec2 screenPos = FlutterFragCoord();
  vec2 textureCoords = screenPos / u_screenSize;

  o_fragColor = texture(u_texture, textureCoords + u_texelSize);
}

Expected results

RenderDoc inspection of the shader should result in this:

o_fragColor_S1_c0 = texture(uTextureSampler_0_S1, mat3x2(umatrix_S1_c0_c0) * vec3(u_texture_size_S1_c0 * (_7_textureCoords + u_texelSize_S1_c0), 1.0), -0.475);

Actual results

RenderDoc inspection of the shader actually results in this (notice the lack of parentheses around _7_textureCoords + u_texelSize_S1_c0 :

o_fragColor_S1_c0 = texture(uTextureSampler_0_S1, mat3x2(umatrix_S1_c0_c0) * vec3(u_texture_size_S1_c0 * _7_textureCoords + u_texelSize_S1_c0, 1.0), -0.475);

This results in _7_textureCoords getting multiplied first and then added, which is incorrect.

Code sample

Code sample
#include <flutter/runtime_effect.glsl>

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_screenSize;
uniform vec2 u_texelSize;
uniform sampler2D u_texture;

out vec4 o_fragColor;

void main() {
  vec2 screenPos = FlutterFragCoord();
  vec2 textureCoords = screenPos / u_screenSize;

  o_fragColor = texture(u_texture, textureCoords + u_texelSize);
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 6.3.9600], locale en-GB)
    • Flutter version 3.16.0 on channel stable at C:\Users\Admin\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (11 days ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[X] Windows Version (Unable to determine Windows version (command `ver` returned Microsoft Windows [Version 6.3.9600]))

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.3)
    • 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.6+0-b2043.56-10027231)

[√] VS Code (version 1.77.3)
    • VS Code at C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 6.3.9600]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 109.0.5414.168

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requestsr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions