Archived

This topic is now archived and is closed to further replies.

What could be restricting my framerate?

This topic is 4945 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a fairly fast CPU (about an Athlon XP 3400+ speed). I have one gig of PC3200 ram, and my system bus is 380mhz. (yeah, it''s an overclock, but it''s stable). My video card is a Geforce 4 Ti4200. Not great, but fast enough for my little game. Yet I can''t break this invisible FPS barrier! My game sits at about 85fps all the time, with VSYNC on, AND off. When I look at my CPU usage when running the game, it''s about 25%. And my FPS values are identical whether I''m running 1600x1200, or 640x480, so I don''t think it''s the video card. (my graphics are very basic - boxes with textures drawn on them). Both my in-game FPS reporter and FRAPS (FPS utility) report the same rates, so I think I can trust my FPS reporter. Turning sound off makes no difference. I''m drawing these simple boxes using display lists (but I wasn''t using lists before, and the problem was the same). And here''s more interesting info, even when viewing the game menu (all game updates are paused, rendering is paused, and a small simple menu is displayed instead), my FPS don''t get high. I''m using OpenGL with GLUT to handle my graphics, controls, and game flow (using GLUT''s timer functions). I''m using OpenAL for audio. Whoa, I just discovered something. If I disable sound, then exit the game and restart it, the FPS won''t go over 65 when I re-enter the game without sound! (the sound settings are stored in a config file). But if I go through the menu and re-enable sound, instantly the FPS jumps back to 85/87! HUH? This is a sample of how I''m playing sounds:
//Play an explosion sound

void Sound::explosion() {
	if (sound)
		alSourcePlay(sources[3]);
}
All the OpenAL setup stuff is right out of tutorials and the OpenAL programmer''s guide. I don''t get it. Any ideas? I''m going to try completely removing the sound code (commenting) and see what happens...

Share this post


Link to post
Share on other sites
Ok, this is really wierd. The game runs at 65fps until I play a sound, then it runs at 85fps. For instance, if I start a new game (with sound enabled), it will run at 65fps. But as soon as I shoot a missile (which plays a sound), the fps goes up and stays up.

I have NO idea.

Share this post


Link to post
Share on other sites
If it''s 85 fps it really sounds like you''re syncing to the refresh rate. Are you absolutely sure it''s disabled? What refresh rate are you in in those various resolutions that you''ve tried?

cheers
sam

Share this post


Link to post
Share on other sites
easy sanity test:

1) set refresh rate of monitor to 60 -> run app
2) set refresh rate of minotor to 75 -> run app
3) set refresh rate of minotor to 85 -> run app

if your app is the same FPS as the monitor refresh rate every time you didn''t properly turn vsync off. if it''s 85 for all of those settings then something wierd is going on for sure.

-me

Share this post


Link to post
Share on other sites
My monitor reports the refresh rate. As a test, I told the Nvidia control panel to run 120hz at 640x480. I load my game, and at that resolution I''m getting 65fps. The monitor confirms it''s at 120hz.

I''m freaking out here. I have no clue what the problem is. I completely disabled all sound (and even commented out the sound class). Since I did that, I''m stuck at 65fps all the time (since the only way I got to 85fps was from playing a sound).

It doesn''t make any sense! And it''s not that my system is messed up either, other games run at high framerates! :-(

And I performed a restart, so it''s not that either.

Share this post


Link to post
Share on other sites
Ok, no kidding, I commented out EVERYTHING but the loop that calculates FPS. No game updates, no menu displayed, no nothing except a single loop. Let me summarize the program:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
draw_fps();
glutSwapBuffers();

And still 65fps.

I''m downloading that profiler now...but I''m totally lost. What happened? Does OpenGL have some FPS limit automatically active?

Share this post


Link to post
Share on other sites
That can be either this:

quote:
Original post by Zeu5
I think you have vsync turned on. Look at the options in the nvidia driver, OpenGL section.


OR

quote:
Original post by RuneLancer
Are you sure you''re calculating your FPS properly? Post the code that does it; I can''t see where else there''d be a problem...

Share this post


Link to post
Share on other sites
Do the test that Palidine suggested:

"1) set refresh rate of monitor to 60 -> run app
2) set refresh rate of minotor to 75 -> run app
3) set refresh rate of minotor to 85 -> run app"

Your limited fps are defenatly not depending on your code. It's your driver settings that restrict the fps.

I suggest you download the newest drivers from nvidia and go to the menu "Performance & ..." (or something) and turn of vsync. I got your problem too before I updated my nvidia drivers.

Hope that helps.

/Clontas

[edited by - clontas on May 28, 2004 4:18:56 AM]

Share this post


Link to post
Share on other sites
Well everything points to VSYNC, yet it''s off! I''ve got the latest Nvidia drivers. Within the control panel, they have no seperate settings for OpenGL and Direct3D, they''re combined in this release. But for the only setting they have for VSYNC, it''s disabled.

I then run some games to test, and yes, VSYNC is definatly disabled, with me getting around 500fps in Vice City when looking at the menu.

