Search Unity

Render/Main thread interaction and OnPostRender

Discussion in 'General Graphics' started by lama89625, Sep 19, 2019.

  1. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    14
    Hi everyone!

    I’ve been looking into the timeline section of the CPU profiler and noticed that it looks like the main thread can actually go ahead and start doing stuff (physics, script updates etc.) for the next frame while the render thread is still busy with the previous frame(!) either preparing tasks to be sent to the GPU or waiting for the GPU to complete its job.

    Once the main thread gets to the point when it’s ready to start rendering it stops and waits for the render thread to be available (Gfx.WaitForPresent?)
    It seems logical but I couldn’t really find any information to confirm that my understanding is correct.

    Also I’m curious where the MonoBehaviour events like OnPostRender or OnRenderImage actually get called in this pipeline. From the Unity’s execution order article it seems like OnPostRender gets called before the main thread goes ahead to the next frame