Sync with Vertical Retrace

Sync with Vertical Retrace

Post by Kral Stef » Sat, 26 Oct 2002 18:39:49



Hi,

I want my X-based application (that displays some animation) to sync
with the vertical retrace of the CRT.

So far I have tried (and considered) the following:
  1) DBE                        does not sync
  2) XF86VidMode_SetViewPort    syncs with _some_ drivers (e.g., Matrox MGA)
  3) OpenGL                     not an option for me (as my X-terminals
                                do not offer 3D-hardware)
  4) DGA_SetViewPort            seems to sync with _some_ drivers

Is there any reliable, convenient interface that offers that feature?

Thank you.

Best Regards,
Stefan

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Sun, 27 Oct 2002 02:17:40



> Hi,

> I want my X-based application (that displays some animation) to sync
> with the vertical retrace of the CRT.

Oh, no, you don't. This would make your application terribly non-portable.
On some machines with high scan rates, your applicaiton would not be able
to function at all.

And not all displays even have either scanning or vertical retrace. Flat  
panels, for example. Some of the latter presently accept an analog TV-style
signal, but eventually this fiction will go away and these displays will
become a simple memory-mapped device, coupled to specific addresses in the
system's memory.

What you *do* want to do is use graphic double-buffering in your program.
This is the standard, robust way to make flicker-free animations that are
not platform-dependent. It is the *only* solution that will stand the test
of time.

Like this:

1. Display completed image in buffer A.
2. Write new image to buffer B.
3. When (2) is finished, switch display from buffer A to B, and start over
at (1), transposing A and B in the instructions.

Quote:> Is there any reliable, convenient interface that offers that feature?

You need to rethink your approach to the problem.

--
Paul Lutus
www.arachnoid.com

 
 
 

Sync with Vertical Retrace

Post by Kral Stef » Sun, 27 Oct 2002 20:17:52


: > I want my X-based application (that displays some animation) to sync
: > with the vertical retrace of the CRT.
: Oh, no, you don't. This would make your application terribly non-portable.
: On some machines with high scan rates, your applicaiton would not be able
: to function at all.
Yes, I do.
I want to display consistent states and I can only accomplish
that by syncing with the vertical retrace.

: And not all displays even have either scanning or vertical retrace. Flat  
: panels, for example. Some of the latter presently accept an analog TV-style
: signal, but eventually this fiction will go away and these displays will
: become a simple memory-mapped device, coupled to specific addresses in the
: system's memory.
Granted. Then I would have to insert some additional delay...
(I can use the SYNC-extension for that.)

: What you *do* want to do is use graphic double-buffering in your program.
: This is the standard, robust way to make flicker-free animations that are
: not platform-dependent. It is the *only* solution that will stand the test
: of time.
I already do that. However, flicker-free animations can still show
tearing effects (on CRTs).

: [...]
: > Is there any reliable, convenient interface that offers that feature?
: You need to rethink your approach to the problem.
So how should I do fast animations (that have high contrast)?

Regards,
Stefan

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Mon, 28 Oct 2002 01:45:34





> : > I want my X-based application (that displays some animation) to sync
> : > with the vertical retrace of the CRT.
> : Oh, no, you don't. This would make your application terribly
> : non-portable. On some machines with high scan rates, your applicaiton
> : would not be able to function at all.
> Yes, I do.
> I want to display consistent states and I can only accomplish
> that by syncing with the vertical retrace.

Yes to the first, no to the second. You can and should "display consistent
states" using double buffering. It is not true that you need to know
anyting about vertical retrace. Any such solution will fail immediately on
encountering a display with no vertical retrace, which means the code is
instantly obsolete (because there already are such displays).

Quote:

> : And not all displays even have either scanning or vertical retrace. Flat
> : panels, for example. Some of the latter presently accept an analog
> : TV-style signal, but eventually this fiction will go away and these
> : displays will become a simple memory-mapped device, coupled to specific
> : addresses in the system's memory.
> Granted. Then I would have to insert some additional delay...
> (I can use the SYNC-extension for that.)