Then I load my game. With FRAPS running in the corner (the popular FPS program), and with my own FPS calculation in the other corner, they both indicate 65! It defies logic!

Since FRAPS is showing the same FPS as my own counter, I don''t think there''s any problem with my calculation of FPS. Yet, this is how I''m doing it:

Every time the game runs the render loop, at the end of the function the integer variable "frames" is incremented. Then every second this function is run:


//Set frames per second

void fps(int blah)
{
sprintf(fps_string, "FPS: %i", frame);
frame = 0;

//Reset timer

glutTimerFunc(1000, fps, 0);
}


It''s setup to run on a timer. Every 1000 ms (or close to that) GLUT will call this function which simply takes the frame value and puts it into a string. Inside my render loop, I call this to display the string:


if (Stats::draw_fps)
Graph.draw_fps(fps_string);


//Display frames per second

void Graphics::draw_fps(char *s)
{
glColor3f(1.0, 1.0, 1.0); // set color to White

print(0,0,(void *)font,s); //Display to screen

}


The print function runs through the string and displays values one at a time to screen.

I think what I''m going to do is to create a brand new project file with some basic OpenGL code in it that will display FPS and check if the new project does it too. Maybe something in my files (or Visual Studio) has become corrupted?

Share this post


Link to post
Share on other sites
seems like I had a similar problem with a directx program and I don''t remember which of the two things it was that was it but here are those suggestions:

1. Get one of those NVIDIA tweak programs to set the coolbit or whatever to see extra settings.

2. I believe in DirectX even if you turn off the VSync Globally, you''re program could still initialize directx to use it. I am unfamiliar with OpenGL so I am not sure if it''s the same. One thing that led me to this discovery was that when I ran my program in a window as opposed to fullscreen the framerate went above my refresh. So try running it in a window. I then played around with the initialization and got fullscreen to not use vsync.

Darryl

Share this post


Link to post
Share on other sites
Remember how I said the FPS jumps when I play a sound? Well I just restored the sound capability of the game, and again, when I play a sound the FPS jumps from 65 up to 85/87 (where it stays). In fact, if I sit in the menu holding the arrow key (which quickly moves through all menu items, playing a sound every time it moves), the FPS goes up to 89/90 (and then drops back down to 85 after I stop pressing the key). Huh? When I make it play sound continuously the FPS goes up even more? I''m totally clueless about this.

Thing is, I can keep developing this game and adding more and more stuff to it, and the FPS doesn''t change - it''s been 85 for the longest time. I have no idea how fast it can actually run, or if my code is even good!

I''m going to get new copies of my GLUT and OpenAL DLL files. Maybe that''s the problem?

Share this post


Link to post
Share on other sites
Ok, it''s not the DLLs. Here, try the game for yourself. When the game first loads, don''t touch any keys and just look at the FPS. Then once sound plays, look at the FPS again.

http://www.telusplanet.net/public/kord/misc/fury_fighter.rar

Share this post


Link to post
Share on other sites
Windows XP

"Fury Fighter.exe - Application Error
"The Instruction at 0x77f580c9" referenced memory at "0x00000000". The memory could not be "read".

"Click on OK to terminate the program
"Click on CANCEL to debug the program"

Can''t debug, no logs, etc...

maybe there''s a problem in initialization?

Share this post


Link to post
Share on other sites
Hmmm...

Well it was my understanding that Windows XP caps the framerate (by default) at 60fps. I am able to bypass this setting with the Nvidia control panel, setting custom refresh rates. Yet my game runs at 65fps and 85fps. Assuming it was Windows XP holding me back, I certainly wouldn''t achieve 85fps.

And regarding "Blue Mind" getting a crash...I have no idea what caused that. I''m going to add more extensive error checking and reporting into the game and see if I get anything interesting.

Thanks for the help.

Share this post


Link to post
Share on other sites
"Fury Fighter.exe - Application Error
"The Instruction at 0x77f580c9" referenced memory at "0x00000000". The memory could not be "read".

This error apear on my computer somethimes (but noth with your game becouse I didn''t download it - i hawe 56k dialup) and in my programs it is mostly an error with pointers coding.

Share this post


Link to post
Share on other sites
I don''t use pointers much. The one place I do use them is for the particle engine (linked list), and if they weren''t working properly you''d certainly know it pretty quick (with thousands of particles, a memory leak would show easily).

So then I''m left to point the finger at OpenAL or OpenGL, which surely use pointers. This error checking I''m adding now may shine light on that.

Share this post


Link to post
Share on other sites
How can you not use pointers ??
They are the ultimate at optimizing your engine, esential for assembler optimizations and SIMD.
Well anyway if the game works on other computer than this must bee an error that is related to end user computer.
He might not hawe the drivers that suport some 3D instruction, not hawe OpenAL runtime ....
Any way this is probably (PROBABLY) not your mistake

Share this post


Link to post
Share on other sites
Hey, rest assured - I''m getting to the pointers. But slow and steady. First I make it work, THEN I optimize it later! That''s why I use pointers with my particle engine, because without them it was too slow. (for my liking). Now I can pump out an easy 6000 or more particles on screen at the same time.

Share this post


Link to post
Share on other sites