Search Issue Tracker
Fixed in 5.2.0
Votes
0
Found in
5.0.1p3
Issue ID
693714
Regression
No
[Shaders][Metal] Incorrectly compiled metal shader, missing matrix type cast
At some points compiled metal code doesn't have matrix typecast function. For example, float3x3 -> half3x3.
Project Steps:
1. Open project "MetalCompile" (Attached by LukasC);
2. Open scene "Test".
3. Build & Run.
4. When xCode project starts, you should get some metal compilation errors.
Steps without building project:
1. Select shader "NewShader".
2. Click compile (Only for metal).
3. Goto line 2116, you should see smth like:
...
float3x3 tmpvar_29;
half3x3 tmpvar_30;
tmpvar_30[0].x = tmpvar_27.x;
tmpvar_30[0].y = tmpvar_28.x;
tmpvar_30[0].z = tmpvar_25.x;
tmpvar_30[1].x = tmpvar_27.y;
tmpvar_30[1].y = tmpvar_28.y;
tmpvar_30[1].z = tmpvar_25.y;
tmpvar_30[2].x = tmpvar_27.z;
tmpvar_30[2].y = tmpvar_28.z;
tmpvar_30[2].z = tmpvar_25.z;
tmpvar_29 = tmpvar_30;
...
4. You should notice that "tmpvar_29 = tmpvar_30" that this matrices are in different types.
In metal this type conversion requires cast, however opengles20 doesn't require it.
As I know unity generates metal shaders from openglES20 shaders, so this could explain why this bug happens.
But the strange thing is that, if you would use miss-matched matrix types normally in shader:
float3x3 mat1;
half3x3 mat2;
mat2 = mat1;
In metal it will be compiled correctly.
float3x3 mat1;
half3x3 mat2;
mat2 = _xlcast_half4x4(mat1);
So it means this bug is more complicated and caused by multiple factors.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Tile Palette selected dropdown text does not update when palette is renamed
- ArgumentException thrown and reference to Template gets unset when opening UXML file after editing referenced Template in Play mode
- [iOS][WebGL] Player freezes when multiple properties of a VisualElement are changed at the same time
- Warning 'GetControlID at event ValidateCommand returns a controlID different from the one in the Layout event' is logged when undoing the deletion of an Edited Freeform 2D Light
- ShadowCaster2D breaks on certain Rotation positions when Casting Source is set to PolygonCollider2D
Add comment