Sign in to follow this  
Flawe

FPS/optimizing thoughts

Recommended Posts

ok, i know there are a lot of threads on this topic but i have some other questions and I couldn't come up with a better title for the thread. Anyway, i'm trying to do a top-down shoot 'em up but I have some problems with the graphics. well, maybe not problems, but I don't really know why stuff happens. First...how come I always get exaclty 86 FPS, no matter what I do, when I have v-sync on? When I set it to off, i get around 224 FPS. Another thing that's bothered me...when my friends tested the game on this lap-top, he got a little above 100 FPS, but it still laged and the graphics looked choppy. What could that be caused by? Thanx a lot for any help or ideas

Share this post


Link to post
Share on other sites
Vsync only lets the card draw a frame every time the screen refreshes. This can get rid of tearing and some other graphics badness. If you look, your monitor probably refreshes at 85hz and you friend's at 100hz. I'm not sure why the graphics would be choppy... if you could describe it better that would be helpful.

Share this post


Link to post
Share on other sites
ok..thanx for the v-sync info..didn't knew that =)

well, i'm describing it as he did...i only sent him the demo of the game and eh told me the graphic was choppy..like the frame rate was really low..buts til showed above 100 FPS... =/

i could give you the demo too, if you have time and wat to try it. needs java 1.5 though.


by the way, about v-sync...is it better to leave it on or off?

thanx

Share this post


Link to post
Share on other sites
Methinks that the laptop display is different than a CRT monitor, so even if the application says it's chugging 100fps, the display cannot refresh that fast. I've seen this in other games.

Share this post


Link to post
Share on other sites
sounds reasonable, since it's only his computer that shows the graphics choppy...but how come he can play doom 3 and games like that, without having any problems with the graphics?

This is my first time trying to do something with OpenGL and I know the code is far from optimized...but I got a little scared when I only have a ship and some objects flying around and it already started to get choppy

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you sure your graphics are choppy ? or are you confused with your physics being choppy ?

Share this post


Link to post
Share on other sites
Is your friend a graphics programmer?

In my experience 'choppy' can mean absolutely anything from a user...

I'd guess it's just tearing because vsync is off, but don't try to fix it unless you've seen it yourself.

Share this post


Link to post
Share on other sites
Hi,

Have you considered it could be a latency issue... ie the graphics card is buffering up a lot of frames(more than it should) hence the input responds slower than it should.

You should perhaps check the drivers are the most recent possible(most new drivers for mainstream graphics cards dont buffer too many frames).

Failing that add an option to force the graphics card to syncronize, eg locking the back buffer, or to get a little more sophisticated, ping ponging between a pair of textures rendering one and locking the other in turn(so that no more than 1 frame is buffered, depending how smart the drivers are).

Another issue could be that your timing code isnt working properly, eg the laptop is using speedstep(changing CPU clock rate, to conserve power).

David

Share this post


Link to post
Share on other sites
Here's the demo, if someone would have the time and wanted to take a look, I'd really appreciate it.

Maybe you guys can see if it's the code which destroys everything or if it's the graphics card...

http://www.itstud.chalmers.se/~flavius/klient6.rar


EDIT: I know it's the code...but maybe you could be gentle :P

Share this post


Link to post
Share on other sites
Ok, i have tested it and it looks nice.

The spaceship and powerups moves smooth, but the background moves choppy, especially when my ship moves fast. My FPS is at a steadt 86fps, so that is no problem. However, i now and then get graphical artifacts on the screen in the shape of white bars flashing on the screen.

Ill try to describe them as well as i can. They look like horizontal and verical bars that are a few inches wide. They appear sporadically, and usually only stay for a frame or so, so they could be tearing.

I tried to shoot or pickup the powerups, but couldn't, but maybe that isn't in the game yet, so it's probably not a bug.



System Specs:
------------------
Intel P4 3.4GHz Hyperthreading
2GB RAM
NVidia GeForce FX-5950 Ultra
Creative Audigy 2 ZS Platinum Pro

