OpenXR-Docs
OpenXR-Docs copied to clipboard
Correct time to call xrBeginFrame is unclear
The spec says:
Applications should call xrBeginFrame right before executing any graphics device work for a given frame
"graphics device work" is not well defined. For Vulkan, the most plausible interpretation is that it should be called immediately prior to the first vkQueueSubmit related to rendering the frame. However, another interpretation might be to call it before beginning to record command buffers.
The reference guide further confuses matters by specifying that xrBeginFrame be called immediately after xrWaitFrame, but this seems unlikely to be correct, as it would tend to include significant CPU work. Further, if that were the intended pattern there would be no point to having a separate function call. It also clearly sequences it prior to the swapchain image acquire/wait operations, which are certainly not GPU work for the current frame and may block the thread.
My understanding is that xrBeginFrame's purpose is to improve a runtime's ability to reason about the time required by an application to render a frame. If applications aren't calling it at a consistent time with regard to other operations, that purpose will be defeated, so specific language should be added defining precisely when xrBeginFrame should be called with regard to per-frame CPU work, GPU work (with a clearer definition of its own), and other OpenXR calls, and the reference guide updated to match.
An issue (number 1265) has been filed to correspond to this issue in the internal Khronos GitLab.
If you have a Khronos account, you can access that issue at KHR:openxr/openxr#1265.
Is there any update available on this issue?
For Vulkan, the most plausible interpretation is that it should be called immediately prior to the first vkQueueSubmit related to rendering the frame.
This is the correct interpretation.