What is the best approach to syncing frame index between PC and headset?


We are working on a VR headset which employs pixel shifting technology to increase perceived resolution. We need to make sure the frame index is in sync at the PC runtime and headset PCB, so that the PCB can properly control the electro-optical component which handles the pixel shifting.

Below I explain how we currently think of doing it. Please let me know if this should work and whether there may be a better way of doing it.

We started off by assuming that the first frame we send to the HMD/monitor is the first frame it will display, but it looks like setting up a DirectMode connection with NvAPI_D3D_DirectModeSetDisplayMode() takes a bit of time (~500ms), and when we query the frame index right after it we get frame index 14-17, not 0. So this simplest method of keeping count of frame index doesn’t seem possible.

So instead what we think of doing now is calling NvAPI_D3D_GetDirectModePresentStats() instead of trying to count our own index. This way our VR runtime will become Slave and the headset PCB the Master and we will need to adjust how to render our first frame based on the frame index returned by NvAPI_D3D_GetDirectModePresentStats() .
The NvAPI_D3D_GetDirectModePresentStats() call itself takes only ~15us.

Should this work? Is there maybe a better approach?