<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>21st Century game development</title>
	<atom:link href="http://astronautz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://astronautz.wordpress.com</link>
	<description>Game development for the iPhone (mainly)</description>
	<lastBuildDate>Fri, 02 Dec 2011 14:49:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='astronautz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/80585f0a632369fe2f9e183eb40c9710?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>21st Century game development</title>
		<link>http://astronautz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://astronautz.wordpress.com/osd.xml" title="21st Century game development" />
	<atom:link rel='hub' href='http://astronautz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Optimizing meshes for the iPhone</title>
		<link>http://astronautz.wordpress.com/2010/11/13/optimizing-meshes-for-the-iphone/</link>
		<comments>http://astronautz.wordpress.com/2010/11/13/optimizing-meshes-for-the-iphone/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 18:25:58 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[Graphic engine design]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[iPhone development]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=412</guid>
		<description><![CDATA[The PowerVR guide says if you order triangle indices as if they were triangle strips you will get a speed boost, because the PowerVR chip implementation uses  triangle strips internally. The PowerVR SDK has an example to shows this, using a model of a sphere. I assumed that the example was an extreme case and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=412&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The PowerVR guide says if you order triangle indices as if they were triangle strips you will get a speed boost, because the PowerVR chip implementation uses  triangle strips internally. The PowerVR SDK has an example to shows this, using a model of a sphere. I assumed that the example was an extreme case and you wouldn&#8217;t see such a big improvement for real models. However, I was pleasantly surprised to see that it actually did give a big improvement in a real world example &#8211; cutting down render time from 38ms to 35.5ms in a scene with 18 skinned meshes.</p>
<p>I used tootle to re-order the indices:</p>
<pre>int result = TootleOptimizeVCache(pIndices,
      numTriIndices/3, m_listVertexArray[0]-&gt;GetNumVertices(),
      TOOTLE_DEFAULT_VCACHE_SIZE, pIndices, NULL, TOOTLE_VCACHE_LSTRIPS);
if (result != TOOTLE_OK)
    cout &lt;&lt; "could not optimise!" &lt;&lt; endl;</pre>
<p>It&#8217;s important to use TOOTLE_VCACHE_LSTRIPS, because the default ordering is designed for PC GPUs and won&#8217;t work well on the iPhone.<br />
Also, you have to reorder the vertex data to match the order in the triangle index array. Tootle can be found <a href="http://developer.amd.com/archive/gpu/tootle/Pages/default.aspx">here</a>.<br />
Unfortunately, Tootle crashes for certain meshes. If there was source code, I probably could have fixed that &#8211; but there isn&#8217;t <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/412/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=412&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/11/13/optimizing-meshes-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
		<item>
		<title>Vertex data interleaving on iPhone</title>
		<link>http://astronautz.wordpress.com/2010/10/28/vertex-data-interleaving-on-iphone/</link>
		<comments>http://astronautz.wordpress.com/2010/10/28/vertex-data-interleaving-on-iphone/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 15:29:19 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=405</guid>
		<description><![CDATA[In the PowerVR manual it says that you should interleave vertex data: I tried this out on my engine and actually found no measurable improvement for static meshs. For skinned meshes it actually goes slower! Why? Because if you are doing software skinning, you have to reset the vertex buffer ever frame. If the vertex [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=405&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the PowerVR manual it says that you should interleave vertex data:</p>
<p><img src="/DOCUME%7E1/Owner/LOCALS%7E1/Temp/moz-screenshot-3.png" alt="" /></p>
<p><img src="/DOCUME%7E1/Owner/LOCALS%7E1/Temp/moz-screenshot-2.png" alt="" /></p>
<p><a href="http://astronautz.files.wordpress.com/2010/10/interleaving1.png"><img class="aligncenter size-full wp-image-409" title="interleaving" src="http://astronautz.files.wordpress.com/2010/10/interleaving1.png?w=630" alt=""   /></a></p>
<p>I tried this out on my engine and actually found no measurable improvement for static meshs. For skinned meshes it actually goes <strong>slower</strong>! Why? Because if you are doing software skinning, you have to reset the vertex buffer ever frame. If the vertex data isn&#8217;t interleaved then you can do this using memset for the postion and normal data, however if it&#8217;s interleaved you can&#8217;t because you would overwrite the texture co-ordinates, so you have to use a loop instead.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/405/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=405&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/10/28/vertex-data-interleaving-on-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/10/interleaving1.png" medium="image">
			<media:title type="html">interleaving</media:title>
		</media:content>
	</item>
		<item>
		<title>Accelerating Software skinning with VFP assembler</title>
		<link>http://astronautz.wordpress.com/2010/10/24/accelerating-software-skinning-with-vfp/</link>
		<comments>http://astronautz.wordpress.com/2010/10/24/accelerating-software-skinning-with-vfp/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 13:09:38 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[iPhone development]]></category>
		<category><![CDATA[skinned meshes]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[assembler]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[VFP]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=387</guid>
		<description><![CDATA[I was trying to get my engine perform better on older iDevices. I need to be able to render 18 characters on screen simultaneously, however on the 1st gen iPod touch it takes 63ms to render the scene. I thought I&#8217;d try to use vfp assembly to speed it up, using code from this site: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=387&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was trying to get my engine perform better on older iDevices. I  need to be able to render 18 characters on screen simultaneously,  however on the 1st gen iPod touch it takes 63ms to render the scene. I  thought I&#8217;d try to use vfp assembly to speed it up, using code from this  site: <a href="http://code.google.com/p/vfpmathlibrary/">http://code.google.com/p/vfpmathlibrary/</a></p>
<p>Initially,  it didn&#8217;t make any difference at all. This was because it was GPU  bound. So, I reduced the scene to 8 skinned meshes &#8211; which would show up  optimisation improvements better.</p>
<p>The assembler code still didn&#8217;t  speed things that much. I ran the code analyzer tool and found the  piece of code that was most of the time was the code that transforms the  vertices with the current matrix of the joint:</p>
<pre>for (n = 0; n &lt; (int)m_listVertex.size(); n++)
{
weight = m_listWeight[n];
index = m_listVertex[n]*3;
matrix.TransformPoint(&amp;pOrigData[index],weight, &amp;pCurrData[index]);
}

void Matrix::TransformPoint(const float* pInVertex, float weight, float* pOutVertex) const
{
pOutVertex</span><span style="font-size:xx-small;">[0] += weight*(pInVertex[0]*m[0] + pInVertex[1]*m[4] + pInVertex[2]*m[8] + m[12]);
pOutVertex</span><span style="font-size:xx-small;">[1] += weight*(pInVertex[0]*m[1] + pInVertex[1]*m[5] + pInVertex[2]*m[9] + m[13]);
pOutVertex</span><span style="font-size:xx-small;">[2] += weight*(pInVertex[0]*m[2] + pInVertex[1]*m[6] + pInVertex[2]*m[10] + m[14]);
}</pre>
<p>There was a function similiar to this in the vfpmathlibrary. So I modified it and this is the result:</p>
<p><span style="font-size:xx-small;">// Sets length and stride to 0.<br />
#define VFP_VECTOR_LENGTH_ZERO &#8220;fmrx    r0, fpscr            \n\t&#8221; \<br />
&#8220;bic     r0, r0, #0&#215;00370000  \n\t&#8221; \<br />
&#8220;fmxr    fpscr, r0            \n\t&#8221;</span></p>
<p>// Set vector length. VEC_LENGTH has to be bitween 0 for length 1 and 3 for length 4.<br />
#define VFP_VECTOR_LENGTH(VEC_LENGTH) &#8220;fmrx    r0, fpscr                         \n\t&#8221; \<br />
&#8220;bic     r0, r0, #0&#215;00370000               \n\t&#8221; \<br />
&#8220;orr     r0, r0, #0&#215;000&#8243; #VEC_LENGTH &#8220;0000 \n\t&#8221; \<br />
&#8220;fmxr    fpscr, r0                         \n\t&#8221;</p>
<p><span style="font-size:xx-small;">void Matrix::TransformPoint(const float* pInVertex, float weight, float* pOutVertex) const<br />
{<br />
asm volatile (<br />
// Load the whole matrix.<br />
&#8220;fldmias  %[matrix], {s8-s23}     \n\t&#8221;<br />
// Load vector to scalar bank.<br />
&#8220;fldmias  %[pInVertex], {s0-s2}      \n\t&#8221;<br />
// Load weight to scalar bank.<br />
&#8220;fldmias  %[weight], {s3}      \n\t&#8221;<br />
&#8220;fldmias  %[pOutVertex], {s28-s30}      \n\t&#8221;</span></p>
<p>VFP_VECTOR_LENGTH(2)</p>
<p>&#8220;fmuls s24, s8, s0        \n\t&#8221;<br />
&#8220;fmacs s24, s12, s1       \n\t&#8221;<br />
&#8220;fmacs s24, s16, s2       \n\t&#8221;<br />
&#8220;fadds s24, s24, s20        \n\t&#8221;<br />
&#8220;fmuls s24, s24, s3        \n\t&#8221;<br />
&#8220;fadds s24, s24, s28        \n\t&#8221;</p>
<p>// Save vector.<br />
&#8220;fstmias  %[out], {s24-s26}  \n\t&#8221;</p>
<p>VFP_VECTOR_LENGTH_ZERO<br />
:<br />
: [matrix] &#8220;r&#8221; (m),</p>
<p><span style="font-size:xx-small;"> [pInVertex] &#8220;r&#8221; (pInVertex), </span></p>
<p><span style="font-size:xx-small;"> [weight] &#8220;r&#8221; (&amp;weight), </span></p>
<p><span style="font-size:xx-small;"> [out] &#8220;r&#8221; (pOutVertex)<br />
: &#8220;r0&#8243;, &#8220;cc&#8221;,<br />
&#8220;s0&#8243;,  &#8220;s1&#8243;,  &#8220;s2&#8243;,  &#8220;s3&#8243;,<br />
&#8220;s8&#8243;,  &#8220;s9&#8243;,  &#8220;s10&#8243;, &#8220;s11&#8243;, &#8220;s12&#8243;, &#8220;s13&#8243;, &#8220;s14&#8243;, &#8220;s15&#8243;,<br />
&#8220;s16&#8243;, &#8220;s17&#8243;, &#8220;s18&#8243;, &#8220;s19&#8243;, &#8220;s20&#8243;, &#8220;s21&#8243;, &#8220;s22&#8243;, &#8220;s23&#8243;,<br />
&#8220;s24&#8243;, &#8220;s25&#8243;, &#8220;s26&#8243;, &#8220;s28&#8243;, &#8220;s29&#8243;, &#8220;s30&#8243;<br />
);<br />
}</span></p>
<p>It took me quite a while to figure  out the assembler, because you need to reference several very technical  books to figure it out. I&#8217;d like to make this job easier for any  interested programmers out there. So, just let me explain it line by  line.</p>
<p>On the first line you have:<strong> asm volatile</strong>(&#8230;); .This instructs gcc that the stuff in the ( ) brackets is assembler code. <strong>volatile </strong>means, tells gcc not to try to &#8220;optimize&#8221; the code.</p>
<p>Then you have a number of strings each string is an arm vfp instruction.</p>
<p>The vfp has 4 banks of 8 single precision floating point registers:</p>
<p><a href="http://astronautz.files.wordpress.com/2010/10/registers.png"><img src="http://astronautz.files.wordpress.com/2010/10/registers.png?w=400&#038;h=167" border="0" alt="" width="400" height="167" /></a></p>
<p>The  idea is that you can do up to 8 similar floating point operations at  the same time.  If you look at the formula that we&#8217;re trying to  implement again:</p>
<p><span style="font-size:xx-small;"> </span><span style="font-size:xx-small;">pOutVertex</span><span style="font-size:xx-small;">[0] += weight*(pInVertex[0]*m[0] + pInVertex[1]*m[4] + pInVertex[2]*m[8] + m[12]);<br />
</span><span style="font-size:xx-small;">pOutVertex</span><span style="font-size:xx-small;">[1] += weight*(pInVertex[0]*m[1] + pInVertex[1]*m[5] + pInVertex[2]*m[9] + m[13]);<br />
</span><span style="font-size:xx-small;">pOutVertex</span><span style="font-size:xx-small;">[2] += weight*(pInVertex[0]*m[2] + pInVertex[1]*m[6] + pInVertex[2]*m[10] + m[14]);</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">You see that we could do </span></span><em><span style="font-size:xx-small;">pInVertex</span></em><span style="font-size:xx-small;"><span style="font-size:small;"><em><span style="font-size:xx-small;">[0]*m[0], </span></em></span></span><em><span style="font-size:xx-small;">pInVertex</span></em><span style="font-size:xx-small;"><span style="font-size:small;"><em><span style="font-size:xx-small;">[0]*m[1]</span></em> and </span></span><em><span style="font-size:xx-small;">pInVertex</span></em><span style="font-size:xx-small;"><span style="font-size:small;"><em><span style="font-size:xx-small;">[0]*m[2]</span></em> all in one instruction. And the rest of the formula is done the same way &#8211; three operations all in the one go.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">So, let&#8217;s go through the code line by line.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">First you have: </span></span><span style="font-size:xx-small;"> &#8220;fldmias  %[matrix], {s8-s23}     \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">fldmais  loads memory contents into several registers. Here, it&#8217;s loading the  entire matrix (16 floats) into s8-s23. (It doesn&#8217;t actually use all the  data in the matrix, but it&#8217;s easier to do it all in one instruction). </span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">The &#8220;matrix&#8221; is an assember variable defined in the section at the bottom, but we&#8217;ll cover that later.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Notice,  there is \n\t at the end of the line. Thats just to format the assember  code. It&#8217;s just something that you have to add to each assembler line.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Next, we have: </span></span><span style="font-size:xx-small;">&#8220;fldmias  %[</span><span style="font-size:xx-small;">pInVertex</span><span style="font-size:xx-small;">], {s0-s2}      \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">This loads the 3 vertex co-ords </span></span><span style="font-size:xx-small;"><span style="font-size:small;">into s0-s2 &#8211; i.e. bank 0. Bank zero is different than the other banks, but I&#8217;ll go into that later.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Then, we load the weight and the output vertex co-ords into other registers:</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> </span></span><span style="font-size:xx-small;">&#8220;fldmias  %[weight], {s3}      \n\t&#8221;<br />
&#8220;fldmias  %[</span><span style="font-size:xx-small;">pOutVertex</span><span style="font-size:xx-small;">], {s28-s30}      \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">So, now we have everything loaded. </span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Next we have to tell the vpf how many ops we do at the same time. We have a macro:</span></span></p>
<p><span style="font-size:xx-small;"> VFP_VECTOR_LENGTH(2)</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">This sets the vector length setting to 3 (it&#8217;s actually one more than the specified parameter).</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> </span> </span><span style="font-size:xx-small;"><span style="font-size:small;"> </span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">So, now it&#8217;s time to do the fun part: the math ops!</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> The first op is: </span></span><span style="font-size:xx-small;">&#8220;fmuls s24, s8, s0        \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">This is equivalent to three single vector ops:</span></span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">fmuls 24, s8, s0
fmuls 25, s9, s0
fmuls 26, s10, s0</span></span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">s0  is in bank 0 and this bank has special function: the address never  increments for a vector operation ( a so-called scalar vector). Now, if  you remember we had the matrix data in s8-s23 and the vertex data in  s0-s3. So this function does the following calculation:</span></span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">s24 = pInValues[0]*m[0]</span></span>
<span style="font-size:xx-small;"><span style="font-size:small;">s25 = pInValues[0]*m[1] </span></span>
<span style="font-size:xx-small;"><span style="font-size:small;">s26 = pInValues[0]*m[2]</span></span><span style="font-size:xx-small;"> </span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">We are always dumping the results into s24-s26, which we use as temp registers.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">The next instruction is:</span></span></p>
<p><span style="font-size:xx-small;">&#8220;fmacs s24, s12, s1       \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">fmacs multiplies, then adds. So this instruction is the equivilant to:</span></span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">s24 += pInValues[1]*m[4]</span></span>
<span style="font-size:xx-small;"><span style="font-size:small;">s25 += pInValues[1]*m[5]</span></span>
<span style="font-size:xx-small;"><span style="font-size:small;">s26 += pInValues[1]*m[6]</span></span><span style="font-size:xx-small;"> </span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Then</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> </span></span><span style="font-size:xx-small;">&#8220;fmacs s24, s16, s2       \n\t&#8221;</span><span style="font-size:xx-small;"><br />
</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">As you probably guess, this is the equivilant to:</span></span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">s24 += pInValues[2]*m[8]
s25 += pInValues[2]*m[9]
s26 += pInValues[2]*m[10]</span></span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Then:</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> </span></span><span style="font-size:xx-small;"> &#8220;fadds s24, s24, s20        \n\t&#8221;</span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">As you might guess this is addition:</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;"> </span> </span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">s24 += m[12]
s25 += m[13]
s26 += m[14]</span></span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Then multiply by the weight which is stored in s3:</span></span></p>
<p><span style="font-size:xx-small;">&#8220;fmuls s24, s24, s3        \n\t&#8221;</span></p>
<pre><span style="font-size:xx-small;"><span style="font-size:small;">s24 *= weight
s25 *= </span></span><span style="font-size:xx-small;"><span style="font-size:small;">weight</span></span><span style="font-size:xx-small;"><span style="font-size:small;"> </span></span>
<span style="font-size:xx-small;"><span style="font-size:small;">s26 *= </span></span><span style="font-size:xx-small;"><span style="font-size:small;">weight</span></span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">Finally, add to the current vertex data (which we stored in s28-s30):</span></span></p>
<p><span style="font-size:xx-small;"> &#8220;fadds s24, s24, s28        \n\t&#8221;</span></p>
<pre><span style="font-size:small;">s24 += </span><span style="font-size:small;">pOutValues[0]</span>
<span style="font-size:small;">s25 += </span><span style="font-size:small;">pOutValues[1]</span><span style="font-size:small;"> </span>
<span style="font-size:small;">s26 += </span><span style="font-size:small;">pOutValues[2]</span></pre>
<p><span style="font-size:small;">Then, we load the result back into </span><span style="font-size:xx-small;"><span style="font-size:small;">the current vertex data</span></span><span style="font-size:small;">:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:xx-small;"> </span><span style="font-size:xx-small;">&#8220;fstmias  %[out], {s24-s26}  \n\t&#8221; </span></p>
<p><span style="font-size:xx-small;"> <span style="font-size:small;">And the </span></span><span style="font-size:xx-small;">VFP_VECTOR_LENGTH_ZERO <span style="font-size:small;">macro restores the vector size back to the default value of 1 (otherwise all hell would break loose).</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">The  stuff at the end tells gcc the inputs and output of the function. There  always has to be three sections seperated by colons :</span></span></p>
<pre><span style="font-size:xx-small;"> <strong>:</strong> // output parameters
 <strong>:</strong> [matrix] "r" (m),
   [pInVertex] "r" (pInVertex),
   [weight] "r" (&amp;weight),
   [pOutVertex] "r" (pOutVertex)            // input parameters
 <strong>:</strong> "r0", "cc", </span><span style="font-size:xx-small;"><span style="font-size:small;"> </span>"s0",  "s1",  "s2",  "s3",
 "s8",  "s9",  "s10", "s11", "s12", "s13", "s14", "s15",
 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
 "s24", "s25", "s26", "s28", "s29", "s30" </span><span style="font-size:xx-small;"><span style="font-size:small;"> <span style="font-size:xx-small;">// clobber list</span></span></span></pre>
<p><span style="font-size:xx-small;"><span style="font-size:small;">The first section is the output parameters, which is blank. This doesn&#8217;t make any sense, because really it should have </span></span><span style="font-size:xx-small;">pOutVertex</span><span style="font-size:xx-small;"><span style="font-size:small;">, but apparently it just works that way &#8211; don&#8217;t ask me why.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">The next section is the input parameters. First you have the variable name used </span></span>in  the assembler code surrounded by square brackets [], then you have a  &#8220;r&#8221; then the variable name as used in the c++ part of the code in round  brackets (). Note: this has to be an address, <strong>*not*</strong> a value, that&#8217;s why the <em>weight </em>has a &amp; in front of it.</p>
<p>The next section is what is affectionately known as &#8220;<strong>the clobber list</strong>&#8220;.  This tells gcc what registers we have used in the program. If you  accidentally forget to include a register in the clobber list, it&#8217;ll  crash, so this is important.</p>
<p>I found that the program could be speeded up even more by moving the <span style="font-size:xx-small;">VFP_VECTOR_LENGTH <span style="font-size:small;">macros from TransformPoint to <strong>outside </strong>of the main loop:</span></span></p>
<p style="text-align:left;"><span style="font-size:xx-small;"><span style="font-size:small;"><span style="font-size:xx-small;">SetVectorLen2();<br />
for (n = 0; n &lt; (int)m_listVertex.size(); n++)<br />
{<br />
weight = m_listWeight[n];<br />
index = m_listVertex[n]*3;<br />
matrix.TransformPoint(&amp;pOrigData[index], weight, &amp;pCurrData[index]);<br />
}<br />
SetVectorLen0();</span><br />
</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">All in all, the  assembler code reduces the total render time from 34ms to 30.5ms (when  rendering 8 skinned meshes), which is not bad.</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">If you try to run this code on a newer device, like a iPhone 3GS, you&#8217;re in store for a surprise as the 3GS has <strong>no </strong>VFP unit and it actually <strong>reduces </strong>the performance by a large amount <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> .</span></span></p>
<p><span style="font-size:xx-small;"><span style="font-size:small;">But don&#8217;t worry about this because the 3GS goes so fast it doesn&#8217;t really need assembler.</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/387/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=387&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/10/24/accelerating-software-skinning-with-vfp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/10/registers.png?w=300" medium="image" />
	</item>
		<item>
		<title>Protected: DS 2050</title>
		<link>http://astronautz.wordpress.com/2010/10/05/death-squad-2050/</link>
		<comments>http://astronautz.wordpress.com/2010/10/05/death-squad-2050/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 00:18:58 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=363</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=363&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post is password protected. You must visit the website and enter the password to continue reading.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=363&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/10/05/death-squad-2050/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
		<item>
		<title>Slowville: std::map</title>
		<link>http://astronautz.wordpress.com/2010/10/04/slowville-stdmap/</link>
		<comments>http://astronautz.wordpress.com/2010/10/04/slowville-stdmap/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 16:01:16 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[containers]]></category>
		<category><![CDATA[cplusplus]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[standard template library]]></category>
		<category><![CDATA[stl]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=351</guid>
		<description><![CDATA[Many people don&#8217;t realise how slow the  map that comes with the standard template library is. Reciently, did some performance comparisons of std::map versus boost::unordered_map. These are the benchmarks that I tested: fmap&#60;int, int&#62; mapTest; fmap&#60;int, int&#62;::iterator iter; int time1 = GetMilliSeconds(); int n; int randNum, rand2; rand2 = 0; for (n = 0; n [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=351&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many people don&#8217;t realise how slow the  map that comes with the standard template library is.</p>
<p>Reciently, did some performance comparisons of std::map versus boost::unordered_map.</p>
<p>These are the benchmarks that I tested:</p>
<blockquote>
<pre>fmap&lt;int, int&gt; mapTest;
fmap&lt;int, int&gt;::iterator iter;
int time1 = GetMilliSeconds();
int n;
int randNum, rand2;
rand2 = 0;
for (n = 0; n &lt; 100000; n++)
{
 randNum = rand()%1000;
 iter = mapTest.find(randNum);
 if (iter != mapTest.end())
 {
 rand2 = iter-&gt;second;
 }
 else
 {
 mapTest[randNum] = rand2;
 rand2 = n;
 }
}
int time2 = GetMilliSeconds();
int timeElapsed = abs(time2-time1);
cout &lt;&lt; "map test1 time:" &lt;&lt; timeElapsed &lt;&lt; "ms" &lt;&lt; endl;
time1 = time2;

fmap&lt;int, int&gt; mapTest2;
fmap&lt;int, int&gt;::iterator iterLowest;
int f;
for (n = 0; n &lt; 10000; n++)
{
 for (f = 0; f &lt; 10; f++)
 {
 randNum = rand()%1000;
 iter = mapTest2.find(randNum);
 if (iter != mapTest2.end())
 {
 rand2 = iter-&gt;second+1;
 }
 else
 {
 mapTest2[randNum] = rand2;
 rand2 = n;
 }
 }
 // find lowest
 iterLowest = mapTest2.begin();
 for (iter = mapTest2.begin(); iter != mapTest2.end(); iter++)
 {
 if (iter-&gt;second &gt; iterLowest-&gt;second)
 iterLowest = iter;
 }
 mapTest2.erase(iterLowest);
}
time2 = GetMilliSeconds();
timeElapsed = abs(time2-time1);
cout &lt;&lt; "map test2 time:" &lt;&lt; timeElapsed &lt;&lt; "ms" &lt;&lt; endl;</pre>
</blockquote>
<p>(Unfortunately, this looks awful because stupid word press strips out my code indentation <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  )</p>
<p>And these are the results running on 1st gen iPod touch:</p>
<p><strong>boost::unordered_map</strong><br />
map test1 time:115ms<br />
map test2 time:2251ms</p>
<p><strong>std::map</strong><br />
map test1 time:200ms<br />
map test2 time:3940ms</p>
<p>As you can see it&#8217;s nearly twice as slow.</p>
<p>std::map is an ordered map. In other words, when iterating the values are ordered according to the key. Normally, you don&#8217;t need this functionality, so using a hash map like boost::unordered_map is a no-brainer.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/351/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=351&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/10/04/slowville-stdmap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
		<item>
		<title>Reducing game start up time</title>
		<link>http://astronautz.wordpress.com/2010/08/24/reducing-game-start-up-time/</link>
		<comments>http://astronautz.wordpress.com/2010/08/24/reducing-game-start-up-time/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 22:05:04 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[iPhone development]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[targa]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=321</guid>
		<description><![CDATA[A lot game developers consider the start-up time of a game to be of little importance. Unfortunately, the truth is that users do not like looking at the hourglass. So, here are two tips to reduce start-up time: 1. Use Targa instead of PNG. PNGs take several times longer to decode than compressed Targa. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=321&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A lot game developers consider the start-up time of a game to be of little importance. Unfortunately, the truth is that users do not like looking at the hourglass. So, here are two tips to reduce start-up time:</p>
<h3>1. Use Targa instead of PNG.</h3>
<p>PNGs take several times longer to decode than compressed Targa. I think it&#8217;s around 5 times slower. (I once made some measurements on the iPhone, but I lost the figures &lt;doh&gt;).  On the other hand, compressed Targa files are about 40% bigger, but disk space usually isn&#8217;t that critical. You can use the code here to decode targa files:<a href="http://dmr.ath.cx/gfx/targa/"> http://dmr.ath.cx/gfx/targa/</a>.</p>
<p>An interesting side effect of this optimization is that it also reduces development time. Everytime you start up the debugger it has to decode all those 1024&#215;1024 textures, before you can begin.</p>
<h3>2. Read files by blocks, not word by word</h3>
<p>Preferably, read the whole file in one go. This is how you do it with C code:</p>
<blockquote>
<pre>FILE* pFile;
pFile = fopen(fileName.c_str(), "rb");
if (pFile == NULL) return;
fseek(pFile, 0, 2 /* SEEK_END */);
fileSize = (int)ftell(pFile);
fseek(pFile, 0, 0 /* SEEK_SET */);
pBuffer = new char[filesize];
int bytesRead = (int)fread(pBuffer, fileSize, 1, pFile);
fclose(pFile);</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=321&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/08/24/reducing-game-start-up-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
		<item>
		<title>How the App Store featured lists work</title>
		<link>http://astronautz.wordpress.com/2010/07/09/the-app-store-featured-lists/</link>
		<comments>http://astronautz.wordpress.com/2010/07/09/the-app-store-featured-lists/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 20:34:15 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[App Store iPhone games featured lists]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=288</guid>
		<description><![CDATA[I published my game Armageddon Wars a few weeks ago and was very lucky to get on the &#8220;New and Noteworthy&#8221; list under the games category. Apps only stay on that list for one week, but then to my surprise I saw it on the &#8220;What&#8217;s hot&#8221; list. Again Apps only last a week on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=288&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I published my game <em>Armageddon Wars</em> a few weeks ago and was very lucky to get on the &#8220;New and Noteworthy&#8221; list under the games category. Apps only stay on that list for one week, but then to my surprise I saw it on the &#8220;What&#8217;s hot&#8221; list. Again Apps only last a week on the &#8220;What&#8217;s hot&#8221; list. So, I assumed that was that, but again to my surprise I saw yesterday that it was on the &#8220;What we&#8217;re playing&#8221; list.</p>
<p>Anyway, I was looking at the screenshots just now and I noticed that the exact same apps get on all the lists:</p>
<p><a href="http://astronautz.files.wordpress.com/2010/07/new_2010-06-26.jpg"><img class="aligncenter size-full wp-image-290" title="new_2010-06-26" src="http://astronautz.files.wordpress.com/2010/07/new_2010-06-26.jpg?w=630" alt=""   /></a><a href="http://astronautz.files.wordpress.com/2010/07/whats-hot-2010-07-05-at-21-13-07.jpg"><img class="aligncenter size-full wp-image-291" title="Whats Hot 2010-07-05 at 21.13.07" src="http://astronautz.files.wordpress.com/2010/07/whats-hot-2010-07-05-at-21-13-07.jpg?w=630" alt=""   /></a><a href="http://astronautz.files.wordpress.com/2010/07/what-were-playing-2010-07-09-at-14-58-171.jpg"><img class="aligncenter size-full wp-image-293" title="what we're playing 2010-07-09" src="http://astronautz.files.wordpress.com/2010/07/what-were-playing-2010-07-09-at-14-58-171.jpg?w=630" alt=""   /></a>I thought that these lists were hand picked by Apple, but that seems only to be the case with the &#8220;New and Noteworthy&#8221; list. Once you are on that list you automatically get moved onto the other lists after a week.</p>
<p>Edit:</p>
<p>Just now I noticed my game stayed on the &#8220;What we&#8217;re playing&#8221; list for much longer than a week, but it seems that after a week it moved down the list, so the user has to press &#8220;see all&#8221; to see the game. Also, in some countries it stayed on the &#8220;what&#8217;s hot&#8221; list. In Australia for instance it&#8217;s still on the first page of that list. I assume that&#8217;s because the game got a higher star rating there than in other countries</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/288/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=288&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/07/09/the-app-store-featured-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/07/new_2010-06-26.jpg" medium="image">
			<media:title type="html">new_2010-06-26</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/07/whats-hot-2010-07-05-at-21-13-07.jpg" medium="image">
			<media:title type="html">Whats Hot 2010-07-05 at 21.13.07</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/07/what-were-playing-2010-07-09-at-14-58-171.jpg" medium="image">
			<media:title type="html">what we're playing 2010-07-09</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating App Store artwork for Armageddon Wars</title>
		<link>http://astronautz.wordpress.com/2010/04/02/how-i-painted-the-main-promotional-picture/</link>
		<comments>http://astronautz.wordpress.com/2010/04/02/how-i-painted-the-main-promotional-picture/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 18:41:40 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=199</guid>
		<description><![CDATA[This is how I created the main &#8220;icon&#8221; for Armageddon Wars. The main App Store icon has to be 512&#215;512 pixels, but usually is displayed much smaller, so the image had to look good even scaled down 10 times. The shape of a painting is what most affects the composition. If you get this right [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=199&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is how I created the main &#8220;icon&#8221; for Armageddon Wars. The main App Store icon has to be 512&#215;512 pixels, but usually is displayed much smaller, so the image had to look good even scaled down 10 times.</p>
<p>The shape of a painting is what most affects the composition. If you get this right you can get a great dramatic effect, but you need to start out very abstract. So, what I do is just start drawing random abstract shapes, until I hit on one that I like:</p>
<div id="attachment_307" class="wp-caption alignleft" style="width: 160px"><a href="http://astronautz.files.wordpress.com/2010/04/shape3.jpg"><img class="size-thumbnail wp-image-307" title="abstract shape 1" src="http://astronautz.files.wordpress.com/2010/04/shape3.jpg?w=150&#038;h=75" alt="" width="150" height="75" /></a><p class="wp-caption-text">shape 1</p></div>
<div id="attachment_308" class="wp-caption alignright" style="width: 160px"><a href="http://astronautz.files.wordpress.com/2010/04/shape5_0.jpg"><img class="size-thumbnail wp-image-308 " title="abstract shape 2" src="http://astronautz.files.wordpress.com/2010/04/shape5_0.jpg?w=150&#038;h=75" alt="" width="150" height="75" /></a><p class="wp-caption-text">shape 2</p></div>
<p style="text-align:center;">
<div id="attachment_200" class="wp-caption aligncenter" style="width: 160px"><a href="http://astronautz.files.wordpress.com/2010/04/shape11_0.jpg"><img class="size-thumbnail wp-image-200  " title="initial shape" src="http://astronautz.files.wordpress.com/2010/04/shape11_0.jpg?w=150&#038;h=128" alt="" width="150" height="128" /></a><p class="wp-caption-text">finally, this is the one I choose</p></div>
<p>Once you have a good shape you start adding details.</p>
<p>I had some tank models and city ruins done in Max, so I thought I would take advantage of that and made some test scenes in Max. This would also ensure that I got the lighting correct for the scene.</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/renderrailgun.jpg"><img class="aligncenter size-thumbnail wp-image-201" title="renderRailGun" src="http://astronautz.files.wordpress.com/2010/04/renderrailgun.jpg?w=150&#038;h=112" alt="" width="150" height="112" /></a>First, I had the turret facing to the right, which was ok, but everything was too dark because the light was positioned too low and far back.</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/renderbot6.png"><img class="aligncenter size-thumbnail wp-image-202" title="renderBot6" src="http://astronautz.files.wordpress.com/2010/04/renderbot6.png?w=150&#038;h=150" alt="" width="150" height="150" /></a>So, I fixed the light and changed the turret and also have it almost facing camera.</p>
<p>Then I imported this into photoshop, added a background of an inferno (that I took from a photo) and started working on the barrel.</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/turoial1.jpg"><img class="aligncenter size-thumbnail wp-image-203" title="tutorial1" src="http://astronautz.files.wordpress.com/2010/04/turoial1.jpg?w=150&#038;h=150" alt="" width="150" height="150" /></a></p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/tutorial3.jpg"><img class="aligncenter size-medium wp-image-204" title="tutorial3" src="http://astronautz.files.wordpress.com/2010/04/tutorial3.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></a>I started painting over the tank and buildings, making the turret structure more well defined. This picture had to recognisable at very small scale, so I made the outline distinct.</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/tutorial7.jpg"><img class="aligncenter size-medium wp-image-205" title="tutorial7" src="http://astronautz.files.wordpress.com/2010/04/tutorial7.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></a>I added details on the tank and drew some burning ruins in the distance.</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/tutorial10.jpg"><img class="aligncenter size-medium wp-image-206" title="tutorial10" src="http://astronautz.files.wordpress.com/2010/04/tutorial10.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></a>Those ruins weren&#8217;t that great, so added some burning skyscrapers instead.<a href="http://astronautz.files.wordpress.com/2010/04/tutorial11.jpg"><img class="aligncenter size-medium wp-image-207" title="tutorial11" src="http://astronautz.files.wordpress.com/2010/04/tutorial11.jpg?w=300&#038;h=300" alt="" width="300" height="300" /></a>Then I added some smoke for the near foreground&#8230;</p>
<p><a href="http://astronautz.files.wordpress.com/2010/04/bansheeattack5.jpg"><img class="aligncenter size-full wp-image-208" title="bansheeAttack5" src="http://astronautz.files.wordpress.com/2010/04/bansheeattack5.jpg?w=630" alt=""   /></a>and then I rotated it &#8211; if you remember the original sketch was rotated as well, but that was somehow lost in the process. And that&#8217;s it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=199&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2010/04/02/how-i-painted-the-main-promotional-picture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/shape3.jpg?w=150" medium="image">
			<media:title type="html">abstract shape 1</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/shape5_0.jpg?w=150" medium="image">
			<media:title type="html">abstract shape 2</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/shape11_0.jpg?w=150" medium="image">
			<media:title type="html">initial shape</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/renderrailgun.jpg?w=150" medium="image">
			<media:title type="html">renderRailGun</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/renderbot6.png?w=150" medium="image">
			<media:title type="html">renderBot6</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/turoial1.jpg?w=150" medium="image">
			<media:title type="html">tutorial1</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/tutorial3.jpg?w=300" medium="image">
			<media:title type="html">tutorial3</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/tutorial7.jpg?w=300" medium="image">
			<media:title type="html">tutorial7</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/tutorial10.jpg?w=300" medium="image">
			<media:title type="html">tutorial10</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/tutorial11.jpg?w=300" medium="image">
			<media:title type="html">tutorial11</media:title>
		</media:content>

		<media:content url="http://astronautz.files.wordpress.com/2010/04/bansheeattack5.jpg" medium="image">
			<media:title type="html">bansheeAttack5</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio warnings</title>
		<link>http://astronautz.wordpress.com/2009/01/21/visual-studio-warnings/</link>
		<comments>http://astronautz.wordpress.com/2009/01/21/visual-studio-warnings/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 21:30:01 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=84</guid>
		<description><![CDATA[I found it useful to change some of the warnings generated by Visual Studio. For instance, this statement: if (num = 10) { doSomething(); } Generates a warning, but I cannot see any case where this would not be a bug. So I change this warning and some others to errors: like this: #pragma warning [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=84&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found it useful to change some of the warnings generated by Visual Studio.</p>
<p>For instance, this statement:<br />
<code><br />
if (num = 10) { doSomething(); }<br />
</code><br />
Generates a warning, but I cannot see any case where this would not be a bug. So I change this warning and some others to errors: like this:</p>
<p><code><br />
#pragma warning (error: 4715)<br />
#pragma warning (error: 4706)<br />
#pragma warning (error: 4553)    // '==' : operator has no effect; did you intend '='?<br />
#pragma warning (error: 4150)    // deletion of pointer to incomplete type<br />
#pragma warning (error: 4390)    // empty controlled statement found;<br />
#pragma warning (disable: 4996)  // openf is dangerous (not!)<br />
</code></p>
<p>Now, there&#8217;s no way you can ignore it. By the way, there is a bug in Visual Studio, sometimes it won&#8217;t flag warning mentioned above at all.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=84&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2009/01/21/visual-studio-warnings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
		<item>
		<title>Some old performance tricks</title>
		<link>http://astronautz.wordpress.com/2009/01/08/63/</link>
		<comments>http://astronautz.wordpress.com/2009/01/08/63/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 23:25:41 +0000</pubDate>
		<dc:creator>lefty3</dc:creator>
				<category><![CDATA[iPhone development]]></category>

		<guid isPermaLink="false">http://astronautz.wordpress.com/?p=63</guid>
		<description><![CDATA[The documentation for the iphone&#8217;s VFP processor says that all floating point instructions take 1 cycle, apart from divide and square root, which take 15 cycles. This leads to a very obvious optimisation, to cache your divide operations. In other words if you have code like this: float fl = 1.0007f; for (i = 0; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=63&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The documentation for the iphone&#8217;s VFP processor says that all floating point instructions take 1 cycle, apart from divide and square root, which take 15 cycles.</p>
<p>This leads to a very obvious optimisation, to cache your divide operations.</p>
<p>In other words if you have code like this:</p>
<p>float fl = 1.0007f;<br />
for (i = 0; i &lt; 16; i++)<br />
matrix.Set(i, matrix[i]/fl);</p>
<p>you can increase performance by doing the divide outside the loop:</p>
<p>float fl = 1.0f/1.0007f;<br />
for (i = 0; i &lt; 16; i++)<br />
matrix.Set(i, matrix[i]*fl);</p>
<p>I measured this and found that it does indeed make a big improvement.</p>
<p>Also, I thought it would be interesting to try out the old <a href="http://http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/">Quake inverse square root trick</a>.</p>
<pre><code>float InvSqrt(float x){
   float xhalf = 0.5f * x;
   int i = *(int*)&amp;x; // store floating-point bits in integer
   i = 0x5f3759d5 - (i &gt;&gt; 1); // initial guess for Newton's method
   x = *(float*)&amp;i; // convert new bits into float
   x = x*(1.5f - xhalf*x*x); // One round of Newton's method
   return x;
}
</code></pre>
<p>This code works on the iPhone, but the results are less accurate.</p>
<pre><code>float fl = 2.0f;
result = 1.f / sqrt ( fl );   // gives 0.707106769
result = InvSqrt(fl);   // gives 0.706930041
</code></pre>
<p>the actual value should be 0.70710678</p>
<p>I measured the performance and found that it&#8217;s a touch faster, but not much.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/astronautz.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/astronautz.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/astronautz.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=astronautz.wordpress.com&amp;blog=5062339&amp;post=63&amp;subd=astronautz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://astronautz.wordpress.com/2009/01/08/63/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1d7c4628f64ed7e0c891e601b6d0b46a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lefty3</media:title>
		</media:content>
	</item>
	</channel>
</rss>
