<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Things to check when tuning allegro performance</title>
		<link>http://www.allegro.cc/forums/view/610110</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 29 Apr 2012 03:08:47 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,<br />I would like to know things (other that I found out so far) that need to be inspected when tuning allegro application (game), for performance, in my case it is 2d game where lot of objects can be shown on screen.</p><p>The performance isn&#39;t really bad, but I would expect that drawing 2d scene with approximately 2500 images (mostly tiles and some objects) on high end computer should be faster than 500 fps that I have now.<br />I really don&#39;t need 500 fps, but I expect number of shown objects to increase a lot and I also want to be able to run the game on much less powerful computers, my friend on laptop has only 150 fps now.</p><p>Here is the list of things I already discovered/checked:</p><p>1) al_hold_bitmap_drawing before(true); before drawing lot of bitmaps and al_hold_bitmap_drawing before(false); when I&#39;m finished (helped a lot)</p><p>2) This needs to be tested more, but When I draw 100 X 10 different bitmaps it is much slower than drawing 1000 X 1 bitmap.<br />Is it because of some switching of source bitmap for drawing?<br />I guess that it might be solved using some atlas bitmap for all images I use and just drawing part of the bitmap, but it is limited by the maximum size of the atlas bitmap that can be in video memory.</p><p>3) I checked that bitmaps I use for drawing are video bitmaps.</p><p>4) I discovered, that when I only flip display, the fps is 1800, I always thought that flipping backbuffer should be practically instant, could it be because I have some bad backbuffer settings?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kovarex)</author>
		<pubDate>Wed, 25 Apr 2012 12:01:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you done any profiling?</p><p>IMO it&#39;s better to worry about this when performance becomes an actual issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc ( Arvidsson)</author>
		<pubDate>Wed, 25 Apr 2012 12:33:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610110/953465#target">kovarex</a> said:</div><div class="quote"><p>1) al_hold_bitmap_drawing before(true); before drawing lot of bitmaps and al_hold_bitmap_drawing before(false); when I&#39;m finished (helped a lot)</p></div></div><p>This helps a lot more if your bitmaps are merged into a single bitmap. You can make the individual bitmaps subbitmaps if that makes it easier. It&#39;s called Atlasing, and it makes it so the 3D api that allegro uses, doesn&#39;t have to change textures, which is a fairly slow operation.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>This needs to be tested more, but When I draw 100 X 10 different bitmaps it is much slower than drawing 1000 X 1 bitmap.</p></div></div><p>Check if you have NPOT (Non Power Of Two) texture support. If you don&#39;t doing odd things like this will create much larger textures than you ask for, wasting a lot of memory.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>I discovered, that when I only flip display, the fps is 1800, I always thought that flipping backbuffer should be practically instant, could it be because I have some bad backbuffer settings?</p></div></div><p>I&#39;ve heard (but don&#39;t know if its true) that D3D will batch up rendering calls, and then actually execute them on Flip. I really don&#39;t know if that&#39;s accurate, but it could explain why a flip is slower than you&#39;d expect.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 25 Apr 2012 18:57:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thomas Fjellstrom: Thank you for the reply.</p><p>If I wanted to use the atlas method, is there limitation of the atlas bitmap size?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kovarex)</author>
		<pubDate>Thu, 26 Apr 2012 16:26:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610110/953576#target">kovarex</a> said:</div><div class="quote"><p>If I wanted to use the atlas method, is there limitation of the atlas bitmap size?</p></div></div><p>Yes, the GPU has a max texture size you&#39;ll need to check for. It can vary, modern cards support <i>at least</i> 4096x4096, with many support larger (8192 or 16384 possibly) textures. Older cards may only support 2048 or less.</p><p>As a note, my laptop which is a few years old now, and uses an integrated Intel GM45 (4500MHD) gpu, supports a max texture size of 8192x8192.</p><p>append:</p><p>Here&#39;s how I checked (because I couldn&#39;t quickly find an easier way):</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;stdio.h&gt;</span>
<span class="p">#include &lt;allegro5/allegro5.h&gt;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span><span class="k3">*</span>argv<span class="k2">)</span>
<span class="k2">{</span>
   <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>dpy <span class="k3">=</span> NULL<span class="k2">;</span>
   <span class="k1">int</span> maxsize <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
   dpy <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">640</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span>
   maxsize <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_option"><span class="a">al_get_display_option</span></a><span class="k2">(</span>dpy, ALLEGRO_MAX_BITMAP_SIZE<span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"max texture size: %ix%i\n"</span>, maxsize<span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/al_destroy_display"><span class="a">al_destroy_display</span></a><span class="k2">(</span>dpy<span class="k2">)</span><span class="k2">;</span>
   <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 26 Apr 2012 20:04:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you for the info and the example, that will be handy.</p><p>8192x8192 is sufficient atlas to hold all the (even animated) sprites that I can imagine to need <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kovarex)</author>
		<pubDate>Thu, 26 Apr 2012 20:39:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610110/953593#target">kovarex</a> said:</div><div class="quote"><p> 8192x8192 is sufficient atlas to hold all the (even animated) sprites that I can imagine to need</p></div></div><p>Very likely, but don&#39;t assume because his card supports such a huge texture size, other cards will.</p><p>As far as I know, only very few cards support such large textures, some even only support up to 1024x1024.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Sun, 29 Apr 2012 03:03:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610110/953795#target">taron </a> said:</div><div class="quote"><p>As far as I know, only very few cards support such large textures, some even only support up to 1024x1024.</p></div></div><p>If you want to support really old hardware, or really crappy hardware. Even my 4500MHD (GM45) integrated Intel video has 8192x8192. The laptop itself is 3 years old or more, and the video chipset is older still. If my laptop can do it, so can the majority of semi modern computers.</p><p>But, its still best to check for texture size, and if needed, split your resources into multiple atlas&#39;s.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 29 Apr 2012 03:08:47 +0000</pubDate>
	</item>
</rss>
