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 4697 times)

Frobozz

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

Quote from: Toady One
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.
I remember doing a port of a game's ASCII-emulated renderer from 2D to OpenGL to allow for variable resolutions and in that case I was doing some dumb things as well. Like creating and destroying the texture every frame. Regardless it ran without any lag on GeForce 6 cards and up. I suspect to a degree the driver may very well be optimizing some of the potential slowdown away.
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #31 on: August 10, 2008, 01:10:43 pm »

How much the driver optimizes depends to a large part on which driver it is.

nVidia's driver seems to be generally poorer at this, doing exactly what you tell it to instead. At least, it's slower; I switched out my Geforce 8800GTS for a Radeon 9800, and got a major speed boost.

That's not to say nvidia cards can't be fast, though. You just have to write reasonably efficient code for them - this means not calling glEnd more than you have to, and.. well, someone else already wrote this lecture, so I won't.
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Calessa Lynn Orphiel

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #32 on: August 10, 2008, 01:53:04 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.

The obvious problem is that your dwarves are crawling.  :P
Logged

Keldor

  • Bay Watcher
  • Blood for the blood god!
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #33 on: August 10, 2008, 08:00:33 pm »

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.

Another big factor concerning OGL performance is likely how many of us are using Windows Vista, since the changes they made in the driver architecture which make OGL act as a wrapper for DirectX.  Hence the question, how many of us with framerate problems are running Vista?  I know I am.

Concerning your display artifacts with texture atlases, I feel your pain!  texCoords are strange things, mostly because of the way they actually refer to the corners of texels, rather than the centers of the texels.  If you were to just use the coords for these corners, you get unpredictable aliasing simply from rounding errors when the rasterizer is determining which texel is the correct one.  The key thing here is to offset the texcoords by .5 texels inward from the outer edge of the bounding rectangle.



Hence, your texture lookups should look like this:

xCoord1 = (xTile*tileWidthInPixels+0.5)/atlasWidthInPixels;
yCoord1 = (yTile*tileHeightInPixels+0.5)/atlasHeightInPixels;
xCoord3 = ((xTile+1)*tileWidthInPixels-0.5)/atlasWidthInPixels;
yCoord3 = ((yTile+1)*tileHeightInPixels-0.5)/atlasHeightInPixels;
.....
In this case, I'm just showing the coords of the upper left and lower right vertices.  The other two are done the same way.
Logged
If ignorance is bliss, why are my dwarves all tantruming?

Keldor

  • Bay Watcher
  • Blood for the blood god!
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #34 on: August 10, 2008, 10:21:07 pm »

Just noticed something I think is important:  The framerate drop is far, far worse when running in windowed mode.
Logged
If ignorance is bliss, why are my dwarves all tantruming?

Symmetry

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #35 on: August 11, 2008, 06:45:14 am »

I'm running on vista in windowed mode and I get terrible framerate too.

