This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot understand 16-bit arithmetic result of Mali Offline Complier

I have a very simple shader. Basiclly, it just sample a texture and do a cut off based on the a scalar. All variables are medium percision.

#version 310 es

precision mediump float;
precision highp int;
#define HLSLCC_ENABLE_UNIFORM_BUFFERS 1
#if HLSLCC_ENABLE_UNIFORM_BUFFERS
#define UNITY_UNIFORM
#else
#define UNITY_UNIFORM uniform
#endif
#define UNITY_SUPPORTS_UNIFORM_LOCATION 1
#if UNITY_SUPPORTS_UNIFORM_LOCATION
#define UNITY_LOCATION(x) layout(location = x)
#define UNITY_BINDING(x) layout(binding = x, std140)
#else
#define UNITY_LOCATION(x)
#define UNITY_BINDING(x) layout(std140)
#endif
uniform 	mediump float _Cutoff;
UNITY_LOCATION(0) uniform mediump sampler2D _MainTex;
in highp vec2 vs_TEXCOORD0;
layout(location = 0) out mediump vec4 SV_Target0;
mediump vec4 u_xlat16_0;
bool u_xlatb0;
mediump float u_xlat16_1;
void main()
{
    u_xlat16_0 = texture(_MainTex, vs_TEXCOORD0.xy);
    u_xlat16_1 = u_xlat16_0.w + (-_Cutoff);
    SV_Target0 = u_xlat16_0;
#ifdef UNITY_ADRENO_ES3
    u_xlatb0 = !!(u_xlat16_1<0.0);
#else
    u_xlatb0 = u_xlat16_1<0.0;
#endif
    if(u_xlatb0){discard;}
    return;
}

Why does Mali Offline Complier show 16-bit arithmetic zero?

Parents
  • HI TBWorkss, 

    The behaviour you are seeing is mostly a reporting artefact of how we calculate the number of 16-bit operations.

    We only count pure arithmetic instructions (interpolation, texturing and blending not included), of which this shader has very few. We also only count instructions that are entirely 16-bit (16-bit input, 16-bit data processing, 16-bit output). The discard instruction only has a 32-bit data path, so will include implicit widening of a 16-bit input. This has no impact on performance, but does mean it doesn't show up in the stats. 

    HTH, 
    Pete 

Reply
  • HI TBWorkss, 

    The behaviour you are seeing is mostly a reporting artefact of how we calculate the number of 16-bit operations.

    We only count pure arithmetic instructions (interpolation, texturing and blending not included), of which this shader has very few. We also only count instructions that are entirely 16-bit (16-bit input, 16-bit data processing, 16-bit output). The discard instruction only has a 32-bit data path, so will include implicit widening of a 16-bit input. This has no impact on performance, but does mean it doesn't show up in the stats. 

    HTH, 
    Pete 

Children