'&' in 2019.2 compiled shader, not in 2018.2

In a super simple shader shown below

Unity 2018.2.6 will compile the line :-

float test = (i < 0) + (i> .999);
As tmpvar_3.w = (float((i_1 < 0.0)) + float((i_1 > 0.999)));

But 2019.2.2 (and 2019.2.6) will make it

u_xlatb0.x = _Color.w<0.0;
u_xlatb0.y = 0.999000013<_Color.w;
u_xlati0.xy = ivec2((ivec2(u_xlatb0.xy) * -1) & ivec2(1, 1));

A more complex shader that does a similar thing causes issues on OpenGLES2 devices (Android logcat shows something like ‘&’ : supported in pack/unpack shaders only) when build with 2019.2.2 (or 2019.2.6) but is fine in 2018.2.6. (I haven’t had chance to test this simple shader in Android yet)

Is this expected, or something that should be flagged as a bug?

Shader "super simple shader" {
    Properties{
        _Color("Main Color", COLOR) = (1,1,1,1)
    }

        SubShader{
           Pass {
              CGPROGRAM

              #pragma vertex vert

              #pragma fragment frag

               fixed4 _Color;
            float4 vert(float4 vertexPos : POSITION) : SV_POSITION
            {
                 return UnityObjectToClipPos(vertexPos);
            }

            float4 frag(void) : COLOR
            {
               float i = _Color.a;
             float test = (i < 0) + (i > .999);
               return float4(1.0, 0.0, 0.0, test);
            }

            ENDCG
            }
    }
}

Upon further googling. Seems the problem is bitwise operators (of which the ‘&’ is) are not supported in anything lower than shader model 4. So there is indeed a bug as Unity 2019 shouldn’t really be compiling shaders to shadermodel 4 if targeting OpenglES2. Even adding a #pramga target of 2 in there doesn’t fix it. Will submit it.

A target of 2 isn’t really for OpenGLES 2.0. Anything less than a target of 3.5 is GLES 2.0, but not all GLES 2.0 is equal due to OpenGL being kind of a sliding scale.

If you need Shader Model 4.0 or support for & you probably need #pragma target 4.0 or maybe 3.5 (which pushes it to GLES 3.0).

https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html

Ah sorry, I may not have explained properly, so what I want is to just target OpenGLES 2.0. Not shader model 4.

So OpenGLES 2.0 is the only Graphics API I have set in the Player Settings for Android.

But Unity 2019.2 is compiling the example shader I included using the & bitwise operator. Which is shader model 4+ only. Which I think means it wont work on GLES 2.0 (and sure enough I get a crash on Android with it).

Unity 2018.2 compiles this same shader in a different way that avoids using bitwise operators. So all is fine.

It seems to me Unity 2019 is being norty. Have raised it as a bug.

Hi!
Please report a bug.
We removed an older shader compiler that was used for OpenGL ES 2 at some point, and now it’s using a different one.