Search Unity

Build crashes when shader debuggers attach

Discussion in 'Shaders' started by Deivore, Feb 9, 2021.

  1. Deivore

    Deivore

    Joined:
    Oct 21, 2014
    Posts:
    5
    I'm having this happen now with multiple projects where I was once able to debug shaders in visual studio. I'm not sure if I installed or uninstalled something, but I've also tried with RenderDoc and it has the same results. Visual studio crashes look like image attached (apologies for phone pic as the graphics debugger is consuming my print screen input) 20210208_222716.jpg

    I've been following the guide here and installed the listed components of MSVS community 2019 which I'm using for debugging.

    The only instruction I can't follow so far is the mandate to use "#pragma enable_d3d11_debug_symbols", which gives an error I don't understand:

    Shader error in 'Sprites/ImpactCycleShader_Simple': Compilation failed (other error) '' at line 28 (on d3d11)

    Compiling Fragment program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    Disabled keywords: FOG_LINEAR FOG_EXP FOG_EXP2 UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30


    Here is the stripped down version of the shader providing this error:

    Code (CSharp):
    1. Shader "Sprites/ImpactCycleShader_Simple"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    7.  
    8.         _Cycle1 ("Cycle1", Color) = (1,1,1,1)
    9.         _Cycle2 ("Cycle2", Color) = (1,1,1,1)
    10.         _Cycle3 ("Cycle3", Color) = (1,1,1,1)
    11.         _Cycle4 ("Cycle4", Color) = (1,1,1,1)
    12.     }
    13.     SubShader
    14.     {
    15.         Tags
    16.         {
    17.             "Queue" = "Transparent"
    18.         }
    19.  
    20.         Cull Off
    21.         Lighting Off
    22.         ZWrite Off
    23.         Blend SrcAlpha OneMinusSrcAlpha
    24.         ColorMask RGB
    25.  
    26.         Pass
    27.         {
    28.             CGPROGRAM
    29.             #pragma vertex Vert
    30.             #pragma fragment Frag
    31.             #pragma multi_compile_fog
    32.             #pragma enable_d3d11_debug_symbols
    33.             #include "UnityCG.cginc"
    34.  
    35.             sampler2D _MainTex;
    36.             float4 _MainTex_ST;
    37.  
    38.             fixed4 _Color;
    39.             fixed4 _Cycle1;
    40.             fixed4 _Cycle2;
    41.             fixed4 _Cycle3;
    42.             fixed4 _Cycle4;
    43.  
    44.             struct appdata
    45.             {
    46.                 float4 vertex : POSITION;
    47.                 float2 uv : TEXCOORD0;
    48.                 fixed4 color : COLOR;
    49.             };
    50.  
    51.             struct v2f
    52.             {
    53.                 float2 texcoord : TEXCOORD0;
    54.                 UNITY_FOG_COORDS(1)
    55.                 float4 vertex : SV_POSITION;
    56.                 float4 color : COLOR;
    57.             };
    58.  
    59.             v2f Vert(appdata v)
    60.             {
    61.                 v2f o;
    62.                 o.vertex = UnityObjectToClipPos(v.vertex);
    63.                 o.texcoord = TRANSFORM_TEX(v.uv, _MainTex);
    64.                 o.color = v.color;
    65.                 UNITY_TRANSFER_FOG(o, o.vertex);
    66.                 return o;
    67.             }
    68.  
    69.             fixed4 Frag(v2f IN) : SV_Target
    70.             {
    71.                 fixed4 inColor = tex2D(_MainTex, IN.texcoord);
    72.                 int paletteIndex = 0;
    73.                 int tempDetectedValue = 0;
    74.                 float maxColorDistance = 0.01f;
    75.  
    76.                 //pick a new color based on input time
    77.                 int intTime = _Time.y * 1000;
    78.                 int cycleIndex = (intTime) % 4;
    79.                 fixed4 cycleColor = (1, 1, 1, 1);
    80.  
    81.                 cycleColor = cycleIndex == 0 ? _Cycle1 : cycleColor;
    82.                 cycleColor = cycleIndex == 1 ? _Cycle2 : cycleColor;
    83.                 cycleColor = cycleIndex == 2 ? _Cycle3 : cycleColor;
    84.                 cycleColor = cycleIndex == 3 ? _Cycle4 : cycleColor;
    85.  
    86.                 cycleColor.a = inColor.a;
    87.                 return cycleColor;
    88.                 //return inColor;
    89.             }
    90.             ENDCG
    91.         }
    92.     }
    93.     Fallback "Transparent/VertexLit"
    94. }
    95.  
    (there doesn't seem to be a shader language option so I chose C#)

    Any advice y'all can give is very much appreciated!! Solving shader problems is much easier with a debugger.