Search Unity

Feedback Same keyword in different Subgraph doesn't seem to be recognized

Discussion in 'Shader Graph' started by bitinn, Jan 4, 2021.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi, I assume this is known may even be fixed in SG 10.x, but for SG 7.x (2019.4 LTS):

    - it seems even if we use the exact same keyword in 2 different subgraph, the shader variant still explode as if they are different keywords.


    I can certainly up the shader variant limit, but I am at 65536 (2^16):

    - with 5 boolean keywords in 2 subgraphs.
    - and 2 enum keywords each with 5 entries.
    - my main graph now says I am over variant limits.
    - but if I put 2 of the same subgraph, then everything is fine.

    But in either case, our main graph really only need 5 boolean + 2 * 5 enums in total, which should be below variant limit.


    I guess I don't fully understand know keyword in subgraph works with main graph:

    - I would hope it does nothing unless the main graph defines the keyword.
    - which means the variant limit should only count the main graph (we need to copy them to main graph anyway).

    Evidently, it wasn't the case?
     
  2. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    The shader graph also become terribly slow to operate, by default, an empty HDRP Lit node has:

    - 114 variants if you skip unused shader_features, and 99.72K variants if you don't.

    With just the keywords added, without ANY connection at all, the shader graph becomes:

    - 114 variants if you skip unused shader_features, but now 159.54M variants if you don't.

    With all the connection linked:

    - 435 variants if you skip unused shader_features, but now 319.08M variants if you don't.

    I don't necessarily know how SG compile and strip its shader_features, but I have a strong feeling the time increase (from a few seconds to almost a minute), the compile time increase is closer to an exponential increase than a linear increase.

    I know SG has its own continuous integration tests, does it have performance benchmark on 7.x??
     
  3. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    To prove how slow it is, here is a pretty simply graph:

    shader-graph-01.png


    Here is how long it took to compile a single connection change on HDRP master node (around 20 seconds before unity ui unfreeze.)

    shader-graph-02.png

    Saving asset takes even longer:

    shader-graph-03.png

    We REALLY need a disable auto-compile option, even if we can't get any compile speed improvement in SG 7.x
     
    Last edited: Jan 4, 2021