Search Unity

Feedback Array in vertex output not support for metal api?

Discussion in 'Shaders' started by jayatubi, May 17, 2019.

  1. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    I'm working on 2018.3.10f1 and I have such a vertex output struct within an array field which works well on dx and opengl es3 platform:

    Code (csharp):
    1.  
    2. struct v2f
    3. {
    4.     FLOAT4 vertex : SV_POSITION;
    5.     FLOAT4 color : COLOR;
    6.     FLOAT2 texcoord : TEXCOORD0;
    7.     FLOAT4 light[4] : TEXCOORD1;
    8. };
    9.  
    However, I got a wrong result on mac with metal api selected. I checked the generated shader code which only contains one of the array elements such as:

    Code (csharp):
    1.  
    2. struct Mtl_FragmentIn
    3. {
    4.     float4 COLOR0 [[ user(COLOR0) ]] ;
    5.     float2 TEXCOORD0 [[ user(TEXCOORD0) ]] ;
    6.     float4 TEXCOORD1 [[ user(TEXCOORD1) ]] ;
    7. };
    8.  
    If I expand the field manually such as:
    Code (csharp):
    1.  
    2. struct v2f
    3. {
    4.     FLOAT4 vertex : SV_POSITION;
    5.     FLOAT4 color : COLOR;
    6.     FLOAT2 texcoord : TEXCOORD0;
    7.     FLOAT4 light_0 : TEXCOORD1;
    8.     FLOAT4 light_1 : TEXCOORD2;
    9.     FLOAT4 light_2 : TEXCOORD3;
    10.     FLOAT4 light_3 : TEXCOORD4;
    11. };
    12.  
    It could generate the right code:
    Code (csharp):
    1.  
    2. struct Mtl_FragmentIn
    3. {
    4.     float4 COLOR0 [[ user(COLOR0) ]] ;
    5.     float2 TEXCOORD0 [[ user(TEXCOORD0) ]] ;
    6.     float4 TEXCOORD1 [[ user(TEXCOORD1) ]] ;
    7.     float4 TEXCOORD2 [[ user(TEXCOORD2) ]] ;
    8.     float4 TEXCOORD3 [[ user(TEXCOORD3) ]] ;
    9.     float4 TEXCOORD4 [[ user(TEXCOORD4) ]] ;
    10. };
    11.  
    Is this by design that array field in vertex output won't be auto expand when targeting metal api? Or could this be a bug?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    Hi!
    This looks like a bug. Can you please report it?
     
  3. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143