Zotrix
Zotrix > General Discussions > Topic Details
Gemini Dec 25, 2015 @ 8:05am
Horrible Framerate on Decent Gaming Rig
I was just gifted the game and tried playing it and not only is the framerate "skippy", pulsing between two different speeds, but both of those speeds are roughly HALF of what the game's supposed to run at given what I've seen in online videos and trailers. Heck, when watching the intro, the days left counter actually ran under 0 to around -60 ish before the intro was done.

I've tried various compatibility settings and 3D graphics settings, even running in a window, all to no avail. :(

My computer specs are as follows:
* AMD FX-8350 4 GHz 8-Core CPU
* nVidia GeForce 660 GTX GPU
* 16 GB RAM
* 1 TB WD Black HD (180 GB Free)
* Windows 8.1 Pro
* 1920x1080 Screen Resolution

So... yeah. A 2D shooter should be running 60 FPS on this thing no problem. :/

Also, I'm not seeing any visual indication on my ship itself when I take damage. Maybe that's related to my framerate issues but if that feature's missing I recommend adding it IMMEDIATELY. Having some kind of feedback on the player's ship that damage has been received is essential to playing ANY 2D shooter so that you don't have to divert your attention to know you're taking damage.
< >
Showing 1-13 of 13 comments
vedran.klanac [Zotrix]  [developer] Dec 28, 2015 @ 12:25am 
Well, you are first one reporting this. Game is so low-consuming on GPU so there has to be something with your driver or settings. Game is tested on configurations as low as 1.5Ghz and on-board-GPU and runs smooth.
vedran.klanac [Zotrix]  [developer] Dec 28, 2015 @ 12:26am 
Ah yes, now I see, Win 8.1 Pro -> read -> horrible drivers for nVidia cards.
Gemini Dec 28, 2015 @ 8:08am 
Uhhh... OK... speaking as a game developer myself you know as well as I do that that's not an excuse when your minimum specs on Steam itself indicate compatibility with Windows 8. If you're not going to support nVidia cards, even if under specific circumstances, this needs to be indicated in the specs. (I actually found out with my own project recently that Intel cards and the Allegro libraries don't mix very well, so I may need to omit support for Intel GPUs when I'm ready to launch my next project...)

Besides, I should also point out that OpenGL support on the Win8 nVidia side of things is near flawless, actually works better than legacy pre-DX9 Direct3D support! Not to mention I've been coding with OpenGL myself so I know it SHOULD be working fine.

Also, if I'm the first one to report a problem like this, it can't possibly be because of the combination of Win8 and an nVidia GPU because I can't possibly be the only person with that combination playing your game. :P

So... something else must be going on...

...I did a bunch more testing and I've noticed that altering either vertical sync settings at the driver level or adjusting the refresh rate of my monitor has noticeable effects on the framerate. I was able to make it slightly better by decreasing my refresh rate from 60 Hz to 50 Hz, but it still didn't solve the problem, plus I was able to make it slightly worse by using adaptive + half-refresh vsyncing, suggesting to me that your logic timing is linked to the framerate. Since you're using SDL, meaning you've likely had to code much of the timing routines yourself, my best guess is that the game is burning two frames worth of time on my system per actual frame on most but not all frames because it thinks it has to for some reason... possibly exceeding the granularity of a system timer you're relying on or underflowing a counter or something... it's hard to know without seeing the actual code. *shrugs*

But yeah, seems to be timing related so if you do want to deal with this then that's the place to look in your code! :B

Also, fun fact: I noticed that your game runs in Windows 98/ME Compatibility Mode. NOTHING runs in that! Might be worth checking to see if it runs on a REAL Win98 machine! ;)
vedran.klanac [Zotrix]  [developer] Dec 29, 2015 @ 5:26am 
Interesting, can you please let me know what is the CPU consumption when you run the game. Few years back, we had an issue with high CPU usage on ATI cards only ! :) So we figured out that in main system loop we need to call Sleep(10); just to stall the loop to get it better in sync with ATI Radeon cards, and then it all started working fine. Since you don;t have ATI Radeon, this is not the case here. I only have Win7,10 and XP machines here in the office, so it's hard for me to test it from Visual Studio with all the game engine metrics enabled.

