Search Unity

Final Blit Pass from LWRP Killing Perf on Android

Discussion in 'Universal Render Pipeline' started by Claytonious, Sep 1, 2019.

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    This has been an issue for a long time now and even on the latest 6.9.1 it persists. The issue is reported at least here and here and also within several forum posts here.

    This is crucial for performance on Oculus Quest and other Android VR platforms.

    Could we please get any kind of status update on a permanent fix for this issue? (We've been hacking the source code of the LWRP package on each release to work around it so far).

    Thank you!
     
    FromTheFuture, ROBYER1 and webjeff like this.
  2. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    Removing Final blit would cause problem with linear color space on many devices. Unity2019 removed the internal Final Blit for android, so we have to rely on the final blit of the LWRP, otherwise linear color space rendered image will suffer from missing gammar correction, which leads to much darker result
    I don't know if it's safe to remove that in vr applications, but for us, it's definitely neccessary to have the final blit.
    It's also required on some android device to kill alpha value on the framebuffer to prevent display issue, that also requires final blit
     
  3. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Then perhaps the proper fix here is a VR-specific check - at least in the case of Oculus Quest in linear color space rendering seems correct without this expensive final blit.
     
  4. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Have you reported it as a bug through the bug reporter in the editor? Their QA team won't often be checking the forums to see this. Any time I have had an issue I bug reported it and got a response from the developers within a day or so.
     
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    In this case i linked to existing bug reports.
     
    ROBYER1 likes this.
  6. namanam

    namanam

    Joined:
    Jul 27, 2013
    Posts:
    8
    Consider compute shader?
     
  7. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Does anyone know of any news about this yet? @ROBYER1 I think you mentioned in some other thread that you were also manually editing the LWRP package to turn this final blit pass off manually, right? Are you still having to do that on the latest?
     
    ROBYER1 and FromTheFuture like this.
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @Claytonious Final blit pass is there if either conversion between color spaces (Linear -> sRGB) or killing alpha is required. I suppose that both of those are not needed on Oculus.
    Can you check, which keywords are active when this blit is happening?
     
    ROBYER1 likes this.
  9. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Hi, @aleksandrk , in my case, it is definitely being triggered by the fact that I'm using "RenderFeatures", though the simplest possible kind - RenderObjects. This is simply to render groups of things in order. The mere fact that I'm using these causes createColorTexture to become true inside of ForwardRenderer.cs. Is that really necessary? I'm only using these at all since the old "normal" way of simply layering multiple cameras stopped being an option in LWRP a while back.

    I'm not able to run on the Quest at this moment so I can't be sure about whether
    RequiresIntermediateColorTexture() is also triggering it. As soon as I can run on the Quest again, I will update this thread with that info, too.

    Either way, thanks a ton for taking an interest and for any information!
     
  10. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    I would also like to simply ask: is using URP for VR actually a recommended thing to do for projects that want to ship during the first half of 2020? Is this just a bad idea? Thanks!
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    A blit is necessary if the back buffer has a format different from what you're rendering to. This includes cases like HDR rendering, or when the back buffer doesn't support sRGB (older Android ~5.1, and Android 8.1, where the required extension is just broken). Another case is that older Android didn't have a correct implementation for transparency in the compositor, so there was a need to set alpha to 1 on the whole framebuffer before saying "hey, I rendered something, go show it". This has been there for a long time and seems unnecessary nowadays, and I think it has been fixed in some version (not sure if it was in LWRP or Universal).
    I would probably defer to the team that's developing Universal to answer that :)
    In general, Universal should be faster than built-in in many scenarios (and not slower for sure), and afaik performance is crucial with VR.
     
    IgnisIncendio and Claytonious like this.
  12. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
    fherbst, TextusGames, Peter77 and 2 others like this.
  13. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    Woohoo! Thank you letting us know @ElvarOrnUnnthorsson ! When do you think 8.0.0 will be released?
     
  14. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    So apparently on the Oculus Quest, you do *not* need this extra blit even when rendering with linear color space. I tested by hardwiring this extra blit to false in ForwardRenderer.cs and setting to linear color space. Everything looks visually correct (not darker as you would expect if this were needed).

    This extra blit will still be here on the Quest even after @ElvarOrnUnnthorsson 's other fix lands, so we will still have to make a custom hack to this package every time we build until this is fixed in some more permanent way. Is it possible to say something like #if VR_ENABLED then set this flag to false in there?

    Heck - even just a project specific setting where we can check a box that says "Don't do the extra blit - I know the hardware I'm targeting and I don't need it" would be fine!
     
  15. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    There was a thread somewhere here with an explanation of where in the source you could disable the final blit yourself until a first-party fix is available. But now I can't seem to find it to save my life! If anyone knows where it is, please share it here!
     
  16. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
  17. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Could you open a bug about this final Blit and Quest?
    We can poke XR devs about it and share status.

    About the don't do extra Blit. We actually looked at what would be necessary to do this. It turned out that if we exposed it so many paths would stop working that we were worried about the fallback and support for this option. (F.ex camera stacking is a new thing in URP that requires this extra Blit)

    What we think is a better way of doing this is to expose some internal API so you can easily create a modified forward renderer that's very lean in features and doesn't require the final Blit.
     
  18. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I would like to know if it conflicts with the Vulkan FFR which is now enabled in Multiview, could you enquire about that also please?
     
    hippocoder likes this.
  19. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Given that omitting the extra blit is also going to be a very common use case for Android (especially Quest/Vive Focus, and probably more headsets to come in the future) developers, it really should be at least a checkbox with a warning or something. I mean, it's really hard to even get approval to ship a game on Quest without disabling this, so it really needs to be some sort of standardized option. It's a little much to require everyone who will need it to write their own custom pipeline. I could see that if it was an unusual edge case, but it isn't. It's pretty much the default situation for anyone developing for Quest, etc.
     
  20. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    I had to do the same hacks for our Quest app, and talked about / reported bugs since middle of last year about this.
    Any rendering that's not going to backbuffer breaks FFR, reducing performance on top of already killing performance because of the blit(s).
    See https://forum.unity.com/threads/fix...oculus-quest-not-working.686662/#post-4694618

    Commenting out all those extra blits and also everything related to postprocessing is currently necessary to get decent performance on Quest. I have a fork of SRP which is "optimized" (read: hacked) to work on Quest and kill all unecessary features (e.g. 25-30 MB of Uber postprocessing shader that is ALWAYS included in stock URP for no reason, even if turned off everywhere). I'd be very interested in having a good, complete fork of URP for actual high-performance VR - I'll test it with Render Features tomorrow to see whether it actually already supports that without blit.
    (Dev fork is here, in the process of testing it. Production-tested fork is here.)

    @phil_lira can you elaborate on why camera stacking (without post processing) requires an extra blit? In good old builtin rendering stacking cameras would just render them one after the other with their respective clear flags (or none, usually), no blits involved.
     
  21. Wuceng

    Wuceng

    Joined:
    Dec 18, 2018
    Posts:
    9
    Is this issue now fixed with the release of 7.2? It is mentioned in the release notes at least but some clarity would be nice. Especially on the Quest side of things.

    EDIT: The final blit pass still seems to be there in the frame deugger for me. So I guess this was not fixed.
     
    Last edited: Feb 12, 2020
  22. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @Wuceng what keywords are enabled on your final blit pass?
     
  23. Wuceng

    Wuceng

    Joined:
    Dec 18, 2018
    Posts:
    9
    @aleksandrk upload_2020-2-12_15-55-13.png
    No keywords as far as I can tell. I noticed that the blit is related to the AntiAliasing. If I turn off MSAA in my Quality Profile then the blit is gone aswell. Is that blit needed for MSAA to work (I guess it has to resolve the multiple samples)?
     
  24. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Yes, seems like that's the case.
    So the only part that got removed was the KILL_ALPHA, which is no longer needed.
    All other uses of the Final Blit pass are still valid, so you can get into situations when it's actually needed.
     
  25. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Quest doesn't need the final blit to resolve MSAA... that is one of the issues I reported. The internal bool "needs msaa resolve" returns true for Quest but forcing it to false makes MSAA work.
     
    Last edited: Feb 12, 2020
    hippocoder and Claytonious like this.
  26. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    This is the fundamental thing. Just giving us a checkbox to force the blit off would solve it for those of us on this kind of hardware. It can include a big warning icon and flash red and sound a siren if you like, but we want to check it. ;-)
     
    Eclectus and hippocoder like this.
  27. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
  28. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    I don't know how to answer that question. Is this a choice that's made inside of the URP source somewhere that I can check for you?
     
  29. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    @Claytonious does your camera that is supposed to render to the screen and the pipeline settings have MSAA enabled?
     
  30. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    @Claytonious if you also have a renderer feature this will require an extra blit with current version. There's no way atm to tell if a custom injected render pass depends on camera texture as input (a blur pass f.ex).

    We have planned in our roadmap planned to expose API for the custom render pass to declare if it depends on camera color texture or not.
     
    IgnisIncendio and ThomasZeng like this.
  31. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Don't need fancy 2nd Cameras and never have, so I think that's about as common a people wanting a second camera. I think it would be a great idea to provide a lean forward renderer out of the box, from the drop down for the optimised crowd so people can pick.
     
  32. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    It could be done if we would preprocess/evaluate the entire stack before rendering. We are working on some improvements on the stacking system to be able to cache culling between cameras and to cast and receive shadows in between camera. So it might be that while doing this system we can avoid an extra blit in some cases. It's hard to say now.

    Parallel to this, we are working on tile based performance improvements in Android and iOS using RenderPass strategy. When using that, in some cases the final blit can be merged in a subpass and be virtually free.
     
    IgnisIncendio and fherbst like this.
  33. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The problem I have with final blit is on VR it prevents FFR from working as the FFR is only applied to the final blit... if this is fixed than I'll get my coat and politely exit ;)

    Also worried about avoiding any needless Adreno tile resolves.
     
    ROBYER1 likes this.
  34. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    @hippocoder FFR is being worked on by the XR team atm.
     
  35. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Agreed, if it is enabled for all the stack somehow that would be great..
     
  36. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @phil_lira if URP team starts hacking in device-specific pass exclusion rules (done yesterday for Hololens as I can see) why not just hack in Quest as well to get it working? I mean, that's basically what my fork does, but still ... can't really understand why you can't do that for months and then suddenly such a hack is ok.
     
    Last edited: Feb 13, 2020
    ROBYER1 likes this.
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well hololens is generally for clients with deep pockets so you'll have to accept some bias for some things. I don't consider this unfair in the slightest, it's simply the right decision to have exceptions sometimes.

    Looking forward to XR fixes, thanks for the heads up :)
     
  38. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
  39. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
  40. kilogold

    kilogold

    Joined:
    May 28, 2013
    Posts:
    9
  41. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
    kilogold likes this.
  42. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Important note: it's not only a move, but actually a new repo with changed history.
     
  43. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.5/changelog/CHANGELOG.html

    From URP 7.5.3 changelog, which is compatible with 2019 LTS. Just checking, is this the aforementioned fix by @ROBYER1?

    Based on my (newbish) knowledge, there seems to be a few separate issues right now concerning Quest + URP blitting (which disables FFR, and even without FFR would incur a performance cost, if blitting occurs):
    • Linear color space: Fixed in 7.5.3 as shown above...?
    • Eye resolution not 1: Fixed in 7.5.3
    • Post processing: Not yet fixed
    • Camera stacking: Not yet fixed
    • Render features in general: Not yet fixed
    Could anyone confirm this? Thanks :)
     
  44. stocks109

    stocks109

    Joined:
    Jul 18, 2013
    Posts:
    5
    Is there any updates to this situation?
     
  45. stocks109

    stocks109

    Joined:
    Jul 18, 2013
    Posts:
    5
    It seems Linear Color Space is forcing a FinalBlit. We're using 2020.3.18 with URP 10.3.
     
    ROBYER1 likes this.
  46. stocks109

    stocks109

    Joined:
    Jul 18, 2013
    Posts:
    5
    Actually, I was wrong. It was a unique renderer feature we added that was forcing the FinalBlit. We just hardcoded it into URP and forced the FinalBlit to not do its thing.