Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: [39f] FPS drops with increased screen size  (Read 4696 times)

Tormy

  • Bay Watcher
  • I shall not pass?
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #15 on: August 09, 2008, 02:09:16 pm »

Something is surely very wrong here...I cant even imagine how much FPS would we have with a 200 dwarf fortress if we have 50 FPS with the starting seven dwarves...
Logged

avari

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #16 on: August 09, 2008, 02:47:36 pm »

As mentioned at the start I also got only 50 FPS before it was explained to me that modifying the G_FPS_CAP (default 50) was necessary :)

However while I now get ~100 FPS at most times with views such as 80x60, I noticed that the FPS counter drops at times to the 40-60 range and stays there for some time. This is reflected in game speed also. I don't know if I'm seeing things but it seems as though these changes in FPS can be triggered by moving the window around, minimizing/maximizing it, etc.

I have Vista by the way so it could also be screwing with DF in some insidious manner :P
Logged

Zombie

  • Bay Watcher
  • Ǵ̨̕o͘d͝d̡͢e̡̕s̷͟s̵͢ ͝of̴ ͡G͘͠a̧mi̶n̛͝g̨
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #17 on: August 09, 2008, 03:50:08 pm »

Hmm... This may just be me, but I'm on a new map (wanted to try one with a baddy filled chasm and some HFS underneath) and I have 21 dwarves... Also a crazy amount of baddies as I started off in a 16x16 embark.

I don't have FPS turned on but, seeing as my dwarves are rocketing around like they're on some kind of crack, it SEEMS like my computer is running it faster (or at least no different) with a 160x50 tile arrangement... at 1260x850. :3

It's kind of odd. I expected some lag but, if anything, my fortress is a ton faster... Or just not any slower. XD
« Last Edit: August 09, 2008, 04:00:46 pm by Zombie »
Logged
If I had a dollar for every dwarf whose feelings I didn't care about, I'd have seven dollars, with more coming in the fall.

Urist McSharpblade, Axe Sheriff cancels Justice: Needs more than an axe for this.

MULTI-THREADING - I'm talking about it!

Zironic

  • Bay Watcher
  • [SDRAW_KCAB]
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #18 on: August 09, 2008, 05:17:31 pm »

I retract: the game is slower - noticibly.
« Last Edit: August 09, 2008, 05:31:13 pm by Zironic »
Logged

Tormy

  • Bay Watcher
  • I shall not pass?
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #19 on: August 09, 2008, 05:31:52 pm »

I retract: the game is slower - noticibly.

Hm, yeah, I had to set FPS cap to 60 also, because the dwarves were moving with lightspeed when I set FPS cap to 1000. Weird...
Logged

Ashery

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #20 on: August 09, 2008, 06:30:21 pm »

Increased lag here as well.

On a fort in mid-summer of the first year:

Capped fps (100) at the title screen and almost always in fortress mode, just some occasional minor fluctuations using the defaults, but after making these changes:

[GRID:120:50]

[WINDOWEDX:960]
[WINDOWEDY:600]
[FONT:curses_640x300.bmp]

[G_FPS_CAP:100]

I am getting low/mid-80's on the title screen, mid-60's while the fort was paused, and barely hitting 50 unpaused.
Logged

Tormy

  • Bay Watcher
  • I shall not pass?
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #21 on: August 09, 2008, 06:33:20 pm »

Ashery Try to set your g_fps_cap to 10-20
Logged

Ashery

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #22 on: August 09, 2008, 06:48:27 pm »

Testing that out now...I can definitely second the statement that it's the G_FPS being displayed in the upper right while the game runs.

Edit: After just a couple seconds I noticed that that seems to have done the trick.
Logged

danielout

  • Bay Watcher
  • Legendary Lurker
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #23 on: August 09, 2008, 10:00:18 pm »

I can definitely second the statement that it's the G_FPS being displayed in the upper right while the game runs.

Ditto here....
Logged

Keldor

  • Bay Watcher
  • Blood for the blood god!
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #24 on: August 10, 2008, 02:09:54 am »

Ran it through a profiler and found that each frame was making in excess of 200,000 (!!) openGL draw calls!  More importantly, I noticed that every tile on the screen was enclosed in its own glBegin() glEnd() block.  Remember, each glBegin ... glEnd will force a synchronization between the cpu and the gpu!  This is unnessicary as long as you're only passing vertices and texcoords and colors.  Put the entire background color pass into a single glBegin ... glEnd

The worse problem is that during the foreground pass, you're calling bind texture for every single tile.  This is VERY VERY bad, since you're forcing the GPU to do say 128*96=12,288 texture state changes per frame!  These are expensive, so it's very important to avoid doing as many as possible.

One thing to do would be to sort the tiles to be drawn by the texture they use, thus preventing you from needing to call glBindTexture more than once per unique texture.