I have an idea...I can expose our internal profiler on a key shortcut and then you could check certain numbers and let me know the readings. That could help me to figure out where's the bottle neck.

I can prepare such update after NY, in early January. I'll keep you posted.
Gemini Dec 29, 2015 @ 6:33am 
CPU Usage for Zotrix is about 0.05%, which is less than can normally be measured so I'm basing that on seeing 0% half the time and 0.1% the other half. That's with "Threaded Optimization" off in my driver settings, as having that setting on increases CPU usage dramatically across all cores to squeeze more rendering power out of games.

That said, speaking as a programmer, I can tell you a few interesting things about having Sleep() in your game loop:

* Under all circumstances, it's good to have Sleep(0). This tells Windows that the remainder of the program's current time-slice should be given up to other processes of the same priority. Basically, it's how you keep the OS working properly in the background while your game does its thing.

* Using ANY Sleep() value greater than 0 introduces actual system idling, but the granularity is undefined and can be different across different versions of Windows and different hardware configurations. At worst, Sleep(1) can be the equlivalent of Sleep(50)! :O

* High CPU usage in a game solved by introducing Sleep() with a value greater than 0 is caused by the game not having a proper sync method. If vertical sync is disabled at the hardware level, or even in-game, as some people do in order to improve input response time, this eliminates a means of synchronizing frames and thus the game will attempt to render as many frames as it can, and will simply waste CPU power the rest of the time. By default, when using hardware accelerated graphics, vertical syncs are non-busy waits, meaning no CPU time is used while waiting for the next frame. (Vertical syncing with software rendering though WILL be a busy wait unless coded to function differently.)

SO, the solution in your case, given what you've just told me is twofold:

1: Introduce a "Vertical Sync" option into your video settings and either put an appropriate vsync call into your game loop or register your display creation with vertical syncing enabled, if your libraries support this. When Vertical Sync is enabled, call Sleep(0) in your game loop. When Vertical Sync is disabled, call Sleep(1).

2: Add a second option for "Reduce CPU Usage". When enabled, Sleep(10) is called instead of the other Sleep() values, regardless of the Vertical Sync setting.

This way, people who like to have vsync off can still keep CPU usage down if it ramps up, while people who like their vsync like I do can have a silky smooth framerate unaffected by Sleep() calls. ;)

There's actually another potential and better solution, but it's a lot trickier to pull off, and that's to use multi-threading semaphors to idle your game's process by more precise amounts of time. I've done it before, creating my own alternative to Sleep() which can idle the EXACT amount of time you want to idle for in milliseconds.

I've uploaded the source files I wrote for this to my website which you can download and look through, though they were written MANY years ago to use Allegro 4's timer system as they were inteded for use without hardware accelerated graphics, so they aren't usable as they are, but might give you some ideas if you want to get more advanced than just having a couple new options in-game:

http://www.pixelships.com/random/g-idle.c
http://www.pixelships.com/random/g-idle.h

Generally speaking though, having an option for vsync with Sleep(0) and an option for no vsync and Sleep(1) is good enough for most cases, while having an option to reduce CPU usage even further isn't bad either. :B
Greywolf208 Jan 3, 2016 @ 3:18pm 
Originally posted by Gemini:
CPU Usage for Zotrix is about 0.05%, which is less than can normally be measured so I'm basing that on seeing 0% half the time and 0.1% the other half. That's with "Threaded Optimization" off in my driver settings, as having that setting on increases CPU usage dramatically across all cores to squeeze more rendering power out of games.

That said, speaking as a programmer, I can tell you a few interesting things about having Sleep() in your game loop:

* Under all circumstances, it's good to have Sleep(0). This tells Windows that the remainder of the program's current time-slice should be given up to other processes of the same priority. Basically, it's how you keep the OS working properly in the background while your game does its thing.