Also, I'd like to backup what Keldor is saying about the opengl calls.  I'm a bit confused that Toady is getting no difference when removing all opengl calls (if I'm reading his post right).  Calling glBegin/glEnd for every single tile on screen should be a terrible performance hit (for the cpu not gpu).
Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: [39f] FPS drops with increased screen size
« Reply #36 on: August 11, 2008, 07:19:25 am »

I'm running on vista in windowed mode and I get terrible framerate too.

Also, I'd like to backup what Keldor is saying about the opengl calls.  I'm a bit confused that Toady is getting no difference when removing all opengl calls (if I'm reading his post right).  Calling glBegin/glEnd for every single tile on screen should be a terrible performance hit (for the cpu not gpu).

60000 such pairs and 30000 texture binds windowed and I still get 100 FPS on a screen filled with randomly flipping tiles, and I removed all but ~20 of the calls on a 46 framerate screen and the framerate was unchanged at 46.  I'm on XP, and though my graphics card is from 2004ish with 2005 drivers (the Radeon x600 I mentioned above), perhaps the entire setup is in an OpenGL sweetspot or something.  On the other hand, not everybody is getting terrible framerates on the title screen, so I don't think it's just me.

In any case, before I mess around with texture atlases again (I seem to remember trying the +/-.5 but it's been a while, and creature tiles and so on provide extra annoyances there, as will further moves toward individual tiles), we can try out the dirty rectangle (which cuts virtually all of the calls most of the time), as well as pulling the begin/end out of the background loop, and getting rid of the clear call.  I'm not sure exactly when the next version will be up, but it'll be this month by the 21st barring unforeseen catastrophes.
Logged
The Toad, a Natural Resource:  Preserve yours today!

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #37 on: August 11, 2008, 09:59:05 am »


60000 such pairs and 30000 texture binds windowed and I still get 100 FPS on a screen filled with randomly flipping tiles, and I removed all but ~20 of the calls on a 46 framerate screen and the framerate was unchanged at 46.  I'm on XP, and though my graphics card is from 2004ish with 2005 drivers (the Radeon x600 I mentioned above), perhaps the entire setup is in an OpenGL sweetspot or something.  On the other hand, not everybody is getting terrible framerates on the title screen, so I don't think it's just me.

In any case, before I mess around with texture atlases again (I seem to remember trying the +/-.5 but it's been a while, and creature tiles and so on provide extra annoyances there, as will further moves toward individual tiles), we can try out the dirty rectangle (which cuts virtually all of the calls most of the time), as well as pulling the begin/end out of the background loop, and getting rid of the clear call.  I'm not sure exactly when the next version will be up, but it'll be this month by the 21st barring unforeseen catastrophes.

Yes. As I said, ATI seems to have better OpenGL drivers than nVidia - better DF drivers, at least.

It's fairly typical for the cards to act differently, so you really should have access to both, though you don't *have* to if you already know what to do.

I stopped the game from drawing anything whatsoever here, on an nVidia 8800GTS, and the framerate.. appears to have increased; at least, the season change came faster. Unfortunately it's hard to actually be *sure*, since I have to type blind. :P
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Tormy

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

I'm running on vista in windowed mode and I get terrible framerate too.

Also, I'd like to backup what Keldor is saying about the opengl calls.  I'm a bit confused that Toady is getting no difference when removing all opengl calls (if I'm reading his post right).  Calling glBegin/glEnd for every single tile on screen should be a terrible performance hit (for the cpu not gpu).

How is that possible? I have 64bit Vista, and when I set the FPS CAP to 1000 for example, the game runs so fast, that its unplayable....
Something is not right with your system. Slow CPU or not enough RAM?
Logged

FlyingScissorKick

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

Figured I'd add my 2 cents with my experience with this as well.

I'm running 39f on a Dual core 2.20 GHz laptop with 2GB ram with XP Pro.

Loading up an exact game I'm playing in the older versions and yield 50 FPS constant. It says it's slowing to a lower FPS but it doesn't appear to be running that slow.

I have pop capped at 105 so that may be why mine runs faster. Again, I'm not sure if this post will even help but I figured I would contribute what I noticed.
Logged

numerobis

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #40 on: August 12, 2008, 12:36:24 am »

This may be a third rail or a catenary cable or somesuch, but... why is DF using openGL rather than a 2d API?  It seems to cause endless problems.
Logged

EchoP

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #41 on: August 12, 2008, 01:30:30 am »

Loading up an exact game I'm playing in the older versions and yield 50 FPS constant. It says it's slowing to a lower FPS but it doesn't appear to be running that slow.
The new version does not actually display the real FPS for some reason. It actually shows the GFPS, which is a setting in the init.
Logged

Symmetry

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #42 on: August 12, 2008, 08:56:36 am »

I forgot to say which card I'm using.  I've got a 7900GS which I think nvidia have pretty much stopped optimising for, so I guess the different opengl performance is their fault.  I have 4G of ram and a 4200+ X2 on vista 64.  It's a combination of opengl drivers, vista and the way df is rendering things.  Exactly the same game loaded with different grid sizes will half or quarter my frame rate.

Thanks for looking into speeding things up for those of us who have problems Toady.

Using opengl (or directx) to render 2d images is probably the fastest way with graphics apis how they are.  Any other way would mean the cpu was doing lots of memcpys to write pixels to the framebuffer. 
Logged

Exponent

  • Bay Watcher
    • View Profile
Re: [39f] FPS drops with increased screen size
« Reply #43 on: August 12, 2008, 09:46:09 am »

Another advantage to using OpenGL is that future improvements to graphics (such as alpha blending) will be easier.  Not to mention the scaling that can already occur is very easy to implement and is not a burden on the CPU, as it might be with various 2D APIs.
Logged
Pages: 1 2 [3]