Page 2 of 3

Re: Display drivers programming

Posted: Thu Feb 23, 2012 4:54 pm
by John
Based on my understanding, therefore when someone says the video is running at 25 fps, or even 24 fps, that cannot be right...
At 60 hz, the screen refreshes at 0.0167ms.
And 25 fps, the pixels need to switch at every 25 frames. That = 0.04, and this is not a multiple of 0.0167.
Therefore, at somepoint, the video wasnt at 25 fps anymore, but "smear" across?
Am I missing something?

Re: Display drivers programming

Posted: Thu Feb 23, 2012 10:17 pm
by FallenAvatar
John wrote:Based on my understanding, therefore when someone says the video is running at 25 fps, or even 24 fps, that cannot be right...
At 60 hz, the screen refreshes at 0.0167ms.
And 25 fps, the pixels need to switch at every 25 frames. That = 0.04, and this is not a multiple of 0.0167.
Therefore, at somepoint, the video wasnt at 25 fps anymore, but "smear" across?
Am I missing something?
Lets say you have a monitor at 50hz, and a video at 25fps. The display ADAPTER (Not OS, not Driver, the adapter/graphics card) would just either not send a new picture for an extra refresh, or send the same picture twice in a row. (Not sure how it works, I'm sure it is generally done one way or the other tho)

For any other mismatch of fps to refresh rate, the graphics card handles it gracefully by either dropping frames or resending the same frame twice. This is also where motion blur comes in to help fill in the resent images with slightly different pictures, so the human eye doesn't see stutters.

- Monk

Re: Display drivers programming

Posted: Thu Feb 23, 2012 11:35 pm
by bluemoon
As Solar pointed out, by convention, frame-per-seconds, (vertical) refresh rate, and pixel latency are different; they are terms describing different things.

1. frame per seconds are used to describe how smooth your video source. It can be as fast as logic goes.

2. refresh rate are how often the display device make the frame visible on screen; while refresh rate is usually slow it is possible for a device to process and blend multiple video frames and show it at one shot.

3. pixel latency. see solar's description.

To add more confusion, there are response time of human eye, unless you are very concentrated and for a short period, you can't really see anything changes faster than 200Hz.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 12:44 am
by John
So, for a 60 Hz refresh rate, it refreshes the monitor every 0.0167ms.
If I have a game that runs at 24 fps, the game scene would have been updated every 0.04167ms.
So am I right to say that, when the time comes at 0.04167 ms, the game scene is updated. But it wont be shown on the monitor until
the time 0.0501 ms (3*0.0167)? And if that is the case, no games can claim that it runs higher than 60 fps. Is that correct?

Re: Display drivers programming

Posted: Fri Feb 24, 2012 12:52 am
by bluemoon
Almost correct. And you have to add the pixel latency for the scene to be actually shown.

However, the game can still claim it runs higher than 60 fps, in fact it is possible to redraw at 1000Hz; it's just the display card, monitor and the the cable/protocol between them are incapable - you can't blame the game creator for that.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 1:05 am
by John
So what does it mean when Combuster said it is easy to pump a refresh rate of 500Hz? Is this referring to 500 fps? Or that in 1 second, the video frame buffer is updated 500 times?
And why would vertical refresh rate not stated when we purchase a LED monitor? I've the impression that vertical refresh rate is no longer a concern with this new LED monitor where LEDs are switched on and off without having to care about tracing back like the CRT monitor.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 1:35 am
by Solar
John wrote:So what does it mean when Combuster said it is easy to pump a refresh rate of 500Hz? Is this referring to 500 fps?
Read. Understand. Post.

Don't leave out that crucial step in the middle.

"FPS" is a measure of whatever 3D engine you are using, and the detail level you have configured for Doom, Quake, or HalfLife. The limit here is CPU / GPU / RAM speed. (I think I wrote this before...)
And why would vertical refresh rate not stated when we purchase a LED monitor?
Because it does not matter.
I've the impression that vertical refresh rate is no longer a concern with this new LED monitor...
Correct. 60 Hz gives a stable picture, and that is all that counts.

As people wrote in this thread repeatedly.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 1:55 am
by FallenAvatar
Just a note. For gaming, 60hz is ok, not good enough. Preferred for gaming is 120hz+. For basic desktop 10hz is prolly good enough, and for youtube/netflix/videos 24-30hz is generally good enough, shy of blu-ray rips.

In an ideal system fps == refresh rate. This would mean an ideal use of resources, no dropped frames, no blended frames, just the right number of frames per second to keep every thing in the display line (OS, driver, graphics card, monitor.) But things are hardly ever ideal. So games aim for the highest possible FPS to give the player the best possible experience. And then they let the graphics card scale it down for whatever monitor the player has.

But, back on topic. John. You do not need to worry about fps, or [pixel] latency. And only when writing a display driver should you worry about the refresh rate. And if you are planning to write drivers for nVidia and/or AMD/Ati cards, well. good luck.

Your best bet to get the info for that is either the linux drivers, or on the nVidia and AMD sites. They both have released SOME specs for OLDER cards. But even then, that will be a lot of work. And it won't be anywhere near perfect.

- Monk

Re: Display drivers programming

Posted: Fri Feb 24, 2012 1:59 am
by Combuster
John wrote:So what does it mean when Combuster said it is easy to pump a refresh rate of 500Hz? Is this referring to 500 fps?
I used correct terminology, so no. Go figure the rest.
tjmonk wrote:For gaming, 60hz is ok, not good enough. Preferred for gaming is 120hz+ For basic desktop 10hz is prolly good enough
However I try to correct that, it's wrong.

Commercial (console) games are built to run a constant 30 or less constant 60 FPS. The former is sufficient to merge frames into animations, the latter is for smoother viewing if your hardware can handle it. Maintaining 60 Hz is more difficult and any increase in amount of framedrops is more distracting than the 30 extra frames. 120FPS is nonsense. you might get away with 10FPS for a desktop, but people will notice responsiveness issues when dragging windows if you try.

10Hz refresh rate breaks your monitor. 60 is enough for LCDs/LEDs. 120 is only meaningful on CRTs. Apparently, you too must read and understand the rest of the thread.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 2:02 am
by Solar
tjmonk15 wrote:Just a note. For gaming, 60hz is ok, not good enough. Preferred for gaming is 120hz+. For basic desktop 10hz is prolly good enough, and for youtube/netflix/videos 24-30hz is generally good enough, shy of blu-ray rips.
Please don't say "Hz" when you mean "FPS" or "frame rate". Some participants in this thread are already confused enough.

As for your references to Video: PAL is 50 Hz, NTSC is 60 Hz, neither of which is the 24p "movie frame rate" you obviously had in mind, and Blu-ray discs don't exceed a 59-odd frame rate either.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 3:30 am
by Brendan
Hi,
tjmonk15 wrote:So games aim for the highest possible FPS to give the player the best possible experience. And then they let the graphics card scale it down for whatever monitor the player has.
In general, if a game generates more frames than the monitor can display then the game is a stupid piece of crap that wastes CPU/GPU time for nothing.

Unfortunately, a lot of people who play games aren't very smart and think that "more FPS is better". Even more unfortunately, often these people are actually right, but not because of the FPS. Sadly, a lot of games do something like:

Code: Select all

    while(running) {
        Update_AI();
        Get_user_input();
        Update_objects_and_check_collisions();
        Update_screen();
    }
Because of this, "higher FPS" means that the game is checking user input and responding to it more often; so "higher FPS" actually does help make the game feel more responsive even though the extra frames are a waste of time.

A better game would do something like this instead:

Code: Select all

    while(running) {
        Update_AI();
        Get_user_input();
        Update_objects_and_check_collisions();
        if(screen_hasn't_been_updated_in_the_last_16ms) {
            Update_screen();
        }
    }
In this case the game would never exceed 60 FPS, but would check user input and respond to it as often as possible (more often than a game running at "higher than 60 FPS" because the time that would've been wasted on pointless screen updates is spent checking for user input, etc).

Of course the next step is to use multiple threads/CPUs, where one thread is responsible for doing something like:

Code: Select all

    while(running) {
        if(game_state_changed) {
            update_screen();
        }
        wait_until_next_screen_update();
    }
Unfortunately, people who write games aren't smart enough to handle multiple threads (and often aren't even smart enough to add the "if(game_state_changed)" part and will redraw exactly the same graphics repeatedly when nothing has changed at all).


Cheers,

Brendan

Re: Display drivers programming

Posted: Fri Feb 24, 2012 4:18 am
by FallenAvatar
Solar wrote:
tjmonk15 wrote:...
Please don't say "Hz" when you mean "FPS" or "frame rate". Some participants in this thread are already confused enough.

As for your references to Video: PAL is 50 Hz, NTSC is 60 Hz, neither of which is the 24p "movie frame rate" you obviously had in mind, and Blu-ray discs don't exceed a 59-odd frame rate either.
Actually, I did mean HZ, and not FPS in this instance, since most games can run in excess of 60 or 100 FPS, its the HZ that matters. And visual tearing is a big problem in gaming.

And notice I explicity mentioned certain services/formats that generally conform to what I said. (There are, of course, exceptions to every "rule".) I brought these up, because they are general/popular use cases these days.

And Brendan, please see comments in red below.
Brendan wrote:Hi,
tjmonk15 wrote:So games aim for the highest possible FPS to give the player the best possible experience. And then they let the graphics card scale it down for whatever monitor the player has.
In general, if a game generates more frames than the monitor can display then the game is a stupid piece of crap that wastes CPU/GPU time for nothing.

Not really. Gamers expect to be able to disable VSync these days. Usually for the reasons you mention below, and others.

Unfortunately, a lot of people who play games aren't very smart and think that "more FPS is better". Even more unfortunately, often these people are actually right, but not because of the FPS. Sadly, a lot of games do something like:

Code: Select all

    while(running) {
        Update_AI();
        Get_user_input();
        Update_objects_and_check_collisions();
        Update_screen();
    }
Labelly Gamers as not very smart can be hazardous to your health lol, though this would be a "safe" place to do it :P. Also remember that in Game terms, a Frame has several meanings. It can mean what you list above (Graphics, AI, Physics, etc.) all together. And in this case, updating them all as frequently as possible is very, very, very good. (More updates per second allows for better physics simulations, and better AI.)

Because of this, "higher FPS" means that the game is checking user input and responding to it more often; so "higher FPS" actually does help make the game feel more responsive even though the extra frames are a waste of time.

This is a HUGE reason Gamers like/want/demand high FPS. Because like I said, a frame means more than just a screen update.

A better game would do something like this instead:

Code: Select all

    while(running) {
        Update_AI();
        Get_user_input();
        Update_objects_and_check_collisions();
        if(screen_hasn't_been_updated_in_the_last_16ms) {
            Update_screen();
        }
    }
Most new games do this, if and only if, VSync is turned on by the player.

In this case the game would never exceed 60 FPS, but would check user input and respond to it as often as possible (more often than a game running at "higher than 60 FPS" because the time that would've been wasted on pointless screen updates is spent checking for user input, etc).

This would be the best of both worlds until a player has a 75HZ or 120HZ screen. And suddenly this code does more harm than good. Obviously accounting for screen refresh rate would fix this. But with Gamers being used to the way things are, this change would alarm them more than calm them. So this won't happen. (read as a Marketing Decision)

Of course the next step is to use multiple threads/CPUs, where one thread is responsible for doing something like:

Code: Select all

    while(running) {
        if(game_state_changed) {
            update_screen();
        }
        wait_until_next_screen_update();
    }
In Game Programming this generally does more harm than good. There are not a lot of good places to parallelize game logic. Animation relies on game time, Physics rely on animation data (where an arm is in the animation severly impacts whether a bullet hit it or not), rendering relies on both of the above. Don't forget Input changing animations, causing new physics checks to occur, etc. And then add in networking, and realize to get accurate physics (Hit detection and such) you may have to "rewind" several frames, based on ping, to check if the player hit someone when they clicked the fire button, and not now. Everything is too interdependent to make this common place. I'm not saying its impossible, but it is much harder than most people think.

Unfortunately, people who write games aren't smart enough to handle multiple threads (and often aren't even smart enough to add the "if(game_state_changed)" part and will redraw exactly the same graphics repeatedly when nothing has changed at all).

This is because checking if the game state changed would be more expensive than just redrawing the frame. See the list of interactions above to get an idea of the number of checks you would have to make. And don't forget any of those interactions could be altered by a single network packet. And depending on the game, cause the game to go back in time several ms and re calculate EVERYTHING to make up for a bad assumption (because of lag compensation)


Cheers,

Brendan
Brendan, also realize how stressful a game dev's life is. They generally work 80-120 hours a week, and if they do not deliver on time, well lets just say they are suddenly browsing career builder. That career path is extremely competitive and stressful. Saying they aren't smart enough to do something comes straight from ignorance. They cut corners because they have to, because if they don't, they will never deliver on time. And if they don't deliver on time, they will likely end up on the streets (given that so many of them live in or near silicon valley, or even Southern Cali, where the cost of living is astronomical.)

- Monk

EDIT: Changed super bright red for a darker one to help readability. Is it better now?

Re: Display drivers programming

Posted: Fri Feb 24, 2012 4:28 am
by turdus
tjmonk15 wrote:This is because checking if the game state changed would be more expensive than just redrawing the frame. See the list of interactions above to get an idea of the number of checks you would have to make.
LOL. What a bullshit.
Checking game state can be done with an atomic cpu instruction. You set that flag in physics, collusion, AI etc. modules, and clear in redraw. That's all.

Re: Display drivers programming

Posted: Fri Feb 24, 2012 4:49 am
by FallenAvatar
turdus wrote:
tjmonk15 wrote:This is because checking if the game state changed would be more expensive than just redrawing the frame. See the list of interactions above to get an idea of the number of checks you would have to make.
LOL. What a bullshit.
Checking game state can be done with an atomic cpu instruction. You set that flag in physics, collusion, AI etc. modules, and clear in redraw. That's all.
I guess that explanation did leave something to be desired. I apologize about that. But, how about the amount of time it would take to go through all the engine code, and game code to add code to set a variable. In modern games, we are talking about placing that code in probably thousands of places. (Doubt that? go download the Source SDK off steam, and check umm, what file was that... hl2mp/CHL2MPMovement.cpp?) You would have to add that code in probably 100+ places in just that file (This is from memory, so don't quote me on it) But it is a lot. And that is just one file. Now add the rest of the code, and the engine code... You can see how big of a task this is.

And before you say it would save CPU/GPU/RAM/whatever, remember we are talking about a commercial industry here. The guys at the top don't care about doing it right, they care about getting it done. And this just isn't an option.

So accept it as a fact of a game devs/OS devs/gamers life, and move on. *shrug*

- Monk

Re: Display drivers programming

Posted: Fri Feb 24, 2012 5:00 am
by bubach
OMG, I think I have to tear my eyes out. I'm oldschool and use the MegaTokyo theme for this board.. Bright red on dark blue. [-X