No, you do not have to introduce any delay at all. In fact, double buffering
is overall faster than what you are proposing to do, because it always
shows the most recent image, regardless of what display constraints exist.

Quote:

> : What you *do* want to do is use graphic double-buffering in your
> : program. This is the standard, robust way to make flicker-free
> : animations that are not platform-dependent. It is the *only* solution
> : that will stand the test of time.
> I already do that. However, flicker-free animations can still show
> tearing effects (on CRTs).

> : [...]
> : > Is there any reliable, convenient interface that offers that feature?
> : You need to rethink your approach to the problem.
> So how should I do fast animations (that have high contrast)?

Use double buffering? Any graphics textbook explains this, the reasons and
the results. Double buffering guarantees portability and the assurance that
the most recent image is always made available to the display device.
Double buffering can in principle provide image updates much faster than
the display can update itself, and the image is always flicker-free. And
the method is entirely independent of the display hardware.

How do you think high-performance, fast-update graphic games produce their
results? They use double-buffering -- they create a new image off-screen,
then they show it when it is ready, seamlessly, without flicker.

--
Paul Lutus
www.arachnoid.com

 
 
 

Sync with Vertical Retrace

Post by Kral Stef » Mon, 28 Oct 2002 03:29:32




: > I want to display consistent states and I can only accomplish
: > that by syncing with the vertical retrace.
: Yes to the first, no to the second. You can and should "display consistent
: states" using double buffering. It is not true that you need to know
: anyting about vertical retrace. Any such solution will fail immediately on
: encountering a display with no vertical retrace, which means the code is
: instantly obsolete (because there already are such displays).
It would not be obsolete. In that case, a delay of 0 would do.

: > Granted. Then I would have to insert some additional delay...
: > (I can use the SYNC-extension for that.)
: No, you do not have to introduce any delay at all. In fact, double buffering
: is overall faster than what you are proposing to do, because it always
: shows the most recent image, regardless of what display constraints exist.
It is faster. But it does not give me the output that I want.
Maybe because the animation is too fast?!

: > So how should I do fast animations (that have high contrast)?
: Use double buffering? Any graphics textbook explains this, the reasons and
: the results. Double buffering guarantees portability and the assurance that
: the most recent image is always made available to the display device.
: Double buffering can in principle provide image updates much faster than
: the display can update itself, and the image is always flicker-free. And
: the method is entirely independent of the display hardware.
Please listen to me, just for a second:
  1) You do not need to teach me what double-buffering is (or how it works).
  2) Flicker-free does not necessarily imply that the animation is free of
     tearing-effects.

: How do you think high-performance, fast-update graphic games produce their
: results? They use double-buffering -- they create a new image off-screen,
: then they show it when it is ready, seamlessly, without flicker.
Conventional animations usually have small contrast between frames.
The animations that I want to do _always_ have a high contrast.

Please have a look at the following URL
'http://www.complang.tuwien.ac.at/skral/download/eyefriendly_xfree86/'.

If you compile and run test_nosync_dbe or test_nosync_copyarea,
you will see that double-buffering alone does _not_ solve the problem
of images being teared. In fact, most (if not all) all images displayed
on the screen do not reflect a consistent state (which would be
a completely white or a completely black window --- or maybe some window
filled with some grayscale).

Regards,
Stefan

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Mon, 28 Oct 2002 10:14:39







> : > I want to display consistent states and I can only accomplish
> : > that by syncing with the vertical retrace.
> : Yes to the first, no to the second. You can and should "display
> : consistent states" using double buffering. It is not true that you need
> : to know anyting about vertical retrace. Any such solution will fail
> : immediately on encountering a display with no vertical retrace, which
> : means the code is instantly obsolete (because there already are such
> : displays).
> It would not be obsolete. In that case, a delay of 0 would do.

In other words, drop the entire approach.

Quote:

