PDA

View Full Version : quad buffered frame rate confusion


michaelrepucci
09-10-2008, 11:35 AM
Hi, I'm running applications using quad buffered stereo, and I have the refresh rate set to 120 Hz. But when I run even the simplest Vizard script -

import viz
viz.go(viz.QUAD_BUFFER)

- and hit F4 to display the frame rate (framerate), the number of frames-per-second hovers around 60. Is this the intended functionality, or am I have problems? If this is intentionally, is there a way I can force Vizard to display 120 Hz, so as not to confuse the reported refresh rate with that achieved in a non-stereo 60 Hz application. Thanks!

Jeff
09-11-2008, 04:39 PM
Thanks for the post. Sorry, we have not had time to answer yet. We will respond tomorrow or early next week.

michaelrepucci
09-11-2008, 04:45 PM
Although I obviously hope you answer sooner, I just wanted to let you know that I really appreciate your acknowledgment of the question even when you don't have time to answer it.

farshizzo
09-12-2008, 11:39 AM
Are you sure your monitor actually supports a refresh rate of 120Hz? What monitor do you have? Vizards framerate is controlled by the vertical sync signal from the monitor, so it sounds like your monitor does not actually support 120Hz.

michaelrepucci
09-12-2008, 11:45 AM
Yes, for multiple reasons, I'm certain that the monitor (actually a projector) supports 120 Hz. The simplest reason is that viz.go() without viz.QUAD_BUFFER runs at 120 Hz.

I'm also sure that my video card - NVidia Quadro FX 3700 - supports quad-buffered stereo at 120 Hz, since I've tried it on a traditional analog monitor with a non-Vizard application.

mspusch
09-12-2008, 01:27 PM
Is the 120Hz projector the only device that's connected?
Is it s depthQ projector?

if yes, then we have one sitting here at Worldviz for trouble-shooting.

the only problem i have seen with the depthq is that it will NOT render stereo in 120 HZ if you have another device connected. so make sure that the ONLY device conneted to the graphics card is the projector.

michaelrepucci
09-15-2008, 10:10 AM
I do have a second device (an standard analog monitor) connected to the video card, which has two independent DVI-I ports. After much exploration, it seems, however, that the video card bandwidth is narrower than I had expected. So turning down the resolution on the projector helped solved the problem, as did putting both devices at the same refresh rate (there must be some savings at the GPU).

So now viz.go(viz.QUAD_BUFFER) runs fine at 120 Hz. But I started to do some frame time logging with the following code:

import viz
import viztask

def onFrameUpdate(event):
global frameTime
global frameInterval
frameTime += [event.time]
frameInterval += [event.elapsed]

def collectFrames():
print 'Collecting frame times ...'
viz.callback(viz.UPDATE_EVENT,onFrameUpdate)
yield viztask.waitTime(60)
print 'Finished collection.'
viz.callback(viz.UPDATE_EVENT,None)
yield writeFile()

def writeFile():
file = open('frametime.txt','wt')
file.write('frameTime = (')
for i in frameTime:
file.write(str(i)+',')
file.write(')\n')

file.write('frameInterval = (')
for i in frameInterval:
file.write(str(i)+',')
file.write(')\n')

yield file.flush()
file.close()
viz.quit()

frameTime =[]
frameInterval = []

viz.go(viz.QUAD_BUFFER)
viztask.schedule(collectFrames())

and I found that the time stamps were not very precise. I had expected them to be nearly rock-solid, since the frames should be locked to the refresh rate. It this, possibly, due to Windows processes interrupting the Vizard execution, or can I not expect Vizard to run completely real-time?

farshizzo
09-15-2008, 11:03 AM
How precise do you expect the timing to be? When I log the elapsed time between frames it doesn't fluctuate more than 1ms from the expected rate. Either way, Windows does not run at real-time rates so your process can be interrupted by other processes at any time. You can tell Windows to give your process a real-time priority by using the following code:import win32process
import win32con
win32process.SetPriorityClass(win32process.GetCurr entProcess(),win32con.REALTIME_PRIORITY_CLASS)Howe ver, this can cause unexpected problems and might not actually help.

michaelrepucci
09-15-2008, 11:36 AM
If the maximum deviation from the expected value were within 1 ms I would be happy. On my system it is not. At 120 Hz, the expected frame interval is around 8.333 ms. On one run, where the frame rate never noticeably dropped below 120 Hz, I get values in the range from 3.862 ms to 21.94 ms (see the attached histogram). Granted the variation is small; the standard deviation is 0.579 ms. (In the attached figure, counts above 20 are truncated.) However, the longer and shorter values, if accurate, suggest that frames are occasionally being dropped or skipped.

tobin
09-17-2008, 01:08 AM
Your code includes calls to disk every frame, right? You should try storing your timing info into an array and then after a set number of frames, write/flush to disk.

michaelrepucci
09-17-2008, 08:22 AM
No, the code doesn't write to disk on every frame, though it does do so after every trial - it is important to save experimental data after each trial in case of a crash, power-outage, or similar - which occurs irregularly, typically every 6 seconds (i.e., 6s x 120 Hz = 720 frames). But you're right, that does approximately account for the percent of frames that fluctuate significantly.

As another concern, I'm storing the frame timing in an array, which is appended on each frame. In Matlab - I have a lot of experience with Matlab - this would be very slow, and could be sped up by pre-allocating an array of the length I expect to use. Would this also speed up Python?

tobin
09-17-2008, 08:55 AM
I don't know how efficient Python's array append call is, sorry. With Vizard, you generally don't have to worry about small performance issues such as that as long as all your frame processing can occur within 1/(frame rate) seconds.

Since you know matlab and seem intersted in performance related topics, you should read the Vizard docs under Reference / Python add-ons. There's a "just-in-time" compiler you can implement to speed up numerically heavy code, and there's also links to a project called "matplotlib" which provides matlab style plotting from Python. Also referenced is numpy (providing matlab like array & matrix notation), and PIL (imaging library like matlab's image toolbox).