View Full Version : Is it possible to draw this simple map faster?
Michael Hartlef
30-11-2007, 22:31
Hi folks,
attached is a sample code where I draw a map of tiles. I wonder if I have a significant bottle neck here as I think it is damn slow.
If not, then I will try to work with entities on it, but I'm not sure if entities work in 2D mode.
Cheers
Michael
Petr Schreiber
30-11-2007, 23:19
Mike,
optimized version is in the works.
The worst thing is that you set 2D rendering for EACH tile, better to:
- set 2D mode
- render all tiles
- set 3D mode
- render rest
Plus some more tricks I am working on now, please wait :)
Bye,
Petr
Petr Schreiber
30-11-2007, 23:24
Hi,
here is optimization without entities ( in case you do not want to use them ),
entity version in the works now :)
Speed gain: 60FPS -> 100FPS on my box.
Petr
EDIT: Updated
Michael Hartlef
30-11-2007, 23:31
Thanks Petr!
sandyrepope
30-11-2007, 23:32
Petr, I tried to download the file but it keeps telling me I am not authorized for this section. Has anyone else had this problem?
Thanks
Sandy
Don't know what happened when I first tried to download but I tried again and got the file.
Michael Hartlef
30-11-2007, 23:33
No, works fine here.
ErosOlmi
30-11-2007, 23:38
I checked your permissions and they seem ok. If you can see attached files you should be able to download them.
Seems a local problem. try to right-click attached file and choose "save as ...". It is a .tBasic extension file. Maybe some blocks on executing directly from the web page.
sandyrepope
30-11-2007, 23:42
Eros, I tried again and got the file without any trouble. Don't know what happened. It could be a glitch on my end as my server was down for a couple of day. They were putting in some new equipment and there's no telling when they will have their system settled down.
Thanks
Sandy
Petr Schreiber
01-12-2007, 00:06
Hi,
here is entity version attached, again should be faster.
One thing, but I know it is Your script Mike :) - if you will go the 2D route, it will be again resolution dependant. If you plan it 1024x768 only, then no problem.
Second thing :) - you originally had V-Sync on, this might hurt performance in some cases ( as says help file :P ). On other side it provides more stable image. You might want to try "Gears Of War" way, where V-Sync is enabled/disabled in dependence on current framerate.
Bye,
Petr
My results:
Original 100 fps
Opti 1 150 fps
Opti 2 175 fps
All three ran fine, but this will be good code to study to see how done in different ways for sure. Thanks guys!
Michael Hartlef
01-12-2007, 10:23
Hi Petr,
thanks for optimizing and the suggestions. I'll take what fits for me the best.
Michael
Michael Hartlef
01-12-2007, 10:25
Wow,
original : 56
Opti1: 75
Opti2: (drumroll) 475!!!!
Awesome gain. Hopefully it is flexibel enough with a conitnues map. I have to study how you did it.
Michael Hartlef
01-12-2007, 10:41
Petr, regarding the resolution problem. Here is a version that (as long it is fullscreen) you can set it to any of the common resolutions and it works fine.
Petr Schreiber
01-12-2007, 11:27
Kent,
do not cry, I am getting same FPS as you :D
Lower end editions of nVidias give very similar performance.
Just you wait for FPSs with new card. The number won't fit on the screen :D
Mike, your framerate gain is nice! My GF6 is a limited in bandwith stuff, but your card seems one of the faster :)
Your script runs good, only problem is with widescreen displays ( like Eros has ).
Bye,
Petr
Mike, wow 475... you and Eros are running fast!!
Thanks Petr, for encouragement of one day seeing those kind of frame rates :)
Petr, is that where the bandwidth ratings kick in and not the polys drawn in one second?
Petr Schreiber
01-12-2007, 23:02
Kent,
this case is a bit special, as it is rendering of small, but full featured "batches".
Each entity "encapsulates" very tiny geometry ( 4 vertices quad ), and each of those has its individual setup ( texture, color ).
Entity system internally optimizes this case, so in case two following entities have same texture/color, no redundant OpenGL call is generated. But as you can see, it does not help to our cards too much. Second thing is making single quad a display list - it is generally recommended to enclose more polygons in one list.
As each quad is enclosed in TBGL_BeginPoly / TBGL_EndPoly, our accelerators get a kind of hiccups :)
It is possible that creating M15 model on the fly and then managing it internally could paradoxically lead to better performance. But I chose tiny display list way + entities, as the code is cleaner.
Although it is not the best design, and will result in lower framerates on lower end cards, for such a little number of polygons it should not mean grave performance problems on any card.
Eros and Mike cards are power beasts, which can crunch even this "hiccups". Our 3D cards have just 64bit buses I think, lower clocking and lower fillrates. They became nervous easily :)
Nothing is persistent in world of 3D graphics, so behaviour can change ( yes, even improve :) ) from one driver release to another, your forthcoming switch to superaccelerator is definitive solution too :)
Bye,
Petr
P.S. The script, as Mike provided, could be optimized "to the bone", by simple rendering of 1 quad with aprorpiate texture repetition in x and y direction. One quad, one texture, just UV ( even just U ) scroll and we could get awesome framerates all. But this would not be general solution :)
ErosOlmi
01-12-2007, 23:05
Original: 60 FPS
Opti1 : 115 FPS
Opti2 : 780 FPS
More than 10x faster than original :o
Petr Schreiber
01-12-2007, 23:10
;D I cannot say I did not expected it on your notebook ;D
Again - you got perfect framerate, but could be even better, if there would be no Begin/End "hiccups".
Thats advantage of brutal power cards that even my quick opti runs significantly faster :D
Original was fixed 60FPS as there was V-Sync on, so real speed gain is just about 7x.
Petr
Michael Hartlef
01-12-2007, 23:22
Thanks again guys for all the testing and improving. I'm looking into maps as it will be crucial for a game idea I have.
Petr Schreiber
01-12-2007, 23:39
Can't wait to see it Mike,
when in doubts about TBGL code please ask again!
Thanks,
Petr
ErosOlmi
02-12-2007, 00:06
Thanks again guys for all the testing and improving. I'm looking into maps as it will be crucial for a game idea I have.
Mike, to be honest, when I first saw your MapScrolling example I fallen down from the chair thinking about ... ::)
wow we will have a lot of fun !
Thanks a lot.
Eros
PS: do not forget something to destroy. But I'm sure there will be :P
He he he he he, with such a fast scrolling screen system... I am sure there will be lots of things to shoot and things shooting back!
Michael Hartlef
02-12-2007, 09:59
Ok Eros, you will get something to destroy. :D