hi,guys, i have a strange problem about using the new forward shading pipeline in 4.15. I made a scene with some geometry and particles, when in deferred rendering pipeline with temporal AA All is fine with HTC vive the frame rate keeps in 90hz.So i tried the new forward shading and turn on the MSAA . When restart the project and rebuild the light. I dive in the scene use vive, the frame rate suddenly drop to 44hz, i use “stat unit” see the draw is 22ms, so i guess the bottleneck may be in render thread. So i run “stat startfile” to record to log then use Profiler to see what exactly happened.The result point out on render thread the first call is FViewExtensionPreDrawCommand, and in forward shading with MSAA, this function call cost over 20ms compare to forward shading with temporalAA only cost 9ms. Does anybody know why forward shading with MSAA cost so much?
Did you ever figure this out? I can see the exact same behavior on two separate projects and it’s a huge issue. I’ll continue my investigations.
I was able to reliably reproduce the issue in a test level using ray traced distance field shadows. I do have a real world Project project though, where MSAA makes the issue appear like in your case.
I created an answer hub bug report here if you wanna keep an eye on that or comment ray traced distance field shadows in VR cause render thread to go up by 10ms on 4.15 - Rendering - Unreal Engine Forums
I had this in a test project recently so I drilled down just to see what was going on. The extra time in FViewExtensionPreDrawCommand looks like its caused by the VRCompositor getting the pose for the HMD and Motion Controllers here:
vr::EVRCompositorError PoseError = VRCompositor->WaitGetPoses(Poses, ARRAYSIZE(Poses) , NULL, 0);
So my guess is that update waits for a vsync, or some other timing signal, and provides the pose “at the right time”.
For me, this only takes longer than a few microseconds when the render thread is over budget (or nearly over, I’ve seen this at about 10.6ms RT time) and I’m guessing the pose for that frame isn’t available and the wait stalls for the next frame. I’ve not dug any deeper to see what the compositor does internally, and haven’t tested this on a rift yet.
My strategy is to first optimise the RT so we are under 9ms (which you’d have do anyway) and the problem should never manifest. That’s my best advice for now. Keep your render thread time down and you shouldn’t see any problems.
I don’t think its related to the MSAA or Distance Field settings, just anything that pushes the frame out enough so that the Pose stalls. I’m very certain this has started happening recently. I’ve seen VR projects (in 4.15) that didn’t have this problem, so it may be a change to the compositor.
I’ll try and post up if I find anything else.
Thank you very much for taking the time out to post this. It does appear to be an issue outside of unreal indeed. I find your conclusion to be very reasonable.
The issue that remains for me is that FViewExtensionPreDrawCommand takes up 15 more ms when toggling distance field shadows, even when the render thread is fairly simple otherwise. Look at these stats from a scene with shadows off and with shadows on.
LogStats: 11.193ms ( 47) - Thread_4dfc_0 - RenderThread - STATGROUP_Threads - STATCAT_Advanced
LogStats: 8.364ms ( 1) - FViewExtensionPreDrawCommand - STATGROUP_RenderThreadCommands - STATCAT_Advanced
LogStats: 2.516ms ( 1) - FDrawSceneCommand - STATGROUP_RenderThreadCommands - STATCAT_Advanced
LogStats: 2.475ms ( 1) - RenderViewFamily - STAT_TotalSceneRenderingTime - STATGROUP_SceneRendering - STATCAT_Advanced
LogStats: 1.431ms ( 39) - OtherChildren
LogStats: 1.044ms ( 1) - InitViews - STAT_InitViewsTime - STATGROUP_SceneRendering - STATCAT_Advanced
LogStats: 1.044ms ( 8) - OtherChildren
LogStats: 0.041ms ( 3) - OtherChildren
LogStats: 0.313ms ( 45) - OtherChildren
LogStats: 22.131ms ( 57) - Thread_4dfc_0 - RenderThread - STATGROUP_Threads - STATCAT_Advanced
LogStats: 17.864ms ( 1) - FViewExtensionPreDrawCommand - STATGROUP_RenderThreadCommands - STATCAT_Advanced
LogStats: 3.748ms ( 1) - FDrawSceneCommand - STATGROUP_RenderThreadCommands - STATCAT_Advanced
LogStats: 3.685ms ( 1) - RenderViewFamily - STAT_TotalSceneRenderingTime - STATGROUP_SceneRendering - STATCAT_Advanced
LogStats: 2.148ms ( 42) - OtherChildren
LogStats: 1.537ms ( 1) - InitViews - STAT_InitViewsTime - STATGROUP_SceneRendering - STATCAT_Advanced
LogStats: 1.339ms ( 1) - View Visibility - STAT_ViewVisibilityTime - STATGROUP_InitViews - STATCAT_Advanced
LogStats: 1.339ms ( 16) - OtherChildren
LogStats: 0.198ms ( 7) - OtherChildren
LogStats: 0.062ms ( 3) - OtherChildren
LogStats: 0.520ms ( 55) - OtherChildren
Shadows seem to make the scene take about 1ms more to draw but the FViewExtensionPreDrawCommand issue completely takes over. I’m not sure, how to prevent the issue from manifesting in this case. This is a real world project too, no test scene.
We are facing the same issue for some time now. I opened another AnswerHub post here: [VR][Vive] FViewExtensionPreDrawCommand pulsing with huge cost - Rendering - Unreal Engine Forums