ray traced distance field shadows in VR cause render thread to go up by 10ms on 4.15

I have encountered this issue in two separate projects and it is causing a lot of headache. I am having a hard time pinning down the cause so I cannot give an amazing guide to reproduce this. I have attached a project with a scene that demonstrates this however.

The Issue is that that the render thread will jump up to 14-20ms on a relatively simple scene when using ray traced distance field shadows on 4.15.

Toggling ray traced distance field shadows on and off will also toggle the extra 14-18ms on the CPU, while the GPU maintains 6ms shadows off vs 11ms shadows on - but the frame time will be around 20ms.

The attached project should demonstrate this. Add more occluders or shadow casting light sources to exaggerate the issue.

Windows 10, gtx 980, intel x99 platform

Screens from my profiling session are attached and the

[PROJECT CAN BE FOUND HERE][1]

Please note

The issue only appears when playing in VR, with a VIVE in my case
the the setup in this project with the bunch of lights in one spot is a little ridiculous but I to reproduce it somehow. I have another real world project where the same thing happens with just one directional light and one sky light in a scene with like 50 static meshes and 20 rather simple skeletal meshes.

On a side note, I was able to see the same behavior on another project when toggling ray traced distance field shadows, the same way as here BUT on yet another project the behavior happened when switching between MSAA and Temporal AA.

So this might not be 100% exclusive to ray traced soft shadows, but this was the only way i could reliably reproduce the issue.

Can you post a ‘stat dumpframe’? That will show a hierarchical timing view of the rendering thread.

Ray Traced Distance Field shadows aren’t supposed to cost much on the Rendering Thread (the whole algorithm is on the GPU), but they do lock a vertex buffer to upload some data. There was an issue in the past where locking a vertex buffer was slow, as it would require flushing all pending RHI commands. That has been fixed, although I don’t remember when.

As an aside, we unfortunately haven’t really tested distance field features in VR, since our VR projects stick to almost completely static lighting for performance.

Here is the dump Cmd: stat dumpframeLogStats: Single Frame 3191 ------------------------------- - Pastebin.com

I definitely wasn’t expecting the CPU to be an issue when first testing this in VR, but every time this or some variation of this issue comes up, FViewExtensionPreDrawCommand seems to take up all of the time. I was not able to find any documentation on it and was hoping you might know how it relates to the issue.

Thank you very much for looking into this.

In reply to the aside, the project am I working on, makes the trade-off of having realtime shadows in a limited capacity through this feature, and disregarding the issue at hand, they work beautifully.

Yep it’s all in
20.659ms ( 1) - FViewExtensionPreDrawCommand

That’s the Vive implementation callback. I’m afraid I don’t know what happens in there, I’m not familiar with how the Vive integration works.

If I were investigating this, I’d do a sampling profile (either through Visual Studio or something like Very Sleepy CS) which would show all the callstacks (stat dumpframe only shows manually placed events which is why we can’t see further detail).

Got it! I will do further investigation on that.
Thanks so much, can’t wait to get my hands on the upcoming improvements to SDF stuff in 4.16!