> : > Granted. Then I would have to insert some additional delay...
> : > (I can use the SYNC-extension for that.)
> : No, you do not have to introduce any delay at all. In fact, double
> : buffering is overall faster than what you are proposing to do, because
> : it always shows the most recent image, regardless of what display
> : constraints exist.
> It is faster. But it does not give me the output that I want.
> Maybe because the animation is too fast?!

You need to learn how to use time delays, and don't use for-next loops to do
this. Use the various accurate-time delay methods built into modern
languages. That way your animation will run the same speed on computers
with different clock speeds.

Quote:

> : > So how should I do fast animations (that have high contrast)?
> : Use double buffering? Any graphics textbook explains this, the reasons
> : and the results. Double buffering guarantees portability and the
> : assurance that the most recent image is always made available to the
> : display device. Double buffering can in principle provide image updates
> : much faster than the display can update itself, and the image is always
> : flicker-free. And the method is entirely independent of the display
> : hardware.
> Please listen to me, just for a second:
>   1) You do not need to teach me what double-buffering is (or how it
>   works).

Yes, I do. You haven't shown any knowledge of it.

Quote:> 2) Flicker-free does not necessarily imply that the animation is
>   free of
>      tearing-effects.

Double-buffering prevents this. See? I do need to tell you.

Quote:

> : How do you think high-performance, fast-update graphic games produce
> : their results? They use double-buffering -- they create a new image
> : off-screen, then they show it when it is ready, seamlessly, without
> : flicker.
> Conventional animations usually have small contrast between frames.
> The animations that I want to do _always_ have a high contrast.

Double-buffering.

--
Paul Lutus
www.arachnoid.com

 
 
 

Sync with Vertical Retrace

Post by Steve Marti » Mon, 28 Oct 2002 21:44:45



> > I want my X-based application (that displays some animation) to sync
> > with the vertical retrace of the CRT.
> What you *do* want to do is use graphic double-buffering in your program.
> This is the standard, robust way to make flicker-free animations that are
> not platform-dependent. It is the *only* solution that will stand the test
> of time.

The only problem with this is that double-buffering is not necessarily
synchronized with the vertical retrace interval of the display. Yes,
this is not an issue with digital flat panels; however, the majority
of displays in existence at this point in time are the old-fashioned
CRT-based monitors, so this is definitely an issue.

Quote:> 1. Display completed image in buffer A.
> 2. Write new image to buffer B.
> 3. When (2) is finished, switch display from buffer A to B, and start over
> at (1), transposing A and B in the instructions.

This is a good description of the process. However, if the "switch
display"
point in step (3) is not synchronized with vertical retrace, then there
is a discontinuity in the displayed image that is under certain
circumstances quite perceivable to the viewer.

Also, writing a program depending on the viewer to be using a
digital display, it seems to me, would invite the very portability
problems you are warning about.

--
Steve Martin, CPBE CBNT

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Tue, 29 Oct 2002 01:53:21




>> > I want my X-based application (that displays some animation) to sync
>> > with the vertical retrace of the CRT.

>> What you *do* want to do is use graphic double-buffering in your program.
>> This is the standard, robust way to make flicker-free animations that are
>> not platform-dependent. It is the *only* solution that will stand the
>> test of time.

> The only problem with this is that double-buffering is not necessarily
> synchronized with the vertical retrace interval of the display.

The only problem with that it it doesn't matter. Frame buffering always
minimizes artifacts, and those artifacts that remain are unavoidable
regardless of approach.

Quote:> Yes,
> this is not an issue with digital flat panels; however, the majority
> of displays in existence at this point in time are the old-fashioned
> CRT-based monitors, so this is definitely an issue.

Nonsense.

Quote:

>> 1. Display completed image in buffer A.
>> 2. Write new image to buffer B.
>> 3. When (2) is finished, switch display from buffer A to B, and start
>> over at (1), transposing A and B in the instructions.

> This is a good description of the process. However, if the "switch
> display"
> point in step (3) is not synchronized with vertical retrace, then there
> is a discontinuity in the displayed image that is under certain
> circumstances quite perceivable to the viewer.

