Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Internal error communicating with the shader compiler process...

Discussion in 'Shaders' started by JASON01, Jul 7, 2015.

  1. JASON01

    JASON01

    Joined:
    Apr 30, 2014
    Posts:
    4
    I get this error when compiling the following shader targeting Android:

    Code (CSharp):
    1.  
    2. Shader "Hidden/Highlighted/Blur"
    3. {
    4.     Properties
    5.     {
    6.         [HideInInspector] _MainTex ("", 2D) = "" {}
    7.         [HideInInspector] _Intensity ("", Range (0.25,0.5)) = 0.3
    8.     }
    9.    
    10.     SubShader
    11.     {
    12.         Pass
    13.         {
    14.             ZTest Always
    15.             Cull Off
    16.             ZWrite Off
    17.             Lighting Off
    18.             Fog { Mode Off }
    19.            
    20.             CGPROGRAM
    21.             #pragma vertex vert
    22.             #pragma fragment frag
    23.             #pragma fragmentoption ARB_precision_hint_fastest
    24.            
    25.             #include "UnityCG.cginc"
    26.            
    27.             uniform sampler2D _MainTex;
    28.             uniform half4 _MainTex_TexelSize;
    29.            
    30.             uniform half _HighlightingBlurOffset;
    31.             uniform half _Intensity;
    32.            
    33.             struct v2f
    34.             {
    35.                 float4 pos : POSITION;
    36.                 half2 uv[4] : TEXCOORD0;    // 8 to add straight directions
    37.             };
    38.            
    39.             v2f vert (appdata_img v)
    40.             {
    41.                 // Shader code optimized for the Unity shader compiler
    42.                 v2f o;
    43.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    44.                 half2 offs = _HighlightingBlurOffset * _MainTex_TexelSize.xy;
    45.                
    46.                 // Diagonal directions
    47.                 o.uv[0].x = v.texcoord.x - offs.x;
    48.                 o.uv[0].y = v.texcoord.y - offs.y;
    49.                
    50.                 o.uv[1].x = v.texcoord.x + offs.x;
    51.                 o.uv[1].y = v.texcoord.y - offs.y;
    52.                
    53.                 o.uv[2].x = v.texcoord.x + offs.x;
    54.                 o.uv[2].y = v.texcoord.y + offs.y;
    55.                
    56.                 o.uv[3].x = v.texcoord.x - offs.x;
    57.                 o.uv[3].y = v.texcoord.y + offs.y;
    58.                
    59.                 /*
    60.                 // Straight directions
    61.                 o.uv[4].x = v.texcoord.x - offs.x;
    62.                 o.uv[4].y = v.texcoord.y;
    63.                
    64.                 o.uv[5].x = v.texcoord.x + offs.x;
    65.                 o.uv[5].y = v.texcoord.y;
    66.                
    67.                 o.uv[6].x = v.texcoord.x;
    68.                 o.uv[6].y = v.texcoord.y - offs.y;
    69.                
    70.                 o.uv[7].x = v.texcoord.x;
    71.                 o.uv[7].y = v.texcoord.y + offs.y;
    72.                 */
    73.                
    74.                 return o;
    75.             }
    76.            
    77.             half4 frag(v2f i) : COLOR
    78.             {
    79.                 int start = 0;
    80.                 int end = 4;
    81.                
    82.                 half4 color1 = tex2D(_MainTex, i.uv[start]);
    83.                 fixed4 color2;
    84.                 for (int n = start + 1; n < end; n++)
    85.                 {
    86.                     color2 = tex2D(_MainTex, i.uv[n]);
    87.                     color1.rgb = max(color1.rgb, color2.rgb);
    88.                     color1.a += color2.a;
    89.                 }
    90.                
    91.                 color1.a *= _Intensity;
    92.                 return color1;
    93.             }
    94.             ENDCG
    95.         }
    96.     }
    97.    
    98.     Fallback off
    99. }
    100.  
    Debug Error!

    Tools64\UnityShaderCompiler.exe

    R6010
    -abort() has been called


    I'm using Unity 5.1.0f3

    Is this a bug?
     
  2. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
    Yes, it is.. I've experienced this as well with a compute shader. For some reason, some loops crash it... while almost identical ones don't. I suspect it somehow gets stuck in an infinite loop while parsing the code.
    Either way, in your case the loop can be easily unrolled. I don't know why, but the HLSL compiler does not want to unroll this loop by default. So remember to always mark loops that you want to get unrolled explicitly with the [unroll] attribute, which should improve the performance in this case and hopefully get rid of the crash on compile.
     
  3. JASON01

    JASON01

    Joined:
    Apr 30, 2014
    Posts:
    4
    Thanks I'll use that in the future. I've since updated to version 5.1.1p3 and this problem is fixed in that version.