Share this post


Link to post
Share on other sites
mrbastard: I can't think of anything which could cause and OpenAl error =/


Allmight:

You should be able to shoot but there's no collission detection yet, so nothing happens when you "pick up" the power ups

Those bars appear because my logic behind teh background is kinda crapy. I have to do something about that. The background is built up by really big tiles 1024x1024 px. So those bars appear sometimes between the tiles.

I know of the choppyness of the background, but I don't really know why it's caused. You said the ship moves smooth but not the background. I know what you mean, it's exactly the same on my computer. The problem is, that the ship doesn't move at all. It's fixed in the center of the screen and I mvoe teh background relative to the ship. So I'm kinda confused when to look for why the background gives the impression of moving choppy relative to the screen, but smooth relative to the ship =/

Share this post


Link to post
Share on other sites
Ah, didn't notice the ship was centered, but now that you mention it. But the powerups move smooth as well, so that part of the code seems to work fine.

Maybe it has to do with the size of those bacground tiles, they get shuffled from system memory to gfx mamory. So when a new tile shows up on the screen you get a performance hit. But then the fps should drop as well. Hmmm. Are you moving the background at a fixed rate, or do move the background based on how much time has elapsed since the last frame? If you move it with a fixed number, then it probably gets choppy since every frame dont take the exact same time. If so, try to use a formula that use elapsed time as a base.

// Allmight

Share this post


Link to post
Share on other sites
A few things come to mind from a Java perspective as to what could cause your problem. Recently the guys at LWJGL found a problem with System.nanoTime(), where on Hyper-Threaded processors it would report normal, accurate times, but would then spew out one insanely long time causing a good jerk in anything that is based on timing. You could try using something like LWJGL's built-in timer (which I think has fixed this issue), or the GAGE timer.

Second, creating/releasing too many objects during the game loop can cause the garbage collector to run. On a profile of frame times of my 3D engine, I drop about 1 frame out of every 50 due to this, but I haven't made any effort to optimize.

These are some of the more difficult things to track down, but it could just be something in your OpenGL or math code. Do you use any of Java's built-in math functions, i.e. sin, cos, tan, atan, sqrt, etc? When doing a test of Java's built-in sin(), versus a library I implemented natively in C++ using JNI, I found that Java's sin() is about 7 times slower. Calling this a lot could slow things down.

Bottom line: post some code.

Share this post


Link to post
Share on other sites
perhaps its choppy on the laptop cause of speedstep or something
if u use queryperformancecounter under windows this returns incorrect results with a lot of laptops and new desktop processors

Share this post


Link to post
Share on other sites
Allmight:

Actually..teh FPS could drop. I think you have v-sync on, that's why you get a fixed 86 FPS. I have the same thing. When I disable v-sync, i get around 224 FPS and then it usually goes up and down.
Anyways, I have to change how that background works. It's a really bad idea having 1024x1024 px tiles. That's probably why it flickers sometimes when new tiles show up. I did a different technique before where I had a smaller "world". Only one 1024x1024 tile and instead of moving the diles relative to the ship, I changed the s/t coordinates of the texture. Since that was much smaller texture than these one I have now, it should have been choppy but it still was. I think it might be my physics code which calculate the position of the background for the next frame. Though I calculate it depending on how much time has gone since last iteration. I don't use a fix sleep-value for the thread. I might have to take a look at that.

mrbastard:
I'll take a look at the log, see what happens. thanx


Optus:
I use Jogl and Not LWJGL, I'm not very familiar with the latter one. And I use the ms timer, not the nano one. The ms one is actually worse so maybe I should change like you suggested.
I do a lot of Math calculations: sin, cos, sqrt..too many. Maybe I should get a library instead?
I really don't want to post some code yet. I'm to ashamed, haha. I'll do it when I get it a little bit more structured :P

Thanx for the advice guys...really helps a lot...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this