<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Primitive equivalent to al_hold_bitmap_drawing?</title>
		<link>http://www.allegro.cc/forums/view/611825</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 24 Jan 2013 06:40:55 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I find the primitive drawing functions to be very slow compared to the low level drawing routines, al_draw_prim and so on.</p><p>It&#39;s a shame because some of those functions are quite useful; I don&#39;t want to write my own ellipse drawing code for example.</p><p>If I can emulate these functions 10x faster using al_draw_prim and buffering, shouldn&#39;t there be a way to do that internally? I&#39;m thinking of something along the lines of al_hold_bitmap_drawing.</p><p>Any thoughts?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (EWClay)</author>
		<pubDate>Mon, 14 Jan 2013 19:47:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried implementing this once, and there was no performance difference. <span class="source-code"><a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a></span> model doesn&#39;t really work for primitives anyway, as they, somewhat unlike bitmaps, occasionally take quite a bit of CPU work to generate in the first place... and the fact that the <span class="source-code"><a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a></span> model requires you to regenerate the vertex data every frame makes the idea somewhat moot. A <i>real</i> solution would involve the ability to &quot;record&quot; a sequence of drawing calls that can be replayed later.</p><p>That said, I, personally, am no longer interested in this kind of performance optimizations. Half the time they do nothing on my computer, half the time they help performance <i>only</i> on my computer. <span class="source-code"><a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a></span>, for example, pretty much did nothing on my old GPU. I&#39;d suggest optimizing on a different level.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 14 Jan 2013 20:59:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So it seems the functions that are hardest to implement are the least likely to benefit from the optimisation, without adding the ability to record.</p><p>I&#39;m a little surprised that the approach was not a win for more simple shapes. On my system, which is a fairly typical PC, I can absolutely go 10x faster using al-draw_prim for lines and polygons.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (EWClay)</author>
		<pubDate>Tue, 15 Jan 2013 18:47:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Out of pure theoretical interest, care to elaborate?</p><p>I guess you ara passing the vertex data that you have pre-calculated to al draw prim right?</p><p>Wouldn&#39;t this be quite similar to what al_draw_ellipse does? Where exactly ther esi the performance hit?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Wed, 16 Jan 2013 03:03:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The difference is that I only call al_draw_prim once, after buffering possibly hundreds of primitives. The primitive drawing functions will kick off a batch every time.</p><p>For example, I draw a polygon over every tile in my game for fog-of-war. Without buffering, this would destroy my frame rate.</p><p>I also render circles for debug purposes, but they are not so straightforward to optimise.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (EWClay)</author>
		<pubDate>Wed, 16 Jan 2013 04:46:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think in this case, you just load everything up into a VBO and fire it off with a glDrawArrays or whatever the function is.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 16 Jan 2013 05:20:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I still have the primitive holding code somewhere... if you want, I can update it to work with 5.1 and you could see if it does anything.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 Jan 2013 06:18:27 +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/611825/974692#target">EWClay</a> said:</div><div class="quote"><p> The difference is that I only call al_draw_prim once, after buffering possibly hundreds of primitives. The primitive drawing functions will kick off a batch every time.</p></div></div><p>Ah yesss, I get it...pretty straightforward indeed</p><p>I know this may sound stupid, and I am partially hijacking the thread but I would like to understand a little bit more of the inner workings of the addon, so...for the circles, can&#39;t you use the <span class="source-code"><a href="http://www.allegro.cc/manual/al_calculate_arc"><span class="a">al_calculate_arc</span></a></span> with 0 to 360 as theta and delta? you could then append the calculated buffer into your vertex buffer and call <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_prim"><span class="a">al_draw_prim</span></a></span>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Wed, 16 Jan 2013 13:57:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hadn&#39;t noticed al_calculate_arc. The ability to set the number of vertices is a bonus.</p><p>@SiegeLord: Can&#39;t hurt to try it, it the code exists. I can compare with my own simple version.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (EWClay)</author>
		<pubDate>Thu, 17 Jan 2013 00:36:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, here it is. This patch adds the following functions:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> al_hold_primitive_drawing<span class="k2">(</span><span class="k1">bool</span> hold<span class="k2">)</span><span class="k2">;</span>
<span class="k1">bool</span> al_is_primitive_drawing_held<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Which function about the same as the bitmap equivalents. The deferred drawing is only implemented for <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_filled_triangle"><span class="a">al_draw_filled_triangle</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_filled_ellipse"><span class="a">al_draw_filled_ellipse</span></a></span>.</p><p>It&#39;s up to you to come up with a benchmark where this sort of nonsense helps <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 24 Jan 2013 06:40:55 +0000</pubDate>
	</item>
</rss>