* Using ANY Sleep() value greater than 0 introduces actual system idling, but the granularity is undefined and can be different across different versions of Windows and different hardware configurations. At worst, Sleep(1) can be the equlivalent of Sleep(50)! :O

* High CPU usage in a game solved by introducing Sleep() with a value greater than 0 is caused by the game not having a proper sync method. If vertical sync is disabled at the hardware level, or even in-game, as some people do in order to improve input response time, this eliminates a means of synchronizing frames and thus the game will attempt to render as many frames as it can, and will simply waste CPU power the rest of the time. By default, when using hardware accelerated graphics, vertical syncs are non-busy waits, meaning no CPU time is used while waiting for the next frame. (Vertical syncing with software rendering though WILL be a busy wait unless coded to function differently.)

SO, the solution in your case, given what you've just told me is twofold:

1: Introduce a "Vertical Sync" option into your video settings and either put an appropriate vsync call into your game loop or register your display creation with vertical syncing enabled, if your libraries support this. When Vertical Sync is enabled, call Sleep(0) in your game loop. When Vertical Sync is disabled, call Sleep(1).

2: Add a second option for "Reduce CPU Usage". When enabled, Sleep(10) is called instead of the other Sleep() values, regardless of the Vertical Sync setting.

This way, people who like to have vsync off can still keep CPU usage down if it ramps up, while people who like their vsync like I do can have a silky smooth framerate unaffected by Sleep() calls. ;)

There's actually another potential and better solution, but it's a lot trickier to pull off, and that's to use multi-threading semaphors to idle your game's process by more precise amounts of time. I've done it before, creating my own alternative to Sleep() which can idle the EXACT amount of time you want to idle for in milliseconds.

I've uploaded the source files I wrote for this to my website which you can download and look through, though they were written MANY years ago to use Allegro 4's timer system as they were inteded for use without hardware accelerated graphics, so they aren't usable as they are, but might give you some ideas if you want to get more advanced than just having a couple new options in-game:

http://www.pixelships.com/random/g-idle.c
http://www.pixelships.com/random/g-idle.h

Generally speaking though, having an option for vsync with Sleep(0) and an option for no vsync and Sleep(1) is good enough for most cases, while having an option to reduce CPU usage even further isn't bad either. :B

so you know, just saying "as a programmer myself" does not give you immediate knowledge of the problem, for all we know your lying, while this guy has a game already, so you dont need to keep repeating it
Gemini Jan 3, 2016 @ 4:48pm 
Originally posted by greywolf208:
so you know, just saying "as a programmer myself" does not give you immediate knowledge of the problem, for all we know your lying, while this guy has a game already, so you dont need to keep repeating it
Very true, which is why before you make a statement like that you really should learn more about the person you're about to openly criticise...

...for instance, you could've gone to my website and noticed I've released MORE than one game, many of which were freeware and a couple of which are still for sale outside of the Steam system as they came out way before Steam openly accepted indie developers, while the reason I haven't attempted to get them onto Steam is because they're severely outdated and I haven't had the time to update them as I've long since moved on to other projects.

One of the freeware games is even still a top-rated game on the Allegro.cc website for the Allegro Game Programming Libraries, so... yeah, I think I know what I'm talking about, at least to SOME degree! ;)

I've also helped out on the forums there too from time to time with programming advice. You'll notice I go by my real name on Allegro.cc because I joined the website a decade and a half ago and back then, that's how everyone there did it. :P

What I'm trying to do now in this thread is help identify a problem I'm having with Zotrix and suggest potential changes and programming tips given what the developer has already stated. Yes, I could be wrong because I don't have the game's source code in front of me so I can't know exactly how the game works internally, but I can make an educated guess and compare with my own coding experience.

Also, I originally stated "as a game developer myself" to indicate I had experience making games, then later stated "speaking as a programmer" so that the dev would be aware I also had programming knowhow. The two do NOT go hand in hand! When the dev mentioned the Sleep() command I decided to really go all out on an explanation of it when used in a game programming context because of the wide range of effects it can have.

