Search Issue Tracker

Fixed in 2022.2.X

Votes

10

Found in

2019.4

2019.4.29f1c1

2020.3

2021.1

2021.2

2022.1

Issue ID

1363451

Regression

Yes

[Android] [Shader System] FPS drop on some Android devices caused by shader compiler

Shader System

-

How to reproduce:
1. Open the attached user's project 'weilaicheng_2019_4.zip'
2. Build And Run on Android
3. After 15 seconds observe the second FPS counter at the top left of the device screen (average FPS for 15 seconds)

Expected results: The average FPS is 21.7 (different on each device)
Actual results: The average FPS is 20.6 (different on each device)

Reproducible with: 2019.4.31f1, 2020.3.20f1, 2021.1.24f1, 2021.2.0b15, 2022.1.0a12

Reproducible with:
VLNQA00288, Samsung Galaxy J7 (SM-J730F), Android 8.1.0, CPU: Exynos 7 Octa 7870, GPU: Mali-T830
Huawei - (ELS-NX9), Android 10, CPU: NOT FOUND, GPU: Mali-G76
VLNQA00078, Motorola Nexus 6 (Nexus 6), Android 7.1.1, CPU: Snapdragon 805 APQ8084AB, GPU: Adreno (TM) 420
VLNQA00109 - Xiaomi Mi Note Pro (MI NOTE Pro), OS: 7.0.0, CPU: Snapdragon 810 MSM8994, GPU: Adreno 430

Not reproducible with:
VLNQA00022, Xiaomi Redmi Note 3 (Redmi Note 3), Android 6.0.1, CPU: Snapdragon 617 MSM8952, GPU: Adreno (TM) 510
N/A, Huawei - (NOH-NX9), Android 10, CPU: NOT FOUND, GPU: Mali-G78
VLNQA00001, Google Pixel 2 (Pixel 2), Android 11, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540
VLNQA00316, Samsung Galaxy Note10 (SM-N970F), Android 9, CPU: Exynos 9 Series 9825, GPU: Mali-G76
VLNQA00264, Samsung Galaxy S10+ (SM-G975F), Android 10, CPU: NOT FOUND, GPU: Mali-G76
VLNQA00121 - Samsung Galaxy S9 (SM-G960F), OS: 9.0.0, CPU: Exynos 9 Series 9810, GPU: Mali-G72
VLNQA00006 - Samsung Galaxy S7 (SM-G930F), OS: 8.0.0, CPU: Exynos 8 Octa (8890), GPU: Mali-T880
VLNQA00277 - Asus ROG Phone (ASUS_Z01QD), OS: 8.1.0, CPU: Snapdragon 845 SDM845, GPU: Adreno 630
VLNQA00225, Qualcomm null (SDM845 for arm64), Android 8.1.0, CPU: Snapdragon 845 SDM845, GPU: Adreno (TM) 630

Notes:
- The expected and actual FPS can be compared with a build from Unity 2018.4.27f1 (shader compiler does not cause an issue in this version)

  1. Resolution Note (fix version 2022.2):

    Our shader compiler (or rather Microsoft's FXC that we use) doesn't treat floating point literals with the 'h' suffix as half precision (e.g. "0.5h"). Please use constructor-style casts instead (e.g. "half(0.5)").

    To ensure correct sampler precision, please use DX11 style separate texture and sample declaration using the half data type there. E.g:
    SamplerState sampler_MainTex;
    Texture2D<half4> _MainTex;
    We used to have a system in the shader translation that tried to automatically propagate the sampler precision to following calculations. However, it caused more trouble than it solved so we had to remove it. Please use modern syntax above with appropriate type information for proper half precision utilization.
    As a further solution to this bug we're fixing the UNITY_DECLARE_TEX2D_HALF etc macros use the explicit typing syntax so that any shaders using these helpers will get proper precision information on mobile targets.

Add comment

Log in to post comment