Re: How do I sync output changes to vertical retrace?

2006-03-01 Thread Barry Scott

Mark Vojkovich wrote:

   Come to think of it, NVIDIA does, or at least did have device
file that lets you wait for vblank as well.  These types of things
are pretty unportable though.

  

Yes its a shame that X does not have more direct support for VBLANK sync,
being portable would be nice.

I use VIA CLE266 that has VBLANK support and later want to use the i945G,
which I heard DRI is adding the VBLANK support. So I should be O.K.  with
the code I've got.

Barry

___
Devel mailing list
Devel@XFree86.Org
http://XFree86.Org/mailman/listinfo/devel


Re: How do I sync output changes to vertical retrace?

2006-02-22 Thread Barry Scott

Mark Vojkovich wrote:

  The only mechanism I know of is OpenGL.  Most OpenGL drivers have
a mechanism to allow buffer swapping at vblank.
  

Using DRM/DRI this works:

void waitForVSync()
{
if( card_fd  0 )
card_fd = open( /dev/dri/card0, O_RDONLY );

drm_wait_vblank_t wait_vblank;
wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
wait_vblank.request.sequence = 1;
wait_vblank.request.signal = 0;

int rc;
do
{
wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
rc = ioctl( card_fd, DRM_IOCTL_WAIT_VBLANK, wait_vblank );
}
while( rc != 0  errno == EINTR );
}


Barry

___
Devel mailing list
Devel@XFree86.Org
http://XFree86.Org/mailman/listinfo/devel


Re: How do I sync output changes to vertical retrace?

2006-02-22 Thread Mark Vojkovich
On Wed, 22 Feb 2006, Barry Scott wrote:

 Mark Vojkovich wrote:
The only mechanism I know of is OpenGL.  Most OpenGL drivers have
  a mechanism to allow buffer swapping at vblank.
 
 Using DRM/DRI this works:

 void waitForVSync()
 {
 if( card_fd  0 )
 card_fd = open( /dev/dri/card0, O_RDONLY );

 drm_wait_vblank_t wait_vblank;
 wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
 wait_vblank.request.sequence = 1;
 wait_vblank.request.signal = 0;

 int rc;
 do
 {
 wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
 rc = ioctl( card_fd, DRM_IOCTL_WAIT_VBLANK, wait_vblank );
 }
 while( rc != 0  errno == EINTR );
 }


 Barry

   Come to think of it, NVIDIA does, or at least did have device
file that lets you wait for vblank as well.  These types of things
are pretty unportable though.

Mark.


/*
gcc -o polltest -Wall polltest.c
*/

#include stdio.h
#include sys/poll.h
#include sys/types.h
#include sys/time.h
#include sys/stat.h
#include unistd.h
#include fcntl.h

#define FILENAME /dev/nvidia0

#define COUNT_FOR (60*4)

int main (void)
{
struct pollfd pfd;
struct timeval tv;
struct timezone tz;
double t1, t2;
int i, fd, timeout;

fd = open(FILENAME, O_RDONLY);

pfd.fd = fd;
pfd.events = POLLIN | POLLPRI;
pfd.revents = 0;

timeout = 1000;  /* milliseconds */

gettimeofday(tv, tz);
t1 = tv.tv_usec + (tv.tv_sec * 100.0);

for(i = 0; i  COUNT_FOR; i++) {
   if(poll(pfd, 1, timeout) = 0) {
   printf(poll() failed\n);
   break;
   }
usleep(0);
}

gettimeofday(tv, tz);
t2 = tv.tv_usec + (tv.tv_sec * 100.0);

close(fd);

printf(Refresh rate is %f Hz\n,
  (double)COUNT_FOR * 100.0 / (t2 - t1));

return 0;
}

___
Devel mailing list
Devel@XFree86.Org
http://XFree86.Org/mailman/listinfo/devel


Re: How do I sync output changes to vertical retrace?

2006-02-15 Thread Mark Vojkovich
On Mon, 13 Feb 2006, Barry Scott wrote:

 I have a text scrolling app that is not playing smoothly.

 Attempting to update the windows on a timer is not keeping my changes in
 sync with the monitors refresh. This is causing visual glitches.

 What mechanisms can I use to lock my changes to the monitor refresh rate?

  The only mechanism I know of is OpenGL.  Most OpenGL drivers have
a mechanism to allow buffer swapping at vblank.

 If I use DBE is it going to change the screen in the vertical blanking
 interval?


   No, it won't.  At least not in the XFree86/X.org implementations.


Mark.
___
Devel mailing list
Devel@XFree86.Org
http://XFree86.Org/mailman/listinfo/devel