Skip to content

vrend: fix fence polling without sync thread

Chia-I Wu requested to merge olv/virglrenderer:fix-fencing into master

This was regressed by commit 3a2a537c (vrend: hook up per-context fencing internally), bisected by Gert.

When there is no sync thread, vrend_renderer_check_fences checks fences on vrend_state.fence_list for signaled ones and call ctx->fence_retire on them. Because fences belonging to the same context are ordered, as an optimization, we ideally want to call ctx->fence_retire only on the last fence of those belonging to the same context. (Note we are close to that but not quite because we want to avoid complex changes until virgl starts using per-context fencing, if ever)

The issue is in need_fence_retire_signal_locked. It has this check

if (fence->fences.next == &vrend_state.fence_list)
   return true;

which says that, if the fence is the last one in vrend_state.fence_list, call ctx->fence_retire (because it must be the last fence of some context). The check is incorrect because not all fences on the list have signaled when the sync thread is not used. It will fail when there are also unsignaled fences on the list.

To fix the issue, we contruct a list of signaled fences first before calling need_fence_retire_signal_locked. We could merge the paths with and without sync thread further because the non-sync-thread path just needs this extra step to construct a list of signaled fences. But we will save that for future and focus on fixing the performance regression.

Merge request reports