Search Unity

What does the "Deferred PrePass" section of the GPU Profiler refer to?

Discussion in 'Shaders' started by Zergling103, Oct 11, 2013.

  1. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    285
    Hi there,

    I am tweaking the rendering performance of our game.

    I noticed that some objects are taking considerably longer to render than expected because they have roughly equal time spent rendering in the "Opaque" section as the "Deferred PrePass" section. Some objects contribute to the Deferred PrePass time while others do not.

    I was wondering if someone could explain what the "Deferred PrePass" actually is, and how it's role differs from that of "Opaque".

    Is the same object being rendered twice to two different render targets? Does Unity not support multiple render textures in one draw call? (Might switching to dx11 fix this?)

    Thanks for your help.

    -Steve
     
  2. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
    Hey!

    If you click on the GPU tab in the profiler and go to Camera.Render -> Drawing -> Render.OpaqueGeometry, you can see three parts:
    • RenderPrePass.GeometryPass, shows up as Deferred PrePass and is used for rendering the normals and specular power of the objects
    • RenderPrePass.Lighting, is marked as Deferred Lighting and produces the light buffer based on the rendered texture
    • RenderPrePass.FinalPass, or misleadingly Opaque, draws all objects once more to the frame buffer

    So yes, every object is rendered twice and there's no way to prevent that. It's in the design of a deferred lighting renderer.
    You can read more here: http://docs.unity3d.com/Documentation/Components/RenderTech-DeferredLighting.html
     
  3. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    285
    Thanks for the reply. :)

    False.
    From my experience in DirectX, at least, there is a feature which allows multiple render textures to be written to in one pass, in one pixel shader. There was a specific syntax for it in HLSL.
    What that means is that it is possible in a graphics engine for the normal, diffuse, specular, glossiness, emissive, etc. to be output by one pixel shader, simply by using multiple out parameters, instead of returning one value. I seem to remember that you can return a struct as well, with multiple outputs.

    http://en.wikipedia.org/wiki/Multiple_Render_Targets

    (Funny enough, at the bottom of this page you'll read: "Deferred Shading, a shading process that relies heavily on MRT to perform in real-time")

    If Unity did this, there wouldn't be a problem here.



    With all this being said, I'd have to beg the Unity guys to implement this, I presume? I'll have to check to see if this plays out differently on DirectX 11 (although I could swear that DX9 supported MRT).
     
  4. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    285
  5. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
    You're talking about a completely different rendering algorithm though. Unity uses deferred lighting, not deferred shading. It has it's advantages and disadvantages. It's not an easy task to implement a custom rendering path, by the way. I've actually been working on a deferred shading renderer for the past two months or so. See this thread: http://forum.unity3d.com/threads/198539-The-Wish-for-an-Alternative-Rendering-Path

    With deferred lighting renderer, you can't render the two passes in one go, because there are dependencies. The second pass relies on the lighting pass, which relies on the first pass.
     
unityunity