<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Locking bitmaps is very slow</title>
		<link>http://www.allegro.cc/forums/view/615476</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 24 Jun 2015 01:12:35 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is something I&#39;ve noticed: Locking a bitmap under Allegro is very slow.  For video bitmaps this is expected, as the texture data has to be downloaded from the GPU and then re-uploaded, however it&#39;s been my experience that, even with memory bitmaps, calling al_lock_bitmap is very expensive when you would expect it to be instantaneous as the bitmap data is already in main memory.</p><p><b>edit:</b> Nevermind, disregard: Turns out I screwed up the bitmap flags and was actually creating video bitmaps after all.  Oops.  Just to clarify, I use memory bitmaps in some places because performing pixel-level manipulations on them is fast, so they can be used to compose an image in software (using color matrices, etc.) and then convert it to a video bitmap once it&#39;s done.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Tue, 23 Jun 2015 23:20:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For video bitmaps, you can lock it WRITE_ONLY, which should only allocate a memory copy to be uploaded later, or READ_ONLY, which should only download the texture data. At least that&#39;s what I would expect Allegro to do.</p><p>As for memory bitmaps, I agree, ideally it should only return a pointer to the data, which should be instant.</p><p>I&#39;m not familiar with allegro&#39;s internals though, so I can&#39;t say what it really does.</p><p>Edit<br />I didn&#39;t see your edit til now. So locking a memory bitmap is not slow then?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 24 Jun 2015 01:02:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, locking memory bitmaps actually does seem to be fast, at least <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a><span class="k2">(</span><span class="k2">)</span></span> stopped showing up on the hot-path in the profiler once I fixed the flags.  What IS slow is you try to <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span><span class="k2">)</span></span> a memory bitmap directly (without conversion), which seems fair enough.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Wed, 24 Jun 2015 01:12:35 +0000</pubDate>
	</item>
</rss>
