Anywany to fetch the exact timestamp that current frame will refresh on display?

Hi, is there anywany to fetch the exact timestamp that current frame will refresh on display in a update() function on windows Unity? Thx.

Time.time

From Unity Doc, Time.time: “The time at the beginning of the current frame in seconds since the start of the application”.
What I want is the time elapsed between update() is called and the rendered image refreshed on the display. There is a rendering phase between them.

Time.time + Time.deltaTime

I don’t know what you are trying to achieve. I have a hunch you’re on the wrong track. What’s your problem statement?

About the closest you can get to this is to hook your own system into PlayerLoopSystem just before or after the desired system runs.
Accurate timers:
https://stackoverflow.com/questions/9228313/most-accurate-timer-in-net

Emm Maybe I didn’t make it clear.
So in each frame cycle, Unity calls update()、lateupate()、onprerender() … in sequence, and then GPU does the rendering and gets the rendered image. Finally it waits for the VSync signal and refreshed on the display. This is one cycle.
What I want to know is if there is any api that returns the timestamp of the last step, so that I do some pre-processing in those pre-render functions (such as update()).

There is no such API. You would have to measure the time from the start of the frame to OnPreRender. Stopwatch can do that. But whether it’s accurate enough is hard to say.

You still didn’t say why you want to do that. I assume you want to run some extra code if the current frame processing was fast but not when it means that you might exceed the 0.01666 ms frame time target. Something like that?

If so, you may fare better to push this to a background thread with the job system. Or simply allow for a 1-frame delay and perform background processing during rendering ie between OnPreRender and the next Update. PlayerLoopSystem can help with that too to hook into the precise moments where you may want to do stuff.

Thx for your reply.
In short, I hope to update the Camera pose based on the precise display refresh time instead of other callback functions. What I want to do is similar to ATW in VR systems: do a pose prediction in onprerender() and a pose correction in onpostrender(), both of which requires the timing of the display refresh time in that frame cycle.

This is for an actual VR device/app? Normally they implement this kind of behaviour with a shader. Perhaps the GPU is aware of time too?

Not for VR device.
Most of VR devices use Qualcomm Chip, which provides such timer. I am building a windows mock-up, so I am looking for such API or workarounds in Unity. Otherwise I guess I have to check Nvidia’s APIs.

And Yes, I will do the final ATW warp in shader with the predicted pose based on the time gap.