Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Compute Shader Async Execution

Discussion in 'High Definition Render Pipeline' started by Bream_Helen, Dec 8, 2022.

  1. Bream_Helen

    Bream_Helen

    Joined:
    Jul 30, 2021
    Posts:
    2
    Hi!
    First, to avoid confusion, this question is not about AsyncGPUReadback. It's about executing Compute Shaders in parallel asynchronously.

    There are some Unity learning materials that encourage you to use Compute Async. Like this one. So it got me interested.

    1) Is it possible at all in HDRP? SystemInfo.supportsAsyncCompute gives me "false", though I use RTX 3060 and tried both DX11 and DX12. Why is it always false?

    2) If it's possible then how exactly do I use it in the context of SRP? Especially inside the custom pass / post-process system? I would like to dispatch some compute shaders in parallel (because they don't depend on each other), wait for them to finish their work and then continue executing other compute shaders one by one as usual.

    3) What mechanism does Unity use for Async execution of it's screen-space lighting effects? Is it possible to utilize the same approach to dispatch custom compute shaders in the async manner?

    Thanks!
     
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    932
    Hi,

    >1) Is it possible at all in HDRP? SystemInfo.supportsAsyncCompute gives me "false", though I use RTX 3060 and tried >both DX11 and DX12. Why is it always false?

    We use async compute for various effect in HDRP (Build light list, Voxelization, ssr...) already.
    I guess it is false for you as it works in standalone DX12, PS4/5, XSX/Xbox, not in the editor. Note that various effect are disabled to be async when raytacing is enabled.

    2) 3) You can check here:

    https://github.com/Unity-Technologi...ing/HDRenderPipeline.AmbientOcclusion.cs#L207

    to use it in custompass/custom postprocess you need to do everything yourself like pointed in the code above and have a synchronization point.

    Note that there is a win only if you parallelize with different GPU usage. HDRP ,parallelize with Shadow who do low pixel shader usage, but if you parallelize two heavy texture fetch postprocess effect then you may be slower than without paralleilization.

    hope that help
     
    Bream_Helen likes this.
  3. Bream_Helen

    Bream_Helen

    Joined:
    Jul 30, 2021
    Posts:
    2
    Yep, thanks. It does help!

    Just to clarify, by "doing everything yourself" you mean that I need to do everything required inside the existing custom pass system or that I need to edit the custom pass system itself in order to make it work with Async?

    What if each of these effects runs at 1/4 res utilizing 4 times less threads than a full-res effect would?