[Mesa-dev] [PATCH 4/7] mesa: implement glGet(GL_TIMESTAMP)

Adam Jackson ajax at redhat.com
Wed Jun 27 07:42:11 PDT 2012


On Wed, 2012-06-27 at 09:29 +0200, Michel Dänzer wrote:
> On Mit, 2012-06-27 at 03:49 +0200, Marek Olšák wrote: 
> > 
> > +GLuint64
> > +_mesa_get_cpu_timestamp(void)
> > +{
> > +#ifndef _WIN32
> > +   struct timeval tv;
> > +
> > +   gettimeofday(&tv, 0);
> > +   return (GLuint64)tv.tv_sec * 1000000000ull + (GLuint64)tv.tv_usec * 1000;
> 
> As in a recent discussion about DRM vblank counters, it may be better to
> use clock_gettime(CLOCK_MONOTONIC, ...) when possible, as gettimeofday()
> can move backwards.

And if you do so, since it looks like you're working in milliseconds,
please steal xserver's GetTimeInMillis() for it:

http://cgit.freedesktop.org/xorg/xserver/tree/os/utils.c#n409
http://cgit.freedesktop.org/xorg/xserver/commit/os/utils.c?id=44adb31bfece29260a9bbd9075c9212ebf00d24d

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120627/43187401/attachment.pgp>


More information about the mesa-dev mailing list