However, the best thing to do is probably to simply pack all textures into a single large texture, a texture atlas, just like graphics sets are stored in bmp's.  This way, instead of calling glBindTexture, you can simply pass in the texCoords of the appropriate texture to the vertices.  Now you only need to call glBindTexture once.

These changes should increase performance dramatically.  In the profiler, the framerate more than tripled when I toggled the eliminate draw calls option!  This means that at least 2/3rds of the frame time was spent in openGL calls!

Pseudocode:
Code: [Select]
onFramedraw
   glBindTexture(texture atlas)
   glBegin()
   for each tile
      glColor(background color)
      glVertex(...)
      glTexCoord(coord of corner of blank tile in texture atlas)
      glColor(foreground color)
      glVertex(...)
      glTexCoord(coord of corner of tile to render within the atlas)
      ....
   end for
   glEnd()
frameEnd
Logged
If ignorance is bliss, why are my dwarves all tantruming?

Tormy

  • Bay Watcher
  • I shall not pass?
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #25 on: August 10, 2008, 08:06:25 am »

Testing that out now...I can definitely second the statement that it's the G_FPS being displayed in the upper right while the game runs.

Edit: After just a couple seconds I noticed that that seems to have done the trick.

Yep its not the actual FPS.
When I set the FPS cap to 1000, and G_FPS to 20, I see 20 FPS, however my dwarves are running around so fast that the game is unplayable. So I had to set the FPS cap to 60 in order to be able to play.
Toady should perhaps change this, so that we could see our real actual FPS in fortress mode, instead of the G_FPS...
Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: [39f] FPS drops with increased screen size
« Reply #26 on: August 10, 2008, 09:05:58 am »

These changes should increase performance dramatically.  In the profiler, the framerate more than tripled when I toggled the eliminate draw calls option!  This means that at least 2/3rds of the frame time was spent in openGL calls!

Eliminating the background/foreground calls entirely (aside from the FPS tiles) left the FPS unchanged at 46 for me on a 200x150 grid map.  I don't doubt it would help some people with cards worse with OpenGL than my laptop's Radeon X600 or other OpenGL trouble with drivers and all of whatever else, but I think it's important not to overstate the case here.

A lot of my FPS issues depend on what part of the grid is being viewed, which points to map drawing issues prior to the OpenGL code (fixing some of these yielded the 17 -> 36 change I mentioned up on dev for today).  In the 46 FPS map I mentioned, it hits the 30s when I view the sky, since the display of tiles showing through from a level below are apparently a bit clunky.  I'm running this on a single core AMD 2.59 GHz processor of some sort.

edit: (this is with the FPS displaying properly after fixing the bug that was causing render function call rates to be displayed instead)

That said, I can change some of the OpenGL calls around, though I'm not yet sure how to handle the bind calls.  I've leery of the texture atlas -- DF's OpenGL text started with that, but it would always double up pixels at the edges of letters for some tiles in some BMPs and not others regardless of how I tried to fiddle with the texcoords and wrapping, though it has been years since I've tried.  What I did today was some dirty rectangle stuff that cuts virtually all of the calls if the screen isn't changing much, though hopefully that won't introduce display artifacts (haven't seen any yet, but of course there will be trouble somewhere on some or all setups), and it's likely to become more expensive if layering is introduced as more 2D tiles come in, since it has to verify tens of thousands of tiles in the buffer (on large grids) or else track the world for changes closely and annoyingly.  Again, I didn't really notice a change here, since the OpenGL calls aren't a bottleneck for me, but hopefully some people will be helped by it.

I guess I failed to go to bed at 6:30 like I wanted to...  dammit.
« Last Edit: August 10, 2008, 09:12:22 am by Toady One »
Logged
The Toad, a Natural Resource:  Preserve yours today!

penguinofhonor

  • Bay Watcher
  • Minister of Love
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #27 on: August 10, 2008, 11:27:35 am »

Whoa, I just realized that DF is a lot faster at 80x25 than it was in the last version.
Logged

avari

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #28 on: August 10, 2008, 12:12:52 pm »

Well the FPS counter not displaying the actual FPS might explain my somewhat strange testing results :P More thorough testing must wait until the next release then, I guess. But it seems that for me the difference between say 80x60 and 160x120 is very small (in a 30-dwarf fort, at least), if I set the G_FPS cap low enough (20) and use dwarf running speed instead of the FPS counter as a measure :P I have reasonably good CPU and GPU so that probably helps, but anyway with appropriate settings the effect of grid size on FPS seems to be much smaller than I first thought. Setting the G_FPS cap lower seems to significantly cut down on CPU usage as well (which I assume is related to the FPS?).
Logged

penguinofhonor

  • Bay Watcher
  • Minister of Love
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #29 on: August 10, 2008, 12:40:09 pm »

Well, at 80x25 my dwarves are rocketing around at about 4-5 tiles per second. In the old version it was slightly slower. At 110x50, my dwarves crawl along at 1-2 tiles per second.
Logged
Pages: 1 [2] 3