Search Unity

Shader Compiler bailing out with just a few shader features.

Discussion in 'Shaders' started by michal_gjk, Aug 21, 2016.

  1. michal_gjk

    michal_gjk

    Joined:
    Aug 13, 2016
    Posts:
    69
    Below I pasted a minimal shader which always causes the compiler to fail even though it has just about as many shader_fearures as the standard shader.

    If I count correctly there should be: 3 * 4 * 3 * 3 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 27648 variants ?

    Further more compiler never utilizes more than 30% of the CPU (no I don't have a tri-core ;). At the same time there's plenty of free ram and hdd is doing literally nothing so I wonder what's preventing the compiler from running 3 times faster.

    Regardless. Can I ask anyone to try and compile this shader, please?
    Yes, it'll take quite some time but because it is so minimal perhaps it'll help unity to diagnose why the compilation fails and also why is it using so little of the cpu before it fails.

    Win10 - 5.4.0f3; 5.4.0p1; 5.4.0p2. Didn't check older versions. Target platform: android and win x64

    The errors I usually get are as follows:

    Protocol error - failed to read correct magic number
    or
    Internal error communicating with the shader compiler process
    or
    Shader error in '': Parse error: syntax error at line 1 (no there's no BOM - doublechecked)


    Code (csharp):
    1. Shader "Custom/Dev Test" {
    2.   Properties {
    3.     _MainTex("Albedo", 2D) = "white" {}
    4.   }
    5.   SubShader {
    6.     Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    7.     LOD 200
    8.     CGPROGRAM
    9.  
    10.     // Protocol error - failed to read correct magic number
    11.     // Internal error communicating with the shader compiler process
    12.     // Shader error in '': Parse error: syntax error at line 1 (no there's no BOM - doublechecked)
    13.     // no rhyme or reason
    14.  
    15.     #pragma target 3.0
    16.     #pragma shader_feature _PPP _WWW _QQQ
    17.     #pragma shader_feature _ _AAA _CCC _VVV
    18.     #pragma shader_feature _ _OOO _YYY
    19.     #pragma shader_feature _ _FOO _BOO
    20.     #pragma shader_feature _NOTHING_OFF
    21.     #pragma shader_feature _SOMETHING_OFF
    22.     #pragma shader_feature _SOMEMAP
    23.     #pragma shader_feature _OTHERMAP
    24.     #pragma shader_feature _FEATURE_A
    25.     #pragma shader_feature _FEATURE_B
    26.     #pragma shader_feature _FEATURE_C
    27.     #pragma shader_feature _FEATURE_D
    28.  
    29.     // 3 * 4 * 3 * 3 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 27648 variants
    30.  
    31.     #pragma surface surf Lambert
    32.  
    33.     sampler2D _MainTex;
    34.  
    35.     struct Input {
    36.         float2 uv_MainTex;
    37.     };
    38.  
    39.     void surf(Input IN, inout SurfaceOutput o) {
    40.         o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
    41.     }
    42.     ENDCG
    43.     } // SubShader
    44.  
    45.     FallBack "Diffuse"
    46. }
    Thanks in advance.
     
    Last edited: Aug 21, 2016
  2. michal_gjk

    michal_gjk

    Joined:
    Aug 13, 2016
    Posts:
    69
  3. michal_gjk

    michal_gjk

    Joined:
    Aug 13, 2016
    Posts:
    69
    BTW. Could you guys spare a vote on this issue? Assuming Unity even pays any attention.

    It would be good to be able to write highly customizable shaders without having to chop them up into many simpler ones.