[Mesa-dev] [PATCH] llvmpipe: Implement PIPE_QUERY_TIMESTAMP and PIPE_QUERY_TIME_ELAPSED.

Daniel Vetter daniel at ffwll.ch
Tue Dec 4 02:16:11 PST 2012


On Mon, Dec 03, 2012 at 09:29:54AM -0800, Jose Fonseca wrote:
> 
> 
> ----- Original Message -----
> > On Mon, Dec 3, 2012 at 7:33 PM, Dave Airlie <airlied at gmail.com>
> > wrote:
> > >> diff --git a/src/gallium/auxiliary/os/os_time.c
> > >> b/src/gallium/auxiliary/os/os_time.c
> > >> index 3e9d50a..4055125 100644
> > >> --- a/src/gallium/auxiliary/os/os_time.c
> > >> +++ b/src/gallium/auxiliary/os/os_time.c
> > >> @@ -36,6 +36,7 @@
> > >>  #include "pipe/p_config.h"
> > >>
> > >>  #if defined(PIPE_OS_UNIX)
> > >> +#  include <time.h> /* timeval */
> > >>  #  include <sys/time.h> /* timeval */
> > >>  #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
> > >>  #  include <windows.h>
> > >> @@ -68,6 +69,20 @@ os_time_get(void)
> > >>  }
> > >>
> > >>
> > >> +uint64_t
> > >> +os_time_get_nano(void)
> > >> +{
> > >> +#if defined(PIPE_OS_UNIX)
> > >> +   struct timespec tv;
> > >> +   clock_gettime(CLOCK_REALTIME, &tv);
> > >> +   return tv.tv_nsec + tv.tv_sec * 1000000000LL;
> > >> +
> > >> +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
> > >> +   return os_time_get() * 1000;
> > >> +#endif
> > >> +}
> > >
> > > I wonder if we should be using CLOCK_MONOTONIC_RAW (on new Linux)
> > > or
> > > CLOCK_MONOTONIC here, but I also wonder if we should do the same
> > > for
> > > os_time_get so they are the same clock.
> > >
> > > I ran some piglits on this, and it found it doesn't provide the
> > > screen->get_timestamp callback, but that looks like a trivial
> > > addition, though with that it still fails a test, I'll see if I can
> > > spot the problem.
> > >
> > 
> > Okay the attached patch fixes up the piglit fails I see with this
> > patch.
> > 
> > feel free to merge it in.
> 
> Merged and commited. Thanks!
> 
> I think you're right about CLOCK_MONOTONIC. Not sure how to detect CLOCK_MONOTONIC_RAW run/compile time. So let's do that in a follow on change.
> 
> I think that it is unnecessary to have two implementations of os_time_get_nano/os_time_get. os_time_get should be re-defined in term of os_time_get_nano, since it is more general.

Fyi the kernel pageflip timestamping just switched to CLOCK_MONOTONIC for
3.8 by default (well, for those drivers that use the new timestamp event
generation helpers). We've decided against _RAW since alsa/v4l also use
the monotonic clock, leading to nice unified timestamps accross all things
linux media.

Hence I think pipe queries should do the same, just for consistency.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the mesa-dev mailing list