Nonsense.

Quote:

> Also, writing a program depending on the viewer to be using a
> digital display, it seems to me, would invite the very portability
> problems you are warning about.

Complete, total nonsense, and a post that in several ways misinterprets the
original. To summarize, professionals do not write computer programs that
depend in any way on the display device. To the degree that this is
practical, not its size, not its frame rate, nothing.

If the user of a program sees artifacts from the animation, maybe the frame
repetition rate is too low. There are plenty of unavoidable effects caused
by the frame rate in various media, but the single solution is to use frame
buffering. Everything beyond that is an unavoidable artifact (like the
picket-fence effect seen in varioud contexts in movies and TV).

Even synchronizing the program's frame rate with that of the display will
not solve the classic synchronization artifact problem. It has precisely no
worthwhile purpose.

--
Paul Lutus
www.arachnoid.com

 
 
 

Sync with Vertical Retrace

Post by Kral Stef » Tue, 29 Oct 2002 02:52:12


Paul,

In the following, I will give a quick summary of what your
"contribution" to this thread has been so far:
  (1) Everything that was not written by you is either "nonsense"
      or "complete, total nonsense".
        => I do not think that this discussion style is acceptable.

  (2) You do not provide plausible reasons or any kind of proof to
      justify your claims. Things are the way you say, just because
      you say so.
        => Try to convince people with sound logic.
           Do not try to persuade anyone.

  (3) You do not actually _react_ to contributions by others. You could
      have tried one of the test-apps that I wrote.  They illustrate
      that double-buffering alone is _not_ enough (at least on CRTs).
        => Discussions should not be monologs.

  (4) You looked down on me, trying to teach (trivial)
      concepts like double-buffering.
        => I can safely refuse that offer. Almost having completed
           my masters degree in computer science I know about
           basic, intermediate, and advanced concepts in this field.

The reason I wrote this is not to insult you, but to get to the point
where we can have a reasonable discussion.

Best Regards,
Stefan

 
 
 

Sync with Vertical Retrace

Post by Trevin Beatti » Tue, 29 Oct 2002 03:21:41



> Hi,

> I want my X-based application (that displays some animation) to sync
> with the vertical retrace of the CRT.
> ...

> Is there any reliable, convenient interface that offers that feature?

I'm not an authority on this, so someone will have to verify or disprove my
ideas, but here's why I -think- there's no practical way to do this.

First, for older video cards, the hardware and/or X server probably don't
provide any means of timing operations according to the vertical trace.  That
fact alone would prevent any standardized interface (though it wouldn't
preclude an extension to do it.)

