Inconsistent sync wait related to occlusion culling.

We are seeing some inconsistent spikes in occlusion culling when we look at occlusion through insights. This seems to happen regardless of if the task runs on the render thread or on a separate background thread and seems to be less egregious if we are running with raytracing enabled.

After adding some new stat tracking to the culling event and running on the render thread we are seeing that we are only ever really running occlusion on around 600 - 800 objects in the scene. We see a SyncPoint on the first primitive it tries to run on and then eventually frees up (im guessing whatever locked the first locks the rest of the scene primitives). While setting r.NumBufferedOcclusionQueries=2 does help reduce the cost some it doesnt eliminate that SyncPoint outright and setting increasing the value of r.NumBufferedOcclusionQueries doesnt seem to help much.

Are there any tricks or tips to tracking down what could be causing this issue?

Hi there,

You may be interested in this case, I responded to a few days ago to see if it answers your questions: [Content removed]

The SyncPoint_Wait events usually show up when the CPU is running too far ahead of the GPU and has to wait for the GPU to catch up (GPU might be 1 frame behind). In these cases, the project will be GPU bound (GPU time higher than Game, Draw or RHIT).

If you’re getting syncpoint waits inconsistently, then it may just mean that your project is flipping between being CPU and GPU bound.

The SyncPoint_wait events, on occlusion queries, wait for the GPU to have all the occlusion data ready for the CPU before it starts processing occlusion on the CPU. This is why it waits on the first primitive. Increasing the r.NumBufferedOcclusionQueries often just moves these syncpoint waits a bit later, and to the RHI thread (D3D12 RHI thread can be a maximum of 1 frame ahead of the GPU). Increasing r.NumBufferedOcclusionQueries can also result in more incorrect occlusion results, and pop in, due to an increased number of out of date occlusion results.

Let me know if this matches with what you are seeing on your end.

Regards,

Thomas