Search Unity

ComputeShader or buffers invalidated by the editor on certain events, how to avoid or detect?

Discussion in 'Shaders' started by andrea_i, Apr 8, 2020.

  1. andrea_i

    andrea_i

    Joined:
    Nov 18, 2012
    Posts:
    32
    Hi, my computeshader or my buffers are invalidated after each scene save, undo/redo and whenever the editor window looses and regains focus.

    I haven't managed to identify if the shader or the buffers are marked invalid in some way, they just seem healthy, but the result disappears from the viewport until I discard and recreate them from scratch.

    Right now I'm taking the brute force way, I detect the events that trash my shader and I re-init everything from scratch. At some point, this will become a major limit for the tool I'm working on (clayxels).

    If there's a solution, I'd really appreciate some help on this, thanks!
     
  2. andrea_i

    andrea_i

    Joined:
    Nov 18, 2012
    Posts:
    32
    Hi, is there any way to have anyone from unity looking at this?
    I'm getting multiple bug reports on clayxels from people that see the compute buffer disappear, and I'm currently doomed to reply to everyone that I have no solution for this.
    Again, if I had at least a way to check if the compute shader, or the buffers are healthy I could handle it myself, but every api right now says buffers and shader are perfectly fine even when they disappear.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,406
  4. andrea_i

    andrea_i

    Joined:
    Nov 18, 2012
    Posts:
    32
    interesting, that post hints at the material loosing the bindings to the buffer, am I correct?

    Forgot to mention how to easily repro with clayxels at least:
    Open clayxels example scene, then add any post process effect.

    This issue happens in other occasions, some of which I manage to catch and fix myself:
    - Saving a scene.
    - Alt-tab to another app then back to unity editor.
    - after changing a c# script (on assembly reload)
     
  5. Simon-O

    Simon-O

    Joined:
    Jan 22, 2014
    Posts:
    51
    Did you ever get an answer to this? My shader just dies if I alt-tab. I don't know how to detect it reliably, and I can't afford to re-set the buffer frequently.