For newer video cards, double buffering in video memory will automatically be
synchronized with video output by the hardware (I'm guessing), so the X server
doesn't need to do anything for it.

Lastly, vertical refresh rates can vary by card, video mode, and user
preference.  So if, for example, you want your program to display a smooth 60
fps animation, you can't expect an even distribution of the frames on a display
that's running at 72Hz or 87Hz.  And even if you wanted to query the display's
refresh rate and adjust your program's animaion accordingly, you have
additional problems with potential lag time in communicating with the X server
(when competing with other X clients) and getting accurate scheduling from the
host operating system (whose time slices may be as coarse as 100Hz).

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Tue, 29 Oct 2002 04:18:54



> Paul,

> In the following, I will give a quick summary of what your
> "contribution" ...

The classic beginning of a troll - the poster can't seem to address the
topic any more, so he turns his attention to something irrelevant.

Good day.

--
Paul Lutus
www.arachnoid.com

 
 
 

Sync with Vertical Retrace

Post by Kral Stef » Tue, 29 Oct 2002 05:42:36


: > In the following, I will give a quick summary of what your
: > "contribution" ...
: The classic beginning of a troll - the poster can't seem to address the
: topic any more, so he turns his attention to something irrelevant.
That was just the reaction that I expected.  Again, you to not justify
your claims (of what is relevant and what is irrelevant).

I wonder if you take the time to actually read what other people write,
or if you respond even before that.  Please feel free not to respond to
any postings of mine (past, present, and future).

Cheers,
Stefan

 
 
 

Sync with Vertical Retrace

Post by Steve Marti » Tue, 29 Oct 2002 05:47:14



> The only problem with that it it doesn't matter. Frame buffering always
> minimizes artifacts, and those artifacts that remain are unavoidable
> regardless of approach.

Paul, I'm going to suggest that you follow some of your own advice,
something I've seen you suggest to others in some of your other posts.

Try acting like a scientist.

Here's an experiment:

Set up a Linux/XFree86 system with a 3DFX VooDoo3 card (I specify
this card because it is the only one that I have encountered that
I was able successfully to synchronize with the monitor's vertical
retrace period). Ensure that the system is 3D capable, either
with DRI acceleration or simply software-based with the Mesa
libraries. Load and run the classic "gears" OpenGL demo.
Please note any temp*artifacting in the displayed image.

Now, on the same system, set the environment variable
FX_GLIDE_SWAPINTERVAL to 1. Re-run the "gears" demo. Note any
temp*aliasing in the displayed image.

I have performed the above experiment and can testify *by actual
observation* that there is indeed a distinct difference in the
quality of the image.

Please note that both attempts used the same binary, of a program
that employs double-buffering.

Until you have performed this experiment and can report the
results, I feel you have no right to belittle others' posts
with such terms as "nonsense". Try speaking from experience
for a change.

By the way, for what it's worth, I have run the "gears" demo
on both a Radeon SDR and a Matrox G550 with hardware-accelerated
DRI rendering enabled, and on both cards the same temp*aliasing
is evident.

Quote:> > This is a good description of the process. However, if the "switch
> > display"
> > point in step (3) is not synchronized with vertical retrace, then there
> > is a discontinuity in the displayed image that is under certain
> > circumstances quite perceivable to the viewer.

> Nonsense.

I have offered experimental evidence above to substantiate my statement.
Please offer evidence to substantiate your rude repudiation.

Quote:> Complete, total nonsense, and a post that in several ways misinterprets the
> original.

That's certainly possible. I've been wrong before, as I'm sure you have.

Quote:> If the user of a program sees artifacts from the animation, maybe the frame
> repetition rate is too low.

On my current system, "gears" (on the above-mentioned Matrox) runs at
a frame refresh rate of approximately 500 frames per second as reported
by the program. My monitor refresh rate is 60.0 frames per second as
reported by the XFree86 startup log. The frame rate of the program is
obviously not "too low". The software can keep up with the display just
fine.

Quote:> Even synchronizing the program's frame rate with that of the display will
> not solve the classic synchronization artifact problem. It has precisely no
> worthwhile purpose.

Per the above-described experiment, it certainly does address at
least some display artifacts.

--
Steve Martin, CPBE CBNT

 
 
 

Sync with Vertical Retrace

Post by Kirth Gerse » Tue, 29 Oct 2002 07:57:41


Stefan,

Ignore that guy.
That will hurt him most in the long run.

Kirth




> : > In the following, I will give a quick summary of what your
> : > "contribution" ...
> : The classic beginning of a troll - the poster can't seem to address the
> : topic any more, so he turns his attention to something irrelevant.
> That was just the reaction that I expected.  Again, you to not justify
> your claims (of what is relevant and what is irrelevant).

> I wonder if you take the time to actually read what other people write,
> or if you respond even before that.  Please feel free not to respond to
> any postings of mine (past, present, and future).

> Cheers,
> Stefan

 
 
 

Sync with Vertical Retrace

Post by Paul Lutu » Tue, 29 Oct 2002 09:05:01



> I wonder if you take the time to actually read what other people write,
> or if you respond even before that.  Please feel free not to respond to
> any postings of mine (past, present, and future).

Please feel free not to post here, unless you are willing to grant other
people the same right.

Idiot.

--
Paul Lutus
www.arachnoid.com