So... yeah. Please be more careful about leaving such comments for people, Greywolf, especially when you yourself say in your Steam profile to be polite and professional. (We'll just ignore the "plan to kill everyone you meet" part! ;)
Greywolf208 Jan 3, 2016 @ 4:51pm 
Originally posted by Gemini:
Originally posted by greywolf208:
so you know, just saying "as a programmer myself" does not give you immediate knowledge of the problem, for all we know your lying, while this guy has a game already, so you dont need to keep repeating it
Very true, which is why before you make a statement like that you really should learn more about the person you're about to openly criticise...

...for instance, you could've gone to my website and noticed I've released MORE than one game, many of which were freeware and a couple of which are still for sale outside of the Steam system as they came out way before Steam openly accepted indie developers, while the reason I haven't attempted to get them onto Steam is because they're severely outdated and I haven't had the time to update them as I've long since moved on to other projects.

One of the freeware games is even still a top-rated game on the Allegro.cc website for the Allegro Game Programming Libraries, so... yeah, I think I know what I'm talking about, at least to SOME degree! ;)

I've also helped out on the forums there too from time to time with programming advice. You'll notice I go by my real name on Allegro.cc because I joined the website a decade and a half ago and back then, that's how everyone there did it. :P

What I'm trying to do now in this thread is help identify a problem I'm having with Zotrix and suggest potential changes and programming tips given what the developer has already stated. Yes, I could be wrong because I don't have the game's source code in front of me so I can't know exactly how the game works internally, but I can make an educated guess and compare with my own coding experience.

Also, I originally stated "as a game developer myself" to indicate I had experience making games, then later stated "speaking as a programmer" so that the dev would be aware I also had programming knowhow. The two do NOT go hand in hand! When the dev mentioned the Sleep() command I decided to really go all out on an explanation of it when used in a game programming context because of the wide range of effects it can have.

So... yeah. Please be more careful about leaving such comments for people, Greywolf, especially when you yourself say in your Steam profile to be polite and professional. (We'll just ignore the "plan to kill everyone you meet" part! ;)
ok, fine, I admit I was being lazy XP
I was on a phone, so I didn't have much time to write and research, good day to you,
and I wasn't trying to critisize you, was giving(wrong) advice ;)
Last edited by Greywolf208; Jan 3, 2016 @ 4:52pm
Gemini Jan 3, 2016 @ 5:02pm 
Originally posted by greywolf208:
ok, fine, I admit I was being lazy XP
I was on a phone, so I didn't have much time to write and research, good day to you,
and I wasn't trying to critisize you, was giving(wrong) advice ;)
Awesome. This is why I never assume someone is being a jerk just to troll and do my best to understand where someone's coming from before I respond. :)
vedran.klanac [Zotrix]  [developer] Jan 4, 2016 @ 3:43am 
Hey guys, this kind of drifts in wrong direction :) Happy New Year everyone and I wish you both lot of success in your private lives and professional careers.
Gemini Jan 4, 2016 @ 10:23am 
Originally posted by vedran.klanac Zotrix:
Hey guys, this kind of drifts in wrong direction :) Happy New Year everyone and I wish you both lot of success in your private lives and professional careers.
Happy New Year to you too, Vedran! Sorry for the little tangent which happened with Greywolf; I think we're good to be back on topic now. ;)
[JC]Westenra Jan 9, 2016 @ 1:13pm 
"as a programmer myself" turn down Particles under Options. Boom. Problem solved.

You can go back to blowing on your bubble-pipe now, professor ;)
Gemini Jan 9, 2016 @ 3:55pm 
Originally posted by Westenra:
"as a programmer myself" turn down Particles under Options. Boom. Problem solved.
*attempts* Problem not solved. :P
< >
Showing 1-13 of 13 comments
Per page: 15 30 50

Zotrix > General Discussions > Topic Details