Shader Compiler Error when SV_POSITION is a Half4 on Mali GPUs

I found a very specific shader error when testing a shader on android, causing it to render magenta on the device.

5059379--496937--upload_2019-10-12_12-41-28.png

I tested on 3 devices: two Galaxy S8 with different GPUs (Mali-G71 and Adreno 540), and a Galaxy S7 with a Mali-T880. The shader works fine on Adreno, but doesn’t work on the Mali devices.

Here’s a test shader which you can use to reproduce the error. In order to trigger the issue, you need 3 or more TEXCOORDs in your V2F and have SV_POSITION be declared as a Half4.

Shader "Unlit/testHalf"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                half4 vertex : POSITION;
            };

            struct v2f
            {
                half2 uv : TEXCOORD0;
                half2 uv1 : TEXCOORD1;
                half2 uv2 : TEXCOORD2;
                half4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

            half4 frag (v2f i) : SV_Target
            {
                half4 col = half4(1,1,1,1);
                return col;
            }
            ENDCG
        }
    }
}

Changing SV_POSITION to a float4 or having 2 or less TEXCOORDs solves the issue:

5059379--496940--upload_2019-10-12_12-41-59.png

but this is boggling my mind. What could be the cause for this behaviour?

Hi!
Can you please report a bug so that we can investigate this?
Thanks!

Just hit this same issue in 2019.4.6f1, it seems having 2 TEXCOORDS and SV_POSITION suddenly introduces a requirement for gl_ClipDistance in the compiled shader that breaks some compilers, in my case, the Apple simulator.

Was a bug ever recorded for this and fixed, or am I seeing something similar but unrelated?

I don’t think I’ve seen this reported.