Shader compiler issue with any() use on iOS

We target MSL 1.1 on iOS9, and are seeing non-equivalence to the following. The upper code gens bad pixels on iOS but is the more efficient form. macOS (on AMD 5500m) is fine. I will log this to Feedback Assistant, but also here too.

The code was also compiled with -O2. So could be an iOS optimizer bug.

Code Block
#if 1
if ( all( greaterThanEqual(pos.xy, v_clip.xy )) &&
all( lessThanEqual(pos.xy, v_clip.zw )) )
#else
if ( pos.x >= v_clip.x && pos.x <= v_clip.z &&
pos.y >= v_clip.y && pos.y <= v_clip.w )
#endif
This is codgen out of spirv-cross. Mac and iOS codegen is the same for this chunk.
These are on iOS
With #1, this doesn't work:
fsmain_out out = {};
float4 color = float4(0.0);
float2 pos = gl_FragCoord.xy;
bool _35 = all(pos >= in.v_clip.xy);
bool _43;
if (_35)
{
_43 = all(pos <= in.v_clip.zw);
}
else
{
_43 = _35;
}
if (_43) ...
With #0, this works
fsmain_out out = {};
float4 color = float4(0.0);
float2 pos = gl_FragCoord.xy;
bool _38 = pos.x >= in.v_clip.x;
bool _47;
if (_38)
{
_47 = pos.x <= in.v_clip.z;
}
else
{
_47 = _38;
}
bool _56;
if (_47)
{
_56 = pos.y >= in.v_clip.y;
}
else
{
_56 = _47;
}
bool _65;
if (_56)
{
_65 = pos.y <= in.v_clip.w;
}
else
{
_65 = _56;
}
if (_65)

Replies

Thanks for reporting this issue. Can you please share the feedback assistant ID that you created for this?
  • Thanks for filing that - we shall take a look.